diff options
author | kmoore | 2009-02-09 20:00:36 +0000 |
---|---|---|
committer | kmoore | 2009-02-09 20:00:36 +0000 |
commit | 82465be94afa8f54600922d3416c85cf7e6a8b69 (patch) | |
tree | 85b331f4b9dcc6e397f58f90b0c18df5bacba0f2 | |
parent | f90a893061330f64c7e6018c5d120c2776c65927 (diff) | |
download | webtools.dali-82465be94afa8f54600922d3416c85cf7e6a8b69.tar.gz webtools.dali-82465be94afa8f54600922d3416c85cf7e6a8b69.tar.xz webtools.dali-82465be94afa8f54600922d3416c85cf7e6a8b69.zip |
refactored construction of OrmPersistentAttributes and OrmPersistentTypes, passing the resource model object in to the constructor
106 files changed, 925 insertions, 1224 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 5da7e495ea..f64f9b4b77 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 @@ -112,16 +112,20 @@ import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; +import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; import org.eclipse.jpt.core.resource.orm.XmlBasic; +import org.eclipse.jpt.core.resource.orm.XmlEmbeddable; import org.eclipse.jpt.core.resource.orm.XmlEmbedded; import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId; +import org.eclipse.jpt.core.resource.orm.XmlEntity; import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue; import org.eclipse.jpt.core.resource.orm.XmlId; import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; import org.eclipse.jpt.core.resource.orm.XmlManyToMany; import org.eclipse.jpt.core.resource.orm.XmlManyToOne; +import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass; import org.eclipse.jpt.core.resource.orm.XmlNamedNativeQuery; import org.eclipse.jpt.core.resource.orm.XmlNamedQuery; import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping; @@ -129,10 +133,12 @@ import org.eclipse.jpt.core.resource.orm.XmlOneToMany; import org.eclipse.jpt.core.resource.orm.XmlOneToOne; import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn; import org.eclipse.jpt.core.resource.orm.XmlQueryHint; +import org.eclipse.jpt.core.resource.orm.XmlRelationshipMapping; 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.XmlTransient; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint; import org.eclipse.jpt.core.resource.orm.XmlVersion; import org.eclipse.jpt.core.resource.persistence.XmlJarFileRef; @@ -245,15 +251,15 @@ public interface JpaFactory OrmPersistenceUnitDefaults buildPersistenceUnitDefaults(PersistenceUnitMetadata parent, XmlEntityMappings entityMappings); - OrmPersistentType buildOrmPersistentType(EntityMappings parent, String mappingKey); + OrmPersistentType buildOrmPersistentType(EntityMappings parent, XmlTypeMapping resourceMapping); - OrmEntity buildOrmEntity(OrmPersistentType parent); + OrmEntity buildOrmEntity(OrmPersistentType parent, XmlEntity resourceMapping); - OrmMappedSuperclass buildOrmMappedSuperclass(OrmPersistentType parent); + OrmMappedSuperclass buildOrmMappedSuperclass(OrmPersistentType parent, XmlMappedSuperclass resourceMapping); - OrmEmbeddable buildOrmEmbeddable(OrmPersistentType parent); + OrmEmbeddable buildOrmEmbeddable(OrmPersistentType parent, XmlEmbeddable resourceMapping); - OrmPersistentAttribute buildOrmPersistentAttribute(OrmPersistentType parent, OrmPersistentAttribute.Owner owner, String mappingKey); + OrmPersistentAttribute buildOrmPersistentAttribute(OrmPersistentType parent, OrmPersistentAttribute.Owner owner, XmlAttributeMapping resourceMapping); OrmTable buildOrmTable(OrmEntity parent); @@ -261,7 +267,7 @@ public interface JpaFactory OrmPrimaryKeyJoinColumn buildOrmPrimaryKeyJoinColumn(XmlContextNode parent, OrmBaseJoinColumn.Owner owner, XmlPrimaryKeyJoinColumn resourcePkJoinColumn); - OrmJoinTable buildOrmJoinTable(OrmRelationshipMapping parent); + OrmJoinTable buildOrmJoinTable(OrmRelationshipMapping parent, XmlRelationshipMapping resourceMapping); OrmJoinColumn buildOrmJoinColumn(XmlContextNode parent, OrmJoinColumn.Owner owner, XmlJoinColumn resourceJoinColumn); @@ -285,27 +291,27 @@ public interface JpaFactory OrmQueryHint buildOrmQueryHint(OrmQuery parent, XmlQueryHint resourceQueryhint); - OrmBasicMapping buildOrmBasicMapping(OrmPersistentAttribute parent); + OrmBasicMapping buildOrmBasicMapping(OrmPersistentAttribute parent, XmlBasic resourceMapping); - OrmManyToManyMapping buildOrmManyToManyMapping(OrmPersistentAttribute parent); + OrmManyToManyMapping buildOrmManyToManyMapping(OrmPersistentAttribute parent, XmlManyToMany resourceMapping); - OrmOneToManyMapping buildOrmOneToManyMapping(OrmPersistentAttribute parent); + OrmOneToManyMapping buildOrmOneToManyMapping(OrmPersistentAttribute parent, XmlOneToMany resourceMapping); - OrmManyToOneMapping buildOrmManyToOneMapping(OrmPersistentAttribute parent); + OrmManyToOneMapping buildOrmManyToOneMapping(OrmPersistentAttribute parent, XmlManyToOne resourceMapping); - OrmOneToOneMapping buildOrmOneToOneMapping(OrmPersistentAttribute parent); + OrmOneToOneMapping buildOrmOneToOneMapping(OrmPersistentAttribute parent, XmlOneToOne resourceMapping); - OrmEmbeddedIdMapping buildOrmEmbeddedIdMapping(OrmPersistentAttribute parent); + OrmEmbeddedIdMapping buildOrmEmbeddedIdMapping(OrmPersistentAttribute parent, XmlEmbeddedId resourceMapping); - OrmEmbeddedMapping buildOrmEmbeddedMapping(OrmPersistentAttribute parent); + OrmEmbeddedMapping buildOrmEmbeddedMapping(OrmPersistentAttribute parent, XmlEmbedded resourceMapping); - OrmIdMapping buildOrmIdMapping(OrmPersistentAttribute parent); + OrmIdMapping buildOrmIdMapping(OrmPersistentAttribute parent, XmlId resourceMapping); - OrmTransientMapping buildOrmTransientMapping(OrmPersistentAttribute parent); + OrmTransientMapping buildOrmTransientMapping(OrmPersistentAttribute parent, XmlTransient resourceMapping); - OrmVersionMapping buildOrmVersionMapping(OrmPersistentAttribute parent); + OrmVersionMapping buildOrmVersionMapping(OrmPersistentAttribute parent, XmlVersion resourceMapping); - OrmAttributeMapping buildOrmNullAttributeMapping(OrmPersistentAttribute parent); + OrmAttributeMapping buildOrmNullAttributeMapping(OrmPersistentAttribute parent, XmlNullAttributeMapping resourceMapping); OrmUniqueConstraint buildOrmUniqueConstraint(XmlContextNode parent, UniqueConstraint.Owner owner, XmlUniqueConstraint resourceUniqueConstraint); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaPlatform.java index ef147bafb6..7deacff9ed 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaPlatform.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaPlatform.java @@ -10,6 +10,7 @@ package org.eclipse.jpt.core; import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jpt.core.context.MappingFile; import org.eclipse.jpt.core.context.java.JavaAttributeMapping; import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; @@ -21,6 +22,7 @@ import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.context.persistence.MappingFileRef; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.core.resource.xml.JpaXmlResource; import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter; import org.eclipse.jpt.db.ConnectionProfileFactory; @@ -148,22 +150,26 @@ public interface JpaPlatform // ********** ORM type mappings ********** + XmlTypeMapping buildOrmResourceTypeMapping(String key, IContentType contentType); + /** * Build an ORM type mapping for the specified mapping key and persistent type. * Use identity when comparing keys; so clients must use the same key * constants as the providers. */ - OrmTypeMapping buildOrmTypeMappingFromMappingKey(String key, OrmPersistentType type); + OrmTypeMapping buildOrmTypeMappingFromMappingKey(OrmPersistentType type, XmlTypeMapping resourceMapping); // ********** ORM attribute mappings ********** + XmlAttributeMapping buildOrmResourceAttributeMapping(String key, IContentType contentType); + /** * Build an ORM attribute mapping for the specified key and persistent attribute. * Use identity when comparing keys; so clients must use the same key * constants as the providers. */ - OrmAttributeMapping buildOrmAttributeMappingFromMappingKey(String key, OrmPersistentAttribute attribute); + OrmAttributeMapping buildOrmAttributeMappingFromMappingKey(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping); /** * Build a virtual resource attribute mapping to be used when the mapping is not specified in the orm.xml diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/EntityMappings.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/EntityMappings.java index 700d39c87c..6e384e4f72 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/EntityMappings.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/EntityMappings.java @@ -142,12 +142,6 @@ public interface EntityMappings // **************** updating *********************************************** /** - * Initialize the EntityMappings context model object to match the XmlEntityMappings - * resource model object. - */ - void initialize(XmlEntityMappings xmlEntityMappings); - - /** * Update the EntityMappings context model object to match the XmlEntityMappings * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} */ diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmAttributeMapping.java index eb76f92784..f216dfd42a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmAttributeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmAttributeMapping.java @@ -11,8 +11,8 @@ package org.eclipse.jpt.core.context.orm; import org.eclipse.jpt.core.context.AttributeMapping; import org.eclipse.jpt.core.context.XmlContextNode; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.core.utility.TextRange; /** @@ -46,10 +46,9 @@ public interface OrmAttributeMapping extends AttributeMapping, XmlContextNode */ int getXmlSequence(); - void removeFromResourceModel(XmlTypeMapping typeMapping); + void addToResourceModel(Attributes resourceAttributes); - XmlAttributeMapping addToResourceModel(XmlTypeMapping typeMapping); - + void removeFromResourceModel(Attributes resourceAttributes); void initializeOn(OrmAttributeMapping newMapping); @@ -83,8 +82,6 @@ public interface OrmAttributeMapping extends AttributeMapping, XmlContextNode //******************* initialization/updating ******************* - void initialize(XmlAttributeMapping resourceAttributeMapping); - /** * Update the OrmAttributeMapping context model object to match the * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmAttributeMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmAttributeMappingProvider.java index 77a666619a..268cc6dda3 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmAttributeMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmAttributeMappingProvider.java @@ -29,7 +29,9 @@ public interface OrmAttributeMappingProvider String getKey(); - OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory); + XmlAttributeMapping buildResourceMapping(); + + OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory); XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmJoinTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmJoinTable.java index 26e5975964..56111a06cf 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmJoinTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmJoinTable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. All rights reserved. + * Copyright (c) 2008, 2009 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -28,8 +28,6 @@ public interface OrmJoinTable extends JoinTable, XmlContextNode boolean isSpecified(); - void initialize(XmlRelationshipMapping relationshipMapping); - /** * Update the OrmJoinTable context model object to match the XmlRelationshipMapping * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistenceUnitDefaults.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistenceUnitDefaults.java index f6c222f70a..ddf0278076 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistenceUnitDefaults.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistenceUnitDefaults.java @@ -12,7 +12,6 @@ package org.eclipse.jpt.core.context.orm; import org.eclipse.jpt.core.context.AccessType; import org.eclipse.jpt.core.context.MappingFilePersistenceUnitDefaults; import org.eclipse.jpt.core.context.XmlContextNode; -import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; import org.eclipse.jpt.db.Catalog; import org.eclipse.jpt.db.Schema; import org.eclipse.jpt.db.SchemaContainer; @@ -60,12 +59,6 @@ public interface OrmPersistenceUnitDefaults String CASCADE_PERSIST_PROPERTY = "cascadePersist"; //$NON-NLS-1$ /** - * Initialize the OrmPersistenceUnitDefaults context model object to match the XmlEntityMappings - * resource model object. - */ - void initialize(XmlEntityMappings xmlEntityMappings); - - /** * Update the OrmPersistenceUnitDefaults context model object to match the XmlEntityMappings * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} */ diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistentAttribute.java index 956a659236..8b5841eae0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistentAttribute.java @@ -13,7 +13,6 @@ import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jpt.core.context.PersistentAttribute; import org.eclipse.jpt.core.context.XmlContextNode; import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; /** * ORM persistent attribute @@ -88,9 +87,7 @@ public interface OrmPersistentAttribute IContentType getContentType(); - // ********** initialization/updating ********** - - void initialize(XmlAttributeMapping attributeMapping); + // ********** updating ********** /** * Update the OrmPersistentAttribute context model object to match the diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistentType.java index f8f95d2b07..203a88758f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmPersistentType.java @@ -13,7 +13,6 @@ import java.util.ListIterator; import org.eclipse.jpt.core.context.PersistentType; import org.eclipse.jpt.core.context.XmlContextNode; import org.eclipse.jpt.core.context.java.JavaPersistentType; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; /** * Provisional API: This interface is part of an interim API that is still @@ -114,10 +113,8 @@ public interface OrmPersistentType void changeMapping(OrmPersistentAttribute ormPersistentAttribute, OrmAttributeMapping oldMapping, OrmAttributeMapping newMapping); - //******************* initialization/updating ******************* + //******************* updating ******************* - void initialize(XmlTypeMapping xmlTypeMapping); - /** * Update the OrmPersistentType context model object to match the * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTypeMapping.java index 0c7f3f380c..8b8330388c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTypeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTypeMapping.java @@ -55,10 +55,10 @@ public interface OrmTypeMapping * @return */ int getXmlSequence(); + + void addToResourceModel(XmlEntityMappings entityMappings); void removeFromResourceModel(XmlEntityMappings entityMappings); - - XmlTypeMapping addToResourceModel(XmlEntityMappings entityMappings); void initializeFrom(OrmTypeMapping oldMapping); @@ -73,9 +73,6 @@ public interface OrmTypeMapping TextRange getAttributesTextRange(); boolean containsOffset(int textOffset); - - - void initialize(XmlTypeMapping typeMapping); /** * Update the OrmTypeMapping context model object to match the diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTypeMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTypeMappingProvider.java index b212af5a98..629ad729cb 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTypeMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/OrmTypeMappingProvider.java @@ -11,6 +11,7 @@ package org.eclipse.jpt.core.context.orm; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.jpt.core.JpaFactory; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; /** * Part of mechanism to extend the types of ORM type mappings. @@ -26,7 +27,9 @@ public interface OrmTypeMappingProvider { IContentType getContentType(); String getKey(); - - OrmTypeMapping buildMapping(OrmPersistentType parent, JpaFactory factory); + + XmlTypeMapping buildResourceMapping(); + + OrmTypeMapping buildMapping(OrmPersistentType parent, XmlTypeMapping resourceMapping, JpaFactory factory); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/PersistenceUnitMetadata.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/PersistenceUnitMetadata.java index 4293b347cc..679841f833 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/PersistenceUnitMetadata.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/context/orm/PersistenceUnitMetadata.java @@ -10,7 +10,6 @@ package org.eclipse.jpt.core.context.orm; import org.eclipse.jpt.core.context.XmlContextNode; -import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; /** * @@ -28,14 +27,7 @@ public interface PersistenceUnitMetadata extends XmlContextNode String XML_MAPPING_METADATA_COMPLETE_PROPERTY = "xmlMappingMetadataCompleteProperty"; //$NON-NLS-1$ OrmPersistenceUnitDefaults getPersistenceUnitDefaults(); - - - /** - * Initialize the PersistenceUnitMetadata context model object to match the XmlEntityMappings - * resource model object. - */ - void initialize(XmlEntityMappings xmlEntityMappings); - + /** * Update the PersistenceUnitMetadata context model object to match the XmlEntityMappings * resource model object. see {@link org.eclipse.jpt.core.JpaProject#update()} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java index ae60dad2f5..e4a8205e33 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java @@ -61,7 +61,7 @@ public abstract class AbstractEntityMappings extends AbstractXmlContextNode implements EntityMappings { - protected XmlEntityMappings xmlEntityMappings; + protected final XmlEntityMappings xmlEntityMappings; protected String description; @@ -89,13 +89,33 @@ public abstract class AbstractEntityMappings protected final List<OrmNamedNativeQuery> namedNativeQueries; - protected AbstractEntityMappings(OrmXml parent) { + protected AbstractEntityMappings(OrmXml parent, XmlEntityMappings xmlEntityMappings) { super(parent); + this.xmlEntityMappings = xmlEntityMappings; this.persistentTypes = new ArrayList<OrmPersistentType>(); this.sequenceGenerators = new ArrayList<OrmSequenceGenerator>(); this.tableGenerators = new ArrayList<OrmTableGenerator>(); this.namedQueries = new ArrayList<OrmNamedQuery>(); this.namedNativeQueries = new ArrayList<OrmNamedNativeQuery>(); + + this.persistenceUnitMetadata = getJpaFactory().buildPersistenceUnitMetadata(this, this.xmlEntityMappings); + this.description = this.xmlEntityMappings.getDescription(); + this.package_ = this.xmlEntityMappings.getPackage(); + + this.defaultAccess = this.getPersistenceUnit().getDefaultAccess(); + this.specifiedAccess = this.getResourceAccess(); + + this.defaultCatalog = this.getPersistenceUnit().getDefaultCatalog(); + this.specifiedCatalog = this.xmlEntityMappings.getCatalog(); + + this.defaultSchema = this.getPersistenceUnit().getDefaultSchema(); + this.specifiedSchema = this.xmlEntityMappings.getSchema(); + + this.initializePersistentTypes(); + this.initializeTableGenerators(); + this.initializeSequenceGenerators(); + this.initializeNamedQueries(); + this.initializeNamedNativeQueries(); } @@ -332,20 +352,21 @@ public abstract class AbstractEntityMappings } public OrmPersistentType addPersistentType(String mappingKey, String className) { - OrmPersistentType persistentType = buildPersistentType(mappingKey); + XmlTypeMapping typeMapping = getJpaPlatform().buildOrmResourceTypeMapping(mappingKey, getContentType()); + OrmPersistentType persistentType = buildPersistentType(typeMapping); int index = insertionIndex(persistentType); this.persistentTypes.add(index, persistentType); if (className.startsWith(getPackage() + '.')) { // adds short name if package name is specified className = className.substring(getPackage().length() + 1); } - XmlTypeMapping typeMapping = persistentType.getMapping().addToResourceModel(this.xmlEntityMappings); + persistentType.getMapping().addToResourceModel(this.xmlEntityMappings); typeMapping.setClassName(className); fireItemAdded(PERSISTENT_TYPES_LIST, index, persistentType); return persistentType; } - protected abstract OrmPersistentType buildPersistentType(String mappingKey); + protected abstract OrmPersistentType buildPersistentType(XmlTypeMapping typeMapping); protected int insertionIndex(OrmPersistentType ormPersistentType) { return CollectionTools.insertionIndexOf(this.persistentTypes, ormPersistentType, buildMappingComparator()); @@ -603,32 +624,6 @@ public abstract class AbstractEntityMappings // ********** initialization ********** - - public void initialize(XmlEntityMappings entityMappings) { - this.xmlEntityMappings = entityMappings; - this.initialize(); - } - - protected void initialize() { - this.persistenceUnitMetadata = getJpaFactory().buildPersistenceUnitMetadata(this, this.xmlEntityMappings); - this.description = this.xmlEntityMappings.getDescription(); - this.package_ = this.xmlEntityMappings.getPackage(); - - this.defaultAccess = this.getPersistenceUnit().getDefaultAccess(); - this.specifiedAccess = this.getResourceAccess(); - - this.defaultCatalog = this.getPersistenceUnit().getDefaultCatalog(); - this.specifiedCatalog = this.xmlEntityMappings.getCatalog(); - - this.defaultSchema = this.getPersistenceUnit().getDefaultSchema(); - this.specifiedSchema = this.xmlEntityMappings.getSchema(); - - this.initializePersistentTypes(); - this.initializeTableGenerators(); - this.initializeSequenceGenerators(); - this.initializeNamedQueries(); - this.initializeNamedNativeQueries(); - } protected void initializePersistentTypes() { for (XmlTypeMapping typeMapping : this.xmlEntityMappings.getTypeMappings()) { @@ -723,9 +718,8 @@ public abstract class AbstractEntityMappings //not firing change notification so this can be reused in initialize and update protected OrmPersistentType addPersistentType(XmlTypeMapping resourceMapping) { - OrmPersistentType ormPersistentType = buildPersistentType(resourceMapping.getMappingKey()); + OrmPersistentType ormPersistentType = buildPersistentType(resourceMapping); this.persistentTypes.add(ormPersistentType); - ormPersistentType.initialize(resourceMapping); return ormPersistentType; } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java index bfbc18d006..0cf2c9f28c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java @@ -46,10 +46,12 @@ public abstract class AbstractOrmAttributeMapping<T extends XmlAttributeMapping> { protected String name; - protected T resourceAttributeMapping; + protected final T resourceAttributeMapping; - protected AbstractOrmAttributeMapping(OrmPersistentAttribute parent) { + protected AbstractOrmAttributeMapping(OrmPersistentAttribute parent, T resourceAttributeMapping) { super(parent); + this.resourceAttributeMapping = resourceAttributeMapping; + this.name = this.getResourceMappingName(); } protected JavaPersistentAttribute getJavaPersistentAttribute() { @@ -83,10 +85,6 @@ public abstract class AbstractOrmAttributeMapping<T extends XmlAttributeMapping> return (OrmPersistentAttribute) getParent(); } - public String getAttributeName() { - return this.getPersistentAttribute().getName(); - } - public boolean isDefault() { return false; } @@ -186,16 +184,6 @@ public abstract class AbstractOrmAttributeMapping<T extends XmlAttributeMapping> public T getResourceAttributeMapping() { return this.resourceAttributeMapping; } - - @SuppressWarnings("unchecked") - public void initialize(XmlAttributeMapping resourceAttributeMapping) { - this.resourceAttributeMapping = (T) resourceAttributeMapping; - this.initialize(); - } - - protected void initialize() { - this.name = this.getResourceMappingName(); - } public void update() { this.setName_(this.getResourceMappingName()); @@ -266,7 +254,7 @@ public abstract class AbstractOrmAttributeMapping<T extends XmlAttributeMapping> @Override public void toString(StringBuilder sb) { - sb.append(this.getAttributeName()); + sb.append(this.getName()); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java index 0c28edf790..1654af6651 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java @@ -47,10 +47,13 @@ public abstract class AbstractOrmBaseEmbeddedMapping<T extends BaseXmlEmbedded> private Embeddable embeddable;//TODO hmm, why no property change notification for setting this?? - protected AbstractOrmBaseEmbeddedMapping(OrmPersistentAttribute parent) { - super(parent); + protected AbstractOrmBaseEmbeddedMapping(OrmPersistentAttribute parent, T resourceMapping) { + super(parent, resourceMapping); + this.embeddable = embeddableFor(this.getJavaPersistentAttribute()); this.specifiedAttributeOverrides = new ArrayList<OrmAttributeOverride>(); this.virtualAttributeOverrides = new ArrayList<OrmAttributeOverride>(); + this.initializeSpecifiedAttributeOverrides(); + this.initializeVirtualAttributeOverrides(); } @Override @@ -241,14 +244,6 @@ public abstract class AbstractOrmBaseEmbeddedMapping<T extends BaseXmlEmbedded> return null; } - @Override - public void initialize() { - super.initialize(); - this.embeddable = embeddableFor(this.getJavaPersistentAttribute()); - this.initializeSpecifiedAttributeOverrides(); - this.initializeVirtualAttributeOverrides(); - } - protected void initializeSpecifiedAttributeOverrides() { for (XmlAttributeOverride attributeOverride : this.resourceAttributeMapping.getAttributeOverrides()) { this.specifiedAttributeOverrides.add(buildAttributeOverride(attributeOverride)); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java index a1044a4679..3600974852 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java @@ -48,9 +48,18 @@ public abstract class AbstractOrmMultiRelationshipMapping<T extends XmlMultiRela protected String mapKey; - protected AbstractOrmMultiRelationshipMapping(OrmPersistentAttribute parent) { - super(parent); - this.joinTable = getJpaFactory().buildOrmJoinTable(this); + protected AbstractOrmMultiRelationshipMapping(OrmPersistentAttribute parent, T resourceMapping) { + super(parent, resourceMapping); + this.joinTable = getJpaFactory().buildOrmJoinTable(this, this.resourceAttributeMapping); + this.mappedBy = this.getResourceMappedBy(); + this.mapKey = this.getResourceMapKeyName(); + this.orderBy = this.getResourceOrderBy(); + if (this.orderBy == null) { + this.isNoOrdering = true; + } + else { + this.isCustomOrdering = true; + } } @Override @@ -247,22 +256,7 @@ public abstract class AbstractOrmMultiRelationshipMapping<T extends XmlMultiRela TextRange mappedByTextRange = this.resourceAttributeMapping.getMappedByTextRange(); return mappedByTextRange != null ? mappedByTextRange : getValidationTextRange(); } - - @Override - protected void initialize() { - super.initialize(); - this.mappedBy = this.getResourceMappedBy(); - this.mapKey = this.getResourceMapKeyName(); - this.orderBy = this.getResourceOrderBy(); - if (this.orderBy == null) { - this.isNoOrdering = true; - } - else { - this.isCustomOrdering = true; - } - this.joinTable.initialize(this.resourceAttributeMapping); - } - + @Override public void update() { super.update(); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentType.java index fba707a77a..9bcd346f98 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentType.java @@ -71,11 +71,17 @@ public abstract class AbstractOrmPersistentType protected JavaPersistentType javaPersistentType; - protected AbstractOrmPersistentType(EntityMappings parent, String mappingKey) { + protected AbstractOrmPersistentType(EntityMappings parent, XmlTypeMapping resourceMapping) { super(parent); - this.typeMapping = buildTypeMapping(mappingKey); + this.resourceTypeMapping = resourceMapping; + this.typeMapping = buildTypeMapping(); this.specifiedPersistentAttributes = new ArrayList<OrmPersistentAttribute>(); this.virtualPersistentAttributes = new ArrayList<OrmPersistentAttribute>(); + this.specifiedAccess = this.getResourceAccess(); + this.defaultAccess = this.buildDefaultAccess(); + this.initializeJavaPersistentType(); + this.initializeParentPersistentType(); + this.initializePersistentAttributes(); } @@ -117,8 +123,8 @@ public abstract class AbstractOrmPersistentType return (this.getDefaultPackage() + '.' + mappingClassName).equals(typeName); } - protected OrmTypeMapping buildTypeMapping(String key) { - return this.getJpaPlatform().buildOrmTypeMappingFromMappingKey(key, this); + protected OrmTypeMapping buildTypeMapping() { + return this.getJpaPlatform().buildOrmTypeMappingFromMappingKey(this, this.resourceTypeMapping); } public OrmTypeMapping getMapping() { @@ -170,19 +176,11 @@ public abstract class AbstractOrmPersistentType return; } OrmTypeMapping oldMapping = getMapping(); - this.typeMapping = buildTypeMapping(newMappingKey); + this.resourceTypeMapping = getJpaPlatform().buildOrmResourceTypeMapping(newMappingKey, getContentType()); + this.typeMapping = buildTypeMapping(); this.getEntityMappings().changeMapping(this, oldMapping, this.typeMapping); firePropertyChanged(MAPPING_PROPERTY, oldMapping, this.typeMapping); } - - protected void setMappingKey_(String newMappingKey) { - if (this.getMappingKey() == newMappingKey) { - return; - } - OrmTypeMapping oldMapping = getMapping(); - this.typeMapping = buildTypeMapping(newMappingKey); - firePropertyChanged(MAPPING_PROPERTY, oldMapping, this.typeMapping); - } public Iterator<PersistentType> inheritanceHierarchy() { // using a chain iterator to traverse up the inheritance tree @@ -253,10 +251,10 @@ public abstract class AbstractOrmPersistentType public void changeMapping(OrmPersistentAttribute ormPersistentAttribute, OrmAttributeMapping oldMapping, OrmAttributeMapping newMapping) { int sourceIndex = this.specifiedPersistentAttributes.indexOf(ormPersistentAttribute); this.specifiedPersistentAttributes.remove(sourceIndex); - oldMapping.removeFromResourceModel(this.typeMapping.getResourceTypeMapping()); + oldMapping.removeFromResourceModel(getResourceAttributes()); int targetIndex = insertionIndex(ormPersistentAttribute); this.specifiedPersistentAttributes.add(targetIndex, ormPersistentAttribute); - newMapping.addToResourceModel(getMapping().getResourceTypeMapping()); + newMapping.addToResourceModel(getResourceAttributes()); oldMapping.initializeOn(newMapping); fireItemMoved(SPECIFIED_ATTRIBUTES_LIST, targetIndex, sourceIndex); } @@ -287,14 +285,19 @@ public abstract class AbstractOrmPersistentType if (mappingKey == MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY) { throw new IllegalStateException("Use makePersistentAttributeSpecified(OrmPersistentAttribute, String) instead and specify a mapping type"); //$NON-NLS-1$ } - - OrmPersistentAttribute newPersistentAttribute = buildSpecifiedOrmPersistentAttribute(mappingKey); - if (getMapping().getResourceTypeMapping().getAttributes() == null) { - getMapping().getResourceTypeMapping().setAttributes(createAttributesResource()); + + Attributes resourceAttributes = getResourceAttributes(); + if (resourceAttributes == null) { + resourceAttributes = createResourceAttributes(); + getMapping().getResourceTypeMapping().setAttributes(resourceAttributes); } + + XmlAttributeMapping resourceMapping = getJpaPlatform().buildOrmResourceAttributeMapping(mappingKey, getContentType()); + + OrmPersistentAttribute newPersistentAttribute = buildSpecifiedOrmPersistentAttribute(resourceMapping); int insertionIndex = insertionIndex(newPersistentAttribute); this.specifiedPersistentAttributes.add(insertionIndex, newPersistentAttribute); - newPersistentAttribute.getMapping().addToResourceModel(getMapping().getResourceTypeMapping()); + newPersistentAttribute.getMapping().addToResourceModel(resourceAttributes); int removalIndex = this.virtualPersistentAttributes.indexOf(ormPersistentAttribute); this.virtualPersistentAttributes.remove(ormPersistentAttribute); @@ -304,7 +307,11 @@ public abstract class AbstractOrmPersistentType fireItemRemoved(VIRTUAL_ATTRIBUTES_LIST, removalIndex, ormPersistentAttribute); } - protected abstract Attributes createAttributesResource(); + protected Attributes getResourceAttributes() { + return this.resourceTypeMapping.getAttributes(); + } + + protected abstract Attributes createResourceAttributes(); public Iterator<String> allAttributeNames() { return this.attributeNames(this.allAttributes()); @@ -409,13 +416,17 @@ public abstract class AbstractOrmPersistentType } public OrmPersistentAttribute addSpecifiedPersistentAttribute(String mappingKey, String attributeName) { - OrmPersistentAttribute persistentAttribute = buildSpecifiedOrmPersistentAttribute(mappingKey); - int index = insertionIndex(persistentAttribute); - if (getMapping().getResourceTypeMapping().getAttributes() == null) { - getMapping().getResourceTypeMapping().setAttributes(createAttributesResource()); + Attributes resourceAttributes = getResourceAttributes(); + if (resourceAttributes == null) { + resourceAttributes = createResourceAttributes(); + getMapping().getResourceTypeMapping().setAttributes(resourceAttributes); } + + XmlAttributeMapping resourceMapping = getJpaPlatform().buildOrmResourceAttributeMapping(mappingKey, getContentType()); + OrmPersistentAttribute persistentAttribute = buildSpecifiedOrmPersistentAttribute(resourceMapping); + int index = insertionIndex(persistentAttribute); this.specifiedPersistentAttributes.add(index, persistentAttribute); - persistentAttribute.getSpecifiedMapping().addToResourceModel(getMapping().getResourceTypeMapping()); + persistentAttribute.getMapping().addToResourceModel(resourceAttributes); persistentAttribute.getSpecifiedMapping().setName(attributeName); fireItemAdded(PersistentType.SPECIFIED_ATTRIBUTES_LIST, index, persistentAttribute); @@ -453,8 +464,8 @@ public abstract class AbstractOrmPersistentType public void removeSpecifiedPersistentAttribute(OrmPersistentAttribute ormPersistentAttribute) { int index = this.specifiedPersistentAttributes.indexOf(ormPersistentAttribute); this.specifiedPersistentAttributes.remove(ormPersistentAttribute); - ormPersistentAttribute.getMapping().removeFromResourceModel(this.typeMapping.getResourceTypeMapping()); - if (this.typeMapping.getResourceTypeMapping().getAttributes().isUnset()) { + ormPersistentAttribute.getMapping().removeFromResourceModel(getResourceAttributes()); + if (getResourceAttributes().isUnset()) { this.typeMapping.getResourceTypeMapping().setAttributes(null); } fireItemRemoved(PersistentType.SPECIFIED_ATTRIBUTES_LIST, index, ormPersistentAttribute); @@ -489,16 +500,6 @@ public abstract class AbstractOrmPersistentType this.javaPersistentType = newJavaPersistentType; firePropertyChanged(JAVA_PERSISTENT_TYPE_PROPERTY, oldJavaPersistentType, newJavaPersistentType); } - - public void initialize(XmlTypeMapping resourceTypeMapping) { - this.resourceTypeMapping = resourceTypeMapping; - this.specifiedAccess = this.getResourceAccess(); - this.defaultAccess = this.buildDefaultAccess(); - getMapping().initialize(resourceTypeMapping); - this.initializeJavaPersistentType(); - this.initializeParentPersistentType(); - this.initializePersistentAttributes(); - } protected AccessType getResourceAccess() { return AccessType.fromXmlResourceModel(this.resourceTypeMapping.getAccess()); @@ -548,8 +549,8 @@ public abstract class AbstractOrmPersistentType this.initializeVirtualPersistentAttributes(); } - protected OrmPersistentAttribute buildSpecifiedOrmPersistentAttribute(String mappingKey) { - return getJpaFactory().buildOrmPersistentAttribute(this, buildSpecifiedPersistentAttributeOwner(), mappingKey); + protected OrmPersistentAttribute buildSpecifiedOrmPersistentAttribute(XmlAttributeMapping resourceMapping) { + return getJpaFactory().buildOrmPersistentAttribute(this, buildSpecifiedPersistentAttributeOwner(), resourceMapping); } protected OrmPersistentAttribute.Owner buildSpecifiedPersistentAttributeOwner() { @@ -625,8 +626,8 @@ public abstract class AbstractOrmPersistentType } } - protected OrmPersistentAttribute buildVirtualOrmPersistentAttribute(JavaAttributeMapping javaAttributeMapping) { - return getJpaFactory().buildOrmPersistentAttribute(this, buildVirtualPersistentAttributeOwner(javaAttributeMapping.getPersistentAttribute()), javaAttributeMapping.getKey()); + protected OrmPersistentAttribute buildVirtualOrmPersistentAttribute(JavaAttributeMapping javaAttributeMapping, XmlAttributeMapping resourceMapping) { + return getJpaFactory().buildOrmPersistentAttribute(this, buildVirtualPersistentAttributeOwner(javaAttributeMapping.getPersistentAttribute()), resourceMapping); } protected OrmPersistentAttribute.Owner buildVirtualPersistentAttributeOwner(final JavaPersistentAttribute javaPersistentAttribute) { @@ -643,7 +644,7 @@ public abstract class AbstractOrmPersistentType } protected void initializeSpecifiedPersistentAttributes() { - Attributes attributes = this.resourceTypeMapping.getAttributes(); + Attributes attributes = this.getResourceAttributes(); if (attributes == null) { return; } @@ -725,7 +726,7 @@ public abstract class AbstractOrmPersistentType } protected void updateSpecifiedPersistentAttributes() { - Attributes attributes = this.resourceTypeMapping.getAttributes(); + Attributes attributes = this.getResourceAttributes(); Collection<OrmPersistentAttribute> contextAttributesToRemove = CollectionTools.collection(specifiedAttributes()); Collection<OrmPersistentAttribute> contextAttributesToUpdate = new ArrayList<OrmPersistentAttribute>(); int resourceIndex = 0; @@ -761,9 +762,8 @@ public abstract class AbstractOrmPersistentType //not firing change notification so this can be reused in initialize and update protected OrmPersistentAttribute addSpecifiedPersistentAttribute(XmlAttributeMapping resourceMapping) { - OrmPersistentAttribute ormPersistentAttribute = buildSpecifiedOrmPersistentAttribute(resourceMapping.getMappingKey()); + OrmPersistentAttribute ormPersistentAttribute = buildSpecifiedOrmPersistentAttribute(resourceMapping); this.specifiedPersistentAttributes.add(ormPersistentAttribute); - ormPersistentAttribute.initialize(resourceMapping); return ormPersistentAttribute; } @@ -824,10 +824,9 @@ public abstract class AbstractOrmPersistentType //not firing change notification so this can be reused in initialize and update protected OrmPersistentAttribute addVirtualPersistentAttribute(JavaAttributeMapping javaAttributeMapping) { - OrmPersistentAttribute virtualPersistentAttribute = buildVirtualOrmPersistentAttribute(javaAttributeMapping); XmlAttributeMapping resourceMapping = getJpaPlatform().buildVirtualOrmResourceMappingFromMappingKey(javaAttributeMapping.getKey(), getMapping(), javaAttributeMapping); + OrmPersistentAttribute virtualPersistentAttribute = buildVirtualOrmPersistentAttribute(javaAttributeMapping, resourceMapping); this.virtualPersistentAttributes.add(virtualPersistentAttribute); - virtualPersistentAttribute.initialize(resourceMapping); return virtualPersistentAttribute; } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipMapping.java index b55f7e8562..84fcc1df4f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipMapping.java @@ -41,9 +41,13 @@ public abstract class AbstractOrmRelationshipMapping<T extends XmlRelationshipMa protected FetchType specifiedFetch; - protected AbstractOrmRelationshipMapping(OrmPersistentAttribute parent) { - super(parent); - this.cascade = new OrmCascade(this); + protected AbstractOrmRelationshipMapping(OrmPersistentAttribute parent, T resourceMapping) { + super(parent, resourceMapping); + this.cascade = new OrmCascade(this, this.resourceAttributeMapping); + this.specifiedTargetEntity = this.getResourceTargetEntity(); + this.defaultTargetEntity = this.buildDefaultTargetEntity(); + this.resolvedTargetEntity = this.buildResolvedTargetEntity(); + this.specifiedFetch = this.getResourceFetch(); } @Override @@ -127,16 +131,6 @@ public abstract class AbstractOrmRelationshipMapping<T extends XmlRelationshipMa // ********** resource => context ********** - - @Override - protected void initialize() { - super.initialize(); - this.specifiedTargetEntity = this.getResourceTargetEntity(); - this.defaultTargetEntity = this.buildDefaultTargetEntity(); - this.resolvedTargetEntity = this.buildResolvedTargetEntity(); - this.specifiedFetch = this.getResourceFetch(); - this.cascade.initialize(this.resourceAttributeMapping); - } @Override public void update() { @@ -244,7 +238,7 @@ public abstract class AbstractOrmRelationshipMapping<T extends XmlRelationshipMa DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED, - new String[] {this.getAttributeName()}, + new String[] {this.getName()}, this, this.getValidationTextRange() ) @@ -255,7 +249,7 @@ public abstract class AbstractOrmRelationshipMapping<T extends XmlRelationshipMa DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED, - new String[] {this.getAttributeName()}, + new String[] {this.getName()}, this, this.getValidationTextRange() ) @@ -268,7 +262,7 @@ public abstract class AbstractOrmRelationshipMapping<T extends XmlRelationshipMa DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY, - new String[] {this.getAttributeName(), getTargetEntity()}, + new String[] {this.getName(), getTargetEntity()}, this, this.getValidationTextRange() ) @@ -279,7 +273,7 @@ public abstract class AbstractOrmRelationshipMapping<T extends XmlRelationshipMa DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY, - new String[] {getTargetEntity(), this.getAttributeName()}, + new String[] {getTargetEntity(), this.getName()}, this, this.getTargetEntityTextRange() ) 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 de03e935b7..06361388d4 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 @@ -52,9 +52,13 @@ public abstract class AbstractOrmSingleRelationshipMapping<T extends XmlSingleRe protected Boolean specifiedOptional; - protected AbstractOrmSingleRelationshipMapping(OrmPersistentAttribute parent) { - super(parent); + protected AbstractOrmSingleRelationshipMapping(OrmPersistentAttribute parent, T resourceMapping) { + super(parent, resourceMapping); + this.specifiedOptional = this.getResourceOptional(); + //TODO defaultOptional this.specifiedJoinColumns = new ArrayList<OrmJoinColumn>(); + this.initializeSpecifiedJoinColumns(); + this.initializeDefaultJoinColumn(); } @@ -189,15 +193,6 @@ public abstract class AbstractOrmSingleRelationshipMapping<T extends XmlSingleRe // ********** resource => context ********** - - @Override - protected void initialize() { - super.initialize(); - this.specifiedOptional = this.getResourceOptional(); - //TODO defaultOptional - this.initializeSpecifiedJoinColumns(); - this.initializeDefaultJoinColumn(); - } protected void initializeSpecifiedJoinColumns() { if (this.resourceAttributeMapping != null) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTypeMapping.java index 9065d7369f..17bff074fa 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTypeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTypeMapping.java @@ -41,11 +41,15 @@ public abstract class AbstractOrmTypeMapping<T extends XmlTypeMapping> protected Boolean specifiedMetadataComplete; - protected T resourceTypeMapping; + protected final T resourceTypeMapping; - protected AbstractOrmTypeMapping(OrmPersistentType parent) { + protected AbstractOrmTypeMapping(OrmPersistentType parent, T resourceMapping) { super(parent); + this.resourceTypeMapping = resourceMapping; + this.class_ = this.getResourceClassName(); + this.specifiedMetadataComplete = this.getResourceMetadataComplete(); + this.defaultMetadataComplete = this.getPersistentType().isDefaultMetadataComplete(); } // **************** Type Mapping implementation ***************************** @@ -177,18 +181,6 @@ public abstract class AbstractOrmTypeMapping<T extends XmlTypeMapping> return this.resourceTypeMapping; } - @SuppressWarnings("unchecked") - public void initialize(XmlTypeMapping resourceTypeMapping) { - this.resourceTypeMapping = (T) resourceTypeMapping; - this.initialize(); - } - - protected void initialize() { - this.class_ = this.getResourceClassName(); - this.specifiedMetadataComplete = this.getResourceMetadataComplete(); - this.defaultMetadataComplete = this.getPersistentType().isDefaultMetadataComplete(); - } - public void update() { this.setClass(this.getResourceClassName()); this.setSpecifiedMetadataComplete(this.getResourceMetadataComplete()); 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 8f528aa0a2..8264f1bab3 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 @@ -11,17 +11,19 @@ package org.eclipse.jpt.core.internal.context.orm; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.context.orm.OrmXml; +import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; public class GenericEntityMappings extends AbstractEntityMappings { - public GenericEntityMappings(OrmXml parent) { - super(parent); + public GenericEntityMappings(OrmXml parent, XmlEntityMappings resource) { + super(parent, resource); } @Override - protected OrmPersistentType buildPersistentType(String mappingKey) { - return getJpaFactory().buildOrmPersistentType(this, mappingKey); + protected OrmPersistentType buildPersistentType(XmlTypeMapping resourceMapping) { + return getJpaFactory().buildOrmPersistentType(this, resourceMapping); } } 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 af801f0c17..35201dfb72 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 @@ -52,7 +52,9 @@ public class GenericOrmAssociationOverride extends AbstractXmlContextNode this.owner = owner; this.specifiedJoinColumns = new ArrayList<OrmJoinColumn>(); this.defaultJoinColumns = new ArrayList<OrmJoinColumn>(); - this.initialize(resourceAssociationOverride); + this.resourceAssociationOverride = resourceAssociationOverride; + this.name = resourceAssociationOverride.getName(); + initializeSpecifiedJoinColumns(); } public OrmAssociationOverride setVirtual(boolean virtual) { @@ -145,12 +147,6 @@ public class GenericOrmAssociationOverride extends AbstractXmlContextNode return getOwner().isVirtual(this); } - protected void initialize(XmlAssociationOverride resourceAssociationOverride) { - this.resourceAssociationOverride = resourceAssociationOverride; - this.name = resourceAssociationOverride.getName(); - initializeSpecifiedJoinColumns(); - } - protected void initializeSpecifiedJoinColumns() { for (XmlJoinColumn joinColumn : this.resourceAssociationOverride.getJoinColumns()) { this.specifiedJoinColumns.add(buildJoinColumn(joinColumn)); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmAttributeOverride.java index 06fcc1f231..1dbe1d27a0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmAttributeOverride.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmAttributeOverride.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Oracle. All rights reserved. + * Copyright (c) 2007, 2009 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -45,8 +45,11 @@ public class GenericOrmAttributeOverride extends AbstractXmlContextNode super(parent); this.owner = owner; this.column = getJpaFactory().buildOrmColumn(this, this); - this.initialize(resourceAttributeOverride); + this.resourceAttributeOverride = resourceAttributeOverride; + this.name = resourceAttributeOverride.getName(); + this.column.initialize(resourceAttributeOverride.getColumn()); } + @Override public XmlContextNode getParent() { return (XmlContextNode) super.getParent(); @@ -140,12 +143,6 @@ public class GenericOrmAttributeOverride extends AbstractXmlContextNode //***************** updating **************** - protected void initialize(XmlAttributeOverride xmlAttributeOverride) { - this.resourceAttributeOverride = xmlAttributeOverride; - this.name = xmlAttributeOverride.getName(); - this.column.initialize(xmlAttributeOverride.getColumn()); - } - public void update(XmlAttributeOverride xmlAttributeOverride) { this.resourceAttributeOverride = xmlAttributeOverride; this.setName_(xmlAttributeOverride.getName()); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmBasicMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmBasicMapping.java index 33bdb7f060..2cc4f66799 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmBasicMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmBasicMapping.java @@ -24,10 +24,10 @@ import org.eclipse.jpt.core.context.orm.OrmConverter; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlBasic; import org.eclipse.jpt.core.resource.orm.XmlColumn; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.db.Table; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -45,9 +45,14 @@ public class GenericOrmBasicMapping extends AbstractOrmAttributeMapping<XmlBasic protected OrmConverter specifiedConverter; - public GenericOrmBasicMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmBasicMapping(OrmPersistentAttribute parent, XmlBasic resourceMapping) { + super(parent, resourceMapping); this.column = getJpaFactory().buildOrmColumn(this, this); + this.column.initialize(this.getResourceColumn());//TODO pass in to factory + this.specifiedFetch = this.getResourceFetch(); + this.specifiedOptional = this.getResourceOptional(); + this.defaultConverter = new GenericOrmNullConverter(this); + this.specifiedConverter = this.buildSpecifiedConverter(this.getResourceConverterType()); } public FetchType getFetch() { @@ -171,7 +176,7 @@ public class GenericOrmBasicMapping extends AbstractOrmAttributeMapping<XmlBasic } public String getDefaultColumnName() { - return getAttributeName(); + return getName(); } public String getDefaultTableName() { @@ -183,16 +188,6 @@ public class GenericOrmBasicMapping extends AbstractOrmAttributeMapping<XmlBasic } @Override - protected void initialize() { - super.initialize(); - this.specifiedFetch = this.getResourceFetch(); - this.specifiedOptional = this.getResourceOptional(); - this.column.initialize(this.getResourceColumn()); - this.defaultConverter = new GenericOrmNullConverter(this); - this.specifiedConverter = this.buildSpecifiedConverter(this.getResourceConverterType()); - } - - @Override public void update() { super.update(); this.setSpecifiedFetch_(this.getResourceFetch()); @@ -241,15 +236,12 @@ public class GenericOrmBasicMapping extends AbstractOrmAttributeMapping<XmlBasic return null; } - public XmlBasic addToResourceModel(XmlTypeMapping typeMapping) { - XmlBasic basic = OrmFactory.eINSTANCE.createXmlBasicImpl(); - getPersistentAttribute().initialize(basic); - typeMapping.getAttributes().getBasics().add(basic); - return basic; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getBasics().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getBasics().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getBasics().remove(this.resourceAttributeMapping); } //***************** XmlColumn.Owner implementation **************** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmColumn.java index deead7edd1..8d4e87f50b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmColumn.java @@ -164,28 +164,28 @@ public class GenericOrmColumn extends AbstractOrmBaseColumn<XmlColumn> implement @Override public void initialize(XmlColumn column) { super.initialize(column); - this.specifiedLength = this.specifiedLength(column); - this.specifiedPrecision = this.specifiedPrecision(column); - this.specifiedScale = this.specifiedScale(column); + this.specifiedLength = this.getResourceLength(column); + this.specifiedPrecision = this.getResourcePrecision(column); + this.specifiedScale = this.getResourceScale(column); } @Override public void update(XmlColumn column) { super.update(column); - this.setSpecifiedLength_(this.specifiedLength(column)); - this.setSpecifiedPrecision_(this.specifiedPrecision(column)); - this.setSpecifiedScale_(this.specifiedScale(column)); + this.setSpecifiedLength_(this.getResourceLength(column)); + this.setSpecifiedPrecision_(this.getResourcePrecision(column)); + this.setSpecifiedScale_(this.getResourceScale(column)); } - protected Integer specifiedLength(XmlColumn column) { + protected Integer getResourceLength(XmlColumn column) { return column == null ? null : column.getLength(); } - protected Integer specifiedPrecision(XmlColumn column) { + protected Integer getResourcePrecision(XmlColumn column) { return column == null ? null : column.getPrecision(); } - protected Integer specifiedScale(XmlColumn column) { + protected Integer getResourceScale(XmlColumn column) { return column == null ? null : column.getScale(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddable.java index 0a00a98f81..c272619c37 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 Oracle. All rights reserved. This + * Copyright (c) 2006, 2009 Oracle. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html @@ -15,7 +15,6 @@ import org.eclipse.jpt.core.context.java.JavaEmbeddable; import org.eclipse.jpt.core.context.java.JavaPersistentType; import org.eclipse.jpt.core.context.orm.OrmEmbeddable; import org.eclipse.jpt.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlEmbeddable; import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; @@ -23,8 +22,8 @@ import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; public class GenericOrmEmbeddable extends AbstractOrmTypeMapping<XmlEmbeddable> implements OrmEmbeddable { - public GenericOrmEmbeddable(OrmPersistentType parent) { - super(parent); + public GenericOrmEmbeddable(OrmPersistentType parent, XmlEmbeddable resourceMapping) { + super(parent, resourceMapping); } public JavaEmbeddable getJavaEmbeddable() { @@ -75,18 +74,11 @@ public class GenericOrmEmbeddable extends AbstractOrmTypeMapping<XmlEmbeddable> return attributeMappingKey == MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY || attributeMappingKey == MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY; } - protected Boolean metadataComplete(XmlEmbeddable embeddable) { - return embeddable.getMetadataComplete(); + public void addToResourceModel(XmlEntityMappings entityMappings) { + entityMappings.getEmbeddables().add(this.resourceTypeMapping); } public void removeFromResourceModel(XmlEntityMappings entityMappings) { entityMappings.getEmbeddables().remove(this.resourceTypeMapping); } - - public XmlEmbeddable addToResourceModel(XmlEntityMappings entityMappings) { - XmlEmbeddable embeddable = OrmFactory.eINSTANCE.createXmlEmbeddable(); - getPersistentType().initialize(embeddable); - entityMappings.getEmbeddables().add(embeddable); - return embeddable; - } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddedIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddedIdMapping.java index 780f87ae41..09de8882bb 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddedIdMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddedIdMapping.java @@ -13,16 +13,15 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmEmbeddedIdMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; public class GenericOrmEmbeddedIdMapping extends AbstractOrmBaseEmbeddedMapping<XmlEmbeddedId> implements OrmEmbeddedIdMapping { - public GenericOrmEmbeddedIdMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmEmbeddedIdMapping(OrmPersistentAttribute parent, XmlEmbeddedId resourceMapping) { + super(parent, resourceMapping); } public void initializeOn(OrmAttributeMapping newMapping) { @@ -44,14 +43,11 @@ public class GenericOrmEmbeddedIdMapping extends AbstractOrmBaseEmbeddedMapping< return true; } - public XmlEmbeddedId addToResourceModel(XmlTypeMapping typeMapping) { - XmlEmbeddedId embeddedId = OrmFactory.eINSTANCE.createXmlEmbeddedIdImpl(); - getPersistentAttribute().initialize(embeddedId); - typeMapping.getAttributes().getEmbeddedIds().add(embeddedId); - return embeddedId; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getEmbeddedIds().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getEmbeddedIds().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getEmbeddedIds().remove(this.resourceAttributeMapping); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddedMapping.java index 77713843e5..53795d142f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddedMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmEmbeddedMapping.java @@ -13,16 +13,15 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmEmbeddedMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.XmlEmbedded; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; public class GenericOrmEmbeddedMapping extends AbstractOrmBaseEmbeddedMapping<XmlEmbedded> implements OrmEmbeddedMapping { - public GenericOrmEmbeddedMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmEmbeddedMapping(OrmPersistentAttribute parent, XmlEmbedded resourceMapping) { + super(parent, resourceMapping); } public void initializeOn(OrmAttributeMapping newMapping) { @@ -37,14 +36,11 @@ public class GenericOrmEmbeddedMapping extends AbstractOrmBaseEmbeddedMapping<Xm return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY; } - public XmlEmbedded addToResourceModel(XmlTypeMapping typeMapping) { - XmlEmbedded embedded = OrmFactory.eINSTANCE.createXmlEmbeddedImpl(); - getPersistentAttribute().initialize(embedded); - typeMapping.getAttributes().getEmbeddeds().add(embedded); - return embedded; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getEmbeddeds().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getEmbeddeds().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getEmbeddeds().remove(this.resourceAttributeMapping); } } 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 fcdcf6ffd1..1b08493e0b 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 @@ -134,8 +134,8 @@ public class GenericOrmEntity protected final List<OrmNamedNativeQuery> namedNativeQueries; - public GenericOrmEntity(OrmPersistentType parent) { - super(parent); + public GenericOrmEntity(OrmPersistentType parent, XmlEntity resourceMapping) { + super(parent, resourceMapping); this.table = getJpaFactory().buildOrmTable(this); this.specifiedSecondaryTables = new ArrayList<OrmSecondaryTable>(); this.virtualSecondaryTables = new ArrayList<OrmSecondaryTable>(); @@ -148,6 +148,25 @@ public class GenericOrmEntity this.virtualAssociationOverrides = new ArrayList<OrmAssociationOverride>(); this.namedQueries = new ArrayList<OrmNamedQuery>(); this.namedNativeQueries = new ArrayList<OrmNamedNativeQuery>(); + this.specifiedName = this.resourceTypeMapping.getName(); + this.defaultName = this.buildDefaultName(); + this.initializeInheritance(this.getResourceInheritance()); + this.discriminatorColumn.initialize(this.resourceTypeMapping); //TODO pass in to constructor + this.specifiedDiscriminatorValue = this.resourceTypeMapping.getDiscriminatorValue(); + this.defaultDiscriminatorValue = this.defaultDiscriminatorValue(); + this.discriminatorValueAllowed = this.discriminatorValueIsAllowed(); + this.table.initialize(this.resourceTypeMapping);//TODO pass in to constructor + this.initializeSpecifiedSecondaryTables(); + this.initializeVirtualSecondaryTables(); + this.initializeSequenceGenerator(); + this.initializeTableGenerator(); + this.initializeSpecifiedPrimaryKeyJoinColumns(); + this.initializeDefaultPrimaryKeyJoinColumns(); + this.initializeSpecifiedAttributeOverrides(); + this.initializeSpecifiedAssociationOverrides(); + this.initializeNamedQueries(); + this.initializeNamedNativeQueries(); + this.initializeIdClass(this.getResourceIdClass()); } protected OrmDiscriminatorColumn buildDiscriminatorColumn() { @@ -1323,34 +1342,9 @@ public class GenericOrmEntity // } - @Override - public void initialize() { - super.initialize(); - this.specifiedName = this.resourceTypeMapping.getName(); - this.defaultName = this.buildDefaultName(); - this.initializeInheritance(this.getResourceInheritance()); - this.discriminatorColumn.initialize(this.resourceTypeMapping); - this.specifiedDiscriminatorValue = this.resourceTypeMapping.getDiscriminatorValue(); - this.defaultDiscriminatorValue = this.defaultDiscriminatorValue(); - this.discriminatorValueAllowed = this.discriminatorValueIsAllowed(); - this.table.initialize(this.resourceTypeMapping); - this.initializeSpecifiedSecondaryTables(); - this.initializeVirtualSecondaryTables(); - this.initializeSequenceGenerator(); - this.initializeTableGenerator(); - this.initializeSpecifiedPrimaryKeyJoinColumns(); - this.initializeDefaultPrimaryKeyJoinColumns(); - this.initializeSpecifiedAttributeOverrides(); - this.initializeVirtualAttributeOverrides(); - this.initializeSpecifiedAssociationOverrides(); - this.initializeNamedQueries(); - this.initializeNamedNativeQueries(); - this.initializeIdClass(this.getResourceIdClass()); - } - protected void initializeInheritance(Inheritance inheritanceResource) { this.specifiedInheritanceStrategy = this.specifiedInheritanceStrategy(inheritanceResource); - this.defaultInheritanceStrategy = this.defaultInheritanceStrategy(); + //no need to initialize defaultInheritanceStrategy, need to get all the persistentTypes in the model first } protected void initializeSpecifiedSecondaryTables() { @@ -1429,19 +1423,6 @@ public class GenericOrmEntity this.specifiedAttributeOverrides.add(buildAttributeOverride(attributeOverride)); } } - - protected void initializeVirtualAttributeOverrides() { - for (PersistentAttribute persistentAttribute : CollectionTools.iterable(allOverridableAttributes())) { - OrmAttributeOverride attributeOverride = getAttributeOverrideNamed(persistentAttribute.getName()); - if (attributeOverride == null) { - JavaAttributeOverride javaAttributeOverride = null; - if (getJavaEntity() != null) { - javaAttributeOverride = getJavaEntity().getAttributeOverrideNamed(persistentAttribute.getName()); - } - this.virtualAttributeOverrides.add(buildVirtualAttributeOverride(persistentAttribute, javaAttributeOverride)); - } - } - } protected OrmAttributeOverride buildVirtualAttributeOverride(PersistentAttribute persistentAttribute, JavaAttributeOverride javaAttributeOverride) { return buildAttributeOverride(buildVirtualXmlAttributeOverride(persistentAttribute, javaAttributeOverride)); @@ -1478,10 +1459,10 @@ public class GenericOrmEntity } protected void initializeIdClass(XmlIdClass idClassResource) { - this.idClass = this.idClass(idClassResource); + this.idClass = this.getResourceIdClass(idClassResource); } - protected String idClass(XmlIdClass idClassResource) { + protected String getResourceIdClass(XmlIdClass idClassResource) { return idClassResource == null ? null : idClassResource.getClassName(); } @@ -1841,7 +1822,7 @@ public class GenericOrmEntity } protected void updateIdClass(XmlIdClass idClassResource) { - this.setIdClass_(this.idClass(idClassResource)); + this.setIdClass_(this.getResourceIdClass(idClassResource)); } @@ -1877,15 +1858,12 @@ public class GenericOrmEntity return pkColumnName; } - public void removeFromResourceModel(XmlEntityMappings entityMappings) { - entityMappings.getEntities().remove(this.resourceTypeMapping); + public void addToResourceModel(XmlEntityMappings entityMappings) { + entityMappings.getEntities().add(this.resourceTypeMapping); } - public XmlEntity addToResourceModel(XmlEntityMappings entityMappings) { - XmlEntity entity = OrmFactory.eINSTANCE.createXmlEntity(); - getPersistentType().initialize(entity); - entityMappings.getEntities().add(entity); - return entity; + public void removeFromResourceModel(XmlEntityMappings entityMappings) { + entityMappings.getEntities().remove(this.resourceTypeMapping); } 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 1bf28e3c98..5df51ff36b 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 @@ -28,13 +28,13 @@ import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator; import org.eclipse.jpt.core.context.orm.OrmTableGenerator; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlColumn; import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue; import org.eclipse.jpt.core.resource.orm.XmlId; import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator; import org.eclipse.jpt.core.resource.orm.XmlTableGenerator; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.db.Table; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -56,9 +56,15 @@ public class GenericOrmIdMapping protected OrmSequenceGenerator sequenceGenerator; - public GenericOrmIdMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmIdMapping(OrmPersistentAttribute parent, XmlId resourceMapping) { + super(parent, resourceMapping); this.column = getJpaFactory().buildOrmColumn(this, this); + this.column.initialize(this.resourceAttributeMapping.getColumn());//TODO pass in to constructor + this.initializeSequenceGenerator(); + this.initializeTableGenerator(); + this.initializeGeneratedValue(); + this.defaultConverter = new GenericOrmNullConverter(this); + this.specifiedConverter = this.buildSpecifiedConverter(this.getResourceConverterType()); } @@ -250,15 +256,12 @@ public class GenericOrmIdMapping return true; } - public XmlId addToResourceModel(XmlTypeMapping typeMapping) { - XmlId id = OrmFactory.eINSTANCE.createXmlIdImpl(); - getPersistentAttribute().initialize(id); - typeMapping.getAttributes().getIds().add(id); - return id; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getIds().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getIds().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getIds().remove(this.resourceAttributeMapping); } public Table getDbTable(String tableName) { @@ -266,24 +269,13 @@ public class GenericOrmIdMapping } public String getDefaultColumnName() { - return getAttributeName(); + return getName(); } public String getDefaultTableName() { return getTypeMapping().getPrimaryTableName(); } - @Override - protected void initialize() { - super.initialize(); - this.column.initialize(this.resourceAttributeMapping.getColumn()); - this.initializeSequenceGenerator(); - this.initializeTableGenerator(); - this.initializeGeneratedValue(); - this.defaultConverter = new GenericOrmNullConverter(this); - this.specifiedConverter = this.buildSpecifiedConverter(this.getResourceConverterType()); - } - protected void initializeSequenceGenerator() { if (this.resourceAttributeMapping.getSequenceGenerator() != null) { this.sequenceGenerator = buildSequenceGenerator(this.resourceAttributeMapping.getSequenceGenerator()); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinTable.java index 33aa942312..e4c0f7e5bb 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinTable.java @@ -55,13 +55,15 @@ public class GenericOrmJoinTable protected final List<OrmJoinColumn> specifiedInverseJoinColumns; protected OrmJoinColumn defaultInverseJoinColumn; - protected XmlRelationshipMapping relationshipMappingResource; + protected final XmlRelationshipMapping resourceMapping; - public GenericOrmJoinTable(OrmRelationshipMapping parent) { + public GenericOrmJoinTable(OrmRelationshipMapping parent, XmlRelationshipMapping resourceMapping) { super(parent); + this.resourceMapping = resourceMapping; this.specifiedJoinColumns = new ArrayList<OrmJoinColumn>(); this.specifiedInverseJoinColumns = new ArrayList<OrmJoinColumn>(); + this.initialize(this.getResourceTable()); } @Override @@ -114,19 +116,19 @@ public class GenericOrmJoinTable @Override protected XmlJoinTable getResourceTable() { - return this.relationshipMappingResource.getJoinTable(); + return this.resourceMapping.getJoinTable(); } @Override protected XmlJoinTable addResourceTable() { XmlJoinTable resourceTable = OrmFactory.eINSTANCE.createXmlJoinTableImpl(); - this.relationshipMappingResource.setJoinTable(resourceTable); + this.resourceMapping.setJoinTable(resourceTable); return resourceTable; } @Override protected void removeResourceTable() { - this.relationshipMappingResource.setJoinTable(null); + this.resourceMapping.setJoinTable(null); } @@ -324,11 +326,6 @@ public class GenericOrmJoinTable return this.getResourceTable() != null && getResourceTable().isSpecified(); } - public void initialize(XmlRelationshipMapping relationshipMapping) { - this.relationshipMappingResource = relationshipMapping; - this.initialize(this.getResourceTable()); - } - public void update() { this.update(this.getResourceTable()); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyMapping.java index 1fe6b1728f..671ff83170 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyMapping.java @@ -15,16 +15,15 @@ import org.eclipse.jpt.core.context.NonOwningMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.XmlManyToMany; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; public class GenericOrmManyToManyMapping extends AbstractOrmMultiRelationshipMapping<XmlManyToMany> implements OrmManyToManyMapping { - public GenericOrmManyToManyMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmManyToManyMapping(OrmPersistentAttribute parent, XmlManyToMany resourceMapping) { + super(parent, resourceMapping); } public String getKey() { @@ -51,14 +50,11 @@ public class GenericOrmManyToManyMapping extends AbstractOrmMultiRelationshipMap return (mappedByKey == MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY); } - public XmlManyToMany addToResourceModel(XmlTypeMapping typeMapping) { - XmlManyToMany manyToMany = OrmFactory.eINSTANCE.createXmlManyToManyImpl(); - getPersistentAttribute().initialize(manyToMany); - typeMapping.getAttributes().getManyToManys().add(manyToMany); - return manyToMany; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getManyToManys().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getManyToManys().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getManyToManys().remove(this.resourceAttributeMapping); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToOneMapping.java index 01644dbdd4..80c77b2244 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToOneMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToOneMapping.java @@ -13,17 +13,16 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.XmlManyToOne; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; public class GenericOrmManyToOneMapping extends AbstractOrmSingleRelationshipMapping<XmlManyToOne> implements OrmManyToOneMapping { - public GenericOrmManyToOneMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmManyToOneMapping(OrmPersistentAttribute parent, XmlManyToOne resourceMapping) { + super(parent, resourceMapping); } public int getXmlSequence() { @@ -48,14 +47,11 @@ public class GenericOrmManyToOneMapping extends AbstractOrmSingleRelationshipMap return true; } - public XmlManyToOne addToResourceModel(XmlTypeMapping typeMapping) { - XmlManyToOne manyToOne = OrmFactory.eINSTANCE.createXmlManyToOneImpl(); - getPersistentAttribute().initialize(manyToOne); - typeMapping.getAttributes().getManyToOnes().add(manyToOne); - return manyToOne; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getManyToOnes().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getManyToOnes().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getManyToOnes().remove(this.resourceAttributeMapping); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmMappedSuperclass.java index 21c5e87193..a1418d73ae 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmMappedSuperclass.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmMappedSuperclass.java @@ -10,7 +10,6 @@ package org.eclipse.jpt.core.internal.context.orm; import java.util.Iterator; - import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.Table; import org.eclipse.jpt.core.context.java.JavaMappedSuperclass; @@ -32,8 +31,9 @@ public class GenericOrmMappedSuperclass extends AbstractOrmTypeMapping<XmlMapped { protected String idClass; - public GenericOrmMappedSuperclass(OrmPersistentType parent) { - super(parent); + public GenericOrmMappedSuperclass(OrmPersistentType parent, XmlMappedSuperclass resourceMapping) { + super(parent, resourceMapping); + this.idClass = this.getResourceIdClassName(this.getResourceIdClass()); } public JavaMappedSuperclass getJavaMappedSuperclass() { @@ -158,30 +158,15 @@ public class GenericOrmMappedSuperclass extends AbstractOrmTypeMapping<XmlMapped public int getXmlSequence() { return 0; } - - protected Boolean metadataComplete(XmlMappedSuperclass mappedSuperclass) { - return mappedSuperclass.getMetadataComplete(); + + public void addToResourceModel(XmlEntityMappings entityMappings) { + entityMappings.getMappedSuperclasses().add(this.resourceTypeMapping); } public void removeFromResourceModel(XmlEntityMappings entityMappings) { entityMappings.getMappedSuperclasses().remove(this.resourceTypeMapping); } - public XmlMappedSuperclass addToResourceModel(XmlEntityMappings entityMappings) { - XmlMappedSuperclass mappedSuperclass = OrmFactory.eINSTANCE.createXmlMappedSuperclass(); - getPersistentType().initialize(mappedSuperclass); - entityMappings.getMappedSuperclasses().add(mappedSuperclass); - return mappedSuperclass; - } - - - - @Override - public void initialize() { - super.initialize(); - this.idClass = this.getResourceIdClassName(this.getResourceIdClass()); - } - @Override public void update() { super.update(); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmNullAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmNullAttributeMapping.java index f617906144..e0196c0c97 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmNullAttributeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmNullAttributeMapping.java @@ -11,16 +11,15 @@ package org.eclipse.jpt.core.internal.context.orm; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; public class GenericOrmNullAttributeMapping extends AbstractOrmAttributeMapping<XmlNullAttributeMapping> { - public GenericOrmNullAttributeMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmNullAttributeMapping(OrmPersistentAttribute parent, XmlNullAttributeMapping resourceMapping) { + super(parent, resourceMapping); } public int getXmlSequence() { @@ -35,11 +34,11 @@ public class GenericOrmNullAttributeMapping extends AbstractOrmAttributeMapping< return null; } - public XmlAttributeMapping addToResourceModel(XmlTypeMapping typeMapping) { + public void addToResourceModel(Attributes resourceAttributes) { throw new UnsupportedOperationException(); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { + public void removeFromResourceModel(Attributes resourceAttributes) { throw new UnsupportedOperationException(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToManyMapping.java index 73bf33a6e5..d8388b3b0e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToManyMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToManyMapping.java @@ -15,17 +15,16 @@ import org.eclipse.jpt.core.context.NonOwningMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.XmlOneToMany; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; public class GenericOrmOneToManyMapping extends AbstractOrmMultiRelationshipMapping<XmlOneToMany> implements OrmOneToManyMapping { - public GenericOrmOneToManyMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmOneToManyMapping(OrmPersistentAttribute parent, XmlOneToMany resourceMapping) { + super(parent, resourceMapping); } public String getKey() { @@ -52,14 +51,11 @@ public class GenericOrmOneToManyMapping extends AbstractOrmMultiRelationshipMapp return (mappedByKey == MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY); } - public XmlOneToMany addToResourceModel(XmlTypeMapping typeMapping) { - XmlOneToMany oneToMany = OrmFactory.eINSTANCE.createXmlOneToManyImpl(); - getPersistentAttribute().initialize(oneToMany); - typeMapping.getAttributes().getOneToManys().add(oneToMany); - return oneToMany; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getOneToManys().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getOneToManys().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getOneToManys().remove(this.resourceAttributeMapping); } } 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 214eb807ff..d9ed692ade 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 @@ -26,10 +26,10 @@ import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlOneToOne; import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.core.utility.TextRange; import org.eclipse.jpt.utility.internal.CollectionTools; import org.eclipse.jpt.utility.internal.iterators.CloneIterator; @@ -49,9 +49,11 @@ public class GenericOrmOneToOneMapping protected final List<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns; - public GenericOrmOneToOneMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmOneToOneMapping(OrmPersistentAttribute parent, XmlOneToOne resourceMapping) { + super(parent, resourceMapping); + this.mappedBy = this.getResourceMappedBy(); this.primaryKeyJoinColumns = new ArrayList<OrmPrimaryKeyJoinColumn>(); + this.initializePrimaryKeyJoinColumns(); } @@ -164,15 +166,12 @@ public class GenericOrmOneToOneMapping return true; } - public XmlOneToOne addToResourceModel(XmlTypeMapping typeMapping) { - XmlOneToOne oneToOne = OrmFactory.eINSTANCE.createXmlOneToOneImpl(); - getPersistentAttribute().initialize(oneToOne); - typeMapping.getAttributes().getOneToOnes().add(oneToOne); - return oneToOne; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getOneToOnes().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getOneToOnes().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getOneToOnes().remove(this.resourceAttributeMapping); } @@ -184,13 +183,6 @@ public class GenericOrmOneToOneMapping // ********** resource => context ********** - - @Override - protected void initialize() { - super.initialize(); - this.mappedBy = this.getResourceMappedBy(); - this.initializePrimaryKeyJoinColumns(); - } protected void initializePrimaryKeyJoinColumns() { if (this.resourceAttributeMapping != null) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentAttribute.java index 2c6c93f873..7eb4b6424e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentAttribute.java @@ -37,10 +37,11 @@ public class GenericOrmPersistentAttribute extends AbstractXmlContextNode protected JavaPersistentAttribute javaPersistentAttribute; - public GenericOrmPersistentAttribute(OrmPersistentType parent, Owner owner, String mappingKey) { + public GenericOrmPersistentAttribute(OrmPersistentType parent, Owner owner, XmlAttributeMapping resourceMapping) { super(parent); this.owner = owner; - this.attributeMapping = buildAttributeMapping(mappingKey); + this.attributeMapping = buildAttributeMapping(resourceMapping); + this.javaPersistentAttribute = findJavaPersistentAttribute(); } public JavaPersistentAttribute getJavaPersistentAttribute() { @@ -57,8 +58,8 @@ public class GenericOrmPersistentAttribute extends AbstractXmlContextNode this.firePropertyChanged(JAVA_PERSISTENT_ATTRIBUTE_PROPERTY, old, javaPersistentAttribute); } - protected OrmAttributeMapping buildAttributeMapping(String key) { - return getJpaPlatform().buildOrmAttributeMappingFromMappingKey(key, this); + protected OrmAttributeMapping buildAttributeMapping(XmlAttributeMapping resourceMapping) { + return getJpaPlatform().buildOrmAttributeMappingFromMappingKey(this, resourceMapping); } public String getId() { @@ -94,19 +95,12 @@ public class GenericOrmPersistentAttribute extends AbstractXmlContextNode return; } OrmAttributeMapping oldMapping = this.attributeMapping; - this.attributeMapping = buildAttributeMapping(newMappingKey); + XmlAttributeMapping newResourceAttributeMapping = getJpaPlatform().buildOrmResourceAttributeMapping(newMappingKey, getContentType()); + this.attributeMapping = buildAttributeMapping(newResourceAttributeMapping); + getPersistentType().changeMapping(this, oldMapping, this.attributeMapping); firePropertyChanged(SPECIFIED_MAPPING_PROPERTY, oldMapping, this.attributeMapping); } - - protected void setSpecifiedMappingKey_(String newMappingKey) { - if (this.getMappingKey() == newMappingKey) { - return; - } - OrmAttributeMapping oldMapping = this.attributeMapping; - this.attributeMapping = buildAttributeMapping(newMappingKey); - firePropertyChanged(SPECIFIED_MAPPING_PROPERTY, oldMapping, this.attributeMapping); - } public OrmPersistentType getPersistentType() { return (OrmPersistentType) getParent(); @@ -160,11 +154,6 @@ public class GenericOrmPersistentAttribute extends AbstractXmlContextNode return this.attributeMapping.isIdMapping(); } - public void initialize(XmlAttributeMapping xmlAttributeMapping) { - this.attributeMapping.initialize(xmlAttributeMapping); - this.javaPersistentAttribute = findJavaPersistentAttribute(); - } - public void update() { this.attributeMapping.update(); this.setJavaPersistentAttribute(findJavaPersistentAttribute()); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentType.java index 6af4e6f04c..25838c9966 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPersistentType.java @@ -12,16 +12,17 @@ package org.eclipse.jpt.core.internal.context.orm; import org.eclipse.jpt.core.context.orm.EntityMappings; import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; public class GenericOrmPersistentType extends AbstractOrmPersistentType { - public GenericOrmPersistentType(EntityMappings parent, String mappingKey) { - super(parent, mappingKey); + public GenericOrmPersistentType(EntityMappings parent, XmlTypeMapping resourceMapping) { + super(parent, resourceMapping); } @Override - protected Attributes createAttributesResource() { + protected Attributes createResourceAttributes() { return OrmFactory.eINSTANCE.createAttributes(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmTransientMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmTransientMapping.java index d12cf78028..401500ac82 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmTransientMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmTransientMapping.java @@ -13,16 +13,15 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTransientMapping; -import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.XmlTransient; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; public class GenericOrmTransientMapping extends AbstractOrmAttributeMapping<XmlTransient> implements OrmTransientMapping { - public GenericOrmTransientMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmTransientMapping(OrmPersistentAttribute parent, XmlTransient resourceMapping) { + super(parent, resourceMapping); } public void initializeOn(OrmAttributeMapping newMapping) { @@ -37,14 +36,11 @@ public class GenericOrmTransientMapping extends AbstractOrmAttributeMapping<XmlT return MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY; } - public XmlTransient addToResourceModel(XmlTypeMapping typeMapping) { - XmlTransient transientResource = OrmFactory.eINSTANCE.createXmlTransientImpl(); - getPersistentAttribute().initialize(transientResource); - typeMapping.getAttributes().getTransients().add(transientResource); - return transientResource; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getTransients().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getTransients().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getTransients().remove(this.resourceAttributeMapping); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmVersionMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmVersionMapping.java index 8579075d74..f6edbb76dd 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmVersionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmVersionMapping.java @@ -20,9 +20,9 @@ import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmVersionMapping; import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; +import org.eclipse.jpt.core.resource.orm.Attributes; import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlColumn; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlVersion; import org.eclipse.jpt.db.Table; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -36,9 +36,12 @@ public class GenericOrmVersionMapping extends AbstractOrmAttributeMapping<XmlVer protected OrmConverter defaultConverter; protected OrmConverter specifiedConverter; - public GenericOrmVersionMapping(OrmPersistentAttribute parent) { - super(parent); + public GenericOrmVersionMapping(OrmPersistentAttribute parent, XmlVersion resourceMapping) { + super(parent, resourceMapping); this.column = getJpaFactory().buildOrmColumn(this, this); + this.column.initialize(this.getResourceColumn());//TODO pass in to constructor + this.defaultConverter = new GenericOrmNullConverter(this); + this.specifiedConverter = this.buildSpecifiedConverter(this.getResourceConverterType()); } public int getXmlSequence() { @@ -105,19 +108,16 @@ public class GenericOrmVersionMapping extends AbstractOrmAttributeMapping<XmlVer firePropertyChanged(SPECIFIED_CONVERTER_PROPERTY, oldConverter, newConverter); } - public XmlVersion addToResourceModel(XmlTypeMapping typeMapping) { - XmlVersion version = OrmFactory.eINSTANCE.createXmlVersionImpl(); - getPersistentAttribute().initialize(version); - typeMapping.getAttributes().getVersions().add(version); - return version; + public void addToResourceModel(Attributes resourceAttributes) { + resourceAttributes.getVersions().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - typeMapping.getAttributes().getVersions().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(Attributes resourceAttributes) { + resourceAttributes.getVersions().remove(this.resourceAttributeMapping); } public String getDefaultColumnName() { - return getAttributeName(); + return getName(); } public String getDefaultTableName() { @@ -129,14 +129,6 @@ public class GenericOrmVersionMapping extends AbstractOrmAttributeMapping<XmlVer } @Override - protected void initialize() { - super.initialize(); - this.column.initialize(this.getResourceColumn()); - this.defaultConverter = new GenericOrmNullConverter(this); - this.specifiedConverter = this.buildSpecifiedConverter(this.getResourceConverterType()); - } - - @Override public void update() { super.update(); this.column.update(this.getResourceColumn()); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericPersistenceUnitDefaults.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericPersistenceUnitDefaults.java index 5e32a8a647..d83ce8150b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericPersistenceUnitDefaults.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericPersistenceUnitDefaults.java @@ -29,7 +29,7 @@ public class GenericPersistenceUnitDefaults extends AbstractXmlContextNode implements OrmPersistenceUnitDefaults { - protected XmlEntityMappings entityMappings; + protected final XmlEntityMappings xmlEntityMappings; protected AccessType access; @@ -44,8 +44,18 @@ public class GenericPersistenceUnitDefaults // ********** constructor/initialization ********** - public GenericPersistenceUnitDefaults(PersistenceUnitMetadata parent) { + public GenericPersistenceUnitDefaults(PersistenceUnitMetadata parent, XmlEntityMappings xmlEntityMappings) { super(parent); + this.xmlEntityMappings = xmlEntityMappings; + XmlPersistenceUnitDefaults resourceDefaults = this.getResourceDefaults(); + if (resourceDefaults != null) { + this.access = AccessType.fromXmlResourceModel(resourceDefaults.getAccess()); + this.specifiedCatalog = resourceDefaults.getCatalog(); + this.specifiedSchema = resourceDefaults.getSchema(); + this.cascadePersist = resourceDefaults.isCascadePersist(); + } + this.defaultCatalog = this.getJpaProject().getDefaultCatalog(); + this.defaultSchema = this.getJpaProject().getDefaultSchema(); } public boolean resourceExists() { @@ -220,10 +230,10 @@ public class GenericPersistenceUnitDefaults * build the resource defaults and the resource metadata if necessary */ protected XmlPersistenceUnitDefaults buildResourceDefaults() { - XmlPersistenceUnitMetadata resourceMetadata = this.entityMappings.getPersistenceUnitMetadata(); + XmlPersistenceUnitMetadata resourceMetadata = this.xmlEntityMappings.getPersistenceUnitMetadata(); if (resourceMetadata == null) { resourceMetadata = OrmFactory.eINSTANCE.createXmlPersistenceUnitMetadata(); - this.entityMappings.setPersistenceUnitMetadata(resourceMetadata); + this.xmlEntityMappings.setPersistenceUnitMetadata(resourceMetadata); } XmlPersistenceUnitDefaults resourceDefaults = OrmFactory.eINSTANCE.createXmlPersistenceUnitDefaults(); resourceMetadata.setPersistenceUnitDefaults(resourceDefaults); @@ -235,32 +245,14 @@ public class GenericPersistenceUnitDefaults */ protected void checkResourceDefaults(XmlPersistenceUnitDefaults resourceDefaults) { if (resourceDefaults.isUnset()) { - XmlPersistenceUnitMetadata metadata = this.entityMappings.getPersistenceUnitMetadata(); + XmlPersistenceUnitMetadata metadata = this.xmlEntityMappings.getPersistenceUnitMetadata(); metadata.setPersistenceUnitDefaults(null); if (metadata.isUnset()) { - this.entityMappings.setPersistenceUnitMetadata(null); + this.xmlEntityMappings.setPersistenceUnitMetadata(null); } } } - - public void initialize(XmlEntityMappings xmlEntityMappings) { - this.entityMappings = xmlEntityMappings; - this.initialize(); - } - - protected void initialize() { - XmlPersistenceUnitDefaults resourceDefaults = this.getResourceDefaults(); - if (resourceDefaults != null) { - this.access = AccessType.fromXmlResourceModel(resourceDefaults.getAccess()); - this.specifiedCatalog = resourceDefaults.getCatalog(); - this.specifiedSchema = resourceDefaults.getSchema(); - this.cascadePersist = resourceDefaults.isCascadePersist(); - } - this.defaultCatalog = this.getJpaProject().getDefaultCatalog(); - this.defaultSchema = this.getJpaProject().getDefaultSchema(); - } - public void update() { XmlPersistenceUnitDefaults resourceDefaults = this.getResourceDefaults(); if (resourceDefaults == null) { @@ -280,11 +272,11 @@ public class GenericPersistenceUnitDefaults public TextRange getValidationTextRange() { XmlPersistenceUnitDefaults resourceDefaults = this.getResourceDefaults(); - return (resourceDefaults != null) ? resourceDefaults.getValidationTextRange() : this.entityMappings.getValidationTextRange(); + return (resourceDefaults != null) ? resourceDefaults.getValidationTextRange() : this.xmlEntityMappings.getValidationTextRange(); } protected XmlPersistenceUnitDefaults getResourceDefaults() { - XmlPersistenceUnitMetadata metadata = this.entityMappings.getPersistenceUnitMetadata(); + XmlPersistenceUnitMetadata metadata = this.xmlEntityMappings.getPersistenceUnitMetadata(); return (metadata == null) ? null : metadata.getPersistenceUnitDefaults(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericPersistenceUnitMetadata.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericPersistenceUnitMetadata.java index 07f9771c53..f0187f39bd 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericPersistenceUnitMetadata.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericPersistenceUnitMetadata.java @@ -23,12 +23,15 @@ public class GenericPersistenceUnitMetadata extends AbstractXmlContextNode { protected boolean xmlMappingMetadataComplete; - protected /*final */ OrmPersistenceUnitDefaults persistenceUnitDefaults; + protected final OrmPersistenceUnitDefaults persistenceUnitDefaults; - protected XmlEntityMappings xmlEntityMappings; + protected final XmlEntityMappings xmlEntityMappings; - public GenericPersistenceUnitMetadata(EntityMappings parent) { + public GenericPersistenceUnitMetadata(EntityMappings parent, XmlEntityMappings resource) { super(parent); + this.xmlEntityMappings = resource; + this.xmlMappingMetadataComplete = this.getResourceXmlMappingMetadataComplete(); + this.persistenceUnitDefaults = getJpaFactory().buildPersistenceUnitDefaults(this, this.xmlEntityMappings); } public boolean isXmlMappingMetadataComplete() { @@ -63,16 +66,6 @@ public class GenericPersistenceUnitMetadata extends AbstractXmlContextNode return this.persistenceUnitDefaults; } - public void initialize(XmlEntityMappings xmlEntityMappings) { - this.xmlEntityMappings = xmlEntityMappings; - this.initialize(); - } - - protected void initialize() { - this.xmlMappingMetadataComplete = this.getResourceXmlMappingMetadataComplete(); - this.persistenceUnitDefaults = getJpaFactory().buildPersistenceUnitDefaults(this, this.xmlEntityMappings); - } - public void update() { this.setXmlMappingMetadataComplete_(this.getResourceXmlMappingMetadataComplete()); this.persistenceUnitDefaults.update(); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBasicMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBasicMappingProvider.java index af81518ca1..e98eabbabd 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBasicMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBasicMappingProvider.java @@ -15,11 +15,13 @@ import org.eclipse.jpt.core.JptCorePlugin; import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.java.JavaAttributeMapping; import org.eclipse.jpt.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; +import org.eclipse.jpt.core.context.orm.OrmBasicMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlBasic; public class OrmBasicMappingProvider implements OrmAttributeMappingProvider @@ -48,9 +50,13 @@ public class OrmBasicMappingProvider public String getKey() { return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY; } - - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmBasicMapping(parent); + + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlBasicImpl(); + } + + public OrmBasicMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmBasicMapping(parent, (XmlBasic) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmCascade.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmCascade.java index ddf2affcb5..47bebd013e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmCascade.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmCascade.java @@ -31,10 +31,17 @@ public class OrmCascade extends AbstractXmlContextNode implements Cascade protected boolean refresh; - protected XmlRelationshipMapping relationshipMapping; + protected final XmlRelationshipMapping relationshipMapping; - protected OrmCascade(OrmRelationshipMapping parent) { + protected OrmCascade(OrmRelationshipMapping parent, XmlRelationshipMapping relationshipMapping) { super(parent); + this.relationshipMapping = relationshipMapping; + CascadeType cascade = getResourceCascade(); + this.all = this.getResourceAll(cascade); + this.persist = this.getResourcePersist(cascade); + this.merge = this.getResourceMerge(cascade); + this.remove = this.getResourceRemove(cascade); + this.refresh = this.getResourceRefresh(cascade); } public void initializeFrom(Cascade oldCascade) { @@ -53,15 +60,15 @@ public class OrmCascade extends AbstractXmlContextNode implements Cascade boolean oldAll = this.all; this.all = newAll; if (oldAll != newAll) { - if (this.getCascadeResource() != null) { - this.getCascadeResource().setCascadeAll(newAll); - if (this.getCascadeResource().isUnset()) { - removeCascadeResource(); + if (this.getResourceCascade() != null) { + this.getResourceCascade().setCascadeAll(newAll); + if (this.getResourceCascade().isUnset()) { + removeResourceCascade(); } } else if (newAll != false) { - addCascadeResource(); - getCascadeResource().setCascadeAll(newAll); + addResourceCascade(); + getResourceCascade().setCascadeAll(newAll); } } firePropertyChanged(ALL_PROPERTY, oldAll, newAll); @@ -81,15 +88,15 @@ public class OrmCascade extends AbstractXmlContextNode implements Cascade boolean oldPersist = this.persist; this.persist = newPersist; if (oldPersist != newPersist) { - if (this.getCascadeResource() != null) { - this.getCascadeResource().setCascadePersist(newPersist); - if (this.getCascadeResource().isUnset()) { - removeCascadeResource(); + if (this.getResourceCascade() != null) { + this.getResourceCascade().setCascadePersist(newPersist); + if (this.getResourceCascade().isUnset()) { + removeResourceCascade(); } } else if (newPersist != false) { - addCascadeResource(); - getCascadeResource().setCascadePersist(newPersist); + addResourceCascade(); + getResourceCascade().setCascadePersist(newPersist); } } firePropertyChanged(PERSIST_PROPERTY, oldPersist, newPersist); @@ -110,15 +117,15 @@ public class OrmCascade extends AbstractXmlContextNode implements Cascade boolean oldMerge = this.merge; this.merge = newMerge; if (oldMerge != newMerge) { - if (this.getCascadeResource() != null) { - this.getCascadeResource().setCascadeMerge(newMerge); - if (this.getCascadeResource().isUnset()) { - removeCascadeResource(); + if (this.getResourceCascade() != null) { + this.getResourceCascade().setCascadeMerge(newMerge); + if (this.getResourceCascade().isUnset()) { + removeResourceCascade(); } } else if (newMerge != false) { - addCascadeResource(); - getCascadeResource().setCascadeMerge(newMerge); + addResourceCascade(); + getResourceCascade().setCascadeMerge(newMerge); } } firePropertyChanged(MERGE_PROPERTY, oldMerge, newMerge); @@ -138,15 +145,15 @@ public class OrmCascade extends AbstractXmlContextNode implements Cascade boolean oldRemove = this.remove; this.remove = newRemove; if (oldRemove != newRemove) { - if (this.getCascadeResource() != null) { - this.getCascadeResource().setCascadeRemove(newRemove); - if (this.getCascadeResource().isUnset()) { - removeCascadeResource(); + if (this.getResourceCascade() != null) { + this.getResourceCascade().setCascadeRemove(newRemove); + if (this.getResourceCascade().isUnset()) { + removeResourceCascade(); } } else if (newRemove != false) { - addCascadeResource(); - getCascadeResource().setCascadeRemove(newRemove); + addResourceCascade(); + getResourceCascade().setCascadeRemove(newRemove); } } firePropertyChanged(REMOVE_PROPERTY, oldRemove, newRemove); @@ -166,15 +173,15 @@ public class OrmCascade extends AbstractXmlContextNode implements Cascade boolean oldRefresh = this.refresh; this.refresh = newRefresh; if (oldRefresh != newRefresh) { - if (this.getCascadeResource() != null) { - this.getCascadeResource().setCascadeRefresh(newRefresh); - if (this.getCascadeResource().isUnset()) { - removeCascadeResource(); + if (this.getResourceCascade() != null) { + this.getResourceCascade().setCascadeRefresh(newRefresh); + if (this.getResourceCascade().isUnset()) { + removeResourceCascade(); } } else if (newRefresh != false) { - addCascadeResource(); - getCascadeResource().setCascadeRefresh(newRefresh); + addResourceCascade(); + getResourceCascade().setCascadeRefresh(newRefresh); } } firePropertyChanged(REFRESH_PROPERTY, oldRefresh, newRefresh); @@ -187,58 +194,48 @@ public class OrmCascade extends AbstractXmlContextNode implements Cascade } - protected CascadeType getCascadeResource() { + protected CascadeType getResourceCascade() { return this.relationshipMapping.getCascade(); } - protected void removeCascadeResource() { + protected void removeResourceCascade() { this.relationshipMapping.setCascade(null); } - protected void addCascadeResource() { + protected void addResourceCascade() { this.relationshipMapping.setCascade(OrmFactory.eINSTANCE.createCascadeTypeImpl()); } - - public void initialize(XmlRelationshipMapping relationshipMapping) { - this.relationshipMapping = relationshipMapping; - CascadeType cascade = getCascadeResource(); - this.all = this.all(cascade); - this.persist = this.persist(cascade); - this.merge = this.merge(cascade); - this.remove = this.remove(cascade); - this.refresh = this.refresh(cascade); - } public void update() { - CascadeType cascade = getCascadeResource(); - this.setAll_(this.all(cascade)); - this.setPersist_(this.persist(cascade)); - this.setMerge_(this.merge(cascade)); - this.setRemove_(this.remove(cascade)); - this.setRefresh_(this.refresh(cascade)); + CascadeType cascade = getResourceCascade(); + this.setAll_(this.getResourceAll(cascade)); + this.setPersist_(this.getResourcePersist(cascade)); + this.setMerge_(this.getResourceMerge(cascade)); + this.setRemove_(this.getResourceRemove(cascade)); + this.setRefresh_(this.getResourceRefresh(cascade)); } - protected boolean all(CascadeType cascade) { + protected boolean getResourceAll(CascadeType cascade) { return cascade == null ? false : cascade.isCascadeAll(); } - protected boolean persist(CascadeType cascade) { + protected boolean getResourcePersist(CascadeType cascade) { return cascade == null ? false : cascade.isCascadePersist(); } - protected boolean merge(CascadeType cascade) { + protected boolean getResourceMerge(CascadeType cascade) { return cascade == null ? false : cascade.isCascadeMerge(); } - protected boolean remove(CascadeType cascade) { + protected boolean getResourceRemove(CascadeType cascade) { return cascade == null ? false : cascade.isCascadeRemove(); } - protected boolean refresh(CascadeType cascade) { + protected boolean getResourceRefresh(CascadeType cascade) { return cascade == null ? false : cascade.isCascadeRefresh(); } public TextRange getValidationTextRange() { - return this.getCascadeResource().getValidationTextRange(); + return this.getResourceCascade().getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddableProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddableProvider.java index 88f5f9179b..47b1d6c754 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddableProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddableProvider.java @@ -16,6 +16,9 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmEmbeddable; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.context.orm.OrmTypeMappingProvider; +import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.XmlEmbeddable; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; /** * default ORM Embeddable provider @@ -39,9 +42,13 @@ public class OrmEmbeddableProvider private OrmEmbeddableProvider() { super(); } - - public OrmEmbeddable buildMapping(OrmPersistentType parent, JpaFactory factory) { - return factory.buildOrmEmbeddable(parent); + + public XmlTypeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlEmbeddable(); + } + + public OrmEmbeddable buildMapping(OrmPersistentType parent, XmlTypeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmEmbeddable(parent, (XmlEmbeddable) resourceMapping); } public IContentType getContentType() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedIdMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedIdMappingProvider.java index 2d7e7d88d4..a30214867d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedIdMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedIdMappingProvider.java @@ -19,7 +19,9 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId; public class OrmEmbeddedIdMappingProvider implements OrmAttributeMappingProvider @@ -49,8 +51,12 @@ public class OrmEmbeddedIdMappingProvider return MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY; } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmEmbeddedIdMapping(parent); + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlEmbeddedIdImpl(); + } + + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmEmbeddedIdMapping(parent, (XmlEmbeddedId) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedMappingProvider.java index 0f1ffcd384..96cc779168 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedMappingProvider.java @@ -19,7 +19,9 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlEmbedded; public class OrmEmbeddedMappingProvider implements OrmAttributeMappingProvider @@ -49,8 +51,12 @@ public class OrmEmbeddedMappingProvider return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY; } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmEmbeddedMapping(parent); + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlEmbeddedImpl(); + } + + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmEmbeddedMapping(parent, (XmlEmbedded) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityProvider.java index 70c140725c..dfc4e22d84 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityProvider.java @@ -16,6 +16,9 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmEntity; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.context.orm.OrmTypeMappingProvider; +import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.XmlEntity; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; /** * default ORM Entity provider @@ -39,9 +42,13 @@ public class OrmEntityProvider private OrmEntityProvider() { super(); } + + public XmlTypeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlEntity(); + } - public OrmEntity buildMapping(OrmPersistentType parent, JpaFactory factory) { - return factory.buildOrmEntity(parent); + public OrmEntity buildMapping(OrmPersistentType parent, XmlTypeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmEntity(parent, (XmlEntity) resourceMapping); } public IContentType getContentType() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmIdMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmIdMappingProvider.java index 2f0ea9b569..3d9fa59d49 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmIdMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmIdMappingProvider.java @@ -19,7 +19,9 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlId; public class OrmIdMappingProvider implements OrmAttributeMappingProvider @@ -49,8 +51,12 @@ public class OrmIdMappingProvider return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY; } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmIdMapping(parent); + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlIdImpl(); + } + + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmIdMapping(parent, (XmlId) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToManyMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToManyMappingProvider.java index a0c08aefad..911ae7858a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToManyMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToManyMappingProvider.java @@ -19,7 +19,9 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlManyToMany; public class OrmManyToManyMappingProvider implements OrmAttributeMappingProvider @@ -48,9 +50,13 @@ public class OrmManyToManyMappingProvider public String getKey() { return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlManyToManyImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmManyToManyMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmManyToManyMapping(parent, (XmlManyToMany) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToOneMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToOneMappingProvider.java index 596295ab75..52362e3fde 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToOneMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToOneMappingProvider.java @@ -19,7 +19,9 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlManyToOne; public class OrmManyToOneMappingProvider implements OrmAttributeMappingProvider @@ -48,9 +50,13 @@ public class OrmManyToOneMappingProvider public String getKey() { return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlManyToOneImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmManyToOneMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmManyToOneMapping(parent, (XmlManyToOne) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassProvider.java index 8703476db5..0ef8d3a001 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassProvider.java @@ -16,6 +16,9 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.context.orm.OrmTypeMappingProvider; +import org.eclipse.jpt.core.resource.orm.OrmFactory; +import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; /** * default ORM MappedSuperclass provider @@ -39,9 +42,13 @@ public class OrmMappedSuperclassProvider private OrmMappedSuperclassProvider() { super(); } + + public XmlTypeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlMappedSuperclass(); + } - public OrmMappedSuperclass buildMapping(OrmPersistentType parent, JpaFactory factory) { - return factory.buildOrmMappedSuperclass(parent); + public OrmMappedSuperclass buildMapping(OrmPersistentType parent, XmlTypeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmMappedSuperclass(parent, (XmlMappedSuperclass) resourceMapping); } public IContentType getContentType() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmNullAttributeMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmNullAttributeMappingProvider.java index 2fbcdf6ca1..f0d4d908f0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmNullAttributeMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmNullAttributeMappingProvider.java @@ -19,6 +19,7 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping; public class OrmNullAttributeMappingProvider implements OrmAttributeMappingProvider @@ -47,9 +48,13 @@ public class OrmNullAttributeMappingProvider public String getKey() { return MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + throw new UnsupportedOperationException(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmNullAttributeMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmNullAttributeMapping(parent, (XmlNullAttributeMapping) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToManyMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToManyMappingProvider.java index 869615d36b..b54211f770 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToManyMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToManyMappingProvider.java @@ -19,7 +19,9 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlOneToMany; public class OrmOneToManyMappingProvider implements OrmAttributeMappingProvider @@ -48,9 +50,13 @@ public class OrmOneToManyMappingProvider public String getKey() { return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlOneToManyImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmOneToManyMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmOneToManyMapping(parent, (XmlOneToMany) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToOneMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToOneMappingProvider.java index b813e95fa0..8ab69d26d1 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToOneMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToOneMappingProvider.java @@ -19,7 +19,9 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlOneToOne; public class OrmOneToOneMappingProvider implements OrmAttributeMappingProvider @@ -48,9 +50,13 @@ public class OrmOneToOneMappingProvider public String getKey() { return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlOneToOneImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmOneToOneMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmOneToOneMapping(parent, (XmlOneToOne) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTransientMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTransientMappingProvider.java index 78b79eaf07..10c1b3dfdd 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTransientMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTransientMappingProvider.java @@ -19,7 +19,9 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlTransient; public class OrmTransientMappingProvider implements OrmAttributeMappingProvider @@ -49,8 +51,12 @@ public class OrmTransientMappingProvider return MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY; } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmTransientMapping(parent); + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlTransientImpl(); + } + + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmTransientMapping(parent, (XmlTransient) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmVersionMappingProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmVersionMappingProvider.java index 0da18b7117..2e7dbde043 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmVersionMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmVersionMappingProvider.java @@ -19,7 +19,9 @@ import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmAttributeMappingProvider; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; +import org.eclipse.jpt.core.resource.orm.OrmFactory; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlVersion; public class OrmVersionMappingProvider implements OrmAttributeMappingProvider @@ -48,9 +50,13 @@ public class OrmVersionMappingProvider public String getKey() { return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return OrmFactory.eINSTANCE.createXmlVersionImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return factory.buildOrmVersionMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return factory.buildOrmVersionMapping(parent, (XmlVersion) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeMapping.java index 9eef7fccf7..1f67fd91e5 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeMapping.java @@ -36,9 +36,10 @@ public abstract class VirtualXmlAttributeMapping<T extends JavaAttributeMapping> } public String getMappingKey() { - //TODO unsure about this, but don't believe we should be asking a virtual mapping for it's mapping key - //or maybe we should be asking the javaAttributeMapping for its default or specified mapping key? - throw new UnsupportedOperationException(); + if (this.isOrmMetadataComplete()) { + return this.javaAttributeMapping.getPersistentAttribute().getDefaultMappingKey(); + } + return this.javaAttributeMapping.getKey(); } public String getName() { 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 a8ad547f0a..a3941af019 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 @@ -214,16 +214,20 @@ import org.eclipse.jpt.core.resource.jar.JarResourcePackageFragmentRoot; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; +import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; import org.eclipse.jpt.core.resource.orm.XmlBasic; +import org.eclipse.jpt.core.resource.orm.XmlEmbeddable; import org.eclipse.jpt.core.resource.orm.XmlEmbedded; import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId; +import org.eclipse.jpt.core.resource.orm.XmlEntity; import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue; import org.eclipse.jpt.core.resource.orm.XmlId; import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; import org.eclipse.jpt.core.resource.orm.XmlManyToMany; import org.eclipse.jpt.core.resource.orm.XmlManyToOne; +import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass; import org.eclipse.jpt.core.resource.orm.XmlNamedNativeQuery; import org.eclipse.jpt.core.resource.orm.XmlNamedQuery; import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping; @@ -231,10 +235,12 @@ import org.eclipse.jpt.core.resource.orm.XmlOneToMany; import org.eclipse.jpt.core.resource.orm.XmlOneToOne; import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn; import org.eclipse.jpt.core.resource.orm.XmlQueryHint; +import org.eclipse.jpt.core.resource.orm.XmlRelationshipMapping; 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.XmlTransient; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint; import org.eclipse.jpt.core.resource.orm.XmlVersion; import org.eclipse.jpt.core.resource.persistence.XmlJarFileRef; @@ -329,41 +335,35 @@ public class GenericJpaFactory } public EntityMappings buildEntityMappings(OrmXml parent, XmlEntityMappings xmlEntityMappings) { - EntityMappings entityMappings = new GenericEntityMappings(parent); - entityMappings.initialize(xmlEntityMappings); - return entityMappings; + return new GenericEntityMappings(parent, xmlEntityMappings); } public PersistenceUnitMetadata buildPersistenceUnitMetadata(EntityMappings parent, XmlEntityMappings xmlEntityMappings) { - PersistenceUnitMetadata persistenceUnitMetadata = new GenericPersistenceUnitMetadata(parent); - persistenceUnitMetadata.initialize(xmlEntityMappings); - return persistenceUnitMetadata; + return new GenericPersistenceUnitMetadata(parent, xmlEntityMappings); } public OrmPersistenceUnitDefaults buildPersistenceUnitDefaults(PersistenceUnitMetadata parent, XmlEntityMappings xmlEntityMappings) { - OrmPersistenceUnitDefaults persistenceUnitDefaults = new GenericPersistenceUnitDefaults(parent); - persistenceUnitDefaults.initialize(xmlEntityMappings); - return persistenceUnitDefaults; + return new GenericPersistenceUnitDefaults(parent, xmlEntityMappings); } - public OrmPersistentType buildOrmPersistentType(EntityMappings parent, String mappingKey) { - return new GenericOrmPersistentType(parent, mappingKey); + public OrmPersistentType buildOrmPersistentType(EntityMappings parent, XmlTypeMapping resourceMapping) { + return new GenericOrmPersistentType(parent, resourceMapping); } - public OrmEntity buildOrmEntity(OrmPersistentType parent) { - return new GenericOrmEntity(parent); + public OrmEntity buildOrmEntity(OrmPersistentType parent, XmlEntity resourceMapping) { + return new GenericOrmEntity(parent, resourceMapping); } - public OrmMappedSuperclass buildOrmMappedSuperclass(OrmPersistentType parent) { - return new GenericOrmMappedSuperclass(parent); + public OrmMappedSuperclass buildOrmMappedSuperclass(OrmPersistentType parent, XmlMappedSuperclass resourceMapping) { + return new GenericOrmMappedSuperclass(parent, resourceMapping); } - public OrmEmbeddable buildOrmEmbeddable(OrmPersistentType parent) { - return new GenericOrmEmbeddable(parent); + public OrmEmbeddable buildOrmEmbeddable(OrmPersistentType parent, XmlEmbeddable resourceMapping) { + return new GenericOrmEmbeddable(parent, resourceMapping); } - public OrmPersistentAttribute buildOrmPersistentAttribute(OrmPersistentType parent, OrmPersistentAttribute.Owner owner, String mappingKey) { - return new GenericOrmPersistentAttribute(parent, owner, mappingKey); + public OrmPersistentAttribute buildOrmPersistentAttribute(OrmPersistentType parent, OrmPersistentAttribute.Owner owner, XmlAttributeMapping resourceMapping) { + return new GenericOrmPersistentAttribute(parent, owner, resourceMapping); } public OrmTable buildOrmTable(OrmEntity parent) { @@ -378,8 +378,8 @@ public class GenericJpaFactory return new GenericOrmPrimaryKeyJoinColumn(parent, owner, resourcePkJoinColumn); } - public OrmJoinTable buildOrmJoinTable(OrmRelationshipMapping parent) { - return new GenericOrmJoinTable(parent); + public OrmJoinTable buildOrmJoinTable(OrmRelationshipMapping parent, XmlRelationshipMapping resourceMapping) { + return new GenericOrmJoinTable(parent, resourceMapping); } public OrmJoinColumn buildOrmJoinColumn(XmlContextNode parent, OrmJoinColumn.Owner owner, XmlJoinColumn resourceJoinColumn) { @@ -426,48 +426,48 @@ public class GenericJpaFactory return new GenericOrmQueryHint(parent, resourceQueryHint); } - public OrmBasicMapping buildOrmBasicMapping(OrmPersistentAttribute parent) { - return new GenericOrmBasicMapping(parent); + public OrmBasicMapping buildOrmBasicMapping(OrmPersistentAttribute parent, XmlBasic resourceMapping) { + return new GenericOrmBasicMapping(parent, resourceMapping); } - public OrmEmbeddedMapping buildOrmEmbeddedMapping(OrmPersistentAttribute parent) { - return new GenericOrmEmbeddedMapping(parent); + public OrmEmbeddedMapping buildOrmEmbeddedMapping(OrmPersistentAttribute parent, XmlEmbedded resourceMapping) { + return new GenericOrmEmbeddedMapping(parent, resourceMapping); } - public OrmEmbeddedIdMapping buildOrmEmbeddedIdMapping(OrmPersistentAttribute parent) { - return new GenericOrmEmbeddedIdMapping(parent); + public OrmEmbeddedIdMapping buildOrmEmbeddedIdMapping(OrmPersistentAttribute parent, XmlEmbeddedId resourceMapping) { + return new GenericOrmEmbeddedIdMapping(parent, resourceMapping); } - public OrmIdMapping buildOrmIdMapping(OrmPersistentAttribute parent) { - return new GenericOrmIdMapping(parent); + public OrmIdMapping buildOrmIdMapping(OrmPersistentAttribute parent, XmlId resourceMapping) { + return new GenericOrmIdMapping(parent, resourceMapping); } - public OrmManyToManyMapping buildOrmManyToManyMapping(OrmPersistentAttribute parent) { - return new GenericOrmManyToManyMapping(parent); + public OrmManyToManyMapping buildOrmManyToManyMapping(OrmPersistentAttribute parent, XmlManyToMany resourceMapping) { + return new GenericOrmManyToManyMapping(parent, resourceMapping); } - public OrmManyToOneMapping buildOrmManyToOneMapping(OrmPersistentAttribute parent) { - return new GenericOrmManyToOneMapping(parent); + public OrmManyToOneMapping buildOrmManyToOneMapping(OrmPersistentAttribute parent, XmlManyToOne resourceMapping) { + return new GenericOrmManyToOneMapping(parent, resourceMapping); } - public OrmOneToManyMapping buildOrmOneToManyMapping(OrmPersistentAttribute parent) { - return new GenericOrmOneToManyMapping(parent); + public OrmOneToManyMapping buildOrmOneToManyMapping(OrmPersistentAttribute parent, XmlOneToMany resourceMapping) { + return new GenericOrmOneToManyMapping(parent, resourceMapping); } - public OrmOneToOneMapping buildOrmOneToOneMapping(OrmPersistentAttribute parent) { - return new GenericOrmOneToOneMapping(parent); + public OrmOneToOneMapping buildOrmOneToOneMapping(OrmPersistentAttribute parent, XmlOneToOne resourceMapping) { + return new GenericOrmOneToOneMapping(parent, resourceMapping); } - public OrmTransientMapping buildOrmTransientMapping(OrmPersistentAttribute parent) { - return new GenericOrmTransientMapping(parent); + public OrmTransientMapping buildOrmTransientMapping(OrmPersistentAttribute parent, XmlTransient resourceMapping) { + return new GenericOrmTransientMapping(parent, resourceMapping); } - public OrmVersionMapping buildOrmVersionMapping(OrmPersistentAttribute parent) { - return new GenericOrmVersionMapping(parent); + public OrmVersionMapping buildOrmVersionMapping(OrmPersistentAttribute parent, XmlVersion resourceMapping) { + return new GenericOrmVersionMapping(parent, resourceMapping); } - public OrmAttributeMapping buildOrmNullAttributeMapping(OrmPersistentAttribute parent) { - return new GenericOrmNullAttributeMapping(parent); + public OrmAttributeMapping buildOrmNullAttributeMapping(OrmPersistentAttribute parent, XmlNullAttributeMapping resourceMapping) { + return new GenericOrmNullAttributeMapping(parent, resourceMapping); } public OrmUniqueConstraint buildOrmUniqueConstraint(XmlContextNode parent, UniqueConstraint.Owner owner, XmlUniqueConstraint resourceUniqueConstraint) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaPlatform.java index 50cb0e84b2..c307a7472b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaPlatform.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/GenericJpaPlatform.java @@ -43,6 +43,7 @@ import org.eclipse.jpt.core.internal.context.orm.OrmNullAttributeMappingProvider import org.eclipse.jpt.core.internal.utility.PlatformTools; import org.eclipse.jpt.core.internal.utility.jdt.DefaultAnnotationEditFormatter; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.core.resource.xml.JpaXmlResource; import org.eclipse.jpt.core.utility.jdt.AnnotationEditFormatter; import org.eclipse.jpt.db.ConnectionProfileFactory; @@ -298,8 +299,12 @@ public class GenericJpaPlatform // ********** ORM type mappings ********** - public OrmTypeMapping buildOrmTypeMappingFromMappingKey(String key, OrmPersistentType type) { - return this.getOrmTypeMappingProviderForMappingKey(type.getContentType(), key).buildMapping(type, this.jpaFactory); + public XmlTypeMapping buildOrmResourceTypeMapping(String key, IContentType contentType) { + return this.getOrmTypeMappingProviderForMappingKey(contentType, key).buildResourceMapping(); + } + + public OrmTypeMapping buildOrmTypeMappingFromMappingKey(OrmPersistentType type, XmlTypeMapping resourceMapping) { + return this.getOrmTypeMappingProviderForMappingKey(type.getContentType(), resourceMapping.getMappingKey()).buildMapping(type, resourceMapping, this.jpaFactory); } protected OrmTypeMappingProvider getOrmTypeMappingProviderForMappingKey(IContentType contentType, String key) { @@ -336,9 +341,13 @@ public class GenericJpaPlatform // ********** ORM attribute mappings ********** - - public OrmAttributeMapping buildOrmAttributeMappingFromMappingKey(String key, OrmPersistentAttribute attribute) { - return this.getOrmAttributeMappingProviderForMappingKey(attribute.getContentType(), key).buildMapping(attribute, this.jpaFactory); + + public XmlAttributeMapping buildOrmResourceAttributeMapping(String key, IContentType contentType) { + return this.getOrmAttributeMappingProviderForMappingKey(contentType, key).buildResourceMapping(); + } + + public OrmAttributeMapping buildOrmAttributeMappingFromMappingKey(OrmPersistentAttribute attribute, XmlAttributeMapping resourceMapping) { + return this.getOrmAttributeMappingProviderForMappingKey(attribute.getContentType(), resourceMapping.getMappingKey()).buildMapping(attribute, resourceMapping, this.jpaFactory); } public XmlAttributeMapping buildVirtualOrmResourceMappingFromMappingKey(String key, OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaFactory.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaFactory.java index 00aa9c5930..ed158dc188 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaFactory.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaFactory.java @@ -45,14 +45,7 @@ import org.eclipse.jpt.core.context.persistence.MappingFileRef; import org.eclipse.jpt.core.context.persistence.Persistence; import org.eclipse.jpt.core.context.persistence.PersistenceUnit; import org.eclipse.jpt.core.internal.platform.GenericJpaFactory; -import org.eclipse.jpt.core.resource.orm.XmlBasic; -import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; -import org.eclipse.jpt.core.resource.orm.XmlId; -import org.eclipse.jpt.core.resource.orm.XmlManyToMany; -import org.eclipse.jpt.core.resource.orm.XmlManyToOne; -import org.eclipse.jpt.core.resource.orm.XmlOneToMany; -import org.eclipse.jpt.core.resource.orm.XmlOneToOne; -import org.eclipse.jpt.core.resource.orm.XmlVersion; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit; import org.eclipse.jpt.core.resource.xml.JpaXmlResource; import org.eclipse.jpt.eclipselink.core.EclipseLinkJpaProject; @@ -76,8 +69,6 @@ import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkEntityMa import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkEntityMappingsImpl; import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkOrmBasicMapping; import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkOrmEmbeddableImpl; -import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkOrmEmbeddedIdMapping; -import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkOrmEmbeddedMapping; import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkOrmEntityImpl; import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkOrmIdMapping; import org.eclipse.jpt.eclipselink.core.internal.context.orm.EclipseLinkOrmManyToManyMapping; @@ -106,12 +97,23 @@ import org.eclipse.jpt.eclipselink.core.internal.context.orm.VirtualXmlBasicMap; import org.eclipse.jpt.eclipselink.core.internal.context.orm.VirtualXmlTransformation; import org.eclipse.jpt.eclipselink.core.internal.context.orm.VirtualXmlVariableOneToOne; import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlBasic; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlBasicCollection; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlBasicMap; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbeddable; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbedded; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbeddedId; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEntity; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEntityMappings; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlId; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlManyToMany; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlManyToOne; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlMappedSuperclass; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToMany; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToOne; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlTransformation; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlVariableOneToOne; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlVersion; public class EclipseLinkJpaFactory extends GenericJpaFactory @@ -205,77 +207,75 @@ public class EclipseLinkJpaFactory // ********** EclipseLink-specific ORM Context Model ********** public EntityMappings buildEclipseLinkEntityMappings(OrmXml parent, XmlEntityMappings xmlEntityMappings) { - EntityMappings entityMappings = new EclipseLinkEntityMappingsImpl(parent); - entityMappings.initialize(xmlEntityMappings); - return entityMappings; + return new EclipseLinkEntityMappingsImpl(parent, xmlEntityMappings); } - public OrmPersistentType buildEclipseLinkOrmPersistentType(EclipseLinkEntityMappings parent, String mappingKey) { - return new EclipseLinkOrmPersistentType(parent, mappingKey); + public OrmPersistentType buildEclipseLinkOrmPersistentType(EclipseLinkEntityMappings parent , XmlTypeMapping resourceMapping) { + return new EclipseLinkOrmPersistentType(parent, resourceMapping); } - public OrmEmbeddable buildEclipseLinkOrmEmbeddable(OrmPersistentType type) { - return new EclipseLinkOrmEmbeddableImpl(type); + public OrmEmbeddable buildEclipseLinkOrmEmbeddable(OrmPersistentType type, XmlEmbeddable resourceMapping) { + return new EclipseLinkOrmEmbeddableImpl(type, resourceMapping); } - public OrmEntity buildEclipseLinkOrmEntity(OrmPersistentType type) { - return new EclipseLinkOrmEntityImpl(type); + public OrmEntity buildEclipseLinkOrmEntity(OrmPersistentType type, XmlEntity resourceMapping) { + return new EclipseLinkOrmEntityImpl(type, resourceMapping); } - public OrmMappedSuperclass buildEclipseLinkOrmMappedSuperclass(OrmPersistentType type) { - return new EclipseLinkOrmMappedSuperclassImpl(type); + public OrmMappedSuperclass buildEclipseLinkOrmMappedSuperclass(OrmPersistentType type, XmlMappedSuperclass resourceMapping) { + return new EclipseLinkOrmMappedSuperclassImpl(type, resourceMapping); } - public OrmBasicMapping buildEclipseLinkOrmBasicMapping(OrmPersistentAttribute parent) { - return new EclipseLinkOrmBasicMapping(parent); + public OrmBasicMapping buildEclipseLinkOrmBasicMapping(OrmPersistentAttribute parent, XmlBasic resourceMapping) { + return new EclipseLinkOrmBasicMapping(parent, resourceMapping); } - public OrmIdMapping buildEclipseLinkOrmIdMapping(OrmPersistentAttribute parent) { - return new EclipseLinkOrmIdMapping(parent); + public OrmIdMapping buildEclipseLinkOrmIdMapping(OrmPersistentAttribute parent, XmlId resourceMapping) { + return new EclipseLinkOrmIdMapping(parent, resourceMapping); } - public OrmEmbeddedIdMapping buildEclipseLinkOrmEmbeddedIdMapping(OrmPersistentAttribute parent) { - return new EclipseLinkOrmEmbeddedIdMapping(parent); + public OrmEmbeddedIdMapping buildEclipseLinkOrmEmbeddedIdMapping(OrmPersistentAttribute parent, XmlEmbeddedId resourceMapping) { + return buildOrmEmbeddedIdMapping(parent, resourceMapping); } - public OrmEmbeddedMapping buildEclipseLinkOrmEmbeddedMapping(OrmPersistentAttribute parent) { - return new EclipseLinkOrmEmbeddedMapping(parent); + public OrmEmbeddedMapping buildEclipseLinkOrmEmbeddedMapping(OrmPersistentAttribute parent, XmlEmbedded resourceMapping) { + return buildOrmEmbeddedMapping(parent, resourceMapping); } - public OrmManyToManyMapping buildEclipseLinkOrmManyToManyMapping(OrmPersistentAttribute parent) { - return new EclipseLinkOrmManyToManyMapping(parent); + public OrmManyToManyMapping buildEclipseLinkOrmManyToManyMapping(OrmPersistentAttribute parent, XmlManyToMany resourceMapping) { + return new EclipseLinkOrmManyToManyMapping(parent, resourceMapping); } - public OrmManyToOneMapping buildEclipseLinkOrmManyToOneMapping(OrmPersistentAttribute parent) { - return new EclipseLinkOrmManyToOneMapping(parent); + public OrmManyToOneMapping buildEclipseLinkOrmManyToOneMapping(OrmPersistentAttribute parent, XmlManyToOne resourceMapping) { + return new EclipseLinkOrmManyToOneMapping(parent, resourceMapping); } - public OrmOneToManyMapping buildEclipseLinkOrmOneToManyMapping(OrmPersistentAttribute parent) { - return new EclipseLinkOrmOneToManyMapping(parent); + public OrmOneToManyMapping buildEclipseLinkOrmOneToManyMapping(OrmPersistentAttribute parent, XmlOneToMany resourceMapping) { + return new EclipseLinkOrmOneToManyMapping(parent, resourceMapping); } - public OrmOneToOneMapping buildEclipseLinkOrmOneToOneMapping(OrmPersistentAttribute parent) { - return new EclipseLinkOrmOneToOneMapping(parent); + public OrmOneToOneMapping buildEclipseLinkOrmOneToOneMapping(OrmPersistentAttribute parent, XmlOneToOne resourceMapping) { + return new EclipseLinkOrmOneToOneMapping(parent, resourceMapping); } - public OrmVersionMapping buildEclipseLinkOrmVersionMapping(OrmPersistentAttribute parent) { - return new EclipseLinkOrmVersionMapping(parent); + public OrmVersionMapping buildEclipseLinkOrmVersionMapping(OrmPersistentAttribute parent, XmlVersion resourceMapping) { + return new EclipseLinkOrmVersionMapping(parent, resourceMapping); } - public OrmBasicCollectionMapping buildOrmBasicCollectionMapping(OrmPersistentAttribute parent) { - return new OrmBasicCollectionMapping(parent); + public OrmBasicCollectionMapping buildOrmBasicCollectionMapping(OrmPersistentAttribute parent, XmlBasicCollection resourceMapping) { + return new OrmBasicCollectionMapping(parent, resourceMapping); } - public OrmBasicMapMapping buildOrmBasicMapMapping(OrmPersistentAttribute parent) { - return new OrmBasicMapMapping(parent); + public OrmBasicMapMapping buildOrmBasicMapMapping(OrmPersistentAttribute parent, XmlBasicMap resourceMapping) { + return new OrmBasicMapMapping(parent, resourceMapping); } - public OrmTransformationMapping buildOrmTransformationMapping(OrmPersistentAttribute parent) { - return new OrmTransformationMapping(parent); + public OrmTransformationMapping buildOrmTransformationMapping(OrmPersistentAttribute parent, XmlTransformation resourceMapping) { + return new OrmTransformationMapping(parent, resourceMapping); } - public OrmVariableOneToOneMapping buildOrmVariableOneToOneMapping(OrmPersistentAttribute parent) { - return new OrmVariableOneToOneMapping(parent); + public OrmVariableOneToOneMapping buildOrmVariableOneToOneMapping(OrmPersistentAttribute parent, XmlVariableOneToOne resourceMapping) { + return new OrmVariableOneToOneMapping(parent, resourceMapping); } // ********** Java Context Model ********** diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLink1_1OrmXml.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLink1_1OrmXml.java index fecc9e2da8..013c21a36f 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLink1_1OrmXml.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLink1_1OrmXml.java @@ -39,7 +39,7 @@ public class EclipseLink1_1OrmXml extends AbstractOrmXml @Override protected EntityMappings buildEntityMappings(XmlEntityMappings xmlEntityMappings) { - return getJpaFactory().buildEclipseLinkEntityMappings(this, xmlEntityMappings); + return getJpaFactory().buildEclipseLinkEntityMappings(this, (org.eclipse.jpt.eclipselink.core.resource.orm.XmlEntityMappings) xmlEntityMappings); } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkEntityMappingsImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkEntityMappingsImpl.java index 1f6075ceb7..58691d26aa 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkEntityMappingsImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkEntityMappingsImpl.java @@ -13,6 +13,7 @@ import java.util.List; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.context.orm.OrmXml; import org.eclipse.jpt.core.internal.context.orm.AbstractEntityMappings; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEntityMappings; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -24,14 +25,14 @@ public class EclipseLinkEntityMappingsImpl protected final EclipseLinkOrmConverterHolder converterHolder; - public EclipseLinkEntityMappingsImpl(OrmXml parent) { - super(parent); - this.converterHolder = new EclipseLinkOrmConverterHolder(this); + public EclipseLinkEntityMappingsImpl(OrmXml parent, XmlEntityMappings resource) { + super(parent, resource); + this.converterHolder = new EclipseLinkOrmConverterHolder(this, (XmlEntityMappings) this.xmlEntityMappings); } @Override - protected OrmPersistentType buildPersistentType(String mappingKey) { - return getJpaFactory().buildEclipseLinkOrmPersistentType(this, mappingKey); + protected OrmPersistentType buildPersistentType(XmlTypeMapping resourceMapping) { + return getJpaFactory().buildEclipseLinkOrmPersistentType(this, resourceMapping); } // **************** JpaNode impl ******************************************* @@ -47,11 +48,6 @@ public class EclipseLinkEntityMappingsImpl return this.converterHolder; } - @Override - protected void initialize() { - super.initialize(); - this.converterHolder.initialize((XmlEntityMappings) this.xmlEntityMappings); - } @Override public void update() { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmBasicMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmBasicMapping.java index acf14f9485..f160cae07c 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmBasicMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmBasicMapping.java @@ -14,11 +14,9 @@ import java.util.List; import org.eclipse.jpt.core.context.orm.OrmConverter; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.GenericOrmBasicMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.context.Convert; import org.eclipse.jpt.eclipselink.core.context.EclipseLinkBasicMapping; import org.eclipse.jpt.eclipselink.core.context.Mutable; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlBasic; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlMutable; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -29,9 +27,9 @@ public class EclipseLinkOrmBasicMapping extends GenericOrmBasicMapping protected EclipseLinkOrmMutable mutable; - public EclipseLinkOrmBasicMapping(OrmPersistentAttribute parent) { - super(parent); - this.mutable = new EclipseLinkOrmMutable(this); + public EclipseLinkOrmBasicMapping(OrmPersistentAttribute parent, XmlBasic resourceMapping) { + super(parent, resourceMapping); + this.mutable = new EclipseLinkOrmMutable(this, (XmlMutable) this.resourceAttributeMapping); } @@ -64,20 +62,6 @@ public class EclipseLinkOrmBasicMapping extends GenericOrmBasicMapping // **************** resource-context interaction *************************** @Override - public XmlBasic addToResourceModel(XmlTypeMapping typeMapping) { - XmlBasic basic = EclipseLinkOrmFactory.eINSTANCE.createXmlBasicImpl(); - getPersistentAttribute().initialize(basic); - typeMapping.getAttributes().getBasics().add(basic); - return basic; - } - - @Override - protected void initialize() { - super.initialize(); - this.mutable.initialize((XmlMutable) this.resourceAttributeMapping); - } - - @Override public void update() { super.update(); this.mutable.update(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmBasicMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmBasicMappingProvider.java index 6cae3221f3..7626a17192 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmBasicMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmBasicMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlBasic; public class EclipseLinkOrmBasicMappingProvider implements OrmAttributeMappingProvider @@ -49,9 +51,13 @@ public class EclipseLinkOrmBasicMappingProvider public String getKey() { return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY; } - - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmBasicMapping(parent); + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlBasicImpl(); + } + + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmBasicMapping(parent, (XmlBasic) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmCaching.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmCaching.java index cd1002684e..1c832cb362 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmCaching.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmCaching.java @@ -26,7 +26,7 @@ import org.eclipse.jpt.eclipselink.core.resource.orm.XmlTimeOfDay; public class EclipseLinkOrmCaching extends AbstractXmlContextNode implements OrmCaching { - protected XmlCacheHolder resource; + protected final XmlCacheHolder resource; protected int defaultSize; protected Integer specifiedSize; @@ -55,8 +55,27 @@ public class EclipseLinkOrmCaching extends AbstractXmlContextNode protected Integer expiry; protected EclipseLinkOrmExpiryTimeOfDay expiryTimeOfDay; - public EclipseLinkOrmCaching(OrmTypeMapping parent) { + public EclipseLinkOrmCaching(OrmTypeMapping parent, XmlCacheHolder resource, JavaCaching javaCaching) { super(parent); + this.resource = resource; + XmlCache resourceCache = getResourceCache(); + this.defaultSize = this.defaultSize(javaCaching); + this.specifiedSize = getResourceSize(resourceCache); + this.defaultShared = this.defaultShared(javaCaching); + this.specifiedShared = this.getResourceShared(resourceCache); + this.defaultAlwaysRefresh = this.defaultAlwaysRefresh(javaCaching); + this.specifiedAlwaysRefresh = this.getResourceAlwaysRefresh(resourceCache); + this.defaultRefreshOnlyIfNewer = this.defaultRefreshOnlyIfNewer(javaCaching); + this.specifiedRefreshOnlyIfNewer = this.getResourceRefreshOnlyIfNewer(resourceCache); + this.defaultDisableHits = this.defaultDisableHits(javaCaching); + this.specifiedDisableHits = this.getResourceDisableHits(resourceCache); + this.defaultType = this.defaultType(javaCaching); + this.specifiedType = this.getResourceType(resourceCache); + this.defaultCoordinationType = this.defaultCoordinationType(javaCaching); + this.specifiedCoordinationType = this.getResourceCoordinationType(resourceCache); + this.defaultExistenceType = this.defaultExistenceType(javaCaching); + this.specifiedExistenceType = this.getResourceExistenceChecking(); + this.initializeExpiry(resourceCache); } public int getSize() { @@ -486,28 +505,6 @@ public class EclipseLinkOrmCaching extends AbstractXmlContextNode // **************** initialize/update ************************************** - - protected void initialize(XmlCacheHolder resource, JavaCaching javaCaching) { - this.resource = resource; - XmlCache resourceCache = getResourceCache(); - this.defaultSize = this.defaultSize(javaCaching); - this.specifiedSize = getResourceSize(resourceCache); - this.defaultShared = this.defaultShared(javaCaching); - this.specifiedShared = this.getResourceShared(resourceCache); - this.defaultAlwaysRefresh = this.defaultAlwaysRefresh(javaCaching); - this.specifiedAlwaysRefresh = this.getResourceAlwaysRefresh(resourceCache); - this.defaultRefreshOnlyIfNewer = this.defaultRefreshOnlyIfNewer(javaCaching); - this.specifiedRefreshOnlyIfNewer = this.getResourceRefreshOnlyIfNewer(resourceCache); - this.defaultDisableHits = this.defaultDisableHits(javaCaching); - this.specifiedDisableHits = this.getResourceDisableHits(resourceCache); - this.defaultType = this.defaultType(javaCaching); - this.specifiedType = this.getResourceType(resourceCache); - this.defaultCoordinationType = this.defaultCoordinationType(javaCaching); - this.specifiedCoordinationType = this.getResourceCoordinationType(resourceCache); - this.defaultExistenceType = this.defaultExistenceType(javaCaching); - this.specifiedExistenceType = this.getResourceExistenceChecking(); - this.initializeExpiry(resourceCache); - } protected void initializeExpiry(XmlCache resourceCache) { if (resourceCache == null) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmChangeTracking.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmChangeTracking.java index 3dd671cfa0..42c7470dab 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmChangeTracking.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmChangeTracking.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. + * Copyright (c) 2008, 2009 Oracle. * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -22,15 +22,18 @@ import org.eclipse.jpt.eclipselink.core.resource.orm.XmlChangeTrackingHolder; public class EclipseLinkOrmChangeTracking extends AbstractXmlContextNode implements ChangeTracking { - protected XmlChangeTrackingHolder resource; + protected final XmlChangeTrackingHolder resource; protected ChangeTrackingType defaultType; protected ChangeTrackingType specifiedType; - public EclipseLinkOrmChangeTracking(OrmTypeMapping parent) { + public EclipseLinkOrmChangeTracking(OrmTypeMapping parent, XmlChangeTrackingHolder resource, ChangeTracking javaChangeTracking) { super(parent); + this.resource = resource; + this.defaultType = calculateDefaultType(javaChangeTracking); + this.specifiedType = getResourceChangeTracking(); } @@ -76,13 +79,7 @@ public class EclipseLinkOrmChangeTracking extends AbstractXmlContextNode } - // **************** initialize/update ************************************** - - protected void initialize(XmlChangeTrackingHolder xmlChangeTrackingHolder, ChangeTracking javaChangeTracking) { - this.resource = xmlChangeTrackingHolder; - this.defaultType = calculateDefaultType(javaChangeTracking); - this.specifiedType = getResourceChangeTracking(); - } + // **************** updating ************************************** protected void update(ChangeTracking javaChangeTracking) { setDefaultType_(calculateDefaultType(javaChangeTracking)); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmConverterHolder.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmConverterHolder.java index 76b541c3c1..e2561a6efa 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmConverterHolder.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmConverterHolder.java @@ -31,19 +31,24 @@ import org.eclipse.wst.validation.internal.provisional.core.IMessage; public class EclipseLinkOrmConverterHolder extends AbstractXmlContextNode implements ConverterHolder { - private XmlConvertersHolder resourceConvertersHolder; + private final XmlConvertersHolder resourceConvertersHolder; protected final List<EclipseLinkOrmCustomConverter> customConverters; protected final List<EclipseLinkOrmObjectTypeConverter> objectTypeConverters; protected final List<EclipseLinkOrmStructConverter> structConverters; protected final List<EclipseLinkOrmTypeConverter> typeConverters; - public EclipseLinkOrmConverterHolder(XmlContextNode parent) { + public EclipseLinkOrmConverterHolder(XmlContextNode parent, XmlConvertersHolder resourceConvertersHolder) { super(parent); + this.resourceConvertersHolder = resourceConvertersHolder; this.customConverters = new ArrayList<EclipseLinkOrmCustomConverter>(); this.objectTypeConverters = new ArrayList<EclipseLinkOrmObjectTypeConverter>(); this.structConverters = new ArrayList<EclipseLinkOrmStructConverter>(); this.typeConverters = new ArrayList<EclipseLinkOrmTypeConverter>(); + this.initializeCustomConverters(); + this.initializeObjectTypeConverters(); + this.initializeStructConverters(); + this.initializeTypeConverters(); } public ListIterator<EclipseLinkOrmCustomConverter> customConverters() { @@ -242,17 +247,7 @@ public class EclipseLinkOrmConverterHolder extends AbstractXmlContextNode implem protected void moveTypeConverter_(int index, EclipseLinkOrmTypeConverter converter) { moveItemInList(index, this.typeConverters.indexOf(converter), this.typeConverters, TYPE_CONVERTERS_LIST); } - - - - public void initialize(XmlConvertersHolder resourceConvertersHolder) { - this.resourceConvertersHolder = resourceConvertersHolder; - this.initializeCustomConverters(); - this.initializeObjectTypeConverters(); - this.initializeStructConverters(); - this.initializeTypeConverters(); - } - + protected void initializeCustomConverters() { for (XmlConverter resourceConverter : this.resourceConvertersHolder.getConverters()) { this.customConverters.add(this.buildCustomConverter(resourceConverter)); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmCustomizer.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmCustomizer.java index 5ebfc16ce2..02efc3c378 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmCustomizer.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmCustomizer.java @@ -20,14 +20,17 @@ import org.eclipse.jpt.eclipselink.core.resource.orm.XmlCustomizerHolder; public class EclipseLinkOrmCustomizer extends AbstractXmlContextNode implements Customizer { - protected XmlCustomizerHolder resource; + protected final XmlCustomizerHolder resource; protected String specifiedCustomizerClass; protected String defaultCustomizerClass; - public EclipseLinkOrmCustomizer(OrmTypeMapping parent) { + public EclipseLinkOrmCustomizer(OrmTypeMapping parent, XmlCustomizerHolder resource, Customizer javaCustomizer) { super(parent); + this.resource = resource; + this.defaultCustomizerClass = getJavaCustomizerClass(javaCustomizer); + this.specifiedCustomizerClass = getResourceCustomizerClass(); } public String getCustomizerClass() { @@ -84,13 +87,8 @@ public class EclipseLinkOrmCustomizer extends AbstractXmlContextNode this.resource.setCustomizer(null); } - // **************** initialize/update ************************************** - protected void initialize(XmlCustomizerHolder resource, Customizer javaCustomizer) { - this.resource = resource; - this.defaultCustomizerClass = getJavaCustomizerClass(javaCustomizer); - this.specifiedCustomizerClass = getResourceCustomizerClass(); - } + // **************** updating ************************************** protected void update(Customizer javaCustomizer) { setDefaultCustomizerClass(getJavaCustomizerClass(javaCustomizer)); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddableImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddableImpl.java index bb25acf8ab..fd7336c938 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddableImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddableImpl.java @@ -12,15 +12,13 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import java.util.List; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.internal.context.orm.GenericOrmEmbeddable; -import org.eclipse.jpt.core.resource.orm.XmlEmbeddable; -import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; import org.eclipse.jpt.eclipselink.core.context.ChangeTracking; import org.eclipse.jpt.eclipselink.core.context.Customizer; import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaEmbeddable; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlChangeTrackingHolder; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlConvertersHolder; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlCustomizerHolder; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbeddable; import org.eclipse.wst.validation.internal.provisional.core.IMessage; public class EclipseLinkOrmEmbeddableImpl extends GenericOrmEmbeddable @@ -32,11 +30,11 @@ public class EclipseLinkOrmEmbeddableImpl extends GenericOrmEmbeddable protected final EclipseLinkOrmConverterHolder converterHolder; - public EclipseLinkOrmEmbeddableImpl(OrmPersistentType parent) { - super(parent); - this.customizer = new EclipseLinkOrmCustomizer(this); - this.changeTracking = new EclipseLinkOrmChangeTracking(this); - this.converterHolder = new EclipseLinkOrmConverterHolder(this); + public EclipseLinkOrmEmbeddableImpl(OrmPersistentType parent, XmlEmbeddable resourceMapping) { + super(parent, resourceMapping); + this.customizer = new EclipseLinkOrmCustomizer(this, (XmlCustomizerHolder) this.resourceTypeMapping, getJavaCustomizer()); + this.changeTracking = new EclipseLinkOrmChangeTracking(this, (XmlChangeTrackingHolder) this.resourceTypeMapping, getJavaChangeTracking()); + this.converterHolder = new EclipseLinkOrmConverterHolder(this, (XmlConvertersHolder) this.resourceTypeMapping); } public Customizer getCustomizer() { @@ -54,23 +52,7 @@ public class EclipseLinkOrmEmbeddableImpl extends GenericOrmEmbeddable // **************** resource-context interaction *************************** - - @Override - public XmlEmbeddable addToResourceModel(XmlEntityMappings entityMappings) { - XmlEmbeddable embeddable = EclipseLinkOrmFactory.eINSTANCE.createXmlEmbeddable(); - getPersistentType().initialize(embeddable); - entityMappings.getEmbeddables().add(embeddable); - return embeddable; - } - - @Override - public void initialize() { - super.initialize(); - this.customizer.initialize((XmlCustomizerHolder) this.resourceTypeMapping, getJavaCustomizer()); - this.changeTracking.initialize((XmlChangeTrackingHolder) this.resourceTypeMapping, getJavaChangeTracking()); - this.converterHolder.initialize((XmlConvertersHolder) this.resourceTypeMapping); - } - + @Override public void update() { super.update(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddableProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddableProvider.java index 46245cfeca..52b570bc82 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddableProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddableProvider.java @@ -15,8 +15,11 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.context.orm.OrmTypeMappingProvider; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbeddable; /** * EclipseLink ORM Embeddable provider @@ -46,9 +49,13 @@ public class EclipseLinkOrmEmbeddableProvider public IContentType getContentType() { return JptEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE; } + + public XmlTypeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlEmbeddable(); + } - public OrmTypeMapping buildMapping(OrmPersistentType parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmEmbeddable(parent); + public OrmTypeMapping buildMapping(OrmPersistentType parent, XmlTypeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmEmbeddable(parent, (XmlEmbeddable) resourceMapping); } public String getKey() { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedIdMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedIdMapping.java deleted file mode 100644 index 66f756a830..0000000000 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedIdMapping.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.eclipselink.core.internal.context.orm; - -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.internal.context.orm.GenericOrmEmbeddedIdMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; -import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbeddedId; - -public class EclipseLinkOrmEmbeddedIdMapping extends GenericOrmEmbeddedIdMapping -{ - - public EclipseLinkOrmEmbeddedIdMapping(OrmPersistentAttribute parent) { - super(parent); - } - - // **************** resource-context interaction *************************** - - @Override - public XmlEmbeddedId addToResourceModel(XmlTypeMapping typeMapping) { - XmlEmbeddedId embeddedId = EclipseLinkOrmFactory.eINSTANCE.createXmlEmbeddedIdImpl(); - getPersistentAttribute().initialize(embeddedId); - typeMapping.getAttributes().getEmbeddedIds().add(embeddedId); - return embeddedId; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedIdMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedIdMappingProvider.java index 405daa649e..c94f416900 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedIdMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedIdMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbeddedId; public class EclipseLinkOrmEmbeddedIdMappingProvider implements OrmAttributeMappingProvider @@ -49,9 +51,13 @@ public class EclipseLinkOrmEmbeddedIdMappingProvider public String getKey() { return MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlEmbeddedIdImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmEmbeddedIdMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmEmbeddedIdMapping(parent, (XmlEmbeddedId) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedMapping.java deleted file mode 100644 index fc53c9e34b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedMapping.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ -package org.eclipse.jpt.eclipselink.core.internal.context.orm; - -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.internal.context.orm.GenericOrmEmbeddedMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; -import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbedded; - -public class EclipseLinkOrmEmbeddedMapping extends GenericOrmEmbeddedMapping -{ - - public EclipseLinkOrmEmbeddedMapping(OrmPersistentAttribute parent) { - super(parent); - } - - // **************** resource-context interaction *************************** - - @Override - public XmlEmbedded addToResourceModel(XmlTypeMapping typeMapping) { - XmlEmbedded embedded = EclipseLinkOrmFactory.eINSTANCE.createXmlEmbeddedImpl(); - getPersistentAttribute().initialize(embedded); - typeMapping.getAttributes().getEmbeddeds().add(embedded); - return embedded; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedMappingProvider.java index 525c06774c..78a0a5689d 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEmbeddedMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEmbedded; public class EclipseLinkOrmEmbeddedMappingProvider implements OrmAttributeMappingProvider @@ -49,9 +51,13 @@ public class EclipseLinkOrmEmbeddedMappingProvider public String getKey() { return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlBasicImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmEmbeddedMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmEmbeddedMapping(parent, (XmlEmbedded) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEntityImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEntityImpl.java index 0567b1e511..8b9731d39c 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEntityImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEntityImpl.java @@ -12,19 +12,17 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import java.util.List; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.internal.context.orm.GenericOrmEntity; -import org.eclipse.jpt.core.resource.orm.XmlEntity; -import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; import org.eclipse.jpt.eclipselink.core.context.Caching; import org.eclipse.jpt.eclipselink.core.context.ChangeTracking; import org.eclipse.jpt.eclipselink.core.context.Customizer; import org.eclipse.jpt.eclipselink.core.context.ReadOnly; import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaEntity; import org.eclipse.jpt.eclipselink.core.context.java.JavaCaching; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlCacheHolder; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlChangeTrackingHolder; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlConvertersHolder; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlCustomizerHolder; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEntity; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlReadOnly; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -42,13 +40,13 @@ public class EclipseLinkOrmEntityImpl extends GenericOrmEntity protected final EclipseLinkOrmConverterHolder converterHolder; - public EclipseLinkOrmEntityImpl(OrmPersistentType parent) { - super(parent); - this.readOnly = new EclipseLinkOrmReadOnly(this); - this.customizer = new EclipseLinkOrmCustomizer(this); - this.changeTracking = new EclipseLinkOrmChangeTracking(this); - this.caching = new EclipseLinkOrmCaching(this); - this.converterHolder = new EclipseLinkOrmConverterHolder(this); + public EclipseLinkOrmEntityImpl(OrmPersistentType parent, XmlEntity resourceMapping) { + super(parent, resourceMapping); + this.readOnly = new EclipseLinkOrmReadOnly(this, (XmlReadOnly) this.resourceTypeMapping, getJavaReadOnly()); + this.customizer = new EclipseLinkOrmCustomizer(this, (XmlCustomizerHolder) this.resourceTypeMapping, getJavaCustomizer()); + this.changeTracking = new EclipseLinkOrmChangeTracking(this, (XmlChangeTrackingHolder) this.resourceTypeMapping, getJavaChangeTracking()); + this.caching = new EclipseLinkOrmCaching(this, (XmlCacheHolder) this.resourceTypeMapping, getJavaCaching()); + this.converterHolder = new EclipseLinkOrmConverterHolder(this, (XmlConvertersHolder) this.resourceTypeMapping); } public Caching getCaching() { @@ -74,24 +72,6 @@ public class EclipseLinkOrmEntityImpl extends GenericOrmEntity // **************** resource-context interaction *************************** @Override - public XmlEntity addToResourceModel(XmlEntityMappings entityMappings) { - XmlEntity entity = EclipseLinkOrmFactory.eINSTANCE.createXmlEntity(); - getPersistentType().initialize(entity); - entityMappings.getEntities().add(entity); - return entity; - } - - @Override - public void initialize() { - super.initialize(); - this.readOnly.initialize((XmlReadOnly) this.resourceTypeMapping, getJavaReadOnly()); - this.customizer.initialize((XmlCustomizerHolder) this.resourceTypeMapping, getJavaCustomizer()); - this.changeTracking.initialize((XmlChangeTrackingHolder) this.resourceTypeMapping, getJavaChangeTracking()); - this.caching.initialize((XmlCacheHolder) this.resourceTypeMapping, getJavaCaching()); - this.converterHolder.initialize((XmlConvertersHolder) this.resourceTypeMapping); - } - - @Override public void update() { super.update(); this.readOnly.update(getJavaReadOnly()); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEntityProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEntityProvider.java index 8e6dd5dd25..f9e94839c9 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEntityProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmEntityProvider.java @@ -15,8 +15,11 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.context.orm.OrmTypeMappingProvider; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEntity; /** * EclipseLink ORM Entity provider @@ -45,9 +48,13 @@ public class EclipseLinkOrmEntityProvider public IContentType getContentType() { return JptEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE; } + + public XmlTypeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlEntity(); + } - public OrmTypeMapping buildMapping(OrmPersistentType parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmEntity(parent); + public OrmTypeMapping buildMapping(OrmPersistentType parent, XmlTypeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmEntity(parent, (XmlEntity) resourceMapping); } public String getKey() { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmIdMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmIdMapping.java index 9c7965e534..99f72e5596 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmIdMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmIdMapping.java @@ -14,11 +14,9 @@ import java.util.List; import org.eclipse.jpt.core.context.orm.OrmConverter; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.GenericOrmIdMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.context.Convert; import org.eclipse.jpt.eclipselink.core.context.EclipseLinkIdMapping; import org.eclipse.jpt.eclipselink.core.context.Mutable; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlId; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlMutable; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -29,9 +27,9 @@ public class EclipseLinkOrmIdMapping extends GenericOrmIdMapping protected EclipseLinkOrmMutable mutable; - public EclipseLinkOrmIdMapping(OrmPersistentAttribute parent) { - super(parent); - this.mutable = new EclipseLinkOrmMutable(this); + public EclipseLinkOrmIdMapping(OrmPersistentAttribute parent, XmlId resourceMapping) { + super(parent, resourceMapping); + this.mutable = new EclipseLinkOrmMutable(this, (XmlMutable) this.resourceAttributeMapping); } @@ -63,20 +61,6 @@ public class EclipseLinkOrmIdMapping extends GenericOrmIdMapping // **************** resource-context interaction *************************** @Override - public XmlId addToResourceModel(XmlTypeMapping typeMapping) { - XmlId id = EclipseLinkOrmFactory.eINSTANCE.createXmlIdImpl(); - getPersistentAttribute().initialize(id); - typeMapping.getAttributes().getIds().add(id); - return id; - } - - @Override - protected void initialize() { - super.initialize(); - this.mutable.initialize((XmlMutable) this.resourceAttributeMapping); - } - - @Override public void update() { super.update(); this.mutable.update(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmIdMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmIdMappingProvider.java index e4aee72001..964cc6fbc3 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmIdMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmIdMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlId; public class EclipseLinkOrmIdMappingProvider implements OrmAttributeMappingProvider @@ -49,9 +51,13 @@ public class EclipseLinkOrmIdMappingProvider public String getKey() { return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlIdImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmIdMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmIdMapping(parent, (XmlId) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmJoinFetch.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmJoinFetch.java index eea0d25bb4..1ee0b4405c 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmJoinFetch.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmJoinFetch.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. + * Copyright (c) 2008, 2009 Oracle. * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -25,8 +25,10 @@ public class EclipseLinkOrmJoinFetch extends AbstractXmlContextNode protected JoinFetchType joinFetchValue; - public EclipseLinkOrmJoinFetch(OrmAttributeMapping parent) { + public EclipseLinkOrmJoinFetch(OrmAttributeMapping parent, XmlJoinFetch resource) { super(parent); + this.resource = resource; + this.joinFetchValue = getResourceJoinFetch(); } @@ -50,11 +52,6 @@ public class EclipseLinkOrmJoinFetch extends AbstractXmlContextNode // **************** initialize/update ************************************** - protected void initialize(XmlJoinFetch xmlJoinFetch) { - this.resource = xmlJoinFetch; - this.joinFetchValue = getResourceJoinFetch(); - } - protected void update() { setValue_(getResourceJoinFetch()); } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMapping.java index c163b7129e..b9e2b95b74 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMapping.java @@ -13,10 +13,8 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import java.util.List; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.GenericOrmManyToManyMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.context.EclipseLinkRelationshipMapping; import org.eclipse.jpt.eclipselink.core.context.JoinFetch; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlJoinFetch; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlManyToMany; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -28,9 +26,9 @@ public class EclipseLinkOrmManyToManyMapping protected EclipseLinkOrmJoinFetch joinFetch; - public EclipseLinkOrmManyToManyMapping(OrmPersistentAttribute parent) { - super(parent); - this.joinFetch = new EclipseLinkOrmJoinFetch(this); + public EclipseLinkOrmManyToManyMapping(OrmPersistentAttribute parent, XmlManyToMany resourceMapping) { + super(parent, resourceMapping); + this.joinFetch = new EclipseLinkOrmJoinFetch(this, (XmlJoinFetch) this.resourceAttributeMapping); } @@ -42,20 +40,6 @@ public class EclipseLinkOrmManyToManyMapping // **************** resource-context interaction *************************** @Override - public XmlManyToMany addToResourceModel(XmlTypeMapping typeMapping) { - XmlManyToMany manyToMany = EclipseLinkOrmFactory.eINSTANCE.createXmlManyToManyImpl(); - getPersistentAttribute().initialize(manyToMany); - typeMapping.getAttributes().getManyToManys().add(manyToMany); - return manyToMany; - } - - @Override - protected void initialize() { - super.initialize(); - this.joinFetch.initialize((XmlJoinFetch) this.resourceAttributeMapping); - } - - @Override public void update() { super.update(); this.joinFetch.update(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMappingProvider.java index 082783e50d..9fdc4bea01 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToManyMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlManyToMany; public class EclipseLinkOrmManyToManyMappingProvider implements OrmAttributeMappingProvider @@ -49,9 +51,13 @@ public class EclipseLinkOrmManyToManyMappingProvider public String getKey() { return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlManyToManyImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmManyToManyMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmManyToManyMapping(parent, (XmlManyToMany) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToOneMapping.java index b663577326..65bc890151 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToOneMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToOneMapping.java @@ -14,10 +14,8 @@ import java.util.List; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.GenericOrmManyToOneMapping; import org.eclipse.jpt.core.resource.orm.XmlManyToOne; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.context.EclipseLinkRelationshipMapping; import org.eclipse.jpt.eclipselink.core.context.JoinFetch; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlJoinFetch; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -27,9 +25,9 @@ public class EclipseLinkOrmManyToOneMapping extends GenericOrmManyToOneMapping protected EclipseLinkOrmJoinFetch joinFetch; - public EclipseLinkOrmManyToOneMapping(OrmPersistentAttribute parent) { - super(parent); - this.joinFetch = new EclipseLinkOrmJoinFetch(this); + public EclipseLinkOrmManyToOneMapping(OrmPersistentAttribute parent, XmlManyToOne resourceMapping) { + super(parent, resourceMapping); + this.joinFetch = new EclipseLinkOrmJoinFetch(this, (XmlJoinFetch) this.resourceAttributeMapping); } @@ -41,20 +39,6 @@ public class EclipseLinkOrmManyToOneMapping extends GenericOrmManyToOneMapping // **************** resource-context interaction *************************** @Override - public XmlManyToOne addToResourceModel(XmlTypeMapping typeMapping) { - XmlManyToOne manyToOne = EclipseLinkOrmFactory.eINSTANCE.createXmlManyToOneImpl(); - getPersistentAttribute().initialize(manyToOne); - typeMapping.getAttributes().getManyToOnes().add(manyToOne); - return manyToOne; - } - - @Override - protected void initialize() { - super.initialize(); - this.joinFetch.initialize((XmlJoinFetch) this.resourceAttributeMapping); - } - - @Override public void update() { super.update(); this.joinFetch.update(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToOneMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToOneMappingProvider.java index ac0e07bb44..ac27afaf9b 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToOneMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmManyToOneMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlManyToOne; public class EclipseLinkOrmManyToOneMappingProvider implements OrmAttributeMappingProvider @@ -49,9 +51,13 @@ public class EclipseLinkOrmManyToOneMappingProvider public String getKey() { return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlManyToOneImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmManyToOneMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmManyToOneMapping(parent, (XmlManyToOne) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMappedSuperclassImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMappedSuperclassImpl.java index 509515706b..6a5d44697c 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMappedSuperclassImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMappedSuperclassImpl.java @@ -12,7 +12,6 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import java.util.List; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.internal.context.orm.GenericOrmMappedSuperclass; -import org.eclipse.jpt.core.resource.orm.XmlEntityMappings; import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass; import org.eclipse.jpt.eclipselink.core.context.Caching; import org.eclipse.jpt.eclipselink.core.context.ChangeTracking; @@ -20,7 +19,6 @@ import org.eclipse.jpt.eclipselink.core.context.Customizer; import org.eclipse.jpt.eclipselink.core.context.ReadOnly; import org.eclipse.jpt.eclipselink.core.context.java.EclipseLinkJavaMappedSuperclass; import org.eclipse.jpt.eclipselink.core.context.java.JavaCaching; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlCacheHolder; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlChangeTrackingHolder; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlConvertersHolder; @@ -42,14 +40,14 @@ public class EclipseLinkOrmMappedSuperclassImpl extends GenericOrmMappedSupercla protected final EclipseLinkOrmConverterHolder converterHolder; - public EclipseLinkOrmMappedSuperclassImpl(OrmPersistentType parent) { - super(parent); - this.readOnly = new EclipseLinkOrmReadOnly(this); - this.customizer = new EclipseLinkOrmCustomizer(this); - this.changeTracking = new EclipseLinkOrmChangeTracking(this); - this.caching = new EclipseLinkOrmCaching(this); - this.converterHolder = new EclipseLinkOrmConverterHolder(this); -} + public EclipseLinkOrmMappedSuperclassImpl(OrmPersistentType parent, XmlMappedSuperclass resourceMapping) { + super(parent, resourceMapping); + this.readOnly = new EclipseLinkOrmReadOnly(this, (XmlReadOnly) this.resourceTypeMapping, getJavaReadOnly()); + this.customizer = new EclipseLinkOrmCustomizer(this, (XmlCustomizerHolder) this.resourceTypeMapping, getJavaCustomizer()); + this.changeTracking = new EclipseLinkOrmChangeTracking(this, (XmlChangeTrackingHolder) this.resourceTypeMapping, getJavaChangeTracking()); + this.caching = new EclipseLinkOrmCaching(this, (XmlCacheHolder) this.resourceTypeMapping, getJavaCaching()); + this.converterHolder = new EclipseLinkOrmConverterHolder(this, (XmlConvertersHolder) this.resourceTypeMapping); + } public Caching getCaching() { return this.caching; @@ -75,24 +73,6 @@ public class EclipseLinkOrmMappedSuperclassImpl extends GenericOrmMappedSupercla // **************** resource-context interaction *************************** @Override - public XmlMappedSuperclass addToResourceModel(XmlEntityMappings entityMappings) { - XmlMappedSuperclass mappedSuperclass = EclipseLinkOrmFactory.eINSTANCE.createXmlMappedSuperclass(); - getPersistentType().initialize(mappedSuperclass); - entityMappings.getMappedSuperclasses().add(mappedSuperclass); - return mappedSuperclass; - } - - @Override - public void initialize() { - super.initialize(); - this.readOnly.initialize((XmlReadOnly) this.resourceTypeMapping, getJavaReadOnly()); - this.customizer.initialize((XmlCustomizerHolder) this.resourceTypeMapping, getJavaCustomizer()); - this.changeTracking.initialize((XmlChangeTrackingHolder) this.resourceTypeMapping, getJavaChangeTracking()); - this.caching.initialize((XmlCacheHolder) this.resourceTypeMapping, getJavaCaching()); - this.converterHolder.initialize((XmlConvertersHolder) this.resourceTypeMapping); - } - - @Override public void update() { super.update(); this.readOnly.update(getJavaReadOnly()); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMappedSuperclassProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMappedSuperclassProvider.java index 3ccbab6a3a..9081ecdc3c 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMappedSuperclassProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMappedSuperclassProvider.java @@ -15,8 +15,11 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.orm.OrmPersistentType; import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.context.orm.OrmTypeMappingProvider; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlMappedSuperclass; /** * EclipseLink ORM Mapped Superclass provider @@ -45,9 +48,13 @@ public class EclipseLinkOrmMappedSuperclassProvider public IContentType getContentType() { return JptEclipseLinkCorePlugin.ECLIPSELINK_ORM_XML_CONTENT_TYPE; } + + public XmlTypeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlMappedSuperclass(); + } - public OrmTypeMapping buildMapping(OrmPersistentType parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmMappedSuperclass(parent); + public OrmTypeMapping buildMapping(OrmPersistentType parent, XmlTypeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmMappedSuperclass(parent, (XmlMappedSuperclass) resourceMapping); } public String getKey() { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMutable.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMutable.java index 5230a852f8..5efe612330 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMutable.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmMutable.java @@ -21,15 +21,18 @@ import org.eclipse.jpt.eclipselink.core.resource.orm.XmlMutable; public class EclipseLinkOrmMutable extends AbstractXmlContextNode implements Mutable { - protected XmlMutable resource; + protected final XmlMutable resource; protected boolean defaultMutable; protected Boolean specifiedMutable; - public EclipseLinkOrmMutable(OrmAttributeMapping parent) { + public EclipseLinkOrmMutable(OrmAttributeMapping parent, XmlMutable resource) { super(parent); + this.resource = resource; + this.defaultMutable = this.calculateDefaultMutable(); + this.specifiedMutable = this.getResourceMutable(); } @Override @@ -74,13 +77,7 @@ public class EclipseLinkOrmMutable extends AbstractXmlContextNode // **************** initialize/update ************************************** - - protected void initialize(XmlMutable resource) { - this.resource = resource; - this.defaultMutable = this.calculateDefaultMutable(); - this.specifiedMutable = this.getResourceMutable(); - } - + protected void update() { setDefaultMutable(this.calculateDefaultMutable()); setSpecifiedMutable_(this.getResourceMutable()); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToManyMapping.java index 503e861793..ff97d0cbf7 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToManyMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToManyMapping.java @@ -15,11 +15,9 @@ import org.eclipse.jpt.core.MappingKeys; import org.eclipse.jpt.core.context.AttributeMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.GenericOrmOneToManyMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.context.EclipseLinkOneToManyMapping; import org.eclipse.jpt.eclipselink.core.context.JoinFetch; import org.eclipse.jpt.eclipselink.core.context.PrivateOwned; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlJoinFetch; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToMany; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlPrivateOwned; @@ -33,10 +31,10 @@ public class EclipseLinkOrmOneToManyMapping extends GenericOrmOneToManyMapping protected EclipseLinkOrmJoinFetch joinFetch; - public EclipseLinkOrmOneToManyMapping(OrmPersistentAttribute parent) { - super(parent); - this.privateOwned = new EclipseLinkOrmPrivateOwned(this); - this.joinFetch = new EclipseLinkOrmJoinFetch(this); + public EclipseLinkOrmOneToManyMapping(OrmPersistentAttribute parent, XmlOneToMany resourceMapping) { + super(parent, resourceMapping); + this.privateOwned = new EclipseLinkOrmPrivateOwned(this, (XmlPrivateOwned) this.resourceAttributeMapping); + this.joinFetch = new EclipseLinkOrmJoinFetch(this, (XmlJoinFetch) this.resourceAttributeMapping); } // ********** NonOwningMapping implementation ********** @@ -58,21 +56,6 @@ public class EclipseLinkOrmOneToManyMapping extends GenericOrmOneToManyMapping // **************** resource-context interaction *************************** @Override - public XmlOneToMany addToResourceModel(XmlTypeMapping typeMapping) { - XmlOneToMany oneToMany = EclipseLinkOrmFactory.eINSTANCE.createXmlOneToManyImpl(); - getPersistentAttribute().initialize(oneToMany); - typeMapping.getAttributes().getOneToManys().add(oneToMany); - return oneToMany; - } - - @Override - protected void initialize() { - super.initialize(); - this.privateOwned.initialize((XmlPrivateOwned) this.resourceAttributeMapping); - this.joinFetch.initialize((XmlJoinFetch) this.resourceAttributeMapping); - } - - @Override public void update() { super.update(); this.privateOwned.update(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToManyMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToManyMappingProvider.java index acedc6a705..944b7d29bd 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToManyMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToManyMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToMany; public class EclipseLinkOrmOneToManyMappingProvider implements OrmAttributeMappingProvider @@ -49,9 +51,13 @@ public class EclipseLinkOrmOneToManyMappingProvider public String getKey() { return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlOneToManyImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmOneToManyMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmOneToManyMapping(parent, (XmlOneToMany) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToOneMapping.java index fddc228f78..ee64b8d96d 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToOneMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToOneMapping.java @@ -12,11 +12,9 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import java.util.List; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.GenericOrmOneToOneMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.context.EclipseLinkOneToOneMapping; import org.eclipse.jpt.eclipselink.core.context.JoinFetch; import org.eclipse.jpt.eclipselink.core.context.PrivateOwned; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlJoinFetch; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToOne; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlPrivateOwned; @@ -30,10 +28,10 @@ public class EclipseLinkOrmOneToOneMapping extends GenericOrmOneToOneMapping protected EclipseLinkOrmJoinFetch joinFetch; - public EclipseLinkOrmOneToOneMapping(OrmPersistentAttribute parent) { - super(parent); - this.privateOwned = new EclipseLinkOrmPrivateOwned(this); - this.joinFetch = new EclipseLinkOrmJoinFetch(this); + public EclipseLinkOrmOneToOneMapping(OrmPersistentAttribute parent, XmlOneToOne resourceMapping) { + super(parent, resourceMapping); + this.privateOwned = new EclipseLinkOrmPrivateOwned(this, (XmlPrivateOwned) this.resourceAttributeMapping); + this.joinFetch = new EclipseLinkOrmJoinFetch(this, (XmlJoinFetch) this.resourceAttributeMapping); } @@ -49,21 +47,6 @@ public class EclipseLinkOrmOneToOneMapping extends GenericOrmOneToOneMapping // **************** resource-context interaction *************************** @Override - public XmlOneToOne addToResourceModel(XmlTypeMapping typeMapping) { - XmlOneToOne oneToOne = EclipseLinkOrmFactory.eINSTANCE.createXmlOneToOneImpl(); - getPersistentAttribute().initialize(oneToOne); - typeMapping.getAttributes().getOneToOnes().add(oneToOne); - return oneToOne; - } - - @Override - protected void initialize() { - super.initialize(); - this.privateOwned.initialize((XmlPrivateOwned) this.resourceAttributeMapping); - this.joinFetch.initialize((XmlJoinFetch) this.resourceAttributeMapping); - } - - @Override public void update() { super.update(); this.privateOwned.update(); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToOneMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToOneMappingProvider.java index 3c1043d8f3..6da6412b8d 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToOneMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmOneToOneMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlOneToOne; public class EclipseLinkOrmOneToOneMappingProvider implements OrmAttributeMappingProvider @@ -49,9 +51,13 @@ public class EclipseLinkOrmOneToOneMappingProvider public String getKey() { return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlOneToOneImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmOneToOneMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmOneToOneMapping(parent, (XmlOneToOne) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentType.java index 1956b397f5..a1f4090fb6 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentType.java @@ -11,17 +11,18 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import org.eclipse.jpt.core.internal.context.orm.AbstractOrmPersistentType; import org.eclipse.jpt.core.resource.orm.Attributes; +import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; public class EclipseLinkOrmPersistentType extends AbstractOrmPersistentType { - public EclipseLinkOrmPersistentType(EclipseLinkEntityMappings parent, String mappingKey) { - super(parent, mappingKey); + public EclipseLinkOrmPersistentType(EclipseLinkEntityMappings parent, XmlTypeMapping resourceMapping) { + super(parent, resourceMapping); } @Override - protected Attributes createAttributesResource() { + protected Attributes createResourceAttributes() { return EclipseLinkOrmFactory.eINSTANCE.createAttributes(); } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmPrivateOwned.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmPrivateOwned.java index 82ba1321bf..ef58b74b18 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmPrivateOwned.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmPrivateOwned.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Oracle. + * Copyright (c) 2008, 2009 Oracle. * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which * accompanies this distribution, and is available at @@ -19,13 +19,15 @@ import org.eclipse.jpt.eclipselink.core.resource.orm.XmlPrivateOwned; public class EclipseLinkOrmPrivateOwned extends AbstractXmlContextNode implements PrivateOwned { - protected XmlPrivateOwned resource; + protected final XmlPrivateOwned resource; protected boolean privateOwned; - public EclipseLinkOrmPrivateOwned(OrmAttributeMapping parent) { + public EclipseLinkOrmPrivateOwned(OrmAttributeMapping parent, XmlPrivateOwned resource) { super(parent); + this.resource = resource; + this.privateOwned = this.getResourcePrivateOwned(); } @@ -49,11 +51,6 @@ public class EclipseLinkOrmPrivateOwned extends AbstractXmlContextNode // **************** initialize/update ************************************** - protected void initialize(XmlPrivateOwned xmlPrivateOwned) { - this.resource = xmlPrivateOwned; - this.privateOwned = this.getResourcePrivateOwned(); - } - protected void update() { setPrivateOwned_(this.getResourcePrivateOwned()); } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmReadOnly.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmReadOnly.java index b21277a288..b292b0fd46 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmReadOnly.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmReadOnly.java @@ -19,15 +19,18 @@ import org.eclipse.jpt.eclipselink.core.resource.orm.XmlReadOnly; public class EclipseLinkOrmReadOnly extends AbstractXmlContextNode implements ReadOnly { - protected XmlReadOnly resource; + protected final XmlReadOnly resource; protected boolean defaultReadOnly; protected Boolean specifiedReadOnly; - public EclipseLinkOrmReadOnly(OrmTypeMapping parent) { + public EclipseLinkOrmReadOnly(OrmTypeMapping parent, XmlReadOnly resource, ReadOnly javaReadOnly) { super(parent); + this.resource = resource; + this.defaultReadOnly = this.getJavaReadOnly(javaReadOnly); + this.specifiedReadOnly = this.getResourceReadOnly(); } @@ -59,12 +62,6 @@ public class EclipseLinkOrmReadOnly extends AbstractXmlContextNode // **************** initialize/update ************************************** - protected void initialize(XmlReadOnly resource, ReadOnly javaReadOnly) { - this.resource = resource; - this.defaultReadOnly = this.getJavaReadOnly(javaReadOnly); - this.specifiedReadOnly = this.getResourceReadOnly(); - } - protected void update(ReadOnly javaReadOnly) { setDefaultReadOnly(this.getJavaReadOnly(javaReadOnly)); setSpecifiedReadOnly(this.getResourceReadOnly()); diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmVersionMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmVersionMapping.java index 2a1204322d..2a5fc78060 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmVersionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmVersionMapping.java @@ -14,11 +14,9 @@ import java.util.List; import org.eclipse.jpt.core.context.orm.OrmConverter; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.GenericOrmVersionMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.context.Convert; import org.eclipse.jpt.eclipselink.core.context.EclipseLinkVersionMapping; import org.eclipse.jpt.eclipselink.core.context.Mutable; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlMutable; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlVersion; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -29,9 +27,9 @@ public class EclipseLinkOrmVersionMapping extends GenericOrmVersionMapping protected EclipseLinkOrmMutable mutable; - public EclipseLinkOrmVersionMapping(OrmPersistentAttribute parent) { - super(parent); - this.mutable = new EclipseLinkOrmMutable(this); + public EclipseLinkOrmVersionMapping(OrmPersistentAttribute parent, XmlVersion resourceMapping) { + super(parent, resourceMapping); + this.mutable = new EclipseLinkOrmMutable(this, (XmlMutable) this.resourceAttributeMapping); } @@ -61,20 +59,7 @@ public class EclipseLinkOrmVersionMapping extends GenericOrmVersionMapping } // **************** resource-context interaction *************************** - - @Override - public XmlVersion addToResourceModel(XmlTypeMapping typeMapping) { - XmlVersion version = EclipseLinkOrmFactory.eINSTANCE.createXmlVersionImpl(); - getPersistentAttribute().initialize(version); - typeMapping.getAttributes().getVersions().add(version); - return version; - } - - @Override - protected void initialize() { - super.initialize(); - this.mutable.initialize((XmlMutable) this.resourceAttributeMapping); - } + @Override public void update() { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmVersionMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmVersionMappingProvider.java index 5206bcf3d5..625dd25c76 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmVersionMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmVersionMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.core.context.orm.OrmTypeMapping; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlVersion; public class EclipseLinkOrmVersionMappingProvider implements OrmAttributeMappingProvider @@ -49,9 +51,13 @@ public class EclipseLinkOrmVersionMappingProvider public String getKey() { return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlVersionImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmVersionMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildEclipseLinkOrmVersionMapping(parent, (XmlVersion) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmXml.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmXml.java index ba4106f6ee..2f5ab59763 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmXml.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/EclipseLinkOrmXml.java @@ -40,7 +40,7 @@ public class EclipseLinkOrmXml extends AbstractOrmXml @Override protected EntityMappings buildEntityMappings(XmlEntityMappings xmlEntityMappings) { - return getJpaFactory().buildEclipseLinkEntityMappings(this, xmlEntityMappings); + return getJpaFactory().buildEclipseLinkEntityMappings(this, (org.eclipse.jpt.eclipselink.core.resource.orm.XmlEntityMappings) xmlEntityMappings); } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicCollectionMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicCollectionMapping.java index ca0ba50ab4..382dc3df39 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicCollectionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicCollectionMapping.java @@ -12,18 +12,16 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.AbstractOrmAttributeMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.eclipselink.core.context.BasicCollectionMapping; import org.eclipse.jpt.eclipselink.core.resource.orm.Attributes; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlBasicCollection; public class OrmBasicCollectionMapping extends AbstractOrmAttributeMapping<XmlBasicCollection> implements BasicCollectionMapping { - public OrmBasicCollectionMapping(OrmPersistentAttribute parent) { - super(parent); + public OrmBasicCollectionMapping(OrmPersistentAttribute parent, XmlBasicCollection resourceMapping) { + super(parent, resourceMapping); } public void initializeOn(OrmAttributeMapping newMapping) { @@ -34,15 +32,12 @@ public class OrmBasicCollectionMapping extends AbstractOrmAttributeMapping<XmlBa return EclipseLinkMappingKeys.BASIC_COLLECTION_ATTRIBUTE_MAPPING_KEY; } - public XmlBasicCollection addToResourceModel(XmlTypeMapping typeMapping) { - XmlBasicCollection basicCollection = EclipseLinkOrmFactory.eINSTANCE.createXmlBasicCollectionImpl(); - getPersistentAttribute().initialize(basicCollection); - ((Attributes) typeMapping.getAttributes()).getBasicCollections().add(basicCollection); - return basicCollection; + public void addToResourceModel(org.eclipse.jpt.core.resource.orm.Attributes resourceAttributes) { + ((Attributes) resourceAttributes).getBasicCollections().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - ((Attributes) typeMapping.getAttributes()).getBasicCollections().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(org.eclipse.jpt.core.resource.orm.Attributes resourceAttributes) { + ((Attributes) resourceAttributes).getBasicCollections().remove(this.resourceAttributeMapping); } public int getXmlSequence() { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicCollectionMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicCollectionMappingProvider.java index 8a63609277..e1bc974c1d 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicCollectionMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicCollectionMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaBasicCollectionMapping; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlBasicCollection; public class OrmBasicCollectionMappingProvider implements OrmAttributeMappingProvider @@ -50,9 +52,13 @@ public class OrmBasicCollectionMappingProvider public String getKey() { return EclipseLinkMappingKeys.BASIC_COLLECTION_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlBasicCollectionImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildOrmBasicCollectionMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildOrmBasicCollectionMapping(parent, (XmlBasicCollection) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicMapMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicMapMapping.java index 4a953b6673..d90f3f84a7 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicMapMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicMapMapping.java @@ -12,18 +12,16 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.AbstractOrmAttributeMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.eclipselink.core.context.BasicMapMapping; import org.eclipse.jpt.eclipselink.core.resource.orm.Attributes; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlBasicMap; public class OrmBasicMapMapping extends AbstractOrmAttributeMapping<XmlBasicMap> implements BasicMapMapping { - public OrmBasicMapMapping(OrmPersistentAttribute parent) { - super(parent); + public OrmBasicMapMapping(OrmPersistentAttribute parent, XmlBasicMap resourceMapping) { + super(parent, resourceMapping); } public void initializeOn(OrmAttributeMapping newMapping) { @@ -34,15 +32,12 @@ public class OrmBasicMapMapping extends AbstractOrmAttributeMapping<XmlBasicMap> return EclipseLinkMappingKeys.BASIC_MAP_ATTRIBUTE_MAPPING_KEY; } - public XmlBasicMap addToResourceModel(XmlTypeMapping typeMapping) { - XmlBasicMap basicMap = EclipseLinkOrmFactory.eINSTANCE.createXmlBasicMapImpl(); - getPersistentAttribute().initialize(basicMap); - ((Attributes) typeMapping.getAttributes()).getBasicMaps().add(basicMap); - return basicMap; + public void addToResourceModel(org.eclipse.jpt.core.resource.orm.Attributes resourceAttributes) { + ((Attributes) resourceAttributes).getBasicMaps().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - ((Attributes) typeMapping.getAttributes()).getBasicMaps().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(org.eclipse.jpt.core.resource.orm.Attributes resourceAttributes) { + ((Attributes) resourceAttributes).getBasicMaps().remove(this.resourceAttributeMapping); } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicMapMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicMapMappingProvider.java index 0bf94ce06a..f43724830e 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicMapMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmBasicMapMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaBasicMapMapping; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlBasicMap; public class OrmBasicMapMappingProvider implements OrmAttributeMappingProvider @@ -50,9 +52,13 @@ public class OrmBasicMapMappingProvider public String getKey() { return EclipseLinkMappingKeys.BASIC_MAP_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlBasicMapImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildOrmBasicMapMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildOrmBasicMapMapping(parent, (XmlBasicMap) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmTransformationMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmTransformationMapping.java index 2f3719a29f..f97bbd9c75 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmTransformationMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmTransformationMapping.java @@ -12,18 +12,16 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.AbstractOrmAttributeMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.eclipselink.core.context.TransformationMapping; import org.eclipse.jpt.eclipselink.core.resource.orm.Attributes; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlTransformation; public class OrmTransformationMapping extends AbstractOrmAttributeMapping<XmlTransformation> implements TransformationMapping { - public OrmTransformationMapping(OrmPersistentAttribute parent) { - super(parent); + public OrmTransformationMapping(OrmPersistentAttribute parent, XmlTransformation resourceMapping) { + super(parent, resourceMapping); } public void initializeOn(OrmAttributeMapping newMapping) { @@ -34,15 +32,12 @@ public class OrmTransformationMapping extends AbstractOrmAttributeMapping<XmlTra return EclipseLinkMappingKeys.TRANSFORMATION_ATTRIBUTE_MAPPING_KEY; } - public XmlTransformation addToResourceModel(XmlTypeMapping typeMapping) { - XmlTransformation transformation = EclipseLinkOrmFactory.eINSTANCE.createXmlTransformationImpl(); - getPersistentAttribute().initialize(transformation); - ((Attributes) typeMapping.getAttributes()).getTransformations().add(transformation); - return transformation; + public void addToResourceModel(org.eclipse.jpt.core.resource.orm.Attributes resourceAttributes) { + ((Attributes) resourceAttributes).getTransformations().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - ((Attributes) typeMapping.getAttributes()).getTransformations().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(org.eclipse.jpt.core.resource.orm.Attributes resourceAttributes) { + ((Attributes) resourceAttributes).getTransformations().remove(this.resourceAttributeMapping); } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmTransformationMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmTransformationMappingProvider.java index 88da12cda1..c70751bc6c 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmTransformationMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmTransformationMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaTransformationMapping; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlTransformation; public class OrmTransformationMappingProvider implements OrmAttributeMappingProvider @@ -50,9 +52,13 @@ public class OrmTransformationMappingProvider public String getKey() { return EclipseLinkMappingKeys.TRANSFORMATION_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlTransformationImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildOrmTransformationMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildOrmTransformationMapping(parent, (XmlTransformation) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmVariableOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmVariableOneToOneMapping.java index 760b6146a9..a77363e47e 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmVariableOneToOneMapping.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmVariableOneToOneMapping.java @@ -12,18 +12,16 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; import org.eclipse.jpt.core.internal.context.orm.AbstractOrmAttributeMapping; -import org.eclipse.jpt.core.resource.orm.XmlTypeMapping; import org.eclipse.jpt.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.eclipselink.core.context.VariableOneToOneMapping; import org.eclipse.jpt.eclipselink.core.resource.orm.Attributes; -import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlVariableOneToOne; public class OrmVariableOneToOneMapping extends AbstractOrmAttributeMapping<XmlVariableOneToOne> implements VariableOneToOneMapping { - public OrmVariableOneToOneMapping(OrmPersistentAttribute parent) { - super(parent); + public OrmVariableOneToOneMapping(OrmPersistentAttribute parent, XmlVariableOneToOne resourceMapping) { + super(parent, resourceMapping); } public void initializeOn(OrmAttributeMapping newMapping) { @@ -34,15 +32,12 @@ public class OrmVariableOneToOneMapping extends AbstractOrmAttributeMapping<XmlV return EclipseLinkMappingKeys.VARIABLE_ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY; } - public XmlVariableOneToOne addToResourceModel(XmlTypeMapping typeMapping) { - XmlVariableOneToOne xmlVariableOneToOne = EclipseLinkOrmFactory.eINSTANCE.createXmlVariableOneToOneImpl(); - getPersistentAttribute().initialize(xmlVariableOneToOne); - ((Attributes) typeMapping.getAttributes()).getVariableOneToOnes().add(xmlVariableOneToOne); - return xmlVariableOneToOne; + public void addToResourceModel(org.eclipse.jpt.core.resource.orm.Attributes resourceAttributes) { + ((Attributes) resourceAttributes).getVariableOneToOnes().add(this.resourceAttributeMapping); } - public void removeFromResourceModel(XmlTypeMapping typeMapping) { - ((Attributes) typeMapping.getAttributes()).getVariableOneToOnes().remove(this.resourceAttributeMapping); + public void removeFromResourceModel(org.eclipse.jpt.core.resource.orm.Attributes resourceAttributes) { + ((Attributes) resourceAttributes).getVariableOneToOnes().remove(this.resourceAttributeMapping); } public int getXmlSequence() { diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmVariableOneToOneMappingProvider.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmVariableOneToOneMappingProvider.java index 4d58e19888..7b6cb22d31 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmVariableOneToOneMappingProvider.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmVariableOneToOneMappingProvider.java @@ -21,6 +21,8 @@ import org.eclipse.jpt.eclipselink.core.EclipseLinkMappingKeys; import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaFactory; import org.eclipse.jpt.eclipselink.core.internal.JptEclipseLinkCorePlugin; import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaVariableOneToOneMapping; +import org.eclipse.jpt.eclipselink.core.resource.orm.EclipseLinkOrmFactory; +import org.eclipse.jpt.eclipselink.core.resource.orm.XmlVariableOneToOne; public class OrmVariableOneToOneMappingProvider implements OrmAttributeMappingProvider @@ -50,9 +52,13 @@ public class OrmVariableOneToOneMappingProvider public String getKey() { return EclipseLinkMappingKeys.VARIABLE_ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY; } + + public XmlAttributeMapping buildResourceMapping() { + return EclipseLinkOrmFactory.eINSTANCE.createXmlVariableOneToOneImpl(); + } - public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, JpaFactory factory) { - return ((EclipseLinkJpaFactory) factory).buildOrmVariableOneToOneMapping(parent); + public OrmAttributeMapping buildMapping(OrmPersistentAttribute parent, XmlAttributeMapping resourceMapping, JpaFactory factory) { + return ((EclipseLinkJpaFactory) factory).buildOrmVariableOneToOneMapping(parent, (XmlVariableOneToOne) resourceMapping); } public XmlAttributeMapping buildVirtualResourceMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping, JpaFactory factory) { |