diff options
author | kmoore | 2007-05-10 00:50:22 +0000 |
---|---|---|
committer | kmoore | 2007-05-10 00:50:22 +0000 |
commit | 96c831a775763862bcc5fb5d24656f98e7f57e80 (patch) | |
tree | 58fcfebb952cb986db3ca9d66b0b20b8065906c7 /jpa | |
parent | 78a821627804b247ad157893fab6993898eee29b (diff) | |
download | webtools.dali-96c831a775763862bcc5fb5d24656f98e7f57e80.tar.gz webtools.dali-96c831a775763862bcc5fb5d24656f98e7f57e80.tar.xz webtools.dali-96c831a775763862bcc5fb5d24656f98e7f57e80.zip |
137799 - model support for IdClass - no validation or UI
Diffstat (limited to 'jpa')
15 files changed, 771 insertions, 18 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/model/core.ecore b/jpa/plugins/org.eclipse.jpt.core/model/core.ecore index eb6031a316..69660ffa1c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/model/core.ecore +++ b/jpa/plugins/org.eclipse.jpt.core/model/core.ecore @@ -118,7 +118,9 @@ </eClassifiers> <eSubpackages name="mappings" nsURI="jpt.core.mappings.xmi" nsPrefix="jpt.core.mappings"> <eClassifiers xsi:type="ecore:EClass" name="IMappedSuperclass" abstract="true" - interface="true" eSuperTypes="#//ITypeMapping"/> + interface="true" eSuperTypes="#//ITypeMapping"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="idClass" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/> + </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="IEntity" abstract="true" interface="true" eSuperTypes="#//ITypeMapping"> <eOperations name="discriminatorValueIsAllowed" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> @@ -177,6 +179,7 @@ eType="#//mappings/INamedQuery" containment="true"/> <eStructuralFeatures xsi:type="ecore:EReference" name="namedNativeQueries" upperBound="-1" eType="#//mappings/INamedNativeQuery" containment="true"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="idClass" eType="ecore:EDataType platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/> </eClassifiers> <eClassifiers xsi:type="ecore:EClass" name="IEmbeddable" abstract="true" interface="true" eSuperTypes="#//ITypeMapping"/> diff --git a/jpa/plugins/org.eclipse.jpt.core/model/coreModels.genmodel b/jpa/plugins/org.eclipse.jpt.core/model/coreModels.genmodel index 290a7137d0..f4b96ff1fb 100644 --- a/jpa/plugins/org.eclipse.jpt.core/model/coreModels.genmodel +++ b/jpa/plugins/org.eclipse.jpt.core/model/coreModels.genmodel @@ -151,7 +151,9 @@ <genEnumLiterals ecoreEnumLiteral="core.ecore#//mappings/OrderingType/PRIMARY_KEY"/> <genEnumLiterals ecoreEnumLiteral="core.ecore#//mappings/OrderingType/CUSTOM"/> </genEnums> - <genClasses ecoreClass="core.ecore#//mappings/IMappedSuperclass"/> + <genClasses ecoreClass="core.ecore#//mappings/IMappedSuperclass"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute core.ecore#//mappings/IMappedSuperclass/idClass"/> + </genClasses> <genClasses ecoreClass="core.ecore#//mappings/IEntity"> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute core.ecore#//mappings/IEntity/specifiedName"/> <genFeatures property="Readonly" createChild="false" ecoreFeature="ecore:EAttribute core.ecore#//mappings/IEntity/defaultName"/> @@ -182,6 +184,7 @@ ecoreFeature="ecore:EReference core.ecore#//mappings/IEntity/defaultAssociationOverrides"/> <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference core.ecore#//mappings/IEntity/namedQueries"/> <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference core.ecore#//mappings/IEntity/namedNativeQueries"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute core.ecore#//mappings/IEntity/idClass"/> <genOperations ecoreOperation="core.ecore#//mappings/IEntity/discriminatorValueIsAllowed"/> <genOperations ecoreOperation="core.ecore#//mappings/IEntity/getSecondaryTables"/> <genOperations ecoreOperation="core.ecore#//mappings/IEntity/parentEntity"/> diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java index 1896c2b8ee..2082cb0503 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java @@ -37,6 +37,7 @@ import org.eclipse.jpt.core.internal.jdtutility.EnumDeclarationAnnotationElement import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.internal.jdtutility.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.internal.jdtutility.Type; import org.eclipse.jpt.core.internal.mappings.DiscriminatorType; import org.eclipse.jpt.core.internal.mappings.IAbstractJoinColumn; @@ -313,6 +314,26 @@ public class JavaEntity extends JavaTypeMapping implements IEntity */ protected EList<INamedNativeQuery> namedNativeQueries; + /** + * The default value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getIdClass() + * @generated + * @ordered + */ + protected static final String ID_CLASS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getIdClass() + * @generated + * @ordered + */ + protected String idClass = ID_CLASS_EDEFAULT; + private AnnotationElementAdapter nameAdapter; private AnnotationElementAdapter inheritanceStrategyAdapter; @@ -323,6 +344,14 @@ public class JavaEntity extends JavaTypeMapping implements IEntity private AnnotationAdapter sequenceGeneratorAnnotationAdapter; + private final AnnotationAdapter idClassAnnotationAdapter; + + private final AnnotationElementAdapter idClassValueAdapter; + + public static final DeclarationAnnotationAdapter ID_CLASS_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.ID_CLASS); + + private static final DeclarationAnnotationElementAdapter ID_CLASS_VALUE_ADAPTER = buildIdClassValueAdapter(); + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.ENTITY); private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); @@ -350,6 +379,8 @@ public class JavaEntity extends JavaTypeMapping implements IEntity this.nameAdapter = new ShortCircuitAnnotationElementAdapter(getType(), NAME_ADAPTER); this.inheritanceStrategyAdapter = new ShortCircuitAnnotationElementAdapter(type, INHERITANCE_STRATEGY_ADAPTER); this.discriminatorValueAdapter = new ShortCircuitAnnotationElementAdapter(type, DISCRIMINATOR_VALUE_ADAPTER); + this.idClassAnnotationAdapter = new MemberAnnotationAdapter(this.getType(), ID_CLASS_ADAPTER); + this.idClassValueAdapter = new ShortCircuitAnnotationElementAdapter(this.getType(), ID_CLASS_VALUE_ADAPTER); this.getDefaultPrimaryKeyJoinColumns().add(this.createPrimaryKeyJoinColumn(0)); this.tableGeneratorAnnotationAdapter = new MemberAnnotationAdapter(getType(), JavaTableGenerator.DECLARATION_ANNOTATION_ADAPTER); this.sequenceGeneratorAnnotationAdapter = new MemberAnnotationAdapter(getType(), JavaSequenceGenerator.DECLARATION_ANNOTATION_ADAPTER); @@ -419,6 +450,15 @@ public class JavaEntity extends JavaTypeMapping implements IEntity break; case JpaCoreMappingsPackage.IENTITY__SEQUENCE_GENERATOR : attributeChanged(notification.getNewValue(), this.sequenceGeneratorAnnotationAdapter); + break; + case JpaCoreMappingsPackage.IENTITY__ID_CLASS : + String idClass = (String) notification.getNewValue(); + if (idClass == null) { + this.idClassAnnotationAdapter.removeAnnotation(); + } + else { + this.idClassValueAdapter.setValue(idClass); + } default : break; } @@ -1770,6 +1810,39 @@ public class JavaEntity extends JavaTypeMapping implements IEntity } /** + * Returns the value of the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Id Class</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Id Class</em>' attribute. + * @see #setIdClass(String) + * @see org.eclipse.jpt.core.internal.content.java.mappings.JpaJavaMappingsPackage#getIEntity_IdClass() + * @model + * @generated + */ + public String getIdClass() { + return idClass; + } + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaEntity#getIdClass <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Id Class</em>' attribute. + * @see #getIdClass() + * @generated + */ + public void setIdClass(String newIdClass) { + String oldIdClass = idClass; + idClass = newIdClass; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, JpaJavaMappingsPackage.JAVA_ENTITY__ID_CLASS, oldIdClass, idClass)); + } + + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @model @@ -1903,6 +1976,8 @@ public class JavaEntity extends JavaTypeMapping implements IEntity return getNamedQueries(); case JpaJavaMappingsPackage.JAVA_ENTITY__NAMED_NATIVE_QUERIES : return getNamedNativeQueries(); + case JpaJavaMappingsPackage.JAVA_ENTITY__ID_CLASS : + return getIdClass(); } return super.eGet(featureID, resolve, coreType); } @@ -1970,6 +2045,9 @@ public class JavaEntity extends JavaTypeMapping implements IEntity getNamedNativeQueries().clear(); getNamedNativeQueries().addAll((Collection<? extends INamedNativeQuery>) newValue); return; + case JpaJavaMappingsPackage.JAVA_ENTITY__ID_CLASS : + setIdClass((String) newValue); + return; } super.eSet(featureID, newValue); } @@ -2027,6 +2105,9 @@ public class JavaEntity extends JavaTypeMapping implements IEntity case JpaJavaMappingsPackage.JAVA_ENTITY__NAMED_NATIVE_QUERIES : getNamedNativeQueries().clear(); return; + case JpaJavaMappingsPackage.JAVA_ENTITY__ID_CLASS : + setIdClass(ID_CLASS_EDEFAULT); + return; } super.eUnset(featureID); } @@ -2083,6 +2164,8 @@ public class JavaEntity extends JavaTypeMapping implements IEntity return namedQueries != null && !namedQueries.isEmpty(); case JpaJavaMappingsPackage.JAVA_ENTITY__NAMED_NATIVE_QUERIES : return namedNativeQueries != null && !namedNativeQueries.isEmpty(); + case JpaJavaMappingsPackage.JAVA_ENTITY__ID_CLASS : + return ID_CLASS_EDEFAULT == null ? idClass != null : !ID_CLASS_EDEFAULT.equals(idClass); } return super.eIsSet(featureID); } @@ -2140,6 +2223,8 @@ public class JavaEntity extends JavaTypeMapping implements IEntity return JpaCoreMappingsPackage.IENTITY__NAMED_QUERIES; case JpaJavaMappingsPackage.JAVA_ENTITY__NAMED_NATIVE_QUERIES : return JpaCoreMappingsPackage.IENTITY__NAMED_NATIVE_QUERIES; + case JpaJavaMappingsPackage.JAVA_ENTITY__ID_CLASS : + return JpaCoreMappingsPackage.IENTITY__ID_CLASS; default : return -1; } @@ -2200,6 +2285,8 @@ public class JavaEntity extends JavaTypeMapping implements IEntity return JpaJavaMappingsPackage.JAVA_ENTITY__NAMED_QUERIES; case JpaCoreMappingsPackage.IENTITY__NAMED_NATIVE_QUERIES : return JpaJavaMappingsPackage.JAVA_ENTITY__NAMED_NATIVE_QUERIES; + case JpaCoreMappingsPackage.IENTITY__ID_CLASS : + return JpaJavaMappingsPackage.JAVA_ENTITY__ID_CLASS; default : return -1; } @@ -2227,6 +2314,8 @@ public class JavaEntity extends JavaTypeMapping implements IEntity result.append(defaultDiscriminatorValue); result.append(", specifiedDiscriminatorValue: "); result.append(specifiedDiscriminatorValue); + result.append(", idClass: "); + result.append(idClass); result.append(')'); return result.toString(); } @@ -2276,6 +2365,17 @@ public class JavaEntity extends JavaTypeMapping implements IEntity this.setDefaultDiscriminatorValue(this.javaDefaultDiscriminatorValue()); this.updateTableGeneratorFromJava(astRoot); this.updateSequenceGeneratorFromJava(astRoot); + this.updateIdClassFromJava(astRoot); + } + + private void updateIdClassFromJava(CompilationUnit astRoot) { + if (this.idClassAnnotationAdapter.getAnnotation(astRoot) == null) { + + this.setIdClass(null); + } + else { + this.setIdClass((String) this.idClassValueAdapter.getValue(astRoot)); + } } private JavaTable getJavaTable() { @@ -2813,4 +2913,10 @@ public class JavaEntity extends JavaTypeMapping implements IEntity private static DeclarationAnnotationElementAdapter buildDiscriminatorValueAdapter() { return new ConversionDeclarationAnnotationElementAdapter(DISCRIMINATOR_ANNOTATION_ADAPTER, JPA.DISCRIMINATOR_VALUE__VALUE); } + + // ********** static methods ********** + private static DeclarationAnnotationElementAdapter buildIdClassValueAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(ID_CLASS_ADAPTER, JPA.ID_CLASS__VALUE, false, SimpleTypeStringExpressionConverter.instance()); + } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java index f5e9743bc8..fa75a030f9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java @@ -10,13 +10,24 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Iterator; +import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.IMappingKeys; import org.eclipse.jpt.core.internal.IPersistentAttribute; +import org.eclipse.jpt.core.internal.jdtutility.AnnotationAdapter; +import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; +import org.eclipse.jpt.core.internal.jdtutility.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter; +import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationAdapter; +import org.eclipse.jpt.core.internal.jdtutility.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter; +import org.eclipse.jpt.core.internal.jdtutility.SimpleTypeStringExpressionConverter; import org.eclipse.jpt.core.internal.jdtutility.Type; import org.eclipse.jpt.core.internal.mappings.IMappedSuperclass; +import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; @@ -33,19 +44,45 @@ import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; public class JavaMappedSuperclass extends JavaTypeMapping implements IMappedSuperclass { - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.MAPPED_SUPERCLASS); + /** + * The default value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getIdClass() + * @generated + * @ordered + */ + protected static final String ID_CLASS_EDEFAULT = null; /** + * The cached value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * @see #getIdClass() * @generated + * @ordered */ + protected String idClass = ID_CLASS_EDEFAULT; + + private final AnnotationAdapter idClassAnnotationAdapter; + + private final AnnotationElementAdapter idClassValueAdapter; + + public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.MAPPED_SUPERCLASS); + + public static final DeclarationAnnotationAdapter ID_CLASS_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.ID_CLASS); + + private static final DeclarationAnnotationElementAdapter ID_CLASS_VALUE_ADAPTER = buildIdClassValueAdapter(); + + protected JavaMappedSuperclass() { - super(); + throw new UnsupportedOperationException("Use JavaMappedSuperclass(Type) instead"); } protected JavaMappedSuperclass(Type type) { super(type); + this.idClassAnnotationAdapter = new MemberAnnotationAdapter(this.getType(), ID_CLASS_ADAPTER); + this.idClassValueAdapter = new ShortCircuitAnnotationElementAdapter(this.getType(), ID_CLASS_VALUE_ADAPTER); } @Override @@ -54,6 +91,30 @@ public class JavaMappedSuperclass extends JavaTypeMapping } /** + * check for changes to the 'specifiedJoinColumns' and + * 'specifiedInverseJoinColumns' lists so we can notify the + * model adapter of any changes; + * also listen for changes to the 'defaultJoinColumns' and + * 'defaultInverseJoinColumns' lists so we can spank the developer + */ + @Override + protected void notifyChanged(Notification notification) { + super.notifyChanged(notification); + switch (notification.getFeatureID(IMappedSuperclass.class)) { + case JpaCoreMappingsPackage.IMAPPED_SUPERCLASS__ID_CLASS : + String idClass = (String) notification.getNewValue(); + if (idClass == null) { + this.idClassAnnotationAdapter.removeAnnotation(); + } + else { + this.idClassValueAdapter.setValue(idClass); + } + default : + break; + } + } + + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated @@ -63,6 +124,149 @@ public class JavaMappedSuperclass extends JavaTypeMapping return JpaJavaMappingsPackage.Literals.JAVA_MAPPED_SUPERCLASS; } + /** + * Returns the value of the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Id Class</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Id Class</em>' attribute. + * @see #setIdClass(String) + * @see org.eclipse.jpt.core.internal.content.java.mappings.JpaJavaMappingsPackage#getIMappedSuperclass_IdClass() + * @model + * @generated + */ + public String getIdClass() { + return idClass; + } + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaMappedSuperclass#getIdClass <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Id Class</em>' attribute. + * @see #getIdClass() + * @generated + */ + public void setIdClass(String newIdClass) { + String oldIdClass = idClass; + idClass = newIdClass; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, JpaJavaMappingsPackage.JAVA_MAPPED_SUPERCLASS__ID_CLASS, oldIdClass, idClass)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case JpaJavaMappingsPackage.JAVA_MAPPED_SUPERCLASS__ID_CLASS : + return getIdClass(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case JpaJavaMappingsPackage.JAVA_MAPPED_SUPERCLASS__ID_CLASS : + setIdClass((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case JpaJavaMappingsPackage.JAVA_MAPPED_SUPERCLASS__ID_CLASS : + setIdClass(ID_CLASS_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case JpaJavaMappingsPackage.JAVA_MAPPED_SUPERCLASS__ID_CLASS : + return ID_CLASS_EDEFAULT == null ? idClass != null : !ID_CLASS_EDEFAULT.equals(idClass); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { + if (baseClass == IMappedSuperclass.class) { + switch (derivedFeatureID) { + case JpaJavaMappingsPackage.JAVA_MAPPED_SUPERCLASS__ID_CLASS : + return JpaCoreMappingsPackage.IMAPPED_SUPERCLASS__ID_CLASS; + default : + return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { + if (baseClass == IMappedSuperclass.class) { + switch (baseFeatureID) { + case JpaCoreMappingsPackage.IMAPPED_SUPERCLASS__ID_CLASS : + return JpaJavaMappingsPackage.JAVA_MAPPED_SUPERCLASS__ID_CLASS; + default : + return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (idClass: "); + result.append(idClass); + result.append(')'); + return result.toString(); + } + public String getKey() { return IMappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY; } @@ -103,4 +307,26 @@ public class JavaMappedSuperclass extends JavaTypeMapping } }; } + + @Override + public void updateFromJava(CompilationUnit astRoot) { + super.updateFromJava(astRoot); + this.updateIdClassFromJava(astRoot); + } + + private void updateIdClassFromJava(CompilationUnit astRoot) { + if (this.idClassAnnotationAdapter.getAnnotation(astRoot) == null) { + + this.setIdClass(null); + } + else { + this.setIdClass((String) this.idClassValueAdapter.getValue(astRoot)); + } + } + + // ********** static methods ********** + private static DeclarationAnnotationElementAdapter buildIdClassValueAdapter() { + return new ConversionDeclarationAnnotationElementAdapter(ID_CLASS_ADAPTER, JPA.ID_CLASS__VALUE, false, SimpleTypeStringExpressionConverter.instance()); + } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java index 6ceaad0052..f9e00a64df 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java @@ -22,6 +22,7 @@ import org.eclipse.jpt.core.internal.ITypeMapping; import org.eclipse.jpt.core.internal.jdtutility.AnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.Attribute; +import org.eclipse.jpt.core.internal.jdtutility.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.EnumDeclarationAnnotationElementAdapter; @@ -636,6 +637,6 @@ public abstract class JavaMultiRelationshipMapping // ********** static methods ********** private static DeclarationAnnotationElementAdapter buildMapKeyNameAdapter() { - return new EnumDeclarationAnnotationElementAdapter(MAP_KEY_ADAPTER, JPA.MAP_KEY__NAME, false); + return new ConversionDeclarationAnnotationElementAdapter(MAP_KEY_ADAPTER, JPA.MAP_KEY__NAME, false); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JpaJavaMappingsPackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JpaJavaMappingsPackage.java index 53d32db2f7..eddbc98b84 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JpaJavaMappingsPackage.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JpaJavaMappingsPackage.java @@ -333,13 +333,22 @@ public class JpaJavaMappingsPackage extends EPackageImpl public static final int JAVA_ENTITY__NAMED_NATIVE_QUERIES = JAVA_TYPE_MAPPING_FEATURE_COUNT + 21; /** + * The feature id for the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int JAVA_ENTITY__ID_CLASS = JAVA_TYPE_MAPPING_FEATURE_COUNT + 22; + + /** * The number of structural features of the '<em>Java Entity</em>' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - public static final int JAVA_ENTITY_FEATURE_COUNT = JAVA_TYPE_MAPPING_FEATURE_COUNT + 22; + public static final int JAVA_ENTITY_FEATURE_COUNT = JAVA_TYPE_MAPPING_FEATURE_COUNT + 23; /** * The meta object id for the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaMappedSuperclass <em>Java Mapped Superclass</em>}' class. @@ -370,13 +379,22 @@ public class JpaJavaMappingsPackage extends EPackageImpl public static final int JAVA_MAPPED_SUPERCLASS__TABLE_NAME = JAVA_TYPE_MAPPING__TABLE_NAME; /** + * The feature id for the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int JAVA_MAPPED_SUPERCLASS__ID_CLASS = JAVA_TYPE_MAPPING_FEATURE_COUNT + 0; + + /** * The number of structural features of the '<em>Java Mapped Superclass</em>' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - public static final int JAVA_MAPPED_SUPERCLASS_FEATURE_COUNT = JAVA_TYPE_MAPPING_FEATURE_COUNT + 0; + public static final int JAVA_MAPPED_SUPERCLASS_FEATURE_COUNT = JAVA_TYPE_MAPPING_FEATURE_COUNT + 1; /** * The meta object id for the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaEmbeddable <em>Java Embeddable</em>}' class. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/OrmPackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/OrmPackage.java index b9c8d8c0cc..0529c373d9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/OrmPackage.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/OrmPackage.java @@ -664,13 +664,22 @@ public class OrmPackage extends EPackageImpl public static final int XML_MAPPED_SUPERCLASS__PERSISTENT_TYPE = XML_TYPE_MAPPING__PERSISTENT_TYPE; /** + * The feature id for the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XML_MAPPED_SUPERCLASS__ID_CLASS = XML_TYPE_MAPPING_FEATURE_COUNT + 0; + + /** * The number of structural features of the '<em>Xml Mapped Superclass</em>' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - public static final int XML_MAPPED_SUPERCLASS_FEATURE_COUNT = XML_TYPE_MAPPING_FEATURE_COUNT + 0; + public static final int XML_MAPPED_SUPERCLASS_FEATURE_COUNT = XML_TYPE_MAPPING_FEATURE_COUNT + 1; /** * The meta object id for the '{@link org.eclipse.jpt.core.internal.content.orm.XmlEntityInternal <em>Xml Entity Internal</em>}' class. @@ -962,13 +971,22 @@ public class OrmPackage extends EPackageImpl public static final int XML_ENTITY_INTERNAL__NAMED_NATIVE_QUERIES = XML_TYPE_MAPPING_FEATURE_COUNT + 23; /** + * The feature id for the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XML_ENTITY_INTERNAL__ID_CLASS = XML_TYPE_MAPPING_FEATURE_COUNT + 24; + + /** * The feature id for the '<em><b>Secondary Tables</b></em>' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - public static final int XML_ENTITY_INTERNAL__SECONDARY_TABLES = XML_TYPE_MAPPING_FEATURE_COUNT + 24; + public static final int XML_ENTITY_INTERNAL__SECONDARY_TABLES = XML_TYPE_MAPPING_FEATURE_COUNT + 25; /** * The feature id for the '<em><b>Virtual Secondary Tables</b></em>' containment reference list. @@ -977,7 +995,7 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_ENTITY_INTERNAL__VIRTUAL_SECONDARY_TABLES = XML_TYPE_MAPPING_FEATURE_COUNT + 25; + public static final int XML_ENTITY_INTERNAL__VIRTUAL_SECONDARY_TABLES = XML_TYPE_MAPPING_FEATURE_COUNT + 26; /** * The number of structural features of the '<em>Xml Entity Internal</em>' class. @@ -986,7 +1004,7 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_ENTITY_INTERNAL_FEATURE_COUNT = XML_TYPE_MAPPING_FEATURE_COUNT + 26; + public static final int XML_ENTITY_INTERNAL_FEATURE_COUNT = XML_TYPE_MAPPING_FEATURE_COUNT + 27; /** * The meta object id for the '{@link org.eclipse.jpt.core.internal.content.orm.XmlEntityForXml <em>Xml Entity For Xml</em>}' class. @@ -1252,6 +1270,15 @@ public class OrmPackage extends EPackageImpl public static final int XML_ENTITY__NAMED_NATIVE_QUERIES = JpaCoreMappingsPackage.IENTITY__NAMED_NATIVE_QUERIES; /** + * The feature id for the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XML_ENTITY__ID_CLASS = JpaCoreMappingsPackage.IENTITY__ID_CLASS; + + /** * The feature id for the '<em><b>Secondary Tables</b></em>' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlEntityInternal.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlEntityInternal.java index 8544bb7ba9..93ad2a63e9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlEntityInternal.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlEntityInternal.java @@ -304,6 +304,26 @@ public class XmlEntityInternal extends XmlTypeMapping protected EList<INamedNativeQuery> namedNativeQueries; /** + * The default value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getIdClass() + * @generated + * @ordered + */ + protected static final String ID_CLASS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getIdClass() + * @generated + * @ordered + */ + protected String idClass = ID_CLASS_EDEFAULT; + + /** * The cached value of the '{@link #getVirtualSecondaryTables() <em>Virtual Secondary Tables</em>}' containment reference list. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -984,6 +1004,39 @@ public class XmlEntityInternal extends XmlTypeMapping } /** + * Returns the value of the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Id Class</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Id Class</em>' attribute. + * @see #setIdClass(String) + * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getIEntity_IdClass() + * @model + * @generated + */ + public String getIdClass() { + return idClass; + } + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.orm.XmlEntityInternal#getIdClass <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Id Class</em>' attribute. + * @see #getIdClass() + * @generated + */ + public void setIdClass(String newIdClass) { + String oldIdClass = idClass; + idClass = newIdClass; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_ENTITY_INTERNAL__ID_CLASS, oldIdClass, idClass)); + } + + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @model @@ -1224,6 +1277,8 @@ public class XmlEntityInternal extends XmlTypeMapping return getNamedQueries(); case OrmPackage.XML_ENTITY_INTERNAL__NAMED_NATIVE_QUERIES : return getNamedNativeQueries(); + case OrmPackage.XML_ENTITY_INTERNAL__ID_CLASS : + return getIdClass(); case OrmPackage.XML_ENTITY_INTERNAL__SECONDARY_TABLES : return getSecondaryTables(); case OrmPackage.XML_ENTITY_INTERNAL__VIRTUAL_SECONDARY_TABLES : @@ -1301,6 +1356,9 @@ public class XmlEntityInternal extends XmlTypeMapping getNamedNativeQueries().clear(); getNamedNativeQueries().addAll((Collection<? extends INamedNativeQuery>) newValue); return; + case OrmPackage.XML_ENTITY_INTERNAL__ID_CLASS : + setIdClass((String) newValue); + return; case OrmPackage.XML_ENTITY_INTERNAL__VIRTUAL_SECONDARY_TABLES : getVirtualSecondaryTables().clear(); getVirtualSecondaryTables().addAll((Collection<? extends ISecondaryTable>) newValue); @@ -1368,6 +1426,9 @@ public class XmlEntityInternal extends XmlTypeMapping case OrmPackage.XML_ENTITY_INTERNAL__NAMED_NATIVE_QUERIES : getNamedNativeQueries().clear(); return; + case OrmPackage.XML_ENTITY_INTERNAL__ID_CLASS : + setIdClass(ID_CLASS_EDEFAULT); + return; case OrmPackage.XML_ENTITY_INTERNAL__VIRTUAL_SECONDARY_TABLES : getVirtualSecondaryTables().clear(); return; @@ -1431,6 +1492,8 @@ public class XmlEntityInternal extends XmlTypeMapping return namedQueries != null && !namedQueries.isEmpty(); case OrmPackage.XML_ENTITY_INTERNAL__NAMED_NATIVE_QUERIES : return namedNativeQueries != null && !namedNativeQueries.isEmpty(); + case OrmPackage.XML_ENTITY_INTERNAL__ID_CLASS : + return ID_CLASS_EDEFAULT == null ? idClass != null : !ID_CLASS_EDEFAULT.equals(idClass); case OrmPackage.XML_ENTITY_INTERNAL__SECONDARY_TABLES : return !getSecondaryTables().isEmpty(); case OrmPackage.XML_ENTITY_INTERNAL__VIRTUAL_SECONDARY_TABLES : @@ -1502,6 +1565,8 @@ public class XmlEntityInternal extends XmlTypeMapping return JpaCoreMappingsPackage.IENTITY__NAMED_QUERIES; case OrmPackage.XML_ENTITY_INTERNAL__NAMED_NATIVE_QUERIES : return JpaCoreMappingsPackage.IENTITY__NAMED_NATIVE_QUERIES; + case OrmPackage.XML_ENTITY_INTERNAL__ID_CLASS : + return JpaCoreMappingsPackage.IENTITY__ID_CLASS; default : return -1; } @@ -1582,6 +1647,8 @@ public class XmlEntityInternal extends XmlTypeMapping return OrmPackage.XML_ENTITY_INTERNAL__NAMED_QUERIES; case JpaCoreMappingsPackage.IENTITY__NAMED_NATIVE_QUERIES : return OrmPackage.XML_ENTITY_INTERNAL__NAMED_NATIVE_QUERIES; + case JpaCoreMappingsPackage.IENTITY__ID_CLASS : + return OrmPackage.XML_ENTITY_INTERNAL__ID_CLASS; default : return -1; } @@ -1619,6 +1686,8 @@ public class XmlEntityInternal extends XmlTypeMapping result.append(defaultDiscriminatorValue); result.append(", specifiedDiscriminatorValue: "); result.append(specifiedDiscriminatorValue); + result.append(", idClass: "); + result.append(idClass); result.append(')'); return result.toString(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlMappedSuperclass.java index a3bd1285c3..22839b3bc0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlMappedSuperclass.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlMappedSuperclass.java @@ -10,11 +10,14 @@ package org.eclipse.jpt.core.internal.content.orm; import java.util.Iterator; +import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.jpt.core.internal.IMappingKeys; import org.eclipse.jpt.core.internal.IPersistentAttribute; import org.eclipse.jpt.core.internal.mappings.IMappedSuperclass; import org.eclipse.jpt.core.internal.mappings.ITable; +import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; @@ -33,6 +36,26 @@ public class XmlMappedSuperclass extends XmlTypeMapping implements IMappedSuperclass { /** + * The default value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getIdClass() + * @generated + * @ordered + */ + protected static final String ID_CLASS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getIdClass() <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getIdClass() + * @generated + * @ordered + */ + protected String idClass = ID_CLASS_EDEFAULT; + + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated @@ -51,6 +74,149 @@ public class XmlMappedSuperclass extends XmlTypeMapping return OrmPackage.Literals.XML_MAPPED_SUPERCLASS; } + /** + * Returns the value of the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Id Class</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Id Class</em>' attribute. + * @see #setIdClass(String) + * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getIMappedSuperclass_IdClass() + * @model + * @generated + */ + public String getIdClass() { + return idClass; + } + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.orm.XmlMappedSuperclass#getIdClass <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Id Class</em>' attribute. + * @see #getIdClass() + * @generated + */ + public void setIdClass(String newIdClass) { + String oldIdClass = idClass; + idClass = newIdClass; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS, oldIdClass, idClass)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : + return getIdClass(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : + setIdClass((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : + setIdClass(ID_CLASS_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : + return ID_CLASS_EDEFAULT == null ? idClass != null : !ID_CLASS_EDEFAULT.equals(idClass); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { + if (baseClass == IMappedSuperclass.class) { + switch (derivedFeatureID) { + case OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS : + return JpaCoreMappingsPackage.IMAPPED_SUPERCLASS__ID_CLASS; + default : + return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { + if (baseClass == IMappedSuperclass.class) { + switch (baseFeatureID) { + case JpaCoreMappingsPackage.IMAPPED_SUPERCLASS__ID_CLASS : + return OrmPackage.XML_MAPPED_SUPERCLASS__ID_CLASS; + default : + return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (idClass: "); + result.append(idClass); + result.append(')'); + return result.toString(); + } + public String getKey() { return IMappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY; } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/EntityTranslator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/EntityTranslator.java index 1712009660..3adc4ba000 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/EntityTranslator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/EntityTranslator.java @@ -61,7 +61,7 @@ public class EntityTranslator extends TypeMappingTranslator getTableTranslator(), getSecondaryTableTranslator(), createPrimaryKeyJoinColumnsTranslator(), - createPlaceHolderTranslator(ENTITY__ID_CLASS), + createIdClassTranslator(), createInheritanceTranslator(), createDiscriminatorValueTranslator(), getDiscriminatorColumnTranslator(), @@ -176,4 +176,9 @@ public class EntityTranslator extends TypeMappingTranslator } }; } + + protected Translator createIdClassTranslator() { + return new Translator(ID_CLASS + "/" + ID_CLASS__CLASS, JpaCoreMappingsPackage.eINSTANCE.getIEntity_IdClass(), DOM_ATTRIBUTE); + } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/MappedSuperclassTranslator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/MappedSuperclassTranslator.java index caa365391e..b2d52bd8f9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/MappedSuperclassTranslator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/MappedSuperclassTranslator.java @@ -10,6 +10,7 @@ package org.eclipse.jpt.core.internal.content.orm.resource; import org.eclipse.emf.ecore.EObject; import org.eclipse.jpt.core.internal.content.orm.OrmPackage; +import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; import org.eclipse.wst.common.internal.emf.resource.IDTranslator; import org.eclipse.wst.common.internal.emf.resource.Translator; @@ -37,7 +38,7 @@ public class MappedSuperclassTranslator extends TypeMappingTranslator createAccessTypeTranslator(), createMetadataCompleteTranslator(), createPlaceHolderTranslator(ENTITY__DESCRIPTION), - createPlaceHolderTranslator(ENTITY__ID_CLASS), + createIdClassTranslator(), createPlaceHolderTranslator(ENTITY__EXCLUDE_DEFAULT_LISTENERS), createPlaceHolderTranslator(ENTITY__EXCLUDE_SUPERCLASS_LISTENERS), createPlaceHolderTranslator(ENTITY__ENTITY_LISTENERS), @@ -52,5 +53,8 @@ public class MappedSuperclassTranslator extends TypeMappingTranslator }; } + protected Translator createIdClassTranslator() { + return new Translator(ID_CLASS + "/" + ID_CLASS__CLASS, JpaCoreMappingsPackage.eINSTANCE.getIMappedSuperclass_IdClass(), DOM_ATTRIBUTE); + } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/OrmXmlMapper.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/OrmXmlMapper.java index 10e36d470e..194319dd41 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/OrmXmlMapper.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/resource/OrmXmlMapper.java @@ -61,7 +61,6 @@ public interface OrmXmlMapper String ENTITY__DESCRIPTION = "description"; //$NON-NLS-1$ String ENTITY__TABLE = "table"; //$NON-NLS-1$ String ENTITY__PRIMARY_KEY_JOIN_COLUMN = "primary-key-join-column"; //$NON-NLS-1$ - String ENTITY__ID_CLASS = "id-class"; //$NON-NLS-1$ String ENTITY__INHERITANCE = "inheritance"; //$NON-NLS-1$ String ENTITY__DISCRIMINATOR_VALUE = "discriminator-value"; //$NON-NLS-1$ String ENTITY__DISCRIMINATOR_COLUMN = "discriminator-column"; //$NON-NLS-1$ @@ -101,7 +100,10 @@ public interface OrmXmlMapper String JOIN_TABLE = "join-table"; //$NON-NLS-1$ String ID = "id"; //$NON-NLS-1$ String ID__TEMPORAL = "temporal"; //$NON-NLS-1$ - String GENERATED_VALUE = "generated-value"; //$NON-NLS-1$ + String ID_CLASS = "id-class"; //$NON-NLS-1$ + String ID_CLASS__CLASS = "class"; //$NON-NLS-1$ + + String GENERATED_VALUE = "generated-value"; //$NON-NLS-1$ String GENERATED_VALUE__STRATEGY = "strategy"; //$NON-NLS-1$ String GENERATED_VALUE__GENERATOR = "generator"; //$NON-NLS-1$ String GENERATOR__NAME = "name"; //$NON-NLS-1$ diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IEntity.java index 81e657157a..c64adba92f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IEntity.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IEntity.java @@ -47,6 +47,7 @@ import org.eclipse.jpt.db.internal.Table; * <li>{@link org.eclipse.jpt.core.internal.mappings.IEntity#getDefaultAssociationOverrides <em>Default Association Overrides</em>}</li> * <li>{@link org.eclipse.jpt.core.internal.mappings.IEntity#getNamedQueries <em>Named Queries</em>}</li> * <li>{@link org.eclipse.jpt.core.internal.mappings.IEntity#getNamedNativeQueries <em>Named Native Queries</em>}</li> + * <li>{@link org.eclipse.jpt.core.internal.mappings.IEntity#getIdClass <em>Id Class</em>}</li> * </ul> * </p> * @@ -480,6 +481,32 @@ public interface IEntity extends ITypeMapping EList<INamedNativeQuery> getNamedNativeQueries(); /** + * Returns the value of the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Id Class</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Id Class</em>' attribute. + * @see #setIdClass(String) + * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getIEntity_IdClass() + * @model + * @generated + */ + String getIdClass(); + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.internal.mappings.IEntity#getIdClass <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Id Class</em>' attribute. + * @see #getIdClass() + * @generated + */ + void setIdClass(String value); + + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @model diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IMappedSuperclass.java index 47ef55a570..fa513d0f45 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IMappedSuperclass.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IMappedSuperclass.java @@ -16,10 +16,42 @@ import org.eclipse.jpt.core.internal.ITypeMapping; * A representation of the model object '<em><b>Mapped Superclass</b></em>'. * <!-- end-user-doc --> * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.eclipse.jpt.core.internal.mappings.IMappedSuperclass#getIdClass <em>Id Class</em>}</li> + * </ul> + * </p> * * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getIMappedSuperclass() * @model kind="class" interface="true" abstract="true" * @generated */ public interface IMappedSuperclass extends ITypeMapping -{} // MappedSuperclass +{ + /** + * Returns the value of the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Id Class</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Id Class</em>' attribute. + * @see #setIdClass(String) + * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getIMappedSuperclass_IdClass() + * @model + * @generated + */ + String getIdClass(); + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.internal.mappings.IMappedSuperclass#getIdClass <em>Id Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Id Class</em>' attribute. + * @see #getIdClass() + * @generated + */ + void setIdClass(String value); +} // MappedSuperclass diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/JpaCoreMappingsPackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/JpaCoreMappingsPackage.java index 0acb92c816..d81a5ab7ef 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/JpaCoreMappingsPackage.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/JpaCoreMappingsPackage.java @@ -101,13 +101,22 @@ public class JpaCoreMappingsPackage extends EPackageImpl public static final int IMAPPED_SUPERCLASS__TABLE_NAME = JpaCorePackage.ITYPE_MAPPING__TABLE_NAME; /** + * The feature id for the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int IMAPPED_SUPERCLASS__ID_CLASS = JpaCorePackage.ITYPE_MAPPING_FEATURE_COUNT + 0; + + /** * The number of structural features of the '<em>IMapped Superclass</em>' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - public static final int IMAPPED_SUPERCLASS_FEATURE_COUNT = JpaCorePackage.ITYPE_MAPPING_FEATURE_COUNT + 0; + public static final int IMAPPED_SUPERCLASS_FEATURE_COUNT = JpaCorePackage.ITYPE_MAPPING_FEATURE_COUNT + 1; /** * The meta object id for the '{@link org.eclipse.jpt.core.internal.mappings.IEntity <em>IEntity</em>}' class. @@ -336,13 +345,22 @@ public class JpaCoreMappingsPackage extends EPackageImpl public static final int IENTITY__NAMED_NATIVE_QUERIES = JpaCorePackage.ITYPE_MAPPING_FEATURE_COUNT + 21; /** + * The feature id for the '<em><b>Id Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int IENTITY__ID_CLASS = JpaCorePackage.ITYPE_MAPPING_FEATURE_COUNT + 22; + + /** * The number of structural features of the '<em>IEntity</em>' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - public static final int IENTITY_FEATURE_COUNT = JpaCorePackage.ITYPE_MAPPING_FEATURE_COUNT + 22; + public static final int IENTITY_FEATURE_COUNT = JpaCorePackage.ITYPE_MAPPING_FEATURE_COUNT + 23; /** * The meta object id for the '{@link org.eclipse.jpt.core.internal.mappings.IEmbeddable <em>IEmbeddable</em>}' class. @@ -3923,6 +3941,19 @@ public class JpaCoreMappingsPackage extends EPackageImpl } /** + * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.internal.mappings.IMappedSuperclass#getIdClass <em>Id Class</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Id Class</em>'. + * @see org.eclipse.jpt.core.internal.mappings.IMappedSuperclass#getIdClass() + * @see #getIMappedSuperclass() + * @generated + */ + public EAttribute getIMappedSuperclass_IdClass() { + return (EAttribute) iMappedSuperclassEClass.getEStructuralFeatures().get(0); + } + + /** * Returns the meta object for class '{@link org.eclipse.jpt.core.internal.mappings.IEntity <em>IEntity</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -4221,6 +4252,19 @@ public class JpaCoreMappingsPackage extends EPackageImpl } /** + * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.internal.mappings.IEntity#getIdClass <em>Id Class</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Id Class</em>'. + * @see org.eclipse.jpt.core.internal.mappings.IEntity#getIdClass() + * @see #getIEntity() + * @generated + */ + public EAttribute getIEntity_IdClass() { + return (EAttribute) iEntityEClass.getEStructuralFeatures().get(22); + } + + /** * Returns the meta object for class '{@link org.eclipse.jpt.core.internal.mappings.IEmbeddable <em>IEmbeddable</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -6347,6 +6391,7 @@ public class JpaCoreMappingsPackage extends EPackageImpl isCreated = true; // Create classes and their features iMappedSuperclassEClass = createEClass(IMAPPED_SUPERCLASS); + createEAttribute(iMappedSuperclassEClass, IMAPPED_SUPERCLASS__ID_CLASS); iEntityEClass = createEClass(IENTITY); createEAttribute(iEntityEClass, IENTITY__SPECIFIED_NAME); createEAttribute(iEntityEClass, IENTITY__DEFAULT_NAME); @@ -6370,6 +6415,7 @@ public class JpaCoreMappingsPackage extends EPackageImpl createEReference(iEntityEClass, IENTITY__DEFAULT_ASSOCIATION_OVERRIDES); createEReference(iEntityEClass, IENTITY__NAMED_QUERIES); createEReference(iEntityEClass, IENTITY__NAMED_NATIVE_QUERIES); + createEAttribute(iEntityEClass, IENTITY__ID_CLASS); iEmbeddableEClass = createEClass(IEMBEDDABLE); iTableEClass = createEClass(ITABLE); createEAttribute(iTableEClass, ITABLE__NAME); @@ -6616,6 +6662,7 @@ public class JpaCoreMappingsPackage extends EPackageImpl iQueryHintEClass.getESuperTypes().add(theJpaCorePackage.getIJpaSourceObject()); // Initialize classes and features; add operations and parameters initEClass(iMappedSuperclassEClass, IMappedSuperclass.class, "IMappedSuperclass", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getIMappedSuperclass_IdClass(), theEcorePackage.getEString(), "idClass", null, 0, 1, IMappedSuperclass.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(iEntityEClass, IEntity.class, "IEntity", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getIEntity_SpecifiedName(), ecorePackage.getEString(), "specifiedName", null, 0, 1, IEntity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getIEntity_DefaultName(), ecorePackage.getEString(), "defaultName", null, 0, 1, IEntity.class, !IS_TRANSIENT, !IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); @@ -6639,6 +6686,7 @@ public class JpaCoreMappingsPackage extends EPackageImpl initEReference(getIEntity_DefaultAssociationOverrides(), this.getIAssociationOverride(), null, "defaultAssociationOverrides", null, 0, -1, IEntity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getIEntity_NamedQueries(), this.getINamedQuery(), null, "namedQueries", null, 0, -1, IEntity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getIEntity_NamedNativeQueries(), this.getINamedNativeQuery(), null, "namedNativeQueries", null, 0, -1, IEntity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getIEntity_IdClass(), theEcorePackage.getEString(), "idClass", null, 0, 1, IEntity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); addEOperation(iEntityEClass, ecorePackage.getEBoolean(), "discriminatorValueIsAllowed", 0, 1); addEOperation(iEntityEClass, this.getISecondaryTable(), "getSecondaryTables", 0, -1); addEOperation(iEntityEClass, this.getIEntity(), "parentEntity", 0, 1); @@ -6875,6 +6923,14 @@ public class JpaCoreMappingsPackage extends EPackageImpl public static final EClass IMAPPED_SUPERCLASS = eINSTANCE.getIMappedSuperclass(); /** + * The meta object literal for the '<em><b>Id Class</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute IMAPPED_SUPERCLASS__ID_CLASS = eINSTANCE.getIMappedSuperclass_IdClass(); + + /** * The meta object literal for the '{@link org.eclipse.jpt.core.internal.mappings.IEntity <em>IEntity</em>}' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -7061,6 +7117,14 @@ public class JpaCoreMappingsPackage extends EPackageImpl public static final EReference IENTITY__NAMED_NATIVE_QUERIES = eINSTANCE.getIEntity_NamedNativeQueries(); /** + * The meta object literal for the '<em><b>Id Class</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute IENTITY__ID_CLASS = eINSTANCE.getIEntity_IdClass(); + + /** * The meta object literal for the '{@link org.eclipse.jpt.core.internal.mappings.IEmbeddable <em>IEmbeddable</em>}' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> |