Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractXmlColumn.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractXmlColumn.java301
1 files changed, 301 insertions, 0 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractXmlColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractXmlColumn.java
new file mode 100644
index 0000000000..9de4bfa291
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractXmlColumn.java
@@ -0,0 +1,301 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.core.internal.context.orm;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.ITextRange;
+import org.eclipse.jpt.core.internal.context.base.IAbstractColumn;
+import org.eclipse.jpt.core.internal.context.base.IJpaContextNode;
+import org.eclipse.jpt.core.internal.resource.orm.AbstractColumn;
+
+
+public abstract class AbstractXmlColumn<T extends AbstractColumn> extends AbstractXmlNamedColumn<T>
+ implements IAbstractColumn
+{
+ protected String specifiedTable;
+
+ protected String defaultTable;
+
+ protected Boolean specifiedUnique;
+
+ protected Boolean specifiedNullable;
+
+ protected Boolean specifiedInsertable;
+
+ protected Boolean specifiedUpdatable;
+
+ protected AbstractXmlColumn(IJpaContextNode parent, IAbstractColumn.Owner owner) {
+ super(parent, owner);
+ }
+
+ @Override
+ public IAbstractColumn.Owner owner() {
+ return (IAbstractColumn.Owner) super.owner();
+ }
+
+// @Override
+// protected void addInsignificantXmlFeatureIdsTo(Set<Integer> insignificantXmlFeatureIds) {
+// super.addInsignificantXmlFeatureIdsTo(insignificantXmlFeatureIds);
+// insignificantXmlFeatureIds.add(JpaCoreMappingsPackage.IABSTRACT_COLUMN__DEFAULT_TABLE);
+// insignificantXmlFeatureIds.add(JpaCoreMappingsPackage.IABSTRACT_COLUMN__TABLE);
+// }
+
+ public String getTable() {
+ return (this.getSpecifiedTable() == null) ? getDefaultTable() : this.getSpecifiedTable();
+ }
+
+ public String getSpecifiedTable() {
+ return this.specifiedTable;
+ }
+
+ public void setSpecifiedTable(String newSpecifiedTable) {
+ String oldSpecifiedTable = this.specifiedTable;
+ this.specifiedTable = newSpecifiedTable;
+ if (oldSpecifiedTable != newSpecifiedTable) {
+ if (this.columnResource() != null) {
+ this.columnResource().setTable(newSpecifiedTable);
+ if (this.columnResource().isAllFeaturesUnset()) {
+ removeColumnResource();
+ }
+ }
+ else if (newSpecifiedTable != null) {
+ addColumnResource();
+ columnResource().setTable(newSpecifiedTable);
+ }
+ }
+ firePropertyChanged(IAbstractColumn.SPECIFIED_TABLE_PROPERTY, oldSpecifiedTable, newSpecifiedTable);
+ }
+
+ protected void setSpecifiedTable_(String newSpecifiedTable) {
+ String oldSpecifiedTable = this.specifiedTable;
+ this.specifiedTable = newSpecifiedTable;
+ firePropertyChanged(IAbstractColumn.SPECIFIED_TABLE_PROPERTY, oldSpecifiedTable, newSpecifiedTable);
+ }
+
+ public String getDefaultTable() {
+ return this.defaultTable;
+ }
+
+ protected void setDefaultTable(String newDefaultTable) {
+ String oldDefaultTable = this.defaultTable;
+ this.defaultTable = newDefaultTable;
+ firePropertyChanged(IAbstractColumn.DEFAULT_TABLE_PROPERTY, oldDefaultTable, newDefaultTable);
+ }
+
+ public Boolean getUnique() {
+ return (this.getSpecifiedUnique() == null) ? this.getDefaultUnique() : this.getSpecifiedUnique();
+ }
+
+ public Boolean getDefaultUnique() {
+ return IAbstractColumn.DEFAULT_UNIQUE;
+ }
+
+ public Boolean getSpecifiedUnique() {
+ return this.specifiedUnique;
+ }
+
+ public void setSpecifiedUnique(Boolean newSpecifiedUnique) {
+ Boolean oldSpecifiedUnique = this.specifiedUnique;
+ this.specifiedUnique = newSpecifiedUnique;
+ if (oldSpecifiedUnique != newSpecifiedUnique) {
+ if (this.columnResource() != null) {
+ this.columnResource().setUnique(newSpecifiedUnique);
+ if (this.columnResource().isAllFeaturesUnset()) {
+ removeColumnResource();
+ }
+ }
+ else if (newSpecifiedUnique != null) {
+ addColumnResource();
+ columnResource().setUnique(newSpecifiedUnique);
+ }
+ }
+ firePropertyChanged(IAbstractColumn.SPECIFIED_UNIQUE_PROPERTY, oldSpecifiedUnique, newSpecifiedUnique);
+ }
+
+ protected void setSpecifiedUnique_(Boolean newSpecifiedUnique) {
+ Boolean oldSpecifiedUnique = this.specifiedUnique;
+ this.specifiedUnique = newSpecifiedUnique;
+ firePropertyChanged(IAbstractColumn.SPECIFIED_UNIQUE_PROPERTY, oldSpecifiedUnique, newSpecifiedUnique);
+ }
+
+ public Boolean getNullable() {
+ return (this.getSpecifiedNullable() == null) ? this.getDefaultNullable() : this.getSpecifiedNullable();
+ }
+
+ public Boolean getDefaultNullable() {
+ return IAbstractColumn.DEFAULT_NULLABLE;
+ }
+
+ public Boolean getSpecifiedNullable() {
+ return this.specifiedNullable;
+ }
+
+ public void setSpecifiedNullable(Boolean newSpecifiedNullable) {
+ Boolean oldSpecifiedNullable = this.specifiedNullable;
+ this.specifiedNullable = newSpecifiedNullable;
+ if (oldSpecifiedNullable != newSpecifiedNullable) {
+ if (this.columnResource() != null) {
+ this.columnResource().setNullable(newSpecifiedNullable);
+ if (this.columnResource().isAllFeaturesUnset()) {
+ removeColumnResource();
+ }
+ }
+ else if (newSpecifiedNullable != null) {
+ addColumnResource();
+ columnResource().setNullable(newSpecifiedNullable);
+ }
+ }
+ firePropertyChanged(IAbstractColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable);
+ }
+
+ protected void setSpecifiedNullable_(Boolean newSpecifiedNullable) {
+ Boolean oldSpecifiedNullable = this.specifiedNullable;
+ this.specifiedNullable = newSpecifiedNullable;
+ firePropertyChanged(IAbstractColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable);
+ }
+
+ public Boolean getInsertable() {
+ return (this.getSpecifiedInsertable() == null) ? this.getDefaultInsertable() : this.getSpecifiedInsertable();
+ }
+
+ public Boolean getDefaultInsertable() {
+ return IAbstractColumn.DEFAULT_INSERTABLE;
+ }
+
+ public Boolean getSpecifiedInsertable() {
+ return this.specifiedInsertable;
+ }
+
+ public void setSpecifiedInsertable(Boolean newSpecifiedInsertable) {
+ Boolean oldSpecifiedInsertable = this.specifiedInsertable;
+ this.specifiedInsertable = newSpecifiedInsertable;
+ if (oldSpecifiedInsertable != newSpecifiedInsertable) {
+ if (this.columnResource() != null) {
+ this.columnResource().setInsertable(newSpecifiedInsertable);
+ if (this.columnResource().isAllFeaturesUnset()) {
+ removeColumnResource();
+ }
+ }
+ else if (newSpecifiedInsertable != null) {
+ addColumnResource();
+ columnResource().setInsertable(newSpecifiedInsertable);
+ }
+ }
+ firePropertyChanged(IAbstractColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable);
+ }
+
+ protected void setSpecifiedInsertable_(Boolean newSpecifiedInsertable) {
+ Boolean oldSpecifiedInsertable = this.specifiedInsertable;
+ this.specifiedInsertable = newSpecifiedInsertable;
+ firePropertyChanged(IAbstractColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable);
+ }
+
+ public Boolean getUpdatable() {
+ return (this.getSpecifiedUpdatable() == null) ? this.getDefaultUpdatable() : this.getSpecifiedUpdatable();
+ }
+
+ public Boolean getDefaultUpdatable() {
+ return IAbstractColumn.DEFAULT_UPDATABLE;
+ }
+
+ public Boolean getSpecifiedUpdatable() {
+ return this.specifiedUpdatable;
+ }
+
+ public void setSpecifiedUpdatable(Boolean newSpecifiedUpdatable) {
+ Boolean oldSpecifiedUpdatable = this.specifiedUpdatable;
+ this.specifiedUpdatable = newSpecifiedUpdatable;
+ if (oldSpecifiedUpdatable != newSpecifiedUpdatable) {
+ if (this.columnResource() != null) {
+ this.columnResource().setUpdatable(newSpecifiedUpdatable);
+ if (this.columnResource().isAllFeaturesUnset()) {
+ removeColumnResource();
+ }
+ }
+ else if (newSpecifiedUpdatable != null) {
+ addColumnResource();
+ columnResource().setUpdatable(newSpecifiedUpdatable);
+ }
+ }
+ firePropertyChanged(IAbstractColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable);
+ }
+
+ protected void setSpecifiedUpdatable_(Boolean newSpecifiedUpdatable) {
+ Boolean oldSpecifiedUpdatable = this.specifiedUpdatable;
+ this.specifiedUpdatable = newSpecifiedUpdatable;
+ firePropertyChanged(IAbstractColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable);
+ }
+
+ @Override
+ protected String tableName() {
+ return this.getTable();
+ }
+
+ public ITextRange tableTextRange(CompilationUnit astRoot) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+//
+// public ITextRange tableTextRange() {
+// if (node == null) {
+// return owner.validationTextRange();
+// }
+// IDOMNode tableNode = (IDOMNode) DOMUtilities.getChildAttributeNode(node, OrmXmlMapper.ENTITY__TABLE);
+// return (tableNode == null) ? validationTextRange() : buildTextRange(tableNode);
+// }
+
+ @Override
+ protected void initialize(T column) {
+ super.initialize(column);
+ this.specifiedTable = this.specifiedTable(column);
+ this.defaultTable = this.defaultTable();
+ //TODO default from java for all of these settings
+ this.specifiedNullable = this.specifiedNullable(column);
+ this.specifiedUpdatable = this.specifiedUpdatable(column);
+ this.specifiedUnique = this.specifiedUnique(column);
+ this.specifiedInsertable = this.specifiedInsertable(column);
+ }
+
+ @Override
+ protected void update(T column) {
+ super.update(column);
+ setSpecifiedTable_(this.specifiedTable(column));
+ setDefaultTable(this.defaultTable());
+ setSpecifiedNullable_(this.specifiedNullable(column));
+ setSpecifiedUpdatable_(this.specifiedUpdatable(column));
+ setSpecifiedUnique_(this.specifiedUnique(column));
+ setSpecifiedInsertable_(this.specifiedInsertable(column));
+ }
+
+ protected String specifiedTable(T column) {
+ return column == null ? null : column.getTable();
+ }
+
+ protected Boolean specifiedNullable(T column) {
+ return column == null ? null : column.getNullable();
+ }
+
+ protected Boolean specifiedUpdatable(T column) {
+ return column == null ? null : column.getUpdatable();
+ }
+
+ protected Boolean specifiedUnique(T column) {
+ return column == null ? null : column.getUnique();
+ }
+
+ protected Boolean specifiedInsertable(T column) {
+ return column == null ? null : column.getInsertable();
+ }
+
+ protected String defaultTable() {
+ return owner().defaultTableName();
+ }
+
+}

Back to the top