Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java230
1 files changed, 228 insertions, 2 deletions
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());
+ }
+
}

Back to the top