diff options
author | kmoore | 2008-08-15 15:24:31 +0000 |
---|---|---|
committer | kmoore | 2008-08-15 15:24:31 +0000 |
commit | 3096256dac9260b13ea7707b9be06e671d5fb8bf (patch) | |
tree | ff8b9ae62f2697328edaa223fea82b8a1dc6a25e /jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core | |
parent | ee6048c8124f0c263c7445d8cda98a603b88b2a1 (diff) | |
download | webtools.dali-3096256dac9260b13ea7707b9be06e671d5fb8bf.tar.gz webtools.dali-3096256dac9260b13ea7707b9be06e671d5fb8bf.tar.xz webtools.dali-3096256dac9260b13ea7707b9be06e671d5fb8bf.zip |
removed initialize method from interface, instead pass the resource model object in via the constructor
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core')
25 files changed, 381 insertions, 368 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 18b4673fc7..b3a4c42c1e 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 @@ -101,12 +101,21 @@ import org.eclipse.jpt.core.context.persistence.Persistence; import org.eclipse.jpt.core.context.persistence.PersistenceUnit; import org.eclipse.jpt.core.context.persistence.PersistenceXml; import org.eclipse.jpt.core.context.persistence.Property; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.orm.OrmResource; import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; +import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue; +import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; +import org.eclipse.jpt.core.resource.orm.XmlNamedNativeQuery; +import org.eclipse.jpt.core.resource.orm.XmlNamedQuery; +import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn; +import org.eclipse.jpt.core.resource.orm.XmlQueryHint; import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable; +import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator; +import org.eclipse.jpt.core.resource.orm.XmlTableGenerator; import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint; import org.eclipse.jpt.core.resource.persistence.PersistenceResource; import org.eclipse.jpt.core.resource.persistence.XmlJavaClassRef; @@ -179,9 +188,9 @@ public interface JpaFactory PersistenceXml buildPersistenceXml(JpaRootContextNode parent, PersistenceResource persistenceResource); - Persistence buildPersistence(PersistenceXml parent, XmlPersistence xmlPersistence); + Persistence buildPersistence(PersistenceXml parent, XmlPersistence resourcePersistence); - PersistenceUnit buildPersistenceUnit(Persistence parent, XmlPersistenceUnit persistenceUnit); + PersistenceUnit buildPersistenceUnit(Persistence parent, XmlPersistenceUnit resourcePersistenceUnit); /** * xmlMappingFileRef is allowed to be null, this would be used for the implied mapping file ref @@ -219,11 +228,11 @@ public interface JpaFactory OrmSecondaryTable buildOrmSecondaryTable(OrmEntity parent, XmlSecondaryTable xmlSecondaryTable); - OrmPrimaryKeyJoinColumn buildOrmPrimaryKeyJoinColumn(OrmJpaContextNode parent, OrmBaseJoinColumn.Owner owner); + OrmPrimaryKeyJoinColumn buildOrmPrimaryKeyJoinColumn(OrmJpaContextNode parent, OrmBaseJoinColumn.Owner owner, XmlPrimaryKeyJoinColumn resourcePkJoinColumn); OrmJoinTable buildOrmJoinTable(OrmRelationshipMapping parent); - OrmJoinColumn buildOrmJoinColumn(OrmJpaContextNode parent, OrmJoinColumn.Owner owner); + OrmJoinColumn buildOrmJoinColumn(OrmJpaContextNode parent, OrmJoinColumn.Owner owner, XmlJoinColumn resourceJoinColumn); OrmAttributeOverride buildOrmAttributeOverride(OrmJpaContextNode parent, AttributeOverride.Owner owner, XmlAttributeOverride xmlAttributeOverride); @@ -233,17 +242,17 @@ public interface JpaFactory OrmColumn buildOrmColumn(OrmJpaContextNode parent, OrmColumn.Owner owner); - OrmGeneratedValue buildOrmGeneratedValue(OrmJpaContextNode parent); + OrmGeneratedValue buildOrmGeneratedValue(OrmJpaContextNode parent, XmlGeneratedValue resourceGeneratedValue); - OrmSequenceGenerator buildOrmSequenceGenerator(OrmJpaContextNode parent); + OrmSequenceGenerator buildOrmSequenceGenerator(OrmJpaContextNode parent, XmlSequenceGenerator resourceSequenceGenerator); - OrmTableGenerator buildOrmTableGenerator(OrmJpaContextNode parent); + OrmTableGenerator buildOrmTableGenerator(OrmJpaContextNode parent, XmlTableGenerator resourceTableGenerator); - OrmNamedNativeQuery buildOrmNamedNativeQuery(OrmJpaContextNode parent); + OrmNamedNativeQuery buildOrmNamedNativeQuery(OrmJpaContextNode parent, XmlNamedNativeQuery resourceNamedQuery); - OrmNamedQuery buildOrmNamedQuery(OrmJpaContextNode parent); + OrmNamedQuery buildOrmNamedQuery(OrmJpaContextNode parent, XmlNamedQuery resourceNamedQuery); - OrmQueryHint buildOrmQueryHint(OrmQuery parent); + OrmQueryHint buildOrmQueryHint(OrmQuery parent, XmlQueryHint resourceQueryhint); OrmBasicMapping buildOrmBasicMapping(OrmPersistentAttribute parent); @@ -267,11 +276,11 @@ public interface JpaFactory OrmAttributeMapping buildOrmNullAttributeMapping(OrmPersistentAttribute parent); - OrmUniqueConstraint buildOrmUniqueConstraint(OrmJpaContextNode parent, UniqueConstraint.Owner owner, XmlUniqueConstraint xmlUniqueConstraint); + OrmUniqueConstraint buildOrmUniqueConstraint(OrmJpaContextNode parent, UniqueConstraint.Owner owner, XmlUniqueConstraint resourceUniqueConstraint); // **************** java context objects *********************************** - JavaPersistentType buildJavaPersistentType(JpaContextNode parent, JavaResourcePersistentType resourcePersistentType); + JavaPersistentType buildJavaPersistentType(JpaContextNode parent, JavaResourcePersistentType jrpt); JavaEntity buildJavaEntity(JavaPersistentType parent); @@ -281,7 +290,7 @@ public interface JpaFactory JavaTypeMapping buildJavaNullTypeMapping(JavaPersistentType parent); - JavaPersistentAttribute buildJavaPersistentAttribute(JavaPersistentType parent); + JavaPersistentAttribute buildJavaPersistentAttribute(JavaPersistentType parent, JavaResourcePersistentAttribute jrpa); JavaBasicMapping buildJavaBasicMapping(JavaPersistentAttribute parent); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaPersistentAttribute.java index cbdd31c8b7..77ef5abad9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/java/JavaPersistentAttribute.java @@ -34,10 +34,13 @@ public interface JavaPersistentAttribute extends PersistentAttribute, JavaJpaCon JavaTypeMapping getTypeMapping(); JavaPersistentType getPersistentType(); - - void initialize(JavaResourcePersistentAttribute resourcePersistentAttribute); - void update(JavaResourcePersistentAttribute resourcePersistentAttribute); + /** + * Update the JavaPersistentAttribute context model object to match the JavaResourcePersistentAttribute + * resource model object passed in to the constructor. + * see {@link org.eclipse.jpt.core.JpaProject#update()} + */ + void update(); JavaResourcePersistentAttribute getResourcePersistentAttribute(); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmGeneratedValue.java index 3c031e191e..44803a184d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmGeneratedValue.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmGeneratedValue.java @@ -29,7 +29,9 @@ public interface OrmGeneratedValue extends GeneratedValue, OrmJpaContextNode */ TextRange getGeneratorTextRange(); - void initialize(XmlGeneratedValue generatedValue); - + /** + * Update the OrmGeneratedValue context model object to match the XmlGeneratedValue + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ void update(XmlGeneratedValue generatedValue); }
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmJoinColumn.java index a5f6d1e561..20e89d685d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmJoinColumn.java @@ -24,10 +24,12 @@ import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; public interface OrmJoinColumn extends JoinColumn, OrmBaseJoinColumn, OrmBaseColumn { void initializeFrom(JoinColumn oldColumn); - - void initialize(XmlJoinColumn column); - - void update(XmlJoinColumn column); + + /** + * Update the OrmJoinColumn context model object to match the XmlJoinColumn + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ + void update(XmlJoinColumn resourceJoinColumn); Owner getOwner(); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmNamedNativeQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmNamedNativeQuery.java index d80e1138ee..20b3c204f4 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmNamedNativeQuery.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmNamedNativeQuery.java @@ -26,8 +26,10 @@ public interface OrmNamedNativeQuery extends OrmQuery, NamedNativeQuery { ListIterator<OrmQueryHint> hints(); - void initialize(XmlNamedNativeQuery queryResource); - - void update(XmlNamedNativeQuery queryResource); + /** + * Update the OrmNamedNativeQuery context model object to match the XmlNamedNativeQuery + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ + void update(XmlNamedNativeQuery resourceQuery); }
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmNamedQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmNamedQuery.java index 8d37ba5722..a5886beaa5 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmNamedQuery.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmNamedQuery.java @@ -26,7 +26,9 @@ public interface OrmNamedQuery extends OrmQuery, NamedQuery { ListIterator<OrmQueryHint> hints(); - void initialize(XmlNamedQuery queryResource); - + /** + * Update the OrmNamedQuery context model object to match the XmlNamedQuery + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ void update(XmlNamedQuery queryResource); }
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPrimaryKeyJoinColumn.java index 83efee2974..035b6f6085 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPrimaryKeyJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPrimaryKeyJoinColumn.java @@ -22,9 +22,11 @@ import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn; * will almost certainly be broken (repeatedly) as the API evolves. */ public interface OrmPrimaryKeyJoinColumn extends PrimaryKeyJoinColumn, OrmBaseJoinColumn -{ - void initialize(XmlPrimaryKeyJoinColumn column); - +{ + /** + * Update the OrmPrimaryKeyJoinColumn context model object to match the XmlPrimaryKeyJoinColumn + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ void update(XmlPrimaryKeyJoinColumn column); void initializeFrom(PrimaryKeyJoinColumn oldPkJoinColumn); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmQueryHint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmQueryHint.java index 3031ff6f63..583caeeed2 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmQueryHint.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmQueryHint.java @@ -23,7 +23,9 @@ import org.eclipse.jpt.core.resource.orm.XmlQueryHint; */ public interface OrmQueryHint extends QueryHint, OrmJpaContextNode { - void initialize(XmlQueryHint queryHint); - - void update(XmlQueryHint queryHint); + /** + * Update the OrmQueryHint context model object to match the XmlQueryHint + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ + void update(XmlQueryHint resourceQueryHint); }
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmSequenceGenerator.java index ed75a3be8c..67367b0222 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmSequenceGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmSequenceGenerator.java @@ -23,7 +23,10 @@ import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator; */ public interface OrmSequenceGenerator extends SequenceGenerator, OrmGenerator, OrmJpaContextNode { - void initialize(XmlSequenceGenerator sequenceGenerator); - + + /** + * Update the OrmSequenceGenerator context model object to match the XmlSequenceGenerator + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ void update(XmlSequenceGenerator sequenceGenerator); }
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTableGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTableGenerator.java index 9f3183a4fe..ba8d2add5d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTableGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTableGenerator.java @@ -24,8 +24,11 @@ import org.eclipse.jpt.core.resource.orm.XmlTableGenerator; */ public interface OrmTableGenerator extends TableGenerator, OrmGenerator, OrmJpaContextNode { - void initialize(XmlTableGenerator tableGenerator); + /** + * Update the OrmTableGenerator context model object to match the XmlTableGenerator + * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} + */ void update(XmlTableGenerator tableGenerator); //****************** covariant overrides ******************* diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentAttribute.java index 501f2513af..9e80466e0c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPersistentAttribute.java @@ -40,29 +40,30 @@ public class GenericJavaPersistentAttribute extends AbstractJavaJpaContextNode protected JavaResourcePersistentAttribute resourcePersistentAttribute; - public GenericJavaPersistentAttribute(JavaPersistentType parent) { + public GenericJavaPersistentAttribute(JavaPersistentType parent, JavaResourcePersistentAttribute jrpa) { super(parent); + this.initialize(jrpa); } public String getId() { return JavaStructureNodes.PERSISTENT_ATTRIBUTE_ID; } - public void initialize(JavaResourcePersistentAttribute persistentAttributeResource) { - this.resourcePersistentAttribute = persistentAttributeResource; - this.name = this.name(persistentAttributeResource); - initializeDefaultMapping(persistentAttributeResource); - initializeSpecifiedMapping(persistentAttributeResource); + protected void initialize(JavaResourcePersistentAttribute jrpa) { + this.resourcePersistentAttribute = jrpa; + this.name = this.name(jrpa); + initializeDefaultMapping(jrpa); + initializeSpecifiedMapping(jrpa); } - protected void initializeDefaultMapping(JavaResourcePersistentAttribute persistentAttributeResource) { + protected void initializeDefaultMapping(JavaResourcePersistentAttribute jrpa) { this.defaultMapping = getJpaPlatform().buildDefaultJavaAttributeMapping(this); - this.defaultMapping.initialize(persistentAttributeResource); + this.defaultMapping.initialize(jrpa); } - protected void initializeSpecifiedMapping(JavaResourcePersistentAttribute persistentAttributeResource) { - String javaMappingAnnotationName = this.javaMappingAnnotationName(persistentAttributeResource); - this.specifiedMapping = createJavaAttributeMappingFromAnnotation(javaMappingAnnotationName, persistentAttributeResource); + protected void initializeSpecifiedMapping(JavaResourcePersistentAttribute jrpa) { + String javaMappingAnnotationName = this.javaMappingAnnotationName(jrpa); + this.specifiedMapping = createJavaAttributeMappingFromAnnotation(javaMappingAnnotationName, jrpa); } public JavaResourcePersistentAttribute getResourcePersistentAttribute() { @@ -222,11 +223,10 @@ public class GenericJavaPersistentAttribute extends AbstractJavaJpaContextNode return JDTTools.buildASTRoot(this.resourcePersistentAttribute.getJpaCompilationUnit().getCompilationUnit()); } - public void update(JavaResourcePersistentAttribute jrpa) { - this.resourcePersistentAttribute = jrpa; - this.setName(this.name(jrpa)); - this.updateDefaultMapping(jrpa); - this.updateSpecifiedMapping(jrpa); + public void update() { + this.setName(this.name(this.resourcePersistentAttribute)); + this.updateDefaultMapping(this.resourcePersistentAttribute); + this.updateSpecifiedMapping(this.resourcePersistentAttribute); } protected String name(JavaResourcePersistentAttribute jrpa) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java index 5b02eba937..2939478347 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java @@ -118,15 +118,15 @@ public abstract class AbstractOrmSingleRelationshipMapping<T extends XmlSingleRe //cause change notifications to be sent to the UI in the wrong order this.defaultJoinColumn = null; } - XmlJoinColumn xmlJoinColumn = OrmFactory.eINSTANCE.createXmlJoinColumnImpl(); - OrmJoinColumn joinColumn = buildJoinColumn(xmlJoinColumn); - this.specifiedJoinColumns.add(index, joinColumn); - this.getAttributeMapping().getJoinColumns().add(index, xmlJoinColumn); - this.fireItemAdded(SingleRelationshipMapping.SPECIFIED_JOIN_COLUMNS_LIST, index, joinColumn); + XmlJoinColumn resourceJoinColumn = OrmFactory.eINSTANCE.createXmlJoinColumnImpl(); + OrmJoinColumn contextJoinColumn = buildJoinColumn(resourceJoinColumn); + this.specifiedJoinColumns.add(index, contextJoinColumn); + this.getAttributeMapping().getJoinColumns().add(index, resourceJoinColumn); + this.fireItemAdded(SingleRelationshipMapping.SPECIFIED_JOIN_COLUMNS_LIST, index, contextJoinColumn); if (oldDefaultJoinColumn != null) { this.firePropertyChanged(SingleRelationshipMapping.DEFAULT_JOIN_COLUMN, oldDefaultJoinColumn, null); } - return joinColumn; + return contextJoinColumn; } protected void addSpecifiedJoinColumn(int index, OrmJoinColumn joinColumn) { @@ -201,8 +201,8 @@ public abstract class AbstractOrmSingleRelationshipMapping<T extends XmlSingleRe if (singleRelationshipMapping == null) { return; } - for (XmlJoinColumn joinColumn : singleRelationshipMapping.getJoinColumns()) { - this.specifiedJoinColumns.add(buildJoinColumn(joinColumn)); + for (XmlJoinColumn resourceJoinColumn : singleRelationshipMapping.getJoinColumns()) { + this.specifiedJoinColumns.add(buildJoinColumn(resourceJoinColumn)); } } @@ -217,10 +217,8 @@ public abstract class AbstractOrmSingleRelationshipMapping<T extends XmlSingleRe this.defaultJoinColumn = buildJoinColumn(null); } - protected OrmJoinColumn buildJoinColumn(XmlJoinColumn joinColumn) { - OrmJoinColumn ormJoinColumn = getJpaFactory().buildOrmJoinColumn(this, new JoinColumnOwner()); - ormJoinColumn.initialize(joinColumn); - return ormJoinColumn; + protected OrmJoinColumn buildJoinColumn(XmlJoinColumn resourceJoinColumn) { + return getJpaFactory().buildOrmJoinColumn(this, new JoinColumnOwner(), resourceJoinColumn); } @Override @@ -232,19 +230,19 @@ public abstract class AbstractOrmSingleRelationshipMapping<T extends XmlSingleRe } protected void updateSpecifiedJoinColumns(T singleRelationshipMapping) { - ListIterator<OrmJoinColumn> joinColumns = specifiedJoinColumns(); + ListIterator<OrmJoinColumn> contextJoinColumns = specifiedJoinColumns(); ListIterator<XmlJoinColumn> resourceJoinColumns = EmptyListIterator.instance(); if (singleRelationshipMapping != null) { resourceJoinColumns = new CloneListIterator<XmlJoinColumn>(singleRelationshipMapping.getJoinColumns());//prevent ConcurrentModificiationException } - while (joinColumns.hasNext()) { - OrmJoinColumn joinColumn = joinColumns.next(); + while (contextJoinColumns.hasNext()) { + OrmJoinColumn contextJoinColumn = contextJoinColumns.next(); if (resourceJoinColumns.hasNext()) { - joinColumn.update(resourceJoinColumns.next()); + contextJoinColumn.update(resourceJoinColumns.next()); } else { - removeSpecifiedJoinColumn_(joinColumn); + removeSpecifiedJoinColumn_(contextJoinColumn); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericEntityMappings.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericEntityMappings.java index 4b7293fb34..c8023dd988 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericEntityMappings.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericEntityMappings.java @@ -315,13 +315,12 @@ public class GenericEntityMappings extends AbstractOrmJpaContextNode implements } public OrmSequenceGenerator addSequenceGenerator(int index) { - OrmSequenceGenerator ormSequenceGenerator = getJpaFactory().buildOrmSequenceGenerator(this); - this.sequenceGenerators.add(index, ormSequenceGenerator); - XmlSequenceGenerator sequenceGenerator = OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl(); - ormSequenceGenerator.initialize(sequenceGenerator); - this.xmlEntityMappings.getSequenceGenerators().add(index, sequenceGenerator); - fireItemAdded(SEQUENCE_GENERATORS_LIST, index, ormSequenceGenerator); - return ormSequenceGenerator; + XmlSequenceGenerator resourceSequenceGenerator = OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl(); + OrmSequenceGenerator contextSequenceGenerator = buildSequenceGenerator(resourceSequenceGenerator); + this.sequenceGenerators.add(index, contextSequenceGenerator); + this.xmlEntityMappings.getSequenceGenerators().add(index, resourceSequenceGenerator); + fireItemAdded(SEQUENCE_GENERATORS_LIST, index, contextSequenceGenerator); + return contextSequenceGenerator; } protected void addSequenceGenerator(int index, OrmSequenceGenerator sequenceGenerator) { @@ -357,13 +356,12 @@ public class GenericEntityMappings extends AbstractOrmJpaContextNode implements } public OrmTableGenerator addTableGenerator(int index) { - OrmTableGenerator xmlTableGenerator = getJpaFactory().buildOrmTableGenerator(this); - this.tableGenerators.add(index, xmlTableGenerator); - XmlTableGenerator tableGenerator = OrmFactory.eINSTANCE.createXmlTableGeneratorImpl(); - xmlTableGenerator.initialize(tableGenerator); - this.xmlEntityMappings.getTableGenerators().add(index, tableGenerator); - fireItemAdded(TABLE_GENERATORS_LIST, index, xmlTableGenerator); - return xmlTableGenerator; + XmlTableGenerator resourceTableGenerator = OrmFactory.eINSTANCE.createXmlTableGeneratorImpl(); + OrmTableGenerator contextTableGenerator = buildTableGenerator(resourceTableGenerator); + this.tableGenerators.add(index, contextTableGenerator); + this.xmlEntityMappings.getTableGenerators().add(index, resourceTableGenerator); + fireItemAdded(TABLE_GENERATORS_LIST, index, contextTableGenerator); + return contextTableGenerator; } protected void addTableGenerator(int index, OrmTableGenerator tableGenerator) { @@ -399,11 +397,12 @@ public class GenericEntityMappings extends AbstractOrmJpaContextNode implements } public OrmNamedQuery addNamedQuery(int index) { - OrmNamedQuery namedQuery = getJpaFactory().buildOrmNamedQuery(this); - this.namedQueries.add(index, namedQuery); - this.xmlEntityMappings.getNamedQueries().add(index, OrmFactory.eINSTANCE.createXmlNamedQuery()); - this.fireItemAdded(QueryHolder.NAMED_QUERIES_LIST, index, namedQuery); - return namedQuery; + XmlNamedQuery resourceNamedQuery = OrmFactory.eINSTANCE.createXmlNamedQuery(); + OrmNamedQuery contextNamedQuery = buildNamedQuery(resourceNamedQuery); + this.namedQueries.add(index, contextNamedQuery); + this.xmlEntityMappings.getNamedQueries().add(index, resourceNamedQuery); + this.fireItemAdded(QueryHolder.NAMED_QUERIES_LIST, index, contextNamedQuery); + return contextNamedQuery; } protected void addNamedQuery(int index, OrmNamedQuery namedQuery) { @@ -438,9 +437,10 @@ public class GenericEntityMappings extends AbstractOrmJpaContextNode implements } public OrmNamedNativeQuery addNamedNativeQuery(int index) { - OrmNamedNativeQuery namedNativeQuery = getJpaFactory().buildOrmNamedNativeQuery(this); + XmlNamedNativeQuery resourceNamedNativeQuery = OrmFactory.eINSTANCE.createXmlNamedNativeQuery(); + OrmNamedNativeQuery namedNativeQuery = buildNamedNativeQuery(resourceNamedNativeQuery); this.namedNativeQueries.add(index, namedNativeQuery); - this.xmlEntityMappings.getNamedNativeQueries().add(index, OrmFactory.eINSTANCE.createXmlNamedNativeQuery()); + this.xmlEntityMappings.getNamedNativeQueries().add(index, resourceNamedNativeQuery); this.fireItemAdded(QueryHolder.NAMED_NATIVE_QUERIES_LIST, index, namedNativeQuery); return namedNativeQuery; } @@ -639,15 +639,15 @@ public class GenericEntityMappings extends AbstractOrmJpaContextNode implements } protected void updateTableGenerators(XmlEntityMappings entityMappings) { - ListIterator<OrmTableGenerator> tableGenerators = tableGenerators(); + ListIterator<OrmTableGenerator> contextTableGenerators = tableGenerators(); ListIterator<XmlTableGenerator> resourceTableGenerators = new CloneListIterator<XmlTableGenerator>(entityMappings.getTableGenerators());//prevent ConcurrentModificiationException - while (tableGenerators.hasNext()) { - OrmTableGenerator tableGenerator = tableGenerators.next(); + while (contextTableGenerators.hasNext()) { + OrmTableGenerator contextTableGenerator = contextTableGenerators.next(); if (resourceTableGenerators.hasNext()) { - tableGenerator.update(resourceTableGenerators.next()); + contextTableGenerator.update(resourceTableGenerators.next()); } else { - removeTableGenerator_(tableGenerator); + removeTableGenerator_(contextTableGenerator); } } @@ -656,22 +656,20 @@ public class GenericEntityMappings extends AbstractOrmJpaContextNode implements } } - protected OrmTableGenerator buildTableGenerator(XmlTableGenerator tableGeneratorResource) { - OrmTableGenerator tableGenerator = getJpaFactory().buildOrmTableGenerator(this); - tableGenerator.initialize(tableGeneratorResource); - return tableGenerator; + protected OrmTableGenerator buildTableGenerator(XmlTableGenerator resourceTableGenerator) { + return getJpaFactory().buildOrmTableGenerator(this, resourceTableGenerator); } protected void updateSequenceGenerators(XmlEntityMappings entityMappings) { - ListIterator<OrmSequenceGenerator> sequenceGenerators = sequenceGenerators(); + ListIterator<OrmSequenceGenerator> contextSequenceGenerators = sequenceGenerators(); ListIterator<XmlSequenceGenerator> resourceSequenceGenerators = new CloneListIterator<XmlSequenceGenerator>(entityMappings.getSequenceGenerators());//prevent ConcurrentModificiationException - while (sequenceGenerators.hasNext()) { - OrmSequenceGenerator sequenceGenerator = sequenceGenerators.next(); + while (contextSequenceGenerators.hasNext()) { + OrmSequenceGenerator contextSequenceGenerator = contextSequenceGenerators.next(); if (resourceSequenceGenerators.hasNext()) { - sequenceGenerator.update(resourceSequenceGenerators.next()); + contextSequenceGenerator.update(resourceSequenceGenerators.next()); } else { - removeSequenceGenerator_(sequenceGenerator); + removeSequenceGenerator_(contextSequenceGenerator); } } @@ -680,23 +678,21 @@ public class GenericEntityMappings extends AbstractOrmJpaContextNode implements } } - protected OrmSequenceGenerator buildSequenceGenerator(XmlSequenceGenerator sequenceGeneratorResource) { - OrmSequenceGenerator sequenceGenerator = getJpaFactory().buildOrmSequenceGenerator(this); - sequenceGenerator.initialize(sequenceGeneratorResource); - return sequenceGenerator; + protected OrmSequenceGenerator buildSequenceGenerator(XmlSequenceGenerator resourceSequenceGenerator) { + return getJpaFactory().buildOrmSequenceGenerator(this, resourceSequenceGenerator); } protected void updateNamedQueries(XmlEntityMappings entityMappings) { - ListIterator<OrmNamedQuery> namedQueries = namedQueries(); + ListIterator<OrmNamedQuery> contextNamedQueries = namedQueries(); ListIterator<XmlNamedQuery> resourceNamedQueries = new CloneListIterator<XmlNamedQuery>(entityMappings.getNamedQueries());//prevent ConcurrentModificiationException - while (namedQueries.hasNext()) { - OrmNamedQuery namedQuery = namedQueries.next(); + while (contextNamedQueries.hasNext()) { + OrmNamedQuery contextNamedQuery = contextNamedQueries.next(); if (resourceNamedQueries.hasNext()) { - namedQuery.update(resourceNamedQueries.next()); + contextNamedQuery.update(resourceNamedQueries.next()); } else { - removeNamedQuery_(namedQuery); + removeNamedQuery_(contextNamedQuery); } } @@ -705,10 +701,8 @@ public class GenericEntityMappings extends AbstractOrmJpaContextNode implements } } - protected OrmNamedQuery buildNamedQuery(XmlNamedQuery namedQuery) { - OrmNamedQuery ormNamedQuery = getJpaFactory().buildOrmNamedQuery(this); - ormNamedQuery.initialize(namedQuery); - return ormNamedQuery; + protected OrmNamedQuery buildNamedQuery(XmlNamedQuery resourceNamedQuery) { + return getJpaFactory().buildOrmNamedQuery(this, resourceNamedQuery); } protected void updateNamedNativeQueries(XmlEntityMappings entityMappings) { @@ -730,10 +724,8 @@ public class GenericEntityMappings extends AbstractOrmJpaContextNode implements } } - protected OrmNamedNativeQuery buildNamedNativeQuery(XmlNamedNativeQuery namedQuery) { - OrmNamedNativeQuery ormNamedNativeQuery =getJpaFactory().buildOrmNamedNativeQuery(this); - ormNamedNativeQuery.initialize(namedQuery); - return ormNamedNativeQuery; + protected OrmNamedNativeQuery buildNamedNativeQuery(XmlNamedNativeQuery resourceNamedQuery) { + return getJpaFactory().buildOrmNamedNativeQuery(this, resourceNamedQuery); } protected void updatePersistenceUnitGeneratorsAndQueries() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmAssociationOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmAssociationOverride.java index 92f2999299..591c97cefe 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmAssociationOverride.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmAssociationOverride.java @@ -40,15 +40,15 @@ public class GenericOrmAssociationOverride extends AbstractOrmJpaContextNode private final AssociationOverride.Owner owner; - protected XmlAssociationOverride associationOverride; + protected XmlAssociationOverride resourceAssociationOverride; - public GenericOrmAssociationOverride(OrmJpaContextNode parent, AssociationOverride.Owner owner, XmlAssociationOverride associationOverride) { + public GenericOrmAssociationOverride(OrmJpaContextNode parent, AssociationOverride.Owner owner, XmlAssociationOverride resourceAssociationOverride) { super(parent); this.owner = owner; this.specifiedJoinColumns = new ArrayList<OrmJoinColumn>(); this.defaultJoinColumns = new ArrayList<OrmJoinColumn>(); - this.initialize(associationOverride); + this.initialize(resourceAssociationOverride); } public OrmAssociationOverride setVirtual(boolean virtual) { @@ -68,7 +68,7 @@ public class GenericOrmAssociationOverride extends AbstractOrmJpaContextNode public void setName(String newName) { String oldName = this.name; this.name = newName; - this.associationOverride.setName(newName); + this.resourceAssociationOverride.setName(newName); firePropertyChanged(BaseOverride.NAME_PROPERTY, oldName, newName); } @@ -98,11 +98,12 @@ public class GenericOrmAssociationOverride extends AbstractOrmJpaContextNode } public OrmJoinColumn addSpecifiedJoinColumn(int index) { - OrmJoinColumn joinColumn = getJpaFactory().buildOrmJoinColumn(this, createJoinColumnOwner()); - this.specifiedJoinColumns.add(index, joinColumn); - this.associationOverride.getJoinColumns().add(index, OrmFactory.eINSTANCE.createXmlJoinColumnImpl()); - this.fireItemAdded(AssociationOverride.SPECIFIED_JOIN_COLUMNS_LIST, index, joinColumn); - return joinColumn; + XmlJoinColumn resourceJoinColumn = OrmFactory.eINSTANCE.createXmlJoinColumnImpl(); + OrmJoinColumn contextJoinColumn = buildJoinColumn(resourceJoinColumn); + this.specifiedJoinColumns.add(index, contextJoinColumn); + this.resourceAssociationOverride.getJoinColumns().add(index, resourceJoinColumn); + this.fireItemAdded(AssociationOverride.SPECIFIED_JOIN_COLUMNS_LIST, index, contextJoinColumn); + return contextJoinColumn; } protected OrmJoinColumn.Owner createJoinColumnOwner() { @@ -115,7 +116,7 @@ public class GenericOrmAssociationOverride extends AbstractOrmJpaContextNode public void removeSpecifiedJoinColumn(int index) { OrmJoinColumn removedJoinColumn = this.specifiedJoinColumns.remove(index); - this.associationOverride.getJoinColumns().remove(index); + this.resourceAssociationOverride.getJoinColumns().remove(index); fireItemRemoved(Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedJoinColumn); } @@ -124,7 +125,7 @@ public class GenericOrmAssociationOverride extends AbstractOrmJpaContextNode } public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) { - this.associationOverride.getJoinColumns().move(targetIndex, sourceIndex); + this.resourceAssociationOverride.getJoinColumns().move(targetIndex, sourceIndex); moveItemInList(targetIndex, sourceIndex, this.specifiedJoinColumns, AssociationOverride.SPECIFIED_JOIN_COLUMNS_LIST); } @@ -136,47 +137,45 @@ public class GenericOrmAssociationOverride extends AbstractOrmJpaContextNode return getOwner().isVirtual(this); } - protected void initialize(XmlAssociationOverride associationOverride) { - this.associationOverride = associationOverride; - this.name = associationOverride.getName(); - initializeSpecifiedJoinColumns(associationOverride); + protected void initialize(XmlAssociationOverride resourceAssociationOverride) { + this.resourceAssociationOverride = resourceAssociationOverride; + this.name = resourceAssociationOverride.getName(); + initializeSpecifiedJoinColumns(resourceAssociationOverride); } - protected void initializeSpecifiedJoinColumns(XmlAssociationOverride associationOverride) { - for (XmlJoinColumn joinColumn : associationOverride.getJoinColumns()) { - this.specifiedJoinColumns.add(createJoinColumn(joinColumn)); + protected void initializeSpecifiedJoinColumns(XmlAssociationOverride resourceAssociationOverride) { + for (XmlJoinColumn joinColumn : resourceAssociationOverride.getJoinColumns()) { + this.specifiedJoinColumns.add(buildJoinColumn(joinColumn)); } } - public void update(XmlAssociationOverride associationOverride) { - this.associationOverride = associationOverride; - this.setName(associationOverride.getName()); - updateSpecifiedJoinColumns(associationOverride); + public void update(XmlAssociationOverride resourceAssociationOverride) { + this.resourceAssociationOverride = resourceAssociationOverride; + this.setName(resourceAssociationOverride.getName()); + updateSpecifiedJoinColumns(resourceAssociationOverride); } - protected void updateSpecifiedJoinColumns(XmlAssociationOverride associationOverride) { - ListIterator<OrmJoinColumn> joinColumns = specifiedJoinColumns(); - ListIterator<XmlJoinColumn> resourceJoinColumns = new CloneListIterator<XmlJoinColumn>(associationOverride.getJoinColumns());//prevent ConcurrentModificiationException + protected void updateSpecifiedJoinColumns(XmlAssociationOverride resourceAssociationOverride) { + ListIterator<OrmJoinColumn> contextJoinColumns = specifiedJoinColumns(); + ListIterator<XmlJoinColumn> resourceJoinColumns = new CloneListIterator<XmlJoinColumn>(resourceAssociationOverride.getJoinColumns());//prevent ConcurrentModificiationException - while (joinColumns.hasNext()) { - OrmJoinColumn joinColumn = joinColumns.next(); + while (contextJoinColumns.hasNext()) { + OrmJoinColumn contextJoinColumn = contextJoinColumns.next(); if (resourceJoinColumns.hasNext()) { - joinColumn.update(resourceJoinColumns.next()); + contextJoinColumn.update(resourceJoinColumns.next()); } else { - removeSpecifiedJoinColumn(joinColumn); + removeSpecifiedJoinColumn(contextJoinColumn); } } while (resourceJoinColumns.hasNext()) { - addSpecifiedJoinColumn(specifiedJoinColumnsSize(), createJoinColumn(resourceJoinColumns.next())); + addSpecifiedJoinColumn(specifiedJoinColumnsSize(), buildJoinColumn(resourceJoinColumns.next())); } } - protected OrmJoinColumn createJoinColumn(XmlJoinColumn joinColumn) { - OrmJoinColumn ormJoinColumn = getJpaFactory().buildOrmJoinColumn(this, new JoinColumnOwner()); - ormJoinColumn.initialize(joinColumn); - return ormJoinColumn; + protected OrmJoinColumn buildJoinColumn(XmlJoinColumn resourceJoinColumn) { + return getJpaFactory().buildOrmJoinColumn(this, new JoinColumnOwner(), resourceJoinColumn); } public TextRange getValidationTextRange() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java index cfa37c050c..b5e671605b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEntity.java @@ -535,8 +535,9 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen if (getSequenceGenerator() != null) { throw new IllegalStateException("sequenceGenerator already exists"); //$NON-NLS-1$ } - this.sequenceGenerator = getJpaFactory().buildOrmSequenceGenerator(this); - getTypeMappingResource().setSequenceGenerator(OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl()); + XmlSequenceGenerator resourceSequenceGenerator = OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl(); + this.sequenceGenerator = buildSequenceGenerator(resourceSequenceGenerator); + getTypeMappingResource().setSequenceGenerator(resourceSequenceGenerator); firePropertyChanged(SEQUENCE_GENERATOR_PROPERTY, null, this.sequenceGenerator); return this.sequenceGenerator; } @@ -565,8 +566,9 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen if (getTableGenerator() != null) { throw new IllegalStateException("tableGenerator already exists"); //$NON-NLS-1$ } - this.tableGenerator = getJpaFactory().buildOrmTableGenerator(this); - getTypeMappingResource().setTableGenerator(OrmFactory.eINSTANCE.createXmlTableGeneratorImpl()); + XmlTableGenerator resourceTableGenerator = OrmFactory.eINSTANCE.createXmlTableGeneratorImpl(); + this.tableGenerator = buildTableGenerator(resourceTableGenerator); + getTypeMappingResource().setTableGenerator(resourceTableGenerator); firePropertyChanged(TABLE_GENERATOR_PROPERTY, null, this.tableGenerator); return this.tableGenerator; } @@ -677,14 +679,14 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen if (!this.defaultPrimaryKeyJoinColumns.isEmpty()) { this.defaultPrimaryKeyJoinColumns.clear(); } - XmlPrimaryKeyJoinColumn xmlPrimaryKeyJoinColumn = OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl(); - OrmPrimaryKeyJoinColumn primaryKeyJoinColumn = buildPrimaryKeyJoinColumn(xmlPrimaryKeyJoinColumn); - this.specifiedPrimaryKeyJoinColumns.add(index, primaryKeyJoinColumn); - this.getTypeMappingResource().getPrimaryKeyJoinColumns().add(index, xmlPrimaryKeyJoinColumn); + XmlPrimaryKeyJoinColumn resourcePkJoinColumn = OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl(); + OrmPrimaryKeyJoinColumn contextPkJoinColumn = buildPrimaryKeyJoinColumn(resourcePkJoinColumn); + this.specifiedPrimaryKeyJoinColumns.add(index, contextPkJoinColumn); + this.getTypeMappingResource().getPrimaryKeyJoinColumns().add(index, resourcePkJoinColumn); - this.fireItemAdded(Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, primaryKeyJoinColumn); + this.fireItemAdded(Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, contextPkJoinColumn); this.fireListCleared(OrmEntity.DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST); - return primaryKeyJoinColumn; + return contextPkJoinColumn; } protected OrmBaseJoinColumn.Owner createPrimaryKeyJoinColumnOwner() { @@ -927,13 +929,12 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } public OrmNamedQuery addNamedQuery(int index) { - OrmNamedQuery namedQuery = getJpaFactory().buildOrmNamedQuery(this); - this.namedQueries.add(index, namedQuery); - XmlNamedQuery xmlNamedQuery = OrmFactory.eINSTANCE.createXmlNamedQuery(); - namedQuery.initialize(xmlNamedQuery); - this.getTypeMappingResource().getNamedQueries().add(index, xmlNamedQuery); - this.fireItemAdded(QueryHolder.NAMED_QUERIES_LIST, index, namedQuery); - return namedQuery; + XmlNamedQuery resourceNamedQuery = OrmFactory.eINSTANCE.createXmlNamedQuery(); + OrmNamedQuery contextNamedQuery = buildNamedQuery(resourceNamedQuery); + this.namedQueries.add(index, contextNamedQuery); + this.getTypeMappingResource().getNamedQueries().add(index, resourceNamedQuery); + this.fireItemAdded(QueryHolder.NAMED_QUERIES_LIST, index, contextNamedQuery); + return contextNamedQuery; } protected void addNamedQuery(int index, OrmNamedQuery namedQuery) { @@ -969,13 +970,12 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } public OrmNamedNativeQuery addNamedNativeQuery(int index) { - OrmNamedNativeQuery namedNativeQuery = getJpaFactory().buildOrmNamedNativeQuery(this); - this.namedNativeQueries.add(index, namedNativeQuery); - XmlNamedNativeQuery xmlNamedNativeQuery = OrmFactory.eINSTANCE.createXmlNamedNativeQuery(); - namedNativeQuery.initialize(xmlNamedNativeQuery); - this.getTypeMappingResource().getNamedNativeQueries().add(index, OrmFactory.eINSTANCE.createXmlNamedNativeQuery()); - this.fireItemAdded(QueryHolder.NAMED_NATIVE_QUERIES_LIST, index, namedNativeQuery); - return namedNativeQuery; + XmlNamedNativeQuery resourceNamedNativeQuery = OrmFactory.eINSTANCE.createXmlNamedNativeQuery(); + OrmNamedNativeQuery contextNamedNativeQuery = buildNamedNativeQuery(resourceNamedNativeQuery); + this.namedNativeQueries.add(index, contextNamedNativeQuery); + this.getTypeMappingResource().getNamedNativeQueries().add(index, resourceNamedNativeQuery); + this.fireItemAdded(QueryHolder.NAMED_NATIVE_QUERIES_LIST, index, contextNamedNativeQuery); + return contextNamedNativeQuery; } protected void addNamedNativeQuery(int index, OrmNamedNativeQuery namedNativeQuery) { @@ -1286,10 +1286,8 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } } - protected OrmTableGenerator buildTableGenerator(XmlTableGenerator tableGeneratorResource) { - OrmTableGenerator generator = getJpaFactory().buildOrmTableGenerator(this); - generator.initialize(tableGeneratorResource); - return generator; + protected OrmTableGenerator buildTableGenerator(XmlTableGenerator resourceTableGenerator) { + return getJpaFactory().buildOrmTableGenerator(this, resourceTableGenerator); } protected void initializeSequenceGenerator(XmlEntity entity) { @@ -1298,15 +1296,13 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } } - protected OrmSequenceGenerator buildSequenceGenerator(XmlSequenceGenerator xmlSequenceGenerator) { - OrmSequenceGenerator generator = getJpaFactory().buildOrmSequenceGenerator(this); - generator.initialize(xmlSequenceGenerator); - return generator; + protected OrmSequenceGenerator buildSequenceGenerator(XmlSequenceGenerator resourceSequenceGenerator) { + return getJpaFactory().buildOrmSequenceGenerator(this, resourceSequenceGenerator); } protected void initializeSpecifiedPrimaryKeyJoinColumns(XmlEntity entity) { - for (XmlPrimaryKeyJoinColumn primaryKeyJoinColumn : entity.getPrimaryKeyJoinColumns()) { - this.specifiedPrimaryKeyJoinColumns.add(buildPrimaryKeyJoinColumn(primaryKeyJoinColumn)); + for (XmlPrimaryKeyJoinColumn resourcePkJoinColumn : entity.getPrimaryKeyJoinColumns()) { + this.specifiedPrimaryKeyJoinColumns.add(buildPrimaryKeyJoinColumn(resourcePkJoinColumn)); } } @@ -1478,34 +1474,34 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen return buildSecondaryTable(new VirtualXmlSecondaryTable(javaSecondaryTable)); } - protected void updateTableGenerator(XmlEntity entity) { - if (entity.getTableGenerator() == null) { + protected void updateTableGenerator(XmlEntity resourceEntity) { + if (resourceEntity.getTableGenerator() == null) { if (getTableGenerator() != null) { setTableGenerator(null); } } else { if (getTableGenerator() == null) { - setTableGenerator(buildTableGenerator(entity.getTableGenerator())); + setTableGenerator(buildTableGenerator(resourceEntity.getTableGenerator())); } else { - getTableGenerator().update(entity.getTableGenerator()); + getTableGenerator().update(resourceEntity.getTableGenerator()); } } } - protected void updateSequenceGenerator(XmlEntity entity) { - if (entity.getSequenceGenerator() == null) { + protected void updateSequenceGenerator(XmlEntity resourceEntity) { + if (resourceEntity.getSequenceGenerator() == null) { if (getSequenceGenerator() != null) { setSequenceGenerator(null); } } else { if (getSequenceGenerator() == null) { - setSequenceGenerator(buildSequenceGenerator(entity.getSequenceGenerator())); + setSequenceGenerator(buildSequenceGenerator(resourceEntity.getSequenceGenerator())); } else { - getSequenceGenerator().update(entity.getSequenceGenerator()); + getSequenceGenerator().update(resourceEntity.getSequenceGenerator()); } } } @@ -1530,21 +1526,21 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } protected void updateSpecifiedPrimaryKeyJoinColumns(XmlEntity entity) { - ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns = specifiedPrimaryKeyJoinColumns(); - ListIterator<XmlPrimaryKeyJoinColumn> resourcePrimaryKeyJoinColumns = new CloneListIterator<XmlPrimaryKeyJoinColumn>(entity.getPrimaryKeyJoinColumns());//prevent ConcurrentModificiationException + ListIterator<OrmPrimaryKeyJoinColumn> contextPkJoinColumns = specifiedPrimaryKeyJoinColumns(); + ListIterator<XmlPrimaryKeyJoinColumn> resourcePkJoinColumns = new CloneListIterator<XmlPrimaryKeyJoinColumn>(entity.getPrimaryKeyJoinColumns());//prevent ConcurrentModificiationException - while (primaryKeyJoinColumns.hasNext()) { - OrmPrimaryKeyJoinColumn primaryKeyJoinColumn = primaryKeyJoinColumns.next(); - if (resourcePrimaryKeyJoinColumns.hasNext()) { - primaryKeyJoinColumn.update(resourcePrimaryKeyJoinColumns.next()); + while (contextPkJoinColumns.hasNext()) { + OrmPrimaryKeyJoinColumn contextPkJoinColumn = contextPkJoinColumns.next(); + if (resourcePkJoinColumns.hasNext()) { + contextPkJoinColumn.update(resourcePkJoinColumns.next()); } else { - removeSpecifiedPrimaryKeyJoinColumn_(primaryKeyJoinColumn); + removeSpecifiedPrimaryKeyJoinColumn_(contextPkJoinColumn); } } - while (resourcePrimaryKeyJoinColumns.hasNext()) { - addSpecifiedPrimaryKeyJoinColumn(specifiedPrimaryKeyJoinColumnsSize(), buildPrimaryKeyJoinColumn(resourcePrimaryKeyJoinColumns.next())); + while (resourcePkJoinColumns.hasNext()) { + addSpecifiedPrimaryKeyJoinColumn(specifiedPrimaryKeyJoinColumnsSize(), buildPrimaryKeyJoinColumn(resourcePkJoinColumns.next())); } } @@ -1588,10 +1584,8 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen return buildPrimaryKeyJoinColumn(new VirtualXmlPrimaryKeyJoinColumn(javaSecondaryTable)); } - protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn primaryKeyJoinColumn) { - OrmPrimaryKeyJoinColumn ormPrimaryKeyJoinColumn = getJpaFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner()); - ormPrimaryKeyJoinColumn.initialize(primaryKeyJoinColumn); - return ormPrimaryKeyJoinColumn; + protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn resourcePkJoinColumn) { + return getJpaFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner(), resourcePkJoinColumn); } protected void updateSpecifiedAttributeOverrides(XmlEntity entity) { @@ -1698,10 +1692,8 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } } - protected OrmNamedQuery buildNamedQuery(XmlNamedQuery namedQuery) { - OrmNamedQuery ormNamedQuery = getJpaFactory().buildOrmNamedQuery(this); - ormNamedQuery.initialize(namedQuery); - return ormNamedQuery; + protected OrmNamedQuery buildNamedQuery(XmlNamedQuery resourceNamedQuery) { + return getJpaFactory().buildOrmNamedQuery(this, resourceNamedQuery); } protected void updateNamedNativeQueries(XmlEntity entity) { @@ -1723,10 +1715,8 @@ public class GenericOrmEntity extends AbstractOrmTypeMapping<XmlEntity> implemen } } - protected OrmNamedNativeQuery buildNamedNativeQuery(XmlNamedNativeQuery namedQuery) { - OrmNamedNativeQuery ormNamedNativeQuery = getJpaFactory().buildOrmNamedNativeQuery(this); - ormNamedNativeQuery.initialize(namedQuery); - return ormNamedNativeQuery; + protected OrmNamedNativeQuery buildNamedNativeQuery(XmlNamedNativeQuery resourceNamedNativeQuery) { + return getJpaFactory().buildOrmNamedNativeQuery(this, resourceNamedNativeQuery); } protected void updateIdClass(XmlIdClass idClassResource) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmGeneratedValue.java index 2fe5dac4af..1ca06dc00b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmGeneratedValue.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmGeneratedValue.java @@ -24,10 +24,11 @@ public class GenericOrmGeneratedValue extends AbstractOrmJpaContextNode implemen protected String specifiedGenerator; protected String defaultGenerator; - protected XmlGeneratedValue generatedValue; + protected XmlGeneratedValue resourceGeneratedValue; - public GenericOrmGeneratedValue(OrmJpaContextNode parent) { + public GenericOrmGeneratedValue(OrmJpaContextNode parent, XmlGeneratedValue resourceGeneratedValue) { super(parent); + this.initialize(resourceGeneratedValue); } @Override @@ -50,7 +51,7 @@ public class GenericOrmGeneratedValue extends AbstractOrmJpaContextNode implemen public void setSpecifiedStrategy(GenerationType newSpecifiedStrategy) { GenerationType oldStrategy = this.specifiedStrategy; this.specifiedStrategy = newSpecifiedStrategy; - this.generatedValue.setStrategy(GenerationType.toOrmResourceModel(newSpecifiedStrategy)); + this.resourceGeneratedValue.setStrategy(GenerationType.toOrmResourceModel(newSpecifiedStrategy)); firePropertyChanged(SPECIFIED_STRATEGY_PROPERTY, oldStrategy, newSpecifiedStrategy); } @@ -81,7 +82,7 @@ public class GenericOrmGeneratedValue extends AbstractOrmJpaContextNode implemen public void setSpecifiedGenerator(String newSpecifiedGenerator) { String oldGenerator = this.specifiedGenerator; this.specifiedGenerator = newSpecifiedGenerator; - this.generatedValue.setGenerator(newSpecifiedGenerator); + this.resourceGeneratedValue.setGenerator(newSpecifiedGenerator); firePropertyChanged(SPECIFIED_GENERATOR_PROPERTY, oldGenerator, newSpecifiedGenerator); } @@ -92,39 +93,39 @@ public class GenericOrmGeneratedValue extends AbstractOrmJpaContextNode implemen } public TextRange getGeneratorTextRange() { - TextRange textRange = this.generatedValue.getGeneratorTextRange(); + TextRange textRange = this.resourceGeneratedValue.getGeneratorTextRange(); return textRange != null ? textRange : getValidationTextRange(); } // ********** resource model -> java context model ********** - public void initialize(XmlGeneratedValue generatedValue) { - this.generatedValue = generatedValue; - this.specifiedStrategy = this.strategy(generatedValue); - this.specifiedGenerator = this.generator(generatedValue); + protected void initialize(XmlGeneratedValue resourceGeneratedValue) { + this.resourceGeneratedValue = resourceGeneratedValue; + this.specifiedStrategy = this.strategy(resourceGeneratedValue); + this.specifiedGenerator = this.generator(resourceGeneratedValue); //TODO this.defaultGenerator = null; } - public void update(XmlGeneratedValue generatedValue) { - this.generatedValue = generatedValue; - this.setSpecifiedStrategy_(this.strategy(generatedValue)); - this.setSpecifiedGenerator_(this.generator(generatedValue)); + public void update(XmlGeneratedValue resourceGeneratedValue) { + this.resourceGeneratedValue = resourceGeneratedValue; + this.setSpecifiedStrategy_(this.strategy(resourceGeneratedValue)); + this.setSpecifiedGenerator_(this.generator(resourceGeneratedValue)); //TODO this.setDefaultGenerator(null); } - protected GenerationType strategy(XmlGeneratedValue generatedValue) { - return GenerationType.fromOrmResourceModel(generatedValue.getStrategy()); + protected GenerationType strategy(XmlGeneratedValue resourceGeneratedValue) { + return GenerationType.fromOrmResourceModel(resourceGeneratedValue.getStrategy()); } - protected String generator(XmlGeneratedValue generatedValue) { - return generatedValue.getGenerator(); + protected String generator(XmlGeneratedValue resourceGeneratedValue) { + return resourceGeneratedValue.getGenerator(); } public TextRange getValidationTextRange() { - TextRange validationTextRange = this.generatedValue.getValidationTextRange(); + TextRange validationTextRange = this.resourceGeneratedValue.getValidationTextRange(); return validationTextRange != null ? validationTextRange : getParent().getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmIdMapping.java index 04b3f75f3b..dca060697a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmIdMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmIdMapping.java @@ -105,8 +105,9 @@ public class GenericOrmIdMapping extends AbstractOrmAttributeMapping<XmlId> if (getGeneratedValue() != null) { throw new IllegalStateException("gemeratedValue already exists"); } - this.generatedValue = getJpaFactory().buildOrmGeneratedValue(this); - this.getAttributeMapping().setGeneratedValue(OrmFactory.eINSTANCE.createXmlGeneratedValueImpl()); + XmlGeneratedValue resourceGeneratedValue = OrmFactory.eINSTANCE.createXmlGeneratedValueImpl(); + this.generatedValue = buildGeneratedValue(resourceGeneratedValue); + this.getAttributeMapping().setGeneratedValue(resourceGeneratedValue); firePropertyChanged(GENERATED_VALUE_PROPERTY, null, this.generatedValue); return this.generatedValue; } @@ -135,8 +136,9 @@ public class GenericOrmIdMapping extends AbstractOrmAttributeMapping<XmlId> if (getSequenceGenerator() != null) { throw new IllegalStateException("sequenceGenerator already exists"); } - this.sequenceGenerator = getJpaFactory().buildOrmSequenceGenerator(this); - this.getAttributeMapping().setSequenceGenerator(OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl()); + XmlSequenceGenerator resourceSequenceGenerator = OrmFactory.eINSTANCE.createXmlSequenceGeneratorImpl(); + this.sequenceGenerator = buildSequenceGenerator(resourceSequenceGenerator); + this.getAttributeMapping().setSequenceGenerator(resourceSequenceGenerator); firePropertyChanged(SEQUENCE_GENERATOR_PROPERTY, null, this.sequenceGenerator); return this.sequenceGenerator; } @@ -165,8 +167,9 @@ public class GenericOrmIdMapping extends AbstractOrmAttributeMapping<XmlId> if (getTableGenerator() != null) { throw new IllegalStateException("tableGenerator already exists"); } - this.tableGenerator = getJpaFactory().buildOrmTableGenerator(this); - this.getAttributeMapping().setTableGenerator(OrmFactory.eINSTANCE.createXmlTableGeneratorImpl()); + XmlTableGenerator resourceTableGenerator = OrmFactory.eINSTANCE.createXmlTableGeneratorImpl(); + this.tableGenerator = buildTableGenerator(resourceTableGenerator); + this.getAttributeMapping().setTableGenerator(resourceTableGenerator); firePropertyChanged(TABLE_GENERATOR_PROPERTY, null, this.tableGenerator); return this.tableGenerator; } @@ -260,10 +263,8 @@ public class GenericOrmIdMapping extends AbstractOrmAttributeMapping<XmlId> } } - protected OrmSequenceGenerator buildSequenceGenerator(XmlSequenceGenerator xmlSequenceGenerator) { - OrmSequenceGenerator sequenceGenerator = getJpaFactory().buildOrmSequenceGenerator(this); - sequenceGenerator.initialize(xmlSequenceGenerator); - return sequenceGenerator; + protected OrmSequenceGenerator buildSequenceGenerator(XmlSequenceGenerator resourceSequenceGenerator) { + return getJpaFactory().buildOrmSequenceGenerator(this, resourceSequenceGenerator); } protected void initializeTableGenerator(XmlId id) { @@ -272,10 +273,8 @@ public class GenericOrmIdMapping extends AbstractOrmAttributeMapping<XmlId> } } - protected OrmTableGenerator buildTableGenerator(XmlTableGenerator tableGeneratorResource) { - OrmTableGenerator tableGenerator = getJpaFactory().buildOrmTableGenerator(this); - tableGenerator.initialize(tableGeneratorResource); - return tableGenerator; + protected OrmTableGenerator buildTableGenerator(XmlTableGenerator resourceTableGenerator) { + return getJpaFactory().buildOrmTableGenerator(this, resourceTableGenerator); } protected void initializeGeneratedValue(XmlId id) { @@ -284,10 +283,8 @@ public class GenericOrmIdMapping extends AbstractOrmAttributeMapping<XmlId> } } - protected OrmGeneratedValue buildGeneratedValue(XmlGeneratedValue xmlGeneratedValue) { - OrmGeneratedValue ormGeneratedValue = getJpaFactory().buildOrmGeneratedValue(this); - ormGeneratedValue.initialize(xmlGeneratedValue); - return ormGeneratedValue; + protected OrmGeneratedValue buildGeneratedValue(XmlGeneratedValue resourceGeneratedValue) { + return getJpaFactory().buildOrmGeneratedValue(this, resourceGeneratedValue); } @Override public void update(XmlId id) { @@ -341,7 +338,6 @@ public class GenericOrmIdMapping extends AbstractOrmAttributeMapping<XmlId> else { if (getGeneratedValue() == null) { setGeneratedValue(buildGeneratedValue(id.getGeneratedValue())); - getGeneratedValue().initialize(id.getGeneratedValue()); } else { getGeneratedValue().update(id.getGeneratedValue()); @@ -361,15 +357,15 @@ public class GenericOrmIdMapping extends AbstractOrmAttributeMapping<XmlId> //***************** IXmlColumn.Owner implementation **************** - public XmlColumn getColumnResource() { + public XmlColumn getResourceColumn() { return this.getAttributeMapping().getColumn(); } - public void addColumnResource() { + public void addResourceColumn() { this.getAttributeMapping().setColumn(OrmFactory.eINSTANCE.createXmlColumnImpl()); } - public void removeColumnResource() { + public void removeResourceColumn() { this.getAttributeMapping().setColumn(null); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmNamedQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmNamedQuery.java index 5bd004150f..da45a18c9d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmNamedQuery.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmNamedQuery.java @@ -17,8 +17,8 @@ import org.eclipse.jpt.core.resource.orm.XmlNamedQuery; public class GenericOrmNamedQuery extends AbstractOrmQuery<XmlNamedQuery> implements OrmNamedQuery { - public GenericOrmNamedQuery(OrmJpaContextNode parent) { - super(parent); + public GenericOrmNamedQuery(OrmJpaContextNode parent, XmlNamedQuery resourceNamedQuery) { + super(parent, resourceNamedQuery); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToOneMapping.java index b9cf47f2f2..52dae1e553 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToOneMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToOneMapping.java @@ -75,13 +75,12 @@ public class GenericOrmOneToOneMapping extends AbstractOrmSingleRelationshipMapp } public OrmPrimaryKeyJoinColumn addPrimaryKeyJoinColumn(int index) { - OrmPrimaryKeyJoinColumn pkJoinColumn = getJpaFactory().buildOrmPrimaryKeyJoinColumn(this, new JoinColumnOwner()); - XmlPrimaryKeyJoinColumn xmlPkJoinColumn = OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl(); - this.primaryKeyJoinColumns.add(index, pkJoinColumn); - this.getAttributeMapping().getPrimaryKeyJoinColumns().add(index, xmlPkJoinColumn); - pkJoinColumn.initialize(xmlPkJoinColumn); - this.fireItemAdded(OneToOneMapping.PRIMAY_KEY_JOIN_COLUMNS_LIST, index, pkJoinColumn); - return pkJoinColumn; + XmlPrimaryKeyJoinColumn resourcePkJoinColumn = OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl(); + OrmPrimaryKeyJoinColumn contextPkJoinColumn = buildPrimaryKeyJoinColumn(resourcePkJoinColumn); + this.primaryKeyJoinColumns.add(index, contextPkJoinColumn); + this.getAttributeMapping().getPrimaryKeyJoinColumns().add(index, resourcePkJoinColumn); + this.fireItemAdded(OneToOneMapping.PRIMAY_KEY_JOIN_COLUMNS_LIST, index, contextPkJoinColumn); + return contextPkJoinColumn; } protected void addPrimaryKeyJoinColumn(int index, OrmPrimaryKeyJoinColumn joinColumn) { @@ -249,15 +248,13 @@ public class GenericOrmOneToOneMapping extends AbstractOrmSingleRelationshipMapp if (oneToOne == null) { return; } - for (XmlPrimaryKeyJoinColumn pkJoinColumn : oneToOne.getPrimaryKeyJoinColumns()) { - this.primaryKeyJoinColumns.add(buildPrimaryKeyJoinColumn(pkJoinColumn)); + for (XmlPrimaryKeyJoinColumn resourcePkJoinColumn : oneToOne.getPrimaryKeyJoinColumns()) { + this.primaryKeyJoinColumns.add(buildPrimaryKeyJoinColumn(resourcePkJoinColumn)); } } - protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn xmlPkJoinColumn) { - OrmPrimaryKeyJoinColumn ormPkJoinColumn = getJpaFactory().buildOrmPrimaryKeyJoinColumn(this, new JoinColumnOwner()); - ormPkJoinColumn.initialize(xmlPkJoinColumn); - return ormPkJoinColumn; + protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn resourcePkJoinColumn) { + return getJpaFactory().buildOrmPrimaryKeyJoinColumn(this, new JoinColumnOwner(), resourcePkJoinColumn); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmQueryHint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmQueryHint.java index 0110bd7884..53e8683f49 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmQueryHint.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmQueryHint.java @@ -23,10 +23,11 @@ public class GenericOrmQueryHint extends AbstractOrmJpaContextNode implements Or protected String value; - protected XmlQueryHint queryHint; + protected XmlQueryHint resourceQueryHint; - public GenericOrmQueryHint(OrmQuery parent) { + public GenericOrmQueryHint(OrmQuery parent, XmlQueryHint resourceQueryHint) { super(parent); + this.initialize(resourceQueryHint); } public String getName() { @@ -36,7 +37,7 @@ public class GenericOrmQueryHint extends AbstractOrmJpaContextNode implements Or public void setName(String newName) { String oldName = this.name; this.name = newName; - this.queryHint.setName(newName); + this.resourceQueryHint.setName(newName); firePropertyChanged(QueryHint.NAME_PROPERTY, oldName, newName); } @@ -47,23 +48,23 @@ public class GenericOrmQueryHint extends AbstractOrmJpaContextNode implements Or public void setValue(String newValue) { String oldValue = this.value; this.value = newValue; - this.queryHint.setValue(newValue); + this.resourceQueryHint.setValue(newValue); firePropertyChanged(QueryHint.VALUE_PROPERTY, oldValue, newValue); } - public void initialize(XmlQueryHint queryHint) { - this.queryHint = queryHint; - this.name = queryHint.getName(); - this.value = queryHint.getValue(); + protected void initialize(XmlQueryHint resourceQueryHint) { + this.resourceQueryHint = resourceQueryHint; + this.name = resourceQueryHint.getName(); + this.value = resourceQueryHint.getValue(); } - public void update(XmlQueryHint queryHint) { - this.queryHint = queryHint; - this.setName(queryHint.getName()); - this.setValue(queryHint.getValue()); + public void update(XmlQueryHint resourceQueryHint) { + this.resourceQueryHint = resourceQueryHint; + this.setName(resourceQueryHint.getName()); + this.setValue(resourceQueryHint.getValue()); } public TextRange getValidationTextRange() { - return this.queryHint.getValidationTextRange(); + return this.resourceQueryHint.getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSecondaryTable.java index 8ccd9ff4e3..daed588a9e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSecondaryTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSecondaryTable.java @@ -117,16 +117,16 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable //cause change notifications to be sent to the UI in the wrong order this.defaultPrimaryKeyJoinColumn = null; } - XmlPrimaryKeyJoinColumn xmlPrimaryKeyJoinColumn = OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl(); - OrmPrimaryKeyJoinColumn primaryKeyJoinColumn = createPrimaryKeyJoinColumn(xmlPrimaryKeyJoinColumn); - this.specifiedPrimaryKeyJoinColumns.add(index, primaryKeyJoinColumn); - this.secondaryTable.getPrimaryKeyJoinColumns().add(index, xmlPrimaryKeyJoinColumn); + XmlPrimaryKeyJoinColumn resourcePkJoinColumn = OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumnImpl(); + OrmPrimaryKeyJoinColumn contextPkJoinColumn = buildPrimaryKeyJoinColumn(resourcePkJoinColumn); + this.specifiedPrimaryKeyJoinColumns.add(index, contextPkJoinColumn); + this.secondaryTable.getPrimaryKeyJoinColumns().add(index, resourcePkJoinColumn); - this.fireItemAdded(SecondaryTable.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, primaryKeyJoinColumn); + this.fireItemAdded(SecondaryTable.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, contextPkJoinColumn); if (oldDefaultPkJoinColumn != null) { this.firePropertyChanged(SecondaryTable.DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldDefaultPkJoinColumn, null); } - return primaryKeyJoinColumn; + return contextPkJoinColumn; } protected OrmBaseJoinColumn.Owner createPrimaryKeyJoinColumnOwner() { @@ -147,7 +147,7 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable //create the defaultJoinColumn now or this will happen during project update //after removing the join column from the resource model. That causes problems //in the UI because the change notifications end up in the wrong order. - this.defaultPrimaryKeyJoinColumn = createPrimaryKeyJoinColumn(null); + this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(null); } this.secondaryTable.getPrimaryKeyJoinColumns().remove(index); fireItemRemoved(SecondaryTable.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedPrimaryKeyJoinColumn); @@ -173,19 +173,19 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable } @Override - protected void addTableResource() { + protected void addResourceTable() { //secondaryTables are part of a collection, the secondary-table element will be removed/added //when the XmlSecondaryTable is removed/added to the XmlEntity collection } @Override - protected void removeTableResource() { + protected void removeResourceTable() { //secondaryTables are part of a collection, the secondary-table element will be removed/added //when the XmlSecondaryTable is removed/added to the XmlEntity collection } @Override - protected XmlSecondaryTable getTableResource() { + protected XmlSecondaryTable getResourceTable() { return this.secondaryTable; } @@ -197,8 +197,8 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable } protected void initializeSpecifiedPrimaryKeyJoinColumns(XmlSecondaryTable secondaryTable) { - for (XmlPrimaryKeyJoinColumn primaryKeyJoinColumn : secondaryTable.getPrimaryKeyJoinColumns()) { - this.specifiedPrimaryKeyJoinColumns.add(createPrimaryKeyJoinColumn(primaryKeyJoinColumn)); + for (XmlPrimaryKeyJoinColumn resourcePkJoinColumn : secondaryTable.getPrimaryKeyJoinColumns()) { + this.specifiedPrimaryKeyJoinColumns.add(buildPrimaryKeyJoinColumn(resourcePkJoinColumn)); } } @@ -210,7 +210,7 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable if (!shouldBuildDefaultPrimaryKeyJoinColumn()) { return; } - this.defaultPrimaryKeyJoinColumn = createPrimaryKeyJoinColumn(null); + this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(null); } public void update(XmlSecondaryTable secondaryTable) { @@ -235,7 +235,7 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable } while (resourcePrimaryKeyJoinColumns.hasNext()) { - addSpecifiedPrimaryKeyJoinColumn(specifiedPrimaryKeyJoinColumnsSize(), createPrimaryKeyJoinColumn(resourcePrimaryKeyJoinColumns.next())); + addSpecifiedPrimaryKeyJoinColumn(specifiedPrimaryKeyJoinColumnsSize(), buildPrimaryKeyJoinColumn(resourcePrimaryKeyJoinColumns.next())); } } @@ -245,17 +245,15 @@ public class GenericOrmSecondaryTable extends AbstractOrmTable return; } if (getDefaultPrimaryKeyJoinColumn() == null) { - this.setDefaultPrimaryKeyJoinColumn(createPrimaryKeyJoinColumn(null)); + this.setDefaultPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(null)); } else { this.defaultPrimaryKeyJoinColumn.update(null); } } - protected OrmPrimaryKeyJoinColumn createPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn xmlPrimaryKeyJoinColumn) { - OrmPrimaryKeyJoinColumn ormPrimaryKeyJoinColumn = getJpaFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner()); - ormPrimaryKeyJoinColumn.initialize(xmlPrimaryKeyJoinColumn); - return ormPrimaryKeyJoinColumn; + protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn resourcePkJoinColumn) { + return getJpaFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner(), resourcePkJoinColumn); } @Override diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSequenceGenerator.java index b42cac0d45..0beecdac49 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSequenceGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmSequenceGenerator.java @@ -22,8 +22,9 @@ public class GenericOrmSequenceGenerator extends AbstractOrmGenerator<XmlSequenc protected String defaultSequenceName; - public GenericOrmSequenceGenerator(OrmJpaContextNode parent) { + public GenericOrmSequenceGenerator(OrmJpaContextNode parent, XmlSequenceGenerator resourceSequenceGenerator) { super(parent); + this.initialize(resourceSequenceGenerator); } public String getSequenceName() { @@ -37,7 +38,7 @@ public class GenericOrmSequenceGenerator extends AbstractOrmGenerator<XmlSequenc public void setSpecifiedSequenceName(String newSpecifiedSequenceName) { String oldSpecifiedSequenceName = this.specifiedSequenceName; this.specifiedSequenceName = newSpecifiedSequenceName; - getGeneratorResource().setSequenceName(newSpecifiedSequenceName); + getResourceGenerator().setSequenceName(newSpecifiedSequenceName); firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, oldSpecifiedSequenceName, newSpecifiedSequenceName); } @@ -58,7 +59,7 @@ public class GenericOrmSequenceGenerator extends AbstractOrmGenerator<XmlSequenc } @Override - public void initialize(XmlSequenceGenerator sequenceGenerator) { + protected void initialize(XmlSequenceGenerator sequenceGenerator) { super.initialize(sequenceGenerator); this.specifiedSequenceName = this.specifiedSequenceName(sequenceGenerator); //TODO default sequence name diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmTableGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmTableGenerator.java index 0d8dd025bd..767b99fc41 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmTableGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmTableGenerator.java @@ -51,9 +51,10 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener protected final List<OrmUniqueConstraint> uniqueConstraints; - public GenericOrmTableGenerator(OrmJpaContextNode parent) { + public GenericOrmTableGenerator(OrmJpaContextNode parent, XmlTableGenerator resourceTableGenerator) { super(parent); this.uniqueConstraints = new ArrayList<OrmUniqueConstraint>(); + this.initialize(resourceTableGenerator); } public String getTable() { @@ -67,7 +68,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener public void setSpecifiedTable(String newSpecifiedTable) { String oldSpecifiedTable = this.specifiedTable; this.specifiedTable = newSpecifiedTable; - getGeneratorResource().setTable(newSpecifiedTable); + getResourceGenerator().setTable(newSpecifiedTable); firePropertyChanged(SPECIFIED_TABLE_PROPERTY, oldSpecifiedTable, newSpecifiedTable); } @@ -98,7 +99,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener public void setSpecifiedCatalog(String newSpecifiedCatalog) { String oldSpecifiedCatalog = this.specifiedCatalog; this.specifiedCatalog = newSpecifiedCatalog; - getGeneratorResource().setCatalog(newSpecifiedCatalog); + getResourceGenerator().setCatalog(newSpecifiedCatalog); firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, oldSpecifiedCatalog, newSpecifiedCatalog); } @@ -129,7 +130,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener public void setSpecifiedSchema(String newSpecifiedSchema) { String oldSpecifiedSchema = this.specifiedSchema; this.specifiedSchema = newSpecifiedSchema; - getGeneratorResource().setSchema(newSpecifiedSchema); + getResourceGenerator().setSchema(newSpecifiedSchema); firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, oldSpecifiedSchema, newSpecifiedSchema); } @@ -160,7 +161,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener public void setSpecifiedPkColumnName(String newSpecifiedPkColumnName) { String oldSpecifiedPkColumnName = this.specifiedPkColumnName; this.specifiedPkColumnName = newSpecifiedPkColumnName; - getGeneratorResource().setPkColumnName(newSpecifiedPkColumnName); + getResourceGenerator().setPkColumnName(newSpecifiedPkColumnName); firePropertyChanged(SPECIFIED_PK_COLUMN_NAME_PROPERTY, oldSpecifiedPkColumnName, newSpecifiedPkColumnName); } @@ -191,7 +192,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener public void setSpecifiedValueColumnName(String newSpecifiedValueColumnName) { String oldSpecifiedValueColumnName = this.specifiedValueColumnName; this.specifiedValueColumnName = newSpecifiedValueColumnName; - getGeneratorResource().setValueColumnName(newSpecifiedValueColumnName); + getResourceGenerator().setValueColumnName(newSpecifiedValueColumnName); firePropertyChanged(SPECIFIED_VALUE_COLUMN_NAME_PROPERTY, oldSpecifiedValueColumnName, newSpecifiedValueColumnName); } @@ -222,7 +223,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener public void setSpecifiedPkColumnValue(String newSpecifiedPkColumnValue) { String oldSpecifiedPkColumnValue = this.specifiedPkColumnValue; this.specifiedPkColumnValue = newSpecifiedPkColumnValue; - getGeneratorResource().setPkColumnValue(newSpecifiedPkColumnValue); + getResourceGenerator().setPkColumnValue(newSpecifiedPkColumnValue); firePropertyChanged(SPECIFIED_PK_COLUMN_VALUE_PROPERTY, oldSpecifiedPkColumnValue, newSpecifiedPkColumnValue); } @@ -254,12 +255,12 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener } public OrmUniqueConstraint addUniqueConstraint(int index) { - XmlUniqueConstraint uniqueConstraintResource = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl(); - OrmUniqueConstraint uniqueConstraint = buildUniqueConstraint(uniqueConstraintResource); - this.uniqueConstraints.add(index, uniqueConstraint); - getGeneratorResource().getUniqueConstraints().add(index, uniqueConstraintResource); - fireItemAdded(TableGenerator.UNIQUE_CONSTRAINTS_LIST, index, uniqueConstraint); - return uniqueConstraint; + XmlUniqueConstraint resourceUniqueConstraint = OrmFactory.eINSTANCE.createXmlUniqueConstraintImpl(); + OrmUniqueConstraint contextUniqueConstraint = buildUniqueConstraint(resourceUniqueConstraint); + this.uniqueConstraints.add(index, contextUniqueConstraint); + getResourceGenerator().getUniqueConstraints().add(index, resourceUniqueConstraint); + fireItemAdded(TableGenerator.UNIQUE_CONSTRAINTS_LIST, index, contextUniqueConstraint); + return contextUniqueConstraint; } protected void addUniqueConstraint(int index, OrmUniqueConstraint uniqueConstraint) { @@ -273,7 +274,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener public void removeUniqueConstraint(int index) { OrmUniqueConstraint removedUniqueConstraint = this.uniqueConstraints.remove(index); - getGeneratorResource().getUniqueConstraints().remove(index); + getResourceGenerator().getUniqueConstraints().remove(index); fireItemRemoved(TableGenerator.UNIQUE_CONSTRAINTS_LIST, index, removedUniqueConstraint); } @@ -283,7 +284,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener public void moveUniqueConstraint(int targetIndex, int sourceIndex) { CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex); - this.getGeneratorResource().getUniqueConstraints().move(targetIndex, sourceIndex); + this.getResourceGenerator().getUniqueConstraints().move(targetIndex, sourceIndex); fireItemMoved(TableGenerator.UNIQUE_CONSTRAINTS_LIST, targetIndex, sourceIndex); } @@ -309,7 +310,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener // ********** orm resource model -> context model ********** @Override - public void initialize(XmlTableGenerator tableGenerator) { + protected void initialize(XmlTableGenerator tableGenerator) { super.initialize(tableGenerator); this.specifiedTable = this.specifiedTable(tableGenerator); this.specifiedCatalog = this.specifiedCatalog(tableGenerator); @@ -379,7 +380,7 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener } protected void updateUniqueConstraints(XmlTableGenerator tableGenerator) { - ListIterator<OrmUniqueConstraint> uniqueConstraints = uniqueConstraints(); + ListIterator<OrmUniqueConstraint> contextUniqueConstraints = uniqueConstraints(); ListIterator<XmlUniqueConstraint> resourceUniqueConstraints; if (tableGenerator == null) { resourceUniqueConstraints = EmptyListIterator.instance(); @@ -388,13 +389,13 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener resourceUniqueConstraints = new CloneListIterator<XmlUniqueConstraint>(tableGenerator.getUniqueConstraints());//prevent ConcurrentModificiationException } - while (uniqueConstraints.hasNext()) { - OrmUniqueConstraint uniqueConstraint = uniqueConstraints.next(); + while (contextUniqueConstraints.hasNext()) { + OrmUniqueConstraint contextUniqueConstraint = contextUniqueConstraints.next(); if (resourceUniqueConstraints.hasNext()) { - uniqueConstraint.update(resourceUniqueConstraints.next()); + contextUniqueConstraint.update(resourceUniqueConstraints.next()); } else { - removeUniqueConstraint_(uniqueConstraint); + removeUniqueConstraint_(contextUniqueConstraint); } } @@ -403,8 +404,8 @@ public class GenericOrmTableGenerator extends AbstractOrmGenerator<XmlTableGener } } - protected OrmUniqueConstraint buildUniqueConstraint(XmlUniqueConstraint xmlUniqueConstraint) { - return getJpaFactory().buildOrmUniqueConstraint(this, this, xmlUniqueConstraint); + protected OrmUniqueConstraint buildUniqueConstraint(XmlUniqueConstraint resourceUniqueConstraint) { + return getJpaFactory().buildOrmUniqueConstraint(this, this, resourceUniqueConstraint); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmUniqueConstraint.java index beeda806a7..f480337f1a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmUniqueConstraint.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmUniqueConstraint.java @@ -26,15 +26,15 @@ public class GenericOrmUniqueConstraint extends AbstractOrmJpaContextNode protected final List<String> columnNames; - protected XmlUniqueConstraint uniqueConstraint; + protected XmlUniqueConstraint resourceUniqueConstraint; protected UniqueConstraint.Owner owner; - public GenericOrmUniqueConstraint(OrmJpaContextNode parent, UniqueConstraint.Owner owner, XmlUniqueConstraint uniqueConstraint) { + public GenericOrmUniqueConstraint(OrmJpaContextNode parent, UniqueConstraint.Owner owner, XmlUniqueConstraint resourceUniqueConstraint) { super(parent); this.owner = owner; this.columnNames = new ArrayList<String>(); - this.initialize(uniqueConstraint); + this.initialize(resourceUniqueConstraint); } public ListIterator<String> columnNames() { @@ -47,7 +47,7 @@ public class GenericOrmUniqueConstraint extends AbstractOrmJpaContextNode public void addColumnName(int index, String columnName) { this.columnNames.add(index, columnName); - this.uniqueConstraint.getColumnNames().add(index, columnName); + this.resourceUniqueConstraint.getColumnNames().add(index, columnName); fireItemAdded(UniqueConstraint.COLUMN_NAMES_LIST, index, columnName); } @@ -62,7 +62,7 @@ public class GenericOrmUniqueConstraint extends AbstractOrmJpaContextNode public void removeColumnName(int index) { String removedColumnName = this.columnNames.remove(index); - this.uniqueConstraint.getColumnNames().remove(index); + this.resourceUniqueConstraint.getColumnNames().remove(index); fireItemRemoved(UniqueConstraint.COLUMN_NAMES_LIST, index, removedColumnName); } @@ -73,17 +73,17 @@ public class GenericOrmUniqueConstraint extends AbstractOrmJpaContextNode public void moveColumnName(int targetIndex, int sourceIndex) { CollectionTools.move(this.columnNames, targetIndex, sourceIndex); - this.uniqueConstraint.getColumnNames().move(targetIndex, sourceIndex); + this.resourceUniqueConstraint.getColumnNames().move(targetIndex, sourceIndex); fireItemMoved(UniqueConstraint.COLUMN_NAMES_LIST, targetIndex, sourceIndex); } public TextRange getValidationTextRange() { - return this.uniqueConstraint.getValidationTextRange(); + return this.resourceUniqueConstraint.getValidationTextRange(); } - protected void initialize(XmlUniqueConstraint uniqueConstraint) { - this.uniqueConstraint = uniqueConstraint; - this.initializeColumnNames(uniqueConstraint); + protected void initialize(XmlUniqueConstraint resourceUniqueConstraint) { + this.resourceUniqueConstraint = resourceUniqueConstraint; + this.initializeColumnNames(resourceUniqueConstraint); } protected void initializeColumnNames(XmlUniqueConstraint uniqueConstraint) { @@ -94,13 +94,13 @@ public class GenericOrmUniqueConstraint extends AbstractOrmJpaContextNode } } - public void update(XmlUniqueConstraint uniqueConstraint) { - this.uniqueConstraint = uniqueConstraint; - this.updateColumnNames(uniqueConstraint); + public void update(XmlUniqueConstraint resourceUniqueConstraint) { + this.resourceUniqueConstraint = resourceUniqueConstraint; + this.updateColumnNames(resourceUniqueConstraint); } - protected void updateColumnNames(XmlUniqueConstraint uniqueConstraint) { - ListIterator<String> xmlColumnNames = new CloneListIterator<String>(uniqueConstraint.getColumnNames()); + protected void updateColumnNames(XmlUniqueConstraint resourceUniqueConstraint) { + ListIterator<String> xmlColumnNames = new CloneListIterator<String>(resourceUniqueConstraint.getColumnNames()); int index = 0; for (String xmlColumnName : CollectionTools.iterable(xmlColumnNames)) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java index 320e98d040..ea9e1173d4 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaFactory.java @@ -189,13 +189,22 @@ import org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceXml; import org.eclipse.jpt.core.internal.context.persistence.GenericProperty; import org.eclipse.jpt.core.internal.resource.java.JavaResourceModelImpl; import org.eclipse.jpt.core.internal.utility.jdt.DefaultAnnotationEditFormatter; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.orm.OrmResource; import org.eclipse.jpt.core.resource.orm.OrmResourceModel; import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; +import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue; +import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; +import org.eclipse.jpt.core.resource.orm.XmlNamedNativeQuery; +import org.eclipse.jpt.core.resource.orm.XmlNamedQuery; +import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn; +import org.eclipse.jpt.core.resource.orm.XmlQueryHint; import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable; +import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator; +import org.eclipse.jpt.core.resource.orm.XmlTableGenerator; import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint; import org.eclipse.jpt.core.resource.persistence.PersistenceResource; import org.eclipse.jpt.core.resource.persistence.PersistenceResourceModel; @@ -309,12 +318,12 @@ public class GenericJpaFactory implements JpaFactory return new GenericProperty(parent, xmlProperty); } - public JavaPersistentType buildJavaPersistentType(JpaContextNode parent, JavaResourcePersistentType resourcePersistentType) { - return new GenericJavaPersistentType(parent, resourcePersistentType); + public JavaPersistentType buildJavaPersistentType(JpaContextNode parent, JavaResourcePersistentType jrpt) { + return new GenericJavaPersistentType(parent, jrpt); } - public JavaPersistentAttribute buildJavaPersistentAttribute(JavaPersistentType parent) { - return new GenericJavaPersistentAttribute(parent); + public JavaPersistentAttribute buildJavaPersistentAttribute(JavaPersistentType parent, JavaResourcePersistentAttribute jrpa) { + return new GenericJavaPersistentAttribute(parent, jrpa); } public JavaTypeMapping buildJavaNullTypeMapping(JavaPersistentType parent) { @@ -469,16 +478,16 @@ public class GenericJpaFactory implements JpaFactory return new GenericOrmSecondaryTable(parent, xmlSecondaryTable); } - public OrmPrimaryKeyJoinColumn buildOrmPrimaryKeyJoinColumn(OrmJpaContextNode parent, OrmBaseJoinColumn.Owner owner) { - return new GenericOrmPrimaryKeyJoinColumn(parent, owner); + public OrmPrimaryKeyJoinColumn buildOrmPrimaryKeyJoinColumn(OrmJpaContextNode parent, OrmBaseJoinColumn.Owner owner, XmlPrimaryKeyJoinColumn resourcePkJoinColumn) { + return new GenericOrmPrimaryKeyJoinColumn(parent, owner, resourcePkJoinColumn); } public OrmJoinTable buildOrmJoinTable(OrmRelationshipMapping parent) { return new GenericOrmJoinTable(parent); } - public OrmJoinColumn buildOrmJoinColumn(OrmJpaContextNode parent, OrmJoinColumn.Owner owner) { - return new GenericOrmJoinColumn(parent, owner); + public OrmJoinColumn buildOrmJoinColumn(OrmJpaContextNode parent, OrmJoinColumn.Owner owner, XmlJoinColumn resourceJoinColumn) { + return new GenericOrmJoinColumn(parent, owner, resourceJoinColumn); } public OrmAttributeOverride buildOrmAttributeOverride(OrmJpaContextNode parent, AttributeOverride.Owner owner, XmlAttributeOverride xmlAttributeOverride) { @@ -497,28 +506,28 @@ public class GenericJpaFactory implements JpaFactory return new GenericOrmColumn(parent, owner); } - public OrmGeneratedValue buildOrmGeneratedValue(OrmJpaContextNode parent) { - return new GenericOrmGeneratedValue(parent); + public OrmGeneratedValue buildOrmGeneratedValue(OrmJpaContextNode parent, XmlGeneratedValue resourceGeneratedValue) { + return new GenericOrmGeneratedValue(parent, resourceGeneratedValue); } - public OrmSequenceGenerator buildOrmSequenceGenerator(OrmJpaContextNode parent) { - return new GenericOrmSequenceGenerator(parent); + public OrmSequenceGenerator buildOrmSequenceGenerator(OrmJpaContextNode parent, XmlSequenceGenerator resourceSequenceGenerator) { + return new GenericOrmSequenceGenerator(parent, resourceSequenceGenerator); } - public OrmTableGenerator buildOrmTableGenerator(OrmJpaContextNode parent) { - return new GenericOrmTableGenerator(parent); + public OrmTableGenerator buildOrmTableGenerator(OrmJpaContextNode parent, XmlTableGenerator resourceTableGenerator) { + return new GenericOrmTableGenerator(parent, resourceTableGenerator); } - public OrmNamedNativeQuery buildOrmNamedNativeQuery(OrmJpaContextNode parent) { - return new GenericOrmNamedNativeQuery(parent); + public OrmNamedNativeQuery buildOrmNamedNativeQuery(OrmJpaContextNode parent, XmlNamedNativeQuery resourceNamedNativeQuery) { + return new GenericOrmNamedNativeQuery(parent, resourceNamedNativeQuery); } - public OrmNamedQuery buildOrmNamedQuery(OrmJpaContextNode parent) { - return new GenericOrmNamedQuery(parent); + public OrmNamedQuery buildOrmNamedQuery(OrmJpaContextNode parent, XmlNamedQuery resourceNamedQuery) { + return new GenericOrmNamedQuery(parent, resourceNamedQuery); } - public OrmQueryHint buildOrmQueryHint(OrmQuery parent) { - return new GenericOrmQueryHint(parent); + public OrmQueryHint buildOrmQueryHint(OrmQuery parent, XmlQueryHint resourceQueryHint) { + return new GenericOrmQueryHint(parent, resourceQueryHint); } public OrmBasicMapping buildOrmBasicMapping(OrmPersistentAttribute parent) { @@ -565,7 +574,7 @@ public class GenericJpaFactory implements JpaFactory return new GenericOrmNullAttributeMapping(parent); } - public OrmUniqueConstraint buildOrmUniqueConstraint(OrmJpaContextNode parent, UniqueConstraint.Owner owner, XmlUniqueConstraint xmlUniqueConstraint) { - return new GenericOrmUniqueConstraint(parent, owner, xmlUniqueConstraint); + public OrmUniqueConstraint buildOrmUniqueConstraint(OrmJpaContextNode parent, UniqueConstraint.Owner owner, XmlUniqueConstraint resourceUniqueConstraint) { + return new GenericOrmUniqueConstraint(parent, owner, resourceUniqueConstraint); } } |