Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2009-11-23 15:33:59 -0500
committerkmoore2009-11-23 15:33:59 -0500
commitb1b0d4ea18343d97b65d79b2e9cb43c033374f6d (patch)
tree95549276deb7cd445b3b99268709863326db4412
parent4dc16aff4cfc9b4d6b52d80590cf14cdb77b8af7 (diff)
downloadwebtools.dali-b1b0d4ea18343d97b65d79b2e9cb43c033374f6d.tar.gz
webtools.dali-b1b0d4ea18343d97b65d79b2e9cb43c033374f6d.tar.xz
webtools.dali-b1b0d4ea18343d97b65d79b2e9cb43c033374f6d.zip
refactored AbstractJavaBaseColumn to store the resource column annotation so that all column implementations are more alike now
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaAttributeOverride.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumn.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumnMapping.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaDiscriminatorColumn.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaFactory.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaColumn.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaJoinColumn.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java31
13 files changed, 147 insertions, 174 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java
index ed3693e965..465d64738e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaFactory.java
@@ -25,6 +25,7 @@ import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipRefe
import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
import org.eclipse.jpt.core.context.java.JavaAttributeOverrideContainer;
+import org.eclipse.jpt.core.context.java.JavaBaseColumn;
import org.eclipse.jpt.core.context.java.JavaBaseJoinColumn;
import org.eclipse.jpt.core.context.java.JavaBasicMapping;
import org.eclipse.jpt.core.context.java.JavaCascade;
@@ -174,7 +175,7 @@ public interface JpaFactory
JavaCascade buildJavaCascade(JavaRelationshipMapping parent);
- JavaColumn buildJavaColumn(JavaJpaContextNode parent, JavaColumn.Owner owner);
+ JavaColumn buildJavaColumn(JavaJpaContextNode parent, JavaBaseColumn.Owner owner);
JavaDiscriminatorColumn buildJavaDiscriminatorColumn(JavaEntity parent, JavaDiscriminatorColumn.Owner owner);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaAttributeOverride.java
index d5056fcaff..aeead9f5a3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaAttributeOverride.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaAttributeOverride.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2009 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.
@@ -21,7 +21,7 @@ import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*/
-public interface JavaAttributeOverride extends AttributeOverride, JavaJpaContextNode, JavaColumn.Owner
+public interface JavaAttributeOverride extends AttributeOverride, JavaJpaContextNode, JavaBaseColumn.Owner
{
JavaColumn getColumn();
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumn.java
index cb717c59b2..7ffbb5e302 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumn.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2009 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.
@@ -30,15 +30,5 @@ public interface JavaColumn extends Column, JavaBaseColumn
* resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()}
*/
void update(ColumnAnnotation resourceColumn);
-
- Owner getOwner();
- /**
- * interface allowing columns to be used in multiple places
- * (e.g. basic mappings and attribute overrides)
- */
- interface Owner extends JavaBaseColumn.Owner
- {
- ColumnAnnotation getResourceColumn();
- }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumnMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumnMapping.java
index 99d1248b1b..47643f1b40 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumnMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaColumnMapping.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2009 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.
@@ -20,7 +20,7 @@ import org.eclipse.jpt.core.context.ColumnMapping;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*/
-public interface JavaColumnMapping extends JavaJpaContextNode, ColumnMapping, JavaColumn.Owner
+public interface JavaColumnMapping extends JavaJpaContextNode, ColumnMapping, JavaBaseColumn.Owner
{
JavaColumn getColumn();
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaDiscriminatorColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaDiscriminatorColumn.java
index b20253835a..d29396f723 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaDiscriminatorColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaDiscriminatorColumn.java
@@ -10,7 +10,7 @@
package org.eclipse.jpt.core.context.java;
import org.eclipse.jpt.core.context.DiscriminatorColumn;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation;
/**
*
@@ -23,13 +23,13 @@ import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
*/
public interface JavaDiscriminatorColumn extends JavaNamedColumn, DiscriminatorColumn
{
- void initialize(JavaResourcePersistentMember jrpm);
+ void initialize(DiscriminatorColumnAnnotation resourceColumn);
/**
- * Update the JavaDiscriminatorColumn context model object to match the JavaResourcePersistentMember
+ * Update the JavaDiscriminatorColumn context model object to match the DiscriminatorColumnAnnotation
* resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()}
*/
- void update(JavaResourcePersistentMember jrpm);
+ void update(DiscriminatorColumnAnnotation resourceColumn);
/**
* interface allowing columns to be used in multiple places
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaFactory.java
index 4828830091..10dce416bf 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaFactory.java
@@ -28,6 +28,7 @@ import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipRefe
import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
import org.eclipse.jpt.core.context.java.JavaAttributeOverrideContainer;
+import org.eclipse.jpt.core.context.java.JavaBaseColumn;
import org.eclipse.jpt.core.context.java.JavaBaseJoinColumn;
import org.eclipse.jpt.core.context.java.JavaBasicMapping;
import org.eclipse.jpt.core.context.java.JavaCascade;
@@ -221,7 +222,7 @@ public abstract class AbstractJpaFactory
return new GenericJavaCascade(parent);
}
- public JavaColumn buildJavaColumn(JavaJpaContextNode parent, JavaColumn.Owner owner) {
+ public JavaColumn buildJavaColumn(JavaJpaContextNode parent, JavaBaseColumn.Owner owner) {
return new GenericJavaColumn(parent, owner);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java
index fd55f476d5..98d07e6c80 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java
@@ -45,11 +45,22 @@ public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> ext
protected void initialize(T column) {
super.initialize(column);
this.defaultTable = this.buildDefaultTable();
- this.specifiedTable = this.getResourceTable(column);
- this.specifiedUnique = this.getResourceUnique(column);
- this.specifiedNullable = this.getResourceNullable(column);
- this.specifiedInsertable = this.getResourceInsertable(column);
- this.specifiedUpdatable = this.getResourceUpdatable(column);
+ this.specifiedTable = this.getResourceTable();
+ this.specifiedUnique = this.getResourceUnique();
+ this.specifiedNullable = this.getResourceNullable();
+ this.specifiedInsertable = this.getResourceInsertable();
+ this.specifiedUpdatable = this.getResourceUpdatable();
+ }
+
+ @Override
+ protected void update(T column) {
+ super.update(column);
+ this.setDefaultTable(this.buildDefaultTable());
+ this.setSpecifiedTable_(this.getResourceTable());
+ this.setSpecifiedUnique_(this.getResourceUnique());
+ this.setSpecifiedNullable_(this.getResourceNullable());
+ this.setSpecifiedInsertable_(this.getResourceInsertable());
+ this.setSpecifiedUpdatable_(this.getResourceUpdatable());
}
@Override
@@ -57,8 +68,9 @@ public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> ext
return (JavaBaseColumn.Owner) super.getOwner();
}
- //************** IAbstractColumn implementation *******************
+ //************** BaseColumn implementation *******************
+ //************** table *******************
public String getTable() {
return (this.getSpecifiedTable() == null) ? getDefaultTable() : this.getSpecifiedTable();
@@ -96,6 +108,12 @@ public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> ext
this.defaultTable = newDefaultTable;
firePropertyChanged(BaseColumn.DEFAULT_TABLE_PROPERTY, oldDefaultTable, newDefaultTable);
}
+
+ protected String getResourceTable() {
+ return getResourceColumn().getTable();
+ }
+
+ //************** unique *******************
public boolean isUnique() {
return (this.getSpecifiedUnique() == null) ? this.isDefaultUnique() : this.getSpecifiedUnique().booleanValue();
@@ -128,6 +146,12 @@ public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> ext
firePropertyChanged(BaseColumn.SPECIFIED_UNIQUE_PROPERTY, oldSpecifiedUnique, newSpecifiedUnique);
}
+ protected Boolean getResourceUnique() {
+ return getResourceColumn().getUnique();
+ }
+
+ //************** nullable *******************
+
public boolean isNullable() {
return (this.getSpecifiedNullable() == null) ? this.isDefaultNullable() : this.getSpecifiedNullable().booleanValue();
}
@@ -159,6 +183,12 @@ public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> ext
firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable);
}
+ protected Boolean getResourceNullable() {
+ return getResourceColumn().getNullable();
+ }
+
+ //************** insertable *******************
+
public boolean isInsertable() {
return (this.getSpecifiedInsertable() == null) ? this.isDefaultInsertable() : this.getSpecifiedInsertable().booleanValue();
}
@@ -190,6 +220,12 @@ public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> ext
firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable);
}
+ protected Boolean getResourceInsertable() {
+ return getResourceColumn().getInsertable();
+ }
+
+ //************** updatable *******************
+
public boolean isUpdatable() {
return (this.getSpecifiedUpdatable() == null) ? this.isDefaultUpdatable() : this.getSpecifiedUpdatable().booleanValue();
}
@@ -220,7 +256,11 @@ public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> ext
this.specifiedUpdatable = newSpecifiedUpdatable;
firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable);
}
-
+
+ protected Boolean getResourceUpdatable() {
+ return getResourceColumn().getUpdatable();
+ }
+
@Override
protected String getTableName() {
return this.getTable();
@@ -264,39 +304,9 @@ public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> ext
}
return null;
}
-
- @Override
- protected void update(T column) {
- super.update(column);
- this.setDefaultTable(this.buildDefaultTable());
- this.setSpecifiedTable_(this.getResourceTable(column));
- this.setSpecifiedUnique_(this.getResourceUnique(column));
- this.setSpecifiedNullable_(this.getResourceNullable(column));
- this.setSpecifiedInsertable_(this.getResourceInsertable(column));
- this.setSpecifiedUpdatable_(this.getResourceUpdatable(column));
- }
protected String buildDefaultTable() {
return this.getOwner().getDefaultTableName();
}
-
- protected String getResourceTable(BaseColumnAnnotation column) {
- return column.getTable();
- }
-
- protected Boolean getResourceUnique(BaseColumnAnnotation column) {
- return column.getUnique();
- }
-
- protected Boolean getResourceNullable(BaseColumnAnnotation column) {
- return column.getNullable();
- }
-
- protected Boolean getResourceInsertable(BaseColumnAnnotation column) {
- return column.getInsertable();
- }
-
- protected Boolean getResourceUpdatable(BaseColumnAnnotation column) {
- return column.getUpdatable();
- }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
index 6367440d8a..e5ace7151e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
@@ -50,6 +50,7 @@ import org.eclipse.jpt.core.internal.resource.java.NullPrimaryKeyJoinColumnAnnot
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.core.jpa2.context.java.JavaCacheableHolder2_0;
+import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation;
import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation;
import org.eclipse.jpt.core.resource.java.EntityAnnotation;
import org.eclipse.jpt.core.resource.java.IdClassAnnotation;
@@ -209,7 +210,7 @@ public abstract class AbstractJavaEntity
this.defaultDiscriminatorValue = this.buildDefaultDiscriminatorValue();
this.specifiedDiscriminatorColumnIsAllowed = this.buildSpecifiedDiscriminatorColumnIsAllowed();
this.discriminatorColumnIsUndefined = this.buildDiscriminatorColumnIsUndefined();
- this.discriminatorColumn.initialize(resourcePersistentType);
+ this.discriminatorColumn.initialize(this.getResourceDiscriminatorColumn());
this.specifiedTableIsAllowed = this.buildSpecifiedTableIsAllowed();
this.tableIsUndefined = this.buildTableIsUndefined();
this.table.initialize(resourcePersistentType);
@@ -270,6 +271,11 @@ public abstract class AbstractJavaEntity
getNonNullAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME);
}
+ protected DiscriminatorColumnAnnotation getResourceDiscriminatorColumn() {
+ return (DiscriminatorColumnAnnotation) this.javaResourcePersistentType.
+ getNonNullAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME);
+ }
+
protected void initializeIdClass() {
IdClassAnnotation resourceIdClass = getResourceIdClass();
if (resourceIdClass != null) {
@@ -1158,7 +1164,7 @@ public abstract class AbstractJavaEntity
protected void updateDiscriminatorColumn() {
this.setSpecifiedDiscriminatorColumnIsAllowed(this.buildSpecifiedDiscriminatorColumnIsAllowed());
- getDiscriminatorColumn().update(this.javaResourcePersistentType);
+ getDiscriminatorColumn().update(this.getResourceDiscriminatorColumn());
}
protected void postUpdateDiscriminatorColumn() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java
index 123dd5f57f..62fba6ee5b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java
@@ -36,6 +36,8 @@ public abstract class AbstractJavaNamedColumn<T extends NamedColumnAnnotation> e
protected String columnDefinition;
+ protected T resourceColumn;
+
protected AbstractJavaNamedColumn(JavaJpaContextNode parent, Owner owner) {
super(parent);
this.owner = owner;
@@ -44,16 +46,25 @@ public abstract class AbstractJavaNamedColumn<T extends NamedColumnAnnotation> e
// ******************* initialization from java resource model ********************
protected void initialize(T column) {
+ this.resourceColumn = column;
this.specifiedName = column.getName();
this.defaultName = this.buildDefaultName();
this.columnDefinition = column.getColumnDefinition();
}
-
- protected abstract T getResourceColumn();
+ protected void update(T column) {
+ this.resourceColumn = column;
+ this.setSpecifiedName_(column.getName());
+ this.setDefaultName(this.buildDefaultName());
+ this.setColumnDefinition_(column.getColumnDefinition());
+ }
+
+ protected T getResourceColumn() {
+ return this.resourceColumn;
+ }
- //************** INamedColumn implementation *****************
+ //************** NamedColumn implementation *****************
public String getName() {
return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
}
@@ -90,6 +101,13 @@ public abstract class AbstractJavaNamedColumn<T extends NamedColumnAnnotation> e
this.defaultName = newDefaultName;
firePropertyChanged(NamedColumn.DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName);
}
+
+ /**
+ * Return the default column name.
+ */
+ protected String buildDefaultName() {
+ return this.getOwner().getDefaultColumnName();
+ }
public String getColumnDefinition() {
return this.columnDefinition;
@@ -174,21 +192,4 @@ public abstract class AbstractJavaNamedColumn<T extends NamedColumnAnnotation> e
public void toString(StringBuilder sb) {
sb.append(this.getName());
}
-
-
- // ******************* update from java resource model ********************
-
- protected void update(T column) {
- this.setSpecifiedName_(column.getName());
- this.setDefaultName(this.buildDefaultName());
- this.setColumnDefinition_(column.getColumnDefinition());
- }
-
- /**
- * Return the default column name.
- */
- protected String buildDefaultName() {
- return this.getOwner().getDefaultColumnName();
- }
-
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaColumn.java
index ca9f448ba6..35b1ce06f0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaColumn.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.core.internal.jpa1.context.java;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.Column;
+import org.eclipse.jpt.core.context.java.JavaBaseColumn;
import org.eclipse.jpt.core.context.java.JavaColumn;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaBaseColumn;
@@ -26,26 +27,24 @@ public class GenericJavaColumn extends AbstractJavaBaseColumn<ColumnAnnotation>
protected Integer specifiedScale;
- public GenericJavaColumn(JavaJpaContextNode parent, JavaColumn.Owner owner) {
+ public GenericJavaColumn(JavaJpaContextNode parent, JavaBaseColumn.Owner owner) {
super(parent, owner);
}
@Override
public void initialize(ColumnAnnotation column) {
super.initialize(column);
- this.specifiedLength = this.getResourceLength(column);
- this.specifiedPrecision = this.getResourcePrecision(column);
- this.specifiedScale = this.getResourceScale(column);
+ this.specifiedLength = this.getResourceLength();
+ this.specifiedPrecision = this.getResourcePrecision();
+ this.specifiedScale = this.getResourceScale();
}
@Override
- public JavaColumn.Owner getOwner() {
- return (JavaColumn.Owner) super.getOwner();
- }
-
- @Override
- protected ColumnAnnotation getResourceColumn() {
- return this.getOwner().getResourceColumn();
+ public void update(ColumnAnnotation column) {
+ super.update(column);
+ this.setSpecifiedLength_(this.getResourceLength());
+ this.setSpecifiedPrecision_(this.getResourcePrecision());
+ this.setSpecifiedScale_(this.getResourceScale());
}
public int getLength() {
@@ -72,6 +71,10 @@ public class GenericJavaColumn extends AbstractJavaBaseColumn<ColumnAnnotation>
this.specifiedLength = newSpecifiedLength;
firePropertyChanged(SPECIFIED_LENGTH_PROPERTY, oldSpecifiedLength, newSpecifiedLength);
}
+
+ protected Integer getResourceLength() {
+ return getResourceColumn().getLength();
+ }
public int getPrecision() {
return (this.getSpecifiedPrecision() == null) ? getDefaultPrecision() : this.getSpecifiedPrecision().intValue();
@@ -97,6 +100,10 @@ public class GenericJavaColumn extends AbstractJavaBaseColumn<ColumnAnnotation>
this.specifiedPrecision = newSpecifiedPrecision;
firePropertyChanged(SPECIFIED_PRECISION_PROPERTY, oldSpecifiedPrecision, newSpecifiedPrecision);
}
+
+ protected Integer getResourcePrecision() {
+ return getResourceColumn().getPrecision();
+ }
public int getScale() {
return (this.getSpecifiedScale() == null) ? getDefaultScale() : this.getSpecifiedScale().intValue();
@@ -122,7 +129,11 @@ public class GenericJavaColumn extends AbstractJavaBaseColumn<ColumnAnnotation>
this.specifiedScale = newSpecifiedScale;
firePropertyChanged(SPECIFIED_SCALE_PROPERTY, oldSpecifiedScale, newSpecifiedScale);
}
-
+
+ protected Integer getResourceScale() {
+ return getResourceColumn().getScale();
+ }
+
@Override
public boolean tableIsAllowed() {
return true;
@@ -132,24 +143,4 @@ public class GenericJavaColumn extends AbstractJavaBaseColumn<ColumnAnnotation>
TextRange textRange = getResourceColumn().getTextRange(astRoot);
return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
}
-
- @Override
- public void update(ColumnAnnotation column) {
- super.update(column);
- this.setSpecifiedLength_(this.getResourceLength(column));
- this.setSpecifiedPrecision_(this.getResourcePrecision(column));
- this.setSpecifiedScale_(this.getResourceScale(column));
- }
-
- protected Integer getResourceLength(ColumnAnnotation column) {
- return column.getLength();
- }
-
- protected Integer getResourcePrecision(ColumnAnnotation column) {
- return column.getPrecision();
- }
-
- protected Integer getResourceScale(ColumnAnnotation column) {
- return column.getScale();
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java
index 50c93e70e1..e587138e36 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaDiscriminatorColumn.java
@@ -41,19 +41,14 @@ public class GenericJavaDiscriminatorColumn extends AbstractJavaNamedColumn<Disc
public GenericJavaDiscriminatorColumn(JavaEntity parent, JavaDiscriminatorColumn.Owner owner) {
super(parent, owner);
}
-
- public void initialize(JavaResourcePersistentMember persistentResource) {
- this.persistenceResource = persistentResource;
- this.initialize(this.getResourceColumn());
- }
@Override
public void initialize(DiscriminatorColumnAnnotation column) {
super.initialize(column);
this.defaultDiscriminatorType = this.buildDefaultDiscriminatorType();
this.defaultLength = this.buildDefaultLength();
- this.specifiedDiscriminatorType = this.getResourceDiscriminatorType(column);
- this.specifiedLength = this.getResourceLength(column);
+ this.specifiedDiscriminatorType = this.getResourceDiscriminatorType();
+ this.specifiedLength = this.getResourceLength();
}
@Override
@@ -64,12 +59,6 @@ public class GenericJavaDiscriminatorColumn extends AbstractJavaNamedColumn<Disc
protected JavaEntity getJavaEntity() {
return (JavaEntity) super.getParent();
}
-
- @Override
- protected DiscriminatorColumnAnnotation getResourceColumn() {
- return (DiscriminatorColumnAnnotation) this.persistenceResource.
- getNonNullAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME);
- }
public boolean isResourceSpecified() {
return getResourceColumn().isSpecified();
@@ -170,10 +159,11 @@ public class GenericJavaDiscriminatorColumn extends AbstractJavaNamedColumn<Disc
@Override
public void update(DiscriminatorColumnAnnotation discriminatorColumn) {
//don't call super because postUpdate() handles updating the default column name
+ this.resourceColumn = discriminatorColumn;
this.setSpecifiedName_(discriminatorColumn.getName());
this.setColumnDefinition_(discriminatorColumn.getColumnDefinition());
- this.setSpecifiedDiscriminatorType_(this.getResourceDiscriminatorType(discriminatorColumn));
- this.setSpecifiedLength_(this.getResourceLength(discriminatorColumn));
+ this.setSpecifiedDiscriminatorType_(this.getResourceDiscriminatorType());
+ this.setSpecifiedLength_(this.getResourceLength());
}
@Override
@@ -187,12 +177,12 @@ public class GenericJavaDiscriminatorColumn extends AbstractJavaNamedColumn<Disc
this.setDefaultLength(this.buildDefaultLength());
}
- protected DiscriminatorType getResourceDiscriminatorType(DiscriminatorColumnAnnotation discriminatorColumn) {
- return DiscriminatorType.fromJavaResourceModel(discriminatorColumn.getDiscriminatorType());
+ protected DiscriminatorType getResourceDiscriminatorType() {
+ return DiscriminatorType.fromJavaResourceModel(getResourceColumn().getDiscriminatorType());
}
- protected Integer getResourceLength(DiscriminatorColumnAnnotation discriminatorColumn) {
- return discriminatorColumn.getLength();
+ protected Integer getResourceLength() {
+ return getResourceColumn().getLength();
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaJoinColumn.java
index fe00f95b2e..7914e66777 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaJoinColumn.java
@@ -37,18 +37,26 @@ public class GenericJavaJoinColumn extends AbstractJavaBaseColumn<JoinColumnAnno
protected String specifiedReferencedColumnName;
protected String defaultReferencedColumnName;
-
- protected JoinColumnAnnotation joinColumn;
public GenericJavaJoinColumn(JavaJpaContextNode parent, JavaJoinColumn.Owner owner) {
super(parent, owner);
}
-
+
@Override
- protected JoinColumnAnnotation getResourceColumn() {
- return this.joinColumn;
+ public void initialize(JoinColumnAnnotation annotation) {
+ super.initialize(annotation);
+ this.specifiedReferencedColumnName = annotation.getReferencedColumnName();
+ this.defaultReferencedColumnName = this.buildDefaultReferencedColumnName();
}
+ @Override
+ public void update(JoinColumnAnnotation annotation) {
+ super.update(annotation);
+ this.setSpecifiedReferencedColumnName_(annotation.getReferencedColumnName());
+ this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName());
+ }
+
+
public String getReferencedColumnName() {
return (this.specifiedReferencedColumnName == null) ? this.defaultReferencedColumnName : this.specifiedReferencedColumnName;
}
@@ -60,7 +68,7 @@ public class GenericJavaJoinColumn extends AbstractJavaBaseColumn<JoinColumnAnno
public void setSpecifiedReferencedColumnName(String newSpecifiedReferencedColumnName) {
String oldSpecifiedReferencedColumnName = this.specifiedReferencedColumnName;
this.specifiedReferencedColumnName = newSpecifiedReferencedColumnName;
- this.joinColumn.setReferencedColumnName(newSpecifiedReferencedColumnName);
+ this.getResourceColumn().setReferencedColumnName(newSpecifiedReferencedColumnName);
firePropertyChanged(BaseJoinColumn.SPECIFIED_REFERENCED_COLUMN_NAME_PROPERTY, oldSpecifiedReferencedColumnName, newSpecifiedReferencedColumnName);
}
@@ -148,22 +156,6 @@ public class GenericJavaJoinColumn extends AbstractJavaBaseColumn<JoinColumnAnno
}
@Override
- public void initialize(JoinColumnAnnotation annotation) {
- this.joinColumn = annotation;
- super.initialize(annotation);
- this.specifiedReferencedColumnName = annotation.getReferencedColumnName();
- this.defaultReferencedColumnName = this.buildDefaultReferencedColumnName();
- }
-
- @Override
- public void update(JoinColumnAnnotation annotation) {
- this.joinColumn = annotation;
- super.update(annotation);
- this.setSpecifiedReferencedColumnName_(annotation.getReferencedColumnName());
- this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName());
- }
-
- @Override
protected String buildDefaultName() {
return MappingTools.buildJoinColumnDefaultName(this);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java
index ddfa8a782e..23b3ada09b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java
@@ -31,8 +31,6 @@ public class GenericJavaPrimaryKeyJoinColumn extends AbstractJavaNamedColumn<Pri
protected String specifiedReferencedColumnName;
protected String defaultReferencedColumnName;
-
- protected PrimaryKeyJoinColumnAnnotation resourcePrimaryKeyJoinColumn;
public GenericJavaPrimaryKeyJoinColumn(JavaJpaContextNode parent, JavaBaseJoinColumn.Owner owner) {
super(parent, owner);
@@ -40,24 +38,25 @@ public class GenericJavaPrimaryKeyJoinColumn extends AbstractJavaNamedColumn<Pri
@Override
public void initialize(PrimaryKeyJoinColumnAnnotation column) {
- this.resourcePrimaryKeyJoinColumn = column;
super.initialize(column);
- this.specifiedReferencedColumnName = this.getResourceReferencedColumnName(column);
+ this.specifiedReferencedColumnName = this.getResourceReferencedColumnName();
this.defaultReferencedColumnName = this.buildDefaultReferencedColumnName();
}
+ @Override
+ public void update(PrimaryKeyJoinColumnAnnotation resourceColumn) {
+ super.update(resourceColumn);
+ this.setSpecifiedReferencedColumnName_(this.getResourceReferencedColumnName());
+ this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName());
+ }
+
//************** JavaNamedColumn implementation ***************
@Override
public JavaBaseJoinColumn.Owner getOwner() {
return (JavaBaseJoinColumn.Owner) super.getOwner();
}
- @Override
- protected PrimaryKeyJoinColumnAnnotation getResourceColumn() {
- return this.resourcePrimaryKeyJoinColumn;
- }
-
- //************** IAbstractJoinColumn implementation ***************
+ //************** BaseJoinColumn implementation ***************
public String getReferencedColumnName() {
return (this.specifiedReferencedColumnName == null) ? this.defaultReferencedColumnName : this.specifiedReferencedColumnName;
@@ -149,17 +148,9 @@ public class GenericJavaPrimaryKeyJoinColumn extends AbstractJavaNamedColumn<Pri
TextRange textRange = getResourceColumn().getTextRange(astRoot);
return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
}
-
- @Override
- public void update(PrimaryKeyJoinColumnAnnotation resourceColumn) {
- this.resourcePrimaryKeyJoinColumn = resourceColumn;
- super.update(resourceColumn);
- this.setSpecifiedReferencedColumnName_(this.getResourceReferencedColumnName(resourceColumn));
- this.setDefaultReferencedColumnName(this.buildDefaultReferencedColumnName());
- }
- protected String getResourceReferencedColumnName(PrimaryKeyJoinColumnAnnotation resourceColumn) {
- return resourceColumn.getReferencedColumnName();
+ protected String getResourceReferencedColumnName() {
+ return getResourceColumn().getReferencedColumnName();
}
//TODO not correct when we start supporting primaryKeyJoinColumns in 1-1 mappings

Back to the top