diff options
author | bvosburgh | 2007-05-11 22:41:39 +0000 |
---|---|---|
committer | bvosburgh | 2007-05-11 22:41:39 +0000 |
commit | ae0d57869b3b35ad744674879c71cff004e72f49 (patch) | |
tree | 7cc63fb276400a41eecbe832577a8f30b68e78b7 /jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings | |
parent | 0d2779575354530ac26569c9b37e0f5ced464394 (diff) | |
download | webtools.dali-ae0d57869b3b35ad744674879c71cff004e72f49.tar.gz webtools.dali-ae0d57869b3b35ad744674879c71cff004e72f49.tar.xz webtools.dali-ae0d57869b3b35ad744674879c71cff004e72f49.zip |
[181471] added more code-completion
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings')
28 files changed, 477 insertions, 360 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/AbstractJavaTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/AbstractJavaTable.java index 81c9a282a6..6f86e91312 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/AbstractJavaTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/AbstractJavaTable.java @@ -33,7 +33,6 @@ import org.eclipse.jpt.core.internal.mappings.IUniqueConstraint; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; import org.eclipse.jpt.core.internal.platform.BaseJpaPlatform; import org.eclipse.jpt.core.internal.platform.DefaultsContext; -import org.eclipse.jpt.db.internal.ConnectionProfile; import org.eclipse.jpt.db.internal.Schema; import org.eclipse.jpt.db.internal.Table; import org.eclipse.jpt.utility.internal.Filter; @@ -932,11 +931,6 @@ public abstract class AbstractJavaTable extends JavaEObject implements ITable return this.database().schemaNamed(this.getSchema()); } - public boolean isConnected() { - ConnectionProfile cp = this.connectionProfile(); - return (cp != null) && cp.isConnected(); - } - public boolean hasResolvedSchema() { return this.dbSchema() != null; } @@ -961,21 +955,16 @@ public abstract class AbstractJavaTable extends JavaEObject implements ITable return this.elementTouches(this.member.annotationElementTextRange(elementAdapter, astRoot), pos); } - public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { - if (this.isConnected()) { - Iterator<String> result = this.connectedCandidateValuesFor(pos, filter, astRoot); - if (result != null) { - return result; - } - } - return null; - } - /** * called if the database is connected * name, schema, catalog */ - protected Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + @Override + public Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } if (this.nameTouches(pos, astRoot)) { return this.quotedCandidateNames(filter); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/IntAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/IntAnnotationElementAdapter.java index f5a3ff5b10..1660481a5b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/IntAnnotationElementAdapter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/IntAnnotationElementAdapter.java @@ -27,9 +27,9 @@ import org.eclipse.jpt.utility.internal.StringTools; * These assumptions work reasonably enough with the JPA requirements. */ public class IntAnnotationElementAdapter { - private final AnnotationElementAdapter adapter; + private final AnnotationElementAdapter<String> adapter; - public IntAnnotationElementAdapter(AnnotationElementAdapter adapter) { + public IntAnnotationElementAdapter(AnnotationElementAdapter<String> adapter) { super(); this.adapter = adapter; } @@ -77,14 +77,14 @@ public class IntAnnotationElementAdapter { this.adapter.setValue(this.convertIntToValue(value)); } - protected Object convertIntToValue(int intValue) { + protected String convertIntToValue(int intValue) { return this.convertStringToValue(this.convertIntToString(intValue)); } /** * assume the wrapped adapter expects a string */ - protected Object convertStringToValue(String stringValue) { + protected String convertStringToValue(String stringValue) { return stringValue; } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAbstractQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAbstractQuery.java index 6fb709c33b..bc6aba495a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAbstractQuery.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAbstractQuery.java @@ -54,16 +54,16 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery private final IndexedDeclarationAnnotationAdapter idaa; // hold this so we can get the 'name' text range - private final DeclarationAnnotationElementAdapter nameDeclarationAdapter; + private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; // hold this so we can get the 'query' text range - private final DeclarationAnnotationElementAdapter queryDeclarationAdapter; + private final DeclarationAnnotationElementAdapter<String> queryDeclarationAdapter; private final IndexedAnnotationAdapter annotationAdapter; - private final AnnotationElementAdapter nameAdapter; + private final AnnotationElementAdapter<String> nameAdapter; - private final AnnotationElementAdapter queryAdapter; + private final AnnotationElementAdapter<String> queryAdapter; /** * The default value of the '{@link #getName() <em>Name</em>}' attribute. @@ -131,15 +131,15 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery } // ********** initialization ********** - protected AnnotationElementAdapter buildAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(this.member, daea); + protected AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { + return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); } - protected DeclarationAnnotationElementAdapter nameAdapter(DeclarationAnnotationAdapter daa) { + protected DeclarationAnnotationElementAdapter<String> nameAdapter(DeclarationAnnotationAdapter daa) { return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, nameElementName()); } - protected DeclarationAnnotationElementAdapter queryAdapter(DeclarationAnnotationAdapter daa) { + protected DeclarationAnnotationElementAdapter<String> queryAdapter(DeclarationAnnotationAdapter daa) { return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, queryElementName()); } @@ -152,10 +152,10 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery super.notifyChanged(notification); switch (notification.getFeatureID(IQuery.class)) { case JpaCoreMappingsPackage.IQUERY__NAME : - this.nameAdapter.setValue(notification.getNewValue()); + this.nameAdapter.setValue((String) notification.getNewValue()); break; case JpaCoreMappingsPackage.IQUERY__QUERY : - this.queryAdapter.setValue(notification.getNewValue()); + this.queryAdapter.setValue((String) notification.getNewValue()); break; case JpaCoreMappingsPackage.IQUERY__HINTS : hintsChanged(notification); @@ -165,6 +165,7 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery } } + @SuppressWarnings("unchecked") void hintsChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : @@ -472,12 +473,12 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery } // bjv look at this - public void hintsAdded(int index, List<IQueryHint> hints) { + public void hintsAdded(int index, List<IQueryHint> queryHints) { //JoinColumn was added to persistence model when udating from java, do not need //to edit the java in this case. TODO is there a better way to handle this?? - if (!hints.isEmpty() && ((JavaQueryHint) hints.get(0)).annotation(getMember().astRoot()) == null) { - this.synchHintAnnotationsAfterAdd(index + hints.size()); - for (IQueryHint hint : hints) { + if (!queryHints.isEmpty() && ((JavaQueryHint) queryHints.get(0)).annotation(getMember().astRoot()) == null) { + this.synchHintAnnotationsAfterAdd(index + queryHints.size()); + for (IQueryHint hint : queryHints) { ((JavaQueryHint) hint).newAnnotation(); } } @@ -488,15 +489,15 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery this.synchHintAnnotationsAfterRemove(index); } - public void hintsRemoved(int[] indexes, List<IQueryHint> hints) { - for (IQueryHint hint : hints) { + public void hintsRemoved(int[] indexes, List<IQueryHint> queryHints) { + for (IQueryHint hint : queryHints) { ((JavaQueryHint) hint).removeAnnotation(); } this.synchHintAnnotationsAfterRemove(indexes[0]); } - public void hintsCleared(List<IQueryHint> hints) { - for (IQueryHint hint : hints) { + public void hintsCleared(List<IQueryHint> queryHints) { + for (IQueryHint hint : queryHints) { ((JavaQueryHint) hint).removeAnnotation(); } } @@ -506,11 +507,11 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery } public void hintMoved(int sourceIndex, int targetIndex, IQueryHint hint) { - List<IQueryHint> hints = this.getHints(); + List<IQueryHint> queryHints = this.getHints(); int begin = Math.min(sourceIndex, targetIndex); int end = Math.max(sourceIndex, targetIndex); for (int i = begin; i-- > end;) { - this.synch(hints.get(i), i); + this.synch(queryHints.get(i), i); } } @@ -519,9 +520,9 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery * starting at the end of the list to prevent overlap */ private void synchHintAnnotationsAfterAdd(int index) { - List<IQueryHint> hints = this.getHints(); - for (int i = hints.size(); i-- > index;) { - this.synch(hints.get(i), i); + List<IQueryHint> queryHints = this.getHints(); + for (int i = queryHints.size(); i-- > index;) { + this.synch(queryHints.get(i), i); } } @@ -530,9 +531,9 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery * starting at the specified index to prevent overlap */ private void synchHintAnnotationsAfterRemove(int index) { - List<IQueryHint> hints = this.getHints(); - for (int i = index; i < hints.size(); i++) { - this.synch(hints.get(i), i); + List<IQueryHint> queryHints = this.getHints(); + for (int i = index; i < queryHints.size(); i++) { + this.synch(queryHints.get(i), i); } } @@ -548,8 +549,8 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery } protected void updateFromJava(CompilationUnit astRoot) { - this.setName((String) this.nameAdapter.getValue(astRoot)); - this.setQuery((String) this.queryAdapter.getValue(astRoot)); + this.setName(this.nameAdapter.getValue(astRoot)); + this.setQuery(this.queryAdapter.getValue(astRoot)); this.updateQueryHintsFromJava(astRoot); } @@ -624,7 +625,7 @@ public abstract class JavaAbstractQuery extends JavaEObject implements IQuery } // ********** static methods ********** - protected static DeclarationAnnotationElementAdapter buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + protected static DeclarationAnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { return ConversionDeclarationAnnotationElementAdapter.forStrings(annotationAdapter, elementName); } } // JavaAbstractQuery diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAssociationOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAssociationOverride.java index bae1681686..2aa6f7c3a6 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAssociationOverride.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAssociationOverride.java @@ -10,6 +10,7 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Collection; +import java.util.Iterator; import java.util.List; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; @@ -18,6 +19,7 @@ import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.ITypeMapping; import org.eclipse.jpt.core.internal.jdtutility.CombinationIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.IndexedDeclarationAnnotationAdapter; @@ -27,6 +29,7 @@ import org.eclipse.jpt.core.internal.mappings.IAssociationOverride; import org.eclipse.jpt.core.internal.mappings.IJoinColumn; import org.eclipse.jpt.core.internal.mappings.IJoinTable; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; +import org.eclipse.jpt.utility.internal.Filter; /** * <!-- begin-user-doc --> @@ -92,6 +95,7 @@ public class JavaAssociationOverride extends JavaOverride } } + @SuppressWarnings("unchecked") void specifiedJoinColumnsChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : @@ -424,6 +428,26 @@ public class JavaAssociationOverride extends JavaOverride ((JavaJoinColumn) joinColumn).moveAnnotation(index); } + @Override + protected Iterator<String> candidateNames() { + return this.getOwner().getTypeMapping().overridableAssociationNames(); + } + + @Override + public Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + for (IJoinColumn column : this.getJoinColumns()) { + result = ((JavaJoinColumn) column).connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + return null; + } + static JavaAssociationOverride createAssociationOverride(Owner owner, Member member, int index) { return JpaJavaMappingsFactory.eINSTANCE.createJavaAssociationOverride(owner, member, buildAnnotationAdapter(index)); } @@ -431,4 +455,4 @@ public class JavaAssociationOverride extends JavaOverride private static IndexedDeclarationAnnotationAdapter buildAnnotationAdapter(int index) { return new CombinationIndexedDeclarationAnnotationAdapter(SINGLE_DECLARATION_ANNOTATION_ADAPTER, MULTIPLE_DECLARATION_ANNOTATION_ADAPTER, index, JPA.ASSOCIATION_OVERRIDE); } -} // JavaAssociationOverride +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAttributeMapping.java index 748ff0a0d1..a12eeeaa59 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAttributeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAttributeMapping.java @@ -9,7 +9,6 @@ ******************************************************************************/ package org.eclipse.jpt.core.internal.content.java.mappings; -import java.util.Iterator; import org.eclipse.emf.ecore.EClass; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.dom.CompilationUnit; @@ -26,7 +25,6 @@ import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationAdapter; import org.eclipse.jpt.core.internal.mappings.INamedColumn; import org.eclipse.jpt.core.internal.platform.DefaultsContext; import org.eclipse.jpt.db.internal.Table; -import org.eclipse.jpt.utility.internal.Filter; /** * <!-- begin-user-doc --> @@ -139,10 +137,6 @@ public abstract class JavaAttributeMapping extends JavaEObject return this.elementTouches(this.attribute.annotationElementTextRange(elementAdapter, astRoot), pos); } - public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { - return null; - } - public boolean isOverridableAttributeMapping() { return false; } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAttributeOverride.java index b41f85aa03..1bd1141e26 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAttributeOverride.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaAttributeOverride.java @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.core.internal.content.java.mappings; +import java.util.Iterator; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; @@ -27,6 +28,7 @@ import org.eclipse.jpt.core.internal.mappings.IColumnMapping; import org.eclipse.jpt.core.internal.mappings.INamedColumn; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; import org.eclipse.jpt.db.internal.Table; +import org.eclipse.jpt.utility.internal.Filter; /** * <!-- begin-user-doc --> @@ -213,7 +215,29 @@ public class JavaAttributeOverride extends JavaOverride @Override public void updateFromJava(CompilationUnit astRoot) { super.updateFromJava(astRoot); - ((JavaColumn) getColumn()).updateFromJava(astRoot); + this.getJavaColumn().updateFromJava(astRoot); + } + + private JavaColumn getJavaColumn() { + return (JavaColumn) this.column; + } + + @Override + protected Iterator<String> candidateNames() { + return this.getOwner().getTypeMapping().overridableAttributeNames(); + } + + @Override + public Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + result = this.getJavaColumn().connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + return null; } // ********** static methods ********** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasic.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasic.java index 7903c1ccf0..7ab0f41a1a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasic.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasic.java @@ -21,6 +21,7 @@ import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.WorkingCopyOwner; +import org.eclipse.jdt.core.dom.BooleanLiteral; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.IMappingKeys; import org.eclipse.jpt.core.internal.jdtutility.AnnotationAdapter; @@ -60,33 +61,33 @@ import org.eclipse.jpt.utility.internal.Filter; */ public class JavaBasic extends JavaAttributeMapping implements IBasic { - private final AnnotationElementAdapter optionalAdapter; + private final AnnotationElementAdapter<String> optionalAdapter; - private final AnnotationElementAdapter fetchAdapter; + private final AnnotationElementAdapter<String> fetchAdapter; private final AnnotationAdapter temporalAnnotationAdapter; - private final AnnotationElementAdapter temporalValueAdapter; + private final AnnotationElementAdapter<String> temporalValueAdapter; private final AnnotationAdapter enumeratedAnnotationAdapter; - private final AnnotationElementAdapter enumeratedValueAdapter; + private final AnnotationElementAdapter<String> enumeratedValueAdapter; private final BooleanAnnotationAdapter lobAdapter; public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.BASIC); - private static final DeclarationAnnotationElementAdapter OPTIONAL_ADAPTER = buildOptionalAdapter(); + private static final DeclarationAnnotationElementAdapter<String> OPTIONAL_ADAPTER = buildOptionalAdapter(); - private static final DeclarationAnnotationElementAdapter FETCH_ADAPTER = buildFetchAdapter(); + private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); public static final DeclarationAnnotationAdapter TEMPORAL_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.TEMPORAL); - private static final DeclarationAnnotationElementAdapter TEMPORAL_VALUE_ADAPTER = buildTemporalValueAdapter(); + private static final DeclarationAnnotationElementAdapter<String> TEMPORAL_VALUE_ADAPTER = buildTemporalValueAdapter(); public static final DeclarationAnnotationAdapter ENUMERATED_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.ENUMERATED); - private static final DeclarationAnnotationElementAdapter ENUMERATED_VALUE_ADAPTER = buildEnumeratedValueAdapter(); + private static final DeclarationAnnotationElementAdapter<String> ENUMERATED_VALUE_ADAPTER = buildEnumeratedValueAdapter(); public static final DeclarationAnnotationAdapter LOB_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.LOB); @@ -208,13 +209,13 @@ public class JavaBasic extends JavaAttributeMapping implements IBasic super(attribute); this.column = JavaColumn.createColumnMappingColumn(buildColumnOwner(), getAttribute()); ((InternalEObject) this.column).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JpaJavaMappingsPackage.JAVA_BASIC__COLUMN, null, null); - this.optionalAdapter = new ShortCircuitAnnotationElementAdapter(attribute, OPTIONAL_ADAPTER); - this.fetchAdapter = new ShortCircuitAnnotationElementAdapter(attribute, FETCH_ADAPTER); + this.optionalAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, OPTIONAL_ADAPTER); + this.fetchAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); this.lobAdapter = new SimpleBooleanAnnotationAdapter(new MemberAnnotationAdapter(attribute, LOB_ADAPTER)); this.temporalAnnotationAdapter = new MemberAnnotationAdapter(this.getAttribute(), TEMPORAL_ADAPTER); - this.temporalValueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, TEMPORAL_VALUE_ADAPTER); + this.temporalValueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, TEMPORAL_VALUE_ADAPTER); this.enumeratedAnnotationAdapter = new MemberAnnotationAdapter(this.getAttribute(), ENUMERATED_ADAPTER); - this.enumeratedValueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, ENUMERATED_VALUE_ADAPTER); + this.enumeratedValueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, ENUMERATED_VALUE_ADAPTER); } @Override @@ -738,11 +739,11 @@ public class JavaBasic extends JavaAttributeMapping implements IBasic } // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildOptionalAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__OPTIONAL, false, BooleanStringExpressionConverter.instance()); + private static DeclarationAnnotationElementAdapter<String> buildOptionalAdapter() { + return new ConversionDeclarationAnnotationElementAdapter<String, BooleanLiteral>(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__OPTIONAL, false, BooleanStringExpressionConverter.instance()); } - private static DeclarationAnnotationElementAdapter buildFetchAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__FETCH, false); } @@ -927,11 +928,11 @@ public class JavaBasic extends JavaAttributeMapping implements IBasic } // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildTemporalValueAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildTemporalValueAdapter() { return new EnumDeclarationAnnotationElementAdapter(TEMPORAL_ADAPTER, JPA.TEMPORAL__VALUE, false); } - private static DeclarationAnnotationElementAdapter buildEnumeratedValueAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildEnumeratedValueAdapter() { return new EnumDeclarationAnnotationElementAdapter(ENUMERATED_ADAPTER, JPA.ENUMERATED__VALUE, false); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEmbedded.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEmbedded.java index 129e6002c1..d4551755c8 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEmbedded.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEmbedded.java @@ -33,6 +33,7 @@ import org.eclipse.jpt.core.internal.mappings.IEmbedded; import org.eclipse.jpt.core.internal.mappings.IEntity; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; import org.eclipse.jpt.core.internal.platform.DefaultsContext; +import org.eclipse.jpt.utility.internal.Filter; import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; @@ -100,6 +101,7 @@ public class JavaEmbedded extends JavaAttributeMapping implements IEmbedded } } + @SuppressWarnings("unchecked") void attributeOverridesChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : @@ -531,6 +533,21 @@ public class JavaEmbedded extends JavaAttributeMapping implements IEmbedded return JavaAttributeOverride.createAttributeOverride(new AttributeOverrideOwner(this), this.getAttribute(), index); } + @Override + public Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + for (IAttributeOverride override : this.getAttributeOverrides()) { + result = ((JavaAttributeOverride) override).connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + return null; + } + //******* static methods ********* public static IEmbeddable embeddableFor(Attribute attribute, DefaultsContext defaultsContext) { String resolvedTypeName = attribute.resolvedTypeName(); 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 dae6b7c23a..05499c0825 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 @@ -23,6 +23,7 @@ import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.dom.TypeLiteral; import org.eclipse.jpt.core.internal.IMappingKeys; import org.eclipse.jpt.core.internal.IPersistentAttribute; import org.eclipse.jpt.core.internal.IPersistentType; @@ -334,11 +335,11 @@ public class JavaEntity extends JavaTypeMapping implements IEntity */ protected String idClass = ID_CLASS_EDEFAULT; - private AnnotationElementAdapter nameAdapter; + private AnnotationElementAdapter<String> nameAdapter; - private AnnotationElementAdapter inheritanceStrategyAdapter; + private AnnotationElementAdapter<String> inheritanceStrategyAdapter; - private final AnnotationElementAdapter discriminatorValueAdapter; + private final AnnotationElementAdapter<String> discriminatorValueAdapter; private AnnotationAdapter tableGeneratorAnnotationAdapter; @@ -346,23 +347,23 @@ public class JavaEntity extends JavaTypeMapping implements IEntity private final AnnotationAdapter idClassAnnotationAdapter; - private final AnnotationElementAdapter idClassValueAdapter; + private final AnnotationElementAdapter<String> idClassValueAdapter; public static final DeclarationAnnotationAdapter ID_CLASS_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.ID_CLASS); - private static final DeclarationAnnotationElementAdapter ID_CLASS_VALUE_ADAPTER = buildIdClassValueAdapter(); + private static final DeclarationAnnotationElementAdapter<String> ID_CLASS_VALUE_ADAPTER = buildIdClassValueAdapter(); public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.ENTITY); - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildNameAdapter(); + private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildNameAdapter(); private static final DeclarationAnnotationAdapter INHERITANCE_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.INHERITANCE); - private static final DeclarationAnnotationElementAdapter INHERITANCE_STRATEGY_ADAPTER = buildStrategyAdapter(); + private static final DeclarationAnnotationElementAdapter<String> INHERITANCE_STRATEGY_ADAPTER = buildStrategyAdapter(); private static final DeclarationAnnotationAdapter DISCRIMINATOR_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.DISCRIMINATOR_VALUE); - private static final DeclarationAnnotationElementAdapter DISCRIMINATOR_VALUE_ADAPTER = buildDiscriminatorValueAdapter(); + private static final DeclarationAnnotationElementAdapter<String> DISCRIMINATOR_VALUE_ADAPTER = buildDiscriminatorValueAdapter(); protected JavaEntity() { this(null); @@ -376,11 +377,11 @@ public class JavaEntity extends JavaTypeMapping implements IEntity ((InternalEObject) this.discriminatorColumn).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JpaJavaMappingsPackage.JAVA_ENTITY__DISCRIMINATOR_COLUMN, null, null); // this.getDefaultPrimaryKeyJoinColumns().add(this.createPrimaryKeyJoinColumn(IPrimaryKeyJoinColumnModelAdapter.DEFAULT)); // this.eAdapters().add(this.buildListener()); - this.nameAdapter = new ShortCircuitAnnotationElementAdapter(getType(), NAME_ADAPTER); - this.inheritanceStrategyAdapter = new ShortCircuitAnnotationElementAdapter(type, INHERITANCE_STRATEGY_ADAPTER); - this.discriminatorValueAdapter = new ShortCircuitAnnotationElementAdapter(type, DISCRIMINATOR_VALUE_ADAPTER); + this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(getType(), NAME_ADAPTER); + this.inheritanceStrategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, INHERITANCE_STRATEGY_ADAPTER); + this.discriminatorValueAdapter = new ShortCircuitAnnotationElementAdapter<String>(type, DISCRIMINATOR_VALUE_ADAPTER); this.idClassAnnotationAdapter = new MemberAnnotationAdapter(this.getType(), ID_CLASS_ADAPTER); - this.idClassValueAdapter = new ShortCircuitAnnotationElementAdapter(this.getType(), ID_CLASS_VALUE_ADAPTER); + this.idClassValueAdapter = new ShortCircuitAnnotationElementAdapter<String>(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); @@ -403,7 +404,7 @@ public class JavaEntity extends JavaTypeMapping implements IEntity return DECLARATION_ANNOTATION_ADAPTER; } - private static DeclarationAnnotationElementAdapter buildNameAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildNameAdapter() { return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ENTITY__NAME, false); // false = do not remove annotation when empty } @@ -419,13 +420,13 @@ public class JavaEntity extends JavaTypeMapping implements IEntity super.notifyChanged(notification); switch (notification.getFeatureID(IEntity.class)) { case JpaJavaMappingsPackage.JAVA_ENTITY__SPECIFIED_NAME : - this.nameAdapter.setValue(notification.getNewValue()); + this.nameAdapter.setValue((String) notification.getNewValue()); break; case JpaJavaMappingsPackage.JAVA_ENTITY__INHERITANCE_STRATEGY : this.inheritanceStrategyAdapter.setValue(((InheritanceType) notification.getNewValue()).convertToJavaAnnotationValue()); break; case JpaJavaMappingsPackage.JAVA_ENTITY__SPECIFIED_DISCRIMINATOR_VALUE : - this.discriminatorValueAdapter.setValue(notification.getNewValue()); + this.discriminatorValueAdapter.setValue((String) notification.getNewValue()); break; case JpaCoreMappingsPackage.IENTITY__SPECIFIED_ATTRIBUTE_OVERRIDES : this.attributeOverridesChanged(notification); @@ -452,18 +453,19 @@ public class JavaEntity extends JavaTypeMapping implements IEntity attributeChanged(notification.getNewValue(), this.sequenceGeneratorAnnotationAdapter); break; case JpaCoreMappingsPackage.IENTITY__ID_CLASS : - String idClass = (String) notification.getNewValue(); - if (idClass == null) { + String newIdClass = (String) notification.getNewValue(); + if (newIdClass == null) { this.idClassAnnotationAdapter.removeAnnotation(); } else { - this.idClassValueAdapter.setValue(idClass); + this.idClassValueAdapter.setValue(newIdClass); } default : break; } } + @SuppressWarnings("unchecked") void attributeOverridesChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : @@ -477,11 +479,11 @@ public class JavaEntity extends JavaTypeMapping implements IEntity break; case Notification.REMOVE_MANY : if (notification.getPosition() == Notification.NO_INDEX) { - attributeOverridesCleared((List) notification.getOldValue()); + attributeOverridesCleared((List<JavaAttributeOverride>) notification.getOldValue()); } else { // Notification.getNewValue() returns an array of the positions of objects that were removed - attributeOverridesRemoved((int[]) notification.getNewValue(), (List) notification.getOldValue()); + attributeOverridesRemoved((int[]) notification.getNewValue(), (List<JavaAttributeOverride>) notification.getOldValue()); } break; case Notification.SET : @@ -500,6 +502,7 @@ public class JavaEntity extends JavaTypeMapping implements IEntity } } + @SuppressWarnings("unchecked") void associationOverridesChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : @@ -540,24 +543,25 @@ public class JavaEntity extends JavaTypeMapping implements IEntity throw new IllegalStateException("'defaultJoinColumns' cannot be changed"); } + @SuppressWarnings("unchecked") void secondaryTablesChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : secondaryTableAdded(notification.getPosition(), (JavaSecondaryTable) notification.getNewValue()); break; case Notification.ADD_MANY : - secondaryTablesAdded(notification.getPosition(), (List) notification.getNewValue()); + secondaryTablesAdded(notification.getPosition(), (List<ISecondaryTable>) notification.getNewValue()); break; case Notification.REMOVE : secondaryTableRemoved(notification.getPosition(), (JavaSecondaryTable) notification.getOldValue()); break; case Notification.REMOVE_MANY : if (notification.getPosition() == Notification.NO_INDEX) { - secondaryTablesCleared((List) notification.getOldValue()); + secondaryTablesCleared((List<ISecondaryTable>) notification.getOldValue()); } else { // Notification.getNewValue() returns an array of the positions of objects that were removed - secondaryTablesRemoved((int[]) notification.getNewValue(), (List) notification.getOldValue()); + secondaryTablesRemoved((int[]) notification.getNewValue(), (List<ISecondaryTable>) notification.getOldValue()); } break; case Notification.SET : @@ -576,24 +580,25 @@ public class JavaEntity extends JavaTypeMapping implements IEntity } } + @SuppressWarnings("unchecked") void specifiedPrimaryKeyJoinColumnsChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : specifiedPrimaryKeyJoinColumnAdded(notification.getPosition(), (JavaPrimaryKeyJoinColumn) notification.getNewValue()); break; case Notification.ADD_MANY : - specifiedPrimaryKeyJoinColumnsAdded(notification.getPosition(), (List) notification.getNewValue()); + specifiedPrimaryKeyJoinColumnsAdded(notification.getPosition(), (List<IPrimaryKeyJoinColumn>) notification.getNewValue()); break; case Notification.REMOVE : specifiedPrimaryKeyJoinColumnRemoved(notification.getPosition(), (JavaPrimaryKeyJoinColumn) notification.getOldValue()); break; case Notification.REMOVE_MANY : if (notification.getPosition() == Notification.NO_INDEX) { - specifiedPrimaryKeyJoinColumnsCleared((List) notification.getOldValue()); + specifiedPrimaryKeyJoinColumnsCleared((List<IPrimaryKeyJoinColumn>) notification.getOldValue()); } else { // Notification.getNewValue() returns an array of the positions of objects that were removed - specifiedPrimaryKeyJoinColumnsRemoved((int[]) notification.getNewValue(), (List) notification.getOldValue()); + specifiedPrimaryKeyJoinColumnsRemoved((int[]) notification.getNewValue(), (List<IPrimaryKeyJoinColumn>) notification.getOldValue()); } break; case Notification.SET : @@ -612,6 +617,7 @@ public class JavaEntity extends JavaTypeMapping implements IEntity } } + @SuppressWarnings("unchecked") void namedQueriesChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : @@ -648,6 +654,7 @@ public class JavaEntity extends JavaTypeMapping implements IEntity } } + @SuppressWarnings("unchecked") void namedNativeQueriesChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : @@ -964,7 +971,7 @@ public class JavaEntity extends JavaTypeMapping implements IEntity this.synchPKJCAnnotationsAfterRemove(indexes[0]); } - public void specifiedPrimaryKeyJoinColumnsCleared(List primaryKeyJoinColumns) { + public void specifiedPrimaryKeyJoinColumnsCleared(List<IPrimaryKeyJoinColumn> primaryKeyJoinColumns) { for (Iterator<IPrimaryKeyJoinColumn> stream = primaryKeyJoinColumns.iterator(); stream.hasNext();) { JavaPrimaryKeyJoinColumn primaryKeyJoinColumn = (JavaPrimaryKeyJoinColumn) stream.next(); primaryKeyJoinColumn.removeAnnotation(); @@ -1000,7 +1007,7 @@ public class JavaEntity extends JavaTypeMapping implements IEntity * starting at the specified index to prevent overlap */ private void synchPKJCAnnotationsAfterRemove(int index) { - List primaryKeyJoinColumns = getSpecifiedPrimaryKeyJoinColumns(); + List<IPrimaryKeyJoinColumn> primaryKeyJoinColumns = getSpecifiedPrimaryKeyJoinColumns(); for (int i = index; i < primaryKeyJoinColumns.size(); i++) { this.synch((JavaPrimaryKeyJoinColumn) primaryKeyJoinColumns.get(i), i); } @@ -1023,12 +1030,12 @@ public class JavaEntity extends JavaTypeMapping implements IEntity } } - public void namedQueriesAdded(int index, List<JavaNamedQuery> namedQueries) { + public void namedQueriesAdded(int index, List<JavaNamedQuery> queries) { //JoinColumn was added to persistence model when udating from java, do not need //to edit the java in this case. TODO is there a better way to handle this?? - if (!namedQueries.isEmpty() && namedQueries.get(0).annotation(getType().astRoot()) == null) { - this.synchNamedQueryAnnotationsAfterAdd(index + namedQueries.size()); - for (JavaNamedQuery namedQuery : namedQueries) { + if (!queries.isEmpty() && queries.get(0).annotation(getType().astRoot()) == null) { + this.synchNamedQueryAnnotationsAfterAdd(index + queries.size()); + for (JavaNamedQuery namedQuery : queries) { namedQuery.newAnnotation(); } } @@ -1039,15 +1046,15 @@ public class JavaEntity extends JavaTypeMapping implements IEntity this.synchNamedQueryAnnotationsAfterRemove(index); } - public void namedQueriesRemoved(int[] indexes, List<JavaNamedQuery> namedQueries) { - for (JavaNamedQuery namedQuery : namedQueries) { + public void namedQueriesRemoved(int[] indexes, List<JavaNamedQuery> queries) { + for (JavaNamedQuery namedQuery : queries) { namedQuery.removeAnnotation(); } this.synchNamedQueryAnnotationsAfterRemove(indexes[0]); } - public void namedQueriesCleared(List<JavaNamedQuery> namedQueries) { - for (JavaNamedQuery namedQuery : namedQueries) { + public void namedQueriesCleared(List<JavaNamedQuery> queries) { + for (JavaNamedQuery namedQuery : queries) { namedQuery.removeAnnotation(); } } @@ -1057,11 +1064,11 @@ public class JavaEntity extends JavaTypeMapping implements IEntity } public void namedQueryMoved(int sourceIndex, int targetIndex, JavaNamedQuery namedQuery) { - List<INamedQuery> namedQueries = getNamedQueries(); + List<INamedQuery> queries = getNamedQueries(); int begin = Math.min(sourceIndex, targetIndex); int end = Math.max(sourceIndex, targetIndex); for (int i = begin; i-- > end;) { - this.synch((JavaNamedQuery) namedQueries.get(i), i); + this.synch((JavaNamedQuery) queries.get(i), i); } } @@ -1070,9 +1077,9 @@ public class JavaEntity extends JavaTypeMapping implements IEntity * starting at the end of the list to prevent overlap */ private void synchNamedQueryAnnotationsAfterAdd(int index) { - List<INamedQuery> namedQueries = getNamedQueries(); - for (int i = namedQueries.size(); i-- > index;) { - this.synch((JavaNamedQuery) namedQueries.get(i), i); + List<INamedQuery> queries = getNamedQueries(); + for (int i = queries.size(); i-- > index;) { + this.synch((JavaNamedQuery) queries.get(i), i); } } @@ -1081,9 +1088,9 @@ public class JavaEntity extends JavaTypeMapping implements IEntity * starting at the specified index to prevent overlap */ private void synchNamedQueryAnnotationsAfterRemove(int index) { - List<INamedQuery> namedQueries = getNamedQueries(); - for (int i = index; i < namedQueries.size(); i++) { - this.synch((JavaNamedQuery) namedQueries.get(i), i); + List<INamedQuery> queries = getNamedQueries(); + for (int i = index; i < queries.size(); i++) { + this.synch((JavaNamedQuery) queries.get(i), i); } } @@ -1104,12 +1111,12 @@ public class JavaEntity extends JavaTypeMapping implements IEntity } } - public void namedNativeQueriesAdded(int index, List<JavaNamedNativeQuery> namedQueries) { + public void namedNativeQueriesAdded(int index, List<JavaNamedNativeQuery> queries) { //JoinColumn was added to persistence model when udating from java, do not need //to edit the java in this case. TODO is there a better way to handle this?? - if (!namedQueries.isEmpty() && namedQueries.get(0).annotation(getType().astRoot()) == null) { - this.synchNamedNativeQueryAnnotationsAfterAdd(index + namedQueries.size()); - for (JavaNamedNativeQuery namedQuery : namedQueries) { + if (!queries.isEmpty() && queries.get(0).annotation(getType().astRoot()) == null) { + this.synchNamedNativeQueryAnnotationsAfterAdd(index + queries.size()); + for (JavaNamedNativeQuery namedQuery : queries) { namedQuery.newAnnotation(); } } @@ -1120,15 +1127,15 @@ public class JavaEntity extends JavaTypeMapping implements IEntity this.synchNamedNativeQueryAnnotationsAfterRemove(index); } - public void namedNativeQueriesRemoved(int[] indexes, List<JavaNamedNativeQuery> namedQueries) { - for (JavaNamedNativeQuery namedQuery : namedQueries) { + public void namedNativeQueriesRemoved(int[] indexes, List<JavaNamedNativeQuery> queries) { + for (JavaNamedNativeQuery namedQuery : queries) { namedQuery.removeAnnotation(); } this.synchNamedNativeQueryAnnotationsAfterRemove(indexes[0]); } - public void namedNativeQueriesCleared(List<JavaNamedNativeQuery> namedQueries) { - for (JavaNamedNativeQuery namedQuery : namedQueries) { + public void namedNativeQueriesCleared(List<JavaNamedNativeQuery> queries) { + for (JavaNamedNativeQuery namedQuery : queries) { namedQuery.removeAnnotation(); } } @@ -1138,11 +1145,11 @@ public class JavaEntity extends JavaTypeMapping implements IEntity } public void namedNativeQueryMoved(int sourceIndex, int targetIndex, JavaNamedNativeQuery namedQuery) { - List<INamedNativeQuery> namedQueries = getNamedNativeQueries(); + List<INamedNativeQuery> queries = getNamedNativeQueries(); int begin = Math.min(sourceIndex, targetIndex); int end = Math.max(sourceIndex, targetIndex); for (int i = begin; i-- > end;) { - this.synch((JavaNamedNativeQuery) namedQueries.get(i), i); + this.synch((JavaNamedNativeQuery) queries.get(i), i); } } @@ -1151,9 +1158,9 @@ public class JavaEntity extends JavaTypeMapping implements IEntity * starting at the end of the list to prevent overlap */ private void synchNamedNativeQueryAnnotationsAfterAdd(int index) { - List<INamedNativeQuery> namedQueries = getNamedNativeQueries(); - for (int i = namedQueries.size(); i-- > index;) { - this.synch((JavaNamedNativeQuery) namedQueries.get(i), i); + List<INamedNativeQuery> queries = getNamedNativeQueries(); + for (int i = queries.size(); i-- > index;) { + this.synch((JavaNamedNativeQuery) queries.get(i), i); } } @@ -1162,9 +1169,9 @@ public class JavaEntity extends JavaTypeMapping implements IEntity * starting at the specified index to prevent overlap */ private void synchNamedNativeQueryAnnotationsAfterRemove(int index) { - List<INamedNativeQuery> namedQueries = getNamedNativeQueries(); - for (int i = index; i < namedQueries.size(); i++) { - this.synch((JavaNamedNativeQuery) namedQueries.get(i), i); + List<INamedNativeQuery> queries = getNamedNativeQueries(); + for (int i = index; i < queries.size(); i++) { + this.synch((JavaNamedNativeQuery) queries.get(i), i); } } @@ -2352,16 +2359,17 @@ public class JavaEntity extends JavaTypeMapping implements IEntity @Override public void updateFromJava(CompilationUnit astRoot) { - this.setSpecifiedName((String) this.getType().annotationElementValue(NAME_ADAPTER, astRoot)); + this.setSpecifiedName(this.getType().annotationElementValue(NAME_ADAPTER, astRoot)); this.setDefaultName(this.getType().getName()); this.getJavaTable().updateFromJava(astRoot); this.updateSecondaryTablesFromJava(astRoot); this.updateNamedQueriesFromJava(astRoot); this.updateNamedNativeQueriesFromJava(astRoot); + this.updateSpecifiedPrimaryKeyJoinColumnsFromJava(astRoot); this.updateAttributeOverridesFromJava(astRoot); this.setInheritanceStrategy(InheritanceType.fromJavaAnnotationValue(this.inheritanceStrategyAdapter.getValue(astRoot))); this.getJavaDiscriminatorColumn().updateFromJava(astRoot); - this.setSpecifiedDiscriminatorValue((String) this.discriminatorValueAdapter.getValue(astRoot)); + this.setSpecifiedDiscriminatorValue(this.discriminatorValueAdapter.getValue(astRoot)); this.setDefaultDiscriminatorValue(this.javaDefaultDiscriminatorValue()); this.updateTableGeneratorFromJava(astRoot); this.updateSequenceGeneratorFromJava(astRoot); @@ -2371,9 +2379,8 @@ public class JavaEntity extends JavaTypeMapping implements IEntity private void updateIdClassFromJava(CompilationUnit astRoot) { if (this.idClassAnnotationAdapter.getAnnotation(astRoot) == null) { this.setIdClass(null); - } - else { - this.setIdClass((String) this.idClassValueAdapter.getValue(astRoot)); + } else { + this.setIdClass(this.idClassValueAdapter.getValue(astRoot)); } } @@ -2387,32 +2394,40 @@ public class JavaEntity extends JavaTypeMapping implements IEntity private void updateTableGeneratorFromJava(CompilationUnit astRoot) { if (this.tableGeneratorAnnotationAdapter.getAnnotation(astRoot) == null) { - if (getTableGenerator() != null) { + if (this.tableGenerator != null) { setTableGenerator(null); } } else { - if (getTableGenerator() == null) { + if (this.tableGenerator == null) { setTableGenerator(createTableGenerator()); } - ((JavaTableGenerator) getTableGenerator()).updateFromJava(astRoot); + this.getJavaTableGenerator().updateFromJava(astRoot); } } + private JavaTableGenerator getJavaTableGenerator() { + return (JavaTableGenerator) this.tableGenerator; + } + private void updateSequenceGeneratorFromJava(CompilationUnit astRoot) { if (this.sequenceGeneratorAnnotationAdapter.getAnnotation(astRoot) == null) { - if (getSequenceGenerator() != null) { + if (this.sequenceGenerator != null) { setSequenceGenerator(null); } } else { - if (getSequenceGenerator() == null) { + if (this.sequenceGenerator == null) { setSequenceGenerator(createSequenceGenerator()); } - ((JavaSequenceGenerator) getSequenceGenerator()).updateFromJava(astRoot); + this.getJavaSequenceGenerator().updateFromJava(astRoot); } } + private JavaSequenceGenerator getJavaSequenceGenerator() { + return (JavaSequenceGenerator) this.sequenceGenerator; + } + /** * From the Spec: * If the DiscriminatorValue annotation is not specified, a @@ -2610,7 +2625,7 @@ public class JavaEntity extends JavaTypeMapping implements IEntity * the same size; then we delegate to the join columns to synch * themselves up */ - private void updatePersSpecifiedPrimaryKeyJoinColumns(CompilationUnit astRoot) { + private void updateSpecifiedPrimaryKeyJoinColumnsFromJava(CompilationUnit astRoot) { // synchronize the model primary key join columns with the Java source List<IPrimaryKeyJoinColumn> pkJoinColumns = getSpecifiedPrimaryKeyJoinColumns(); int persSize = pkJoinColumns.size(); @@ -2861,60 +2876,64 @@ public class JavaEntity extends JavaTypeMapping implements IEntity @Override public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterator<String> result; + Iterator<String> result = super.candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } result = this.getJavaTable().candidateValuesFor(pos, filter, astRoot); if (result != null) { return result; } - // result = this.secondaryTablesCandidateValuesFor(pos, astRoot); - // if (result != null) { - // return result; - // } - // - // result = this.specifiedPrimaryKeyJoinColumnsCandidateValuesFor(pos, astRoot); - // if (result != null) { - // return result; - // } - // - // result = this.attributeOverridesCandidateValuesFor(pos, astRoot); - // if (result != null) { - // return result; - // } - // - // result = this.associationOverridesCandidateValuesFor(pos, astRoot); - // if (result != null) { - // return result; - // } - // - // result = this.getJavaDiscriminatorColumn().candidateValuesFor(pos, astRoot); - // if (result != null) { - // return result; - // } - // - // result = this.tableGeneratorCandidateValuesFor(pos, astRoot); - // if (result != null) { - // return result; - // } - // - // result = this.sequenceGeneratorCandidateValuesFor(pos, astRoot); - // if (result != null) { - // return result; - // } - // + for (ISecondaryTable sTable : this.getSecondaryTables()) { + result = ((JavaSecondaryTable) sTable).connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + for (IPrimaryKeyJoinColumn column : this.getPrimaryKeyJoinColumns()) { + result = ((JavaPrimaryKeyJoinColumn) column).connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + for (IAttributeOverride override : this.getAttributeOverrides()) { + result = ((JavaAttributeOverride) override).connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + for (IAssociationOverride override : this.getAssociationOverrides()) { + result = ((JavaAssociationOverride) override).connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + result = this.getJavaDiscriminatorColumn().candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + result = this.getJavaTableGenerator().candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + result = this.getJavaSequenceGenerator().candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } return null; } // ********** static methods ********** - protected static DeclarationAnnotationElementAdapter buildStrategyAdapter() { + protected static DeclarationAnnotationElementAdapter<String> buildStrategyAdapter() { return new EnumDeclarationAnnotationElementAdapter(INHERITANCE_ANNOTATION_ADAPTER, JPA.INHERITANCE__STRATEGY); } - private static DeclarationAnnotationElementAdapter buildDiscriminatorValueAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildDiscriminatorValueAdapter() { return ConversionDeclarationAnnotationElementAdapter.forStrings(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()); + private static DeclarationAnnotationElementAdapter<String> buildIdClassValueAdapter() { + return new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(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/JavaGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGeneratedValue.java index 3bf7b24606..6dbce3992e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGeneratedValue.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGeneratedValue.java @@ -41,15 +41,15 @@ public class JavaGeneratedValue extends JavaEObject implements IGeneratedValue { private Member member; - private final AnnotationElementAdapter strategyAdapter; + private final AnnotationElementAdapter<String> strategyAdapter; - private final AnnotationElementAdapter generatorAdapter; + private final AnnotationElementAdapter<String> generatorAdapter; public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.GENERATED_VALUE); - private static final DeclarationAnnotationElementAdapter STRATEGY_ADAPTER = buildStrategyAdapter(); + private static final DeclarationAnnotationElementAdapter<String> STRATEGY_ADAPTER = buildStrategyAdapter(); - private static final DeclarationAnnotationElementAdapter GENERATOR_ADAPTER = buildGeneratorAdapter(); + private static final DeclarationAnnotationElementAdapter<String> GENERATOR_ADAPTER = buildGeneratorAdapter(); /** * The default value of the '{@link #getStrategy() <em>Strategy</em>}' attribute. @@ -98,8 +98,8 @@ public class JavaGeneratedValue extends JavaEObject implements IGeneratedValue protected JavaGeneratedValue(Member member) { super(); this.member = member; - this.strategyAdapter = new ShortCircuitAnnotationElementAdapter(this.member, STRATEGY_ADAPTER); - this.generatorAdapter = new ShortCircuitAnnotationElementAdapter(this.member, GENERATOR_ADAPTER); + this.strategyAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, STRATEGY_ADAPTER); + this.generatorAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, GENERATOR_ADAPTER); } @Override @@ -107,7 +107,7 @@ public class JavaGeneratedValue extends JavaEObject implements IGeneratedValue super.notifyChanged(notification); switch (notification.getFeatureID(IGeneratedValue.class)) { case JpaJavaMappingsPackage.JAVA_GENERATED_VALUE__GENERATOR : - this.generatorAdapter.setValue(notification.getNewValue()); + this.generatorAdapter.setValue((String) notification.getNewValue()); break; case JpaJavaMappingsPackage.JAVA_GENERATED_VALUE__STRATEGY : this.strategyAdapter.setValue(((GenerationType) notification.getNewValue()).convertToJavaAnnotationValue()); @@ -329,15 +329,15 @@ public class JavaGeneratedValue extends JavaEObject implements IGeneratedValue // ********** java annotations -> persistence model ********** public void updateFromJava(CompilationUnit astRoot) { setStrategy(GenerationType.fromJavaAnnotationValue(this.strategyAdapter.getValue(astRoot))); - setGenerator((String) this.generatorAdapter.getValue(astRoot)); + setGenerator(this.generatorAdapter.getValue(astRoot)); } // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildStrategyAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildStrategyAdapter() { return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__STRATEGY, false); } - private static DeclarationAnnotationElementAdapter buildGeneratorAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildGeneratorAdapter() { return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.GENERATED_VALUE__GENERATOR, false); } } // JavaGeneratedValue diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java index 1843dd7f57..8066e5356c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java @@ -13,6 +13,7 @@ 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.jdt.core.dom.NumberLiteral; import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.content.java.JavaEObject; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; @@ -39,7 +40,7 @@ public abstract class JavaGenerator extends JavaEObject implements IGenerator { private final Member member; - private final AnnotationElementAdapter nameAdapter; + private final AnnotationElementAdapter<String> nameAdapter; private final IntAnnotationElementAdapter initialValueAdapter; @@ -192,7 +193,7 @@ public abstract class JavaGenerator extends JavaEObject implements IGenerator this.initialValueAdapter.setValue(notification.getNewIntValue()); break; case JpaJavaMappingsPackage.JAVA_GENERATOR__NAME : - this.nameAdapter.setValue(notification.getNewValue()); + this.nameAdapter.setValue((String) notification.getNewValue()); break; default : break; @@ -200,21 +201,21 @@ public abstract class JavaGenerator extends JavaEObject implements IGenerator } // ********** initialization ********** - protected AnnotationElementAdapter buildAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(this.member, daea); + protected AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { + return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); } - protected IntAnnotationElementAdapter buildIntAdapter(DeclarationAnnotationElementAdapter daea) { + protected IntAnnotationElementAdapter buildIntAdapter(DeclarationAnnotationElementAdapter<String> daea) { return new IntAnnotationElementAdapter(this.buildAdapter(daea)); } protected abstract DeclarationAnnotationAdapter annotationAdapter(); - protected abstract DeclarationAnnotationElementAdapter nameAdapter(); + protected abstract DeclarationAnnotationElementAdapter<String> nameAdapter(); - protected abstract DeclarationAnnotationElementAdapter initialValueAdapter(); + protected abstract DeclarationAnnotationElementAdapter<String> initialValueAdapter(); - protected abstract DeclarationAnnotationElementAdapter allocationSizeAdapter(); + protected abstract DeclarationAnnotationElementAdapter<String> allocationSizeAdapter(); /** * <!-- begin-user-doc --> @@ -553,17 +554,17 @@ public abstract class JavaGenerator extends JavaEObject implements IGenerator // ********** java annotations -> persistence model ********** public void updateFromJava(CompilationUnit astRoot) { - setName((String) this.nameAdapter.getValue(astRoot)); + setName(this.nameAdapter.getValue(astRoot)); setSpecifiedInitialValue(this.initialValueAdapter.getValue(astRoot)); setSpecifiedAllocationSize(this.allocationSizeAdapter.getValue(astRoot)); } // ********** static methods ********** - protected static DeclarationAnnotationElementAdapter buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + protected static DeclarationAnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { return ConversionDeclarationAnnotationElementAdapter.forStrings(annotationAdapter, elementName); } - protected static DeclarationAnnotationElementAdapter buildNumberAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, NumberStringExpressionConverter.instance()); + protected static DeclarationAnnotationElementAdapter<String> buildNumberAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new ConversionDeclarationAnnotationElementAdapter<String, NumberLiteral>(annotationAdapter, elementName, NumberStringExpressionConverter.instance()); } } // JavaGenerator diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaId.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaId.java index 95168f14ec..f0b7e4ed76 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaId.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaId.java @@ -57,13 +57,13 @@ public class JavaId extends JavaAttributeMapping implements IId private final AnnotationAdapter temporalAnnotationAdapter; - private final AnnotationElementAdapter temporalValueAdapter; + private final AnnotationElementAdapter<String> temporalValueAdapter; public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.ID); private static final DeclarationAnnotationAdapter TEMPORAL_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.TEMPORAL); - private static final DeclarationAnnotationElementAdapter TEMPORAL_VALUE_ADAPTER = buildTemporalValueAdapter(); + private static final DeclarationAnnotationElementAdapter<String> TEMPORAL_VALUE_ADAPTER = buildTemporalValueAdapter(); /** * The cached value of the '{@link #getColumn() <em>Column</em>}' containment reference. @@ -134,7 +134,7 @@ public class JavaId extends JavaAttributeMapping implements IId this.column = JavaColumn.createColumnMappingColumn(buildColumnOwner(), getAttribute()); ((InternalEObject) this.column).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JpaJavaMappingsPackage.JAVA_ID__COLUMN, null, null); this.temporalAnnotationAdapter = new MemberAnnotationAdapter(this.getAttribute(), TEMPORAL_ADAPTER); - this.temporalValueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, TEMPORAL_VALUE_ADAPTER); + this.temporalValueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, TEMPORAL_VALUE_ADAPTER); this.generatedValueAnnotationAdapter = this.buildAnnotationAdapter(JavaGeneratedValue.DECLARATION_ANNOTATION_ADAPTER); this.tableGeneratorAnnotationAdapter = this.buildAnnotationAdapter(JavaTableGenerator.DECLARATION_ANNOTATION_ADAPTER); this.sequenceGeneratorAnnotationAdapter = this.buildAnnotationAdapter(JavaSequenceGenerator.DECLARATION_ANNOTATION_ADAPTER); @@ -761,7 +761,7 @@ public class JavaId extends JavaAttributeMapping implements IId } // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildTemporalValueAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildTemporalValueAdapter() { return new EnumDeclarationAnnotationElementAdapter(TEMPORAL_ADAPTER, JPA.TEMPORAL__VALUE, false); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinColumn.java index e21cf7fb43..1ac54e2822 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinColumn.java @@ -430,7 +430,7 @@ public class JavaJoinColumn extends AbstractJavaColumn implements IJoinColumn } @Override - protected Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + public Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterator<String> result = super.connectedCandidateValuesFor(pos, filter, astRoot); if (result != null) { return result; diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java index c71b6e2f00..ab752491cd 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaJoinTable.java @@ -772,13 +772,13 @@ public class JavaJoinTable extends AbstractJavaTable implements IJoinTable return result; } for (IJoinColumn column : this.getJoinColumns()) { - result = ((JavaJoinColumn) column).candidateValuesFor(pos, filter, astRoot); + result = ((JavaJoinColumn) column).connectedCandidateValuesFor(pos, filter, astRoot); if (result != null) { return result; } } for (IJoinColumn column : this.getInverseJoinColumns()) { - result = ((JavaJoinColumn) column).candidateValuesFor(pos, filter, astRoot); + result = ((JavaJoinColumn) column).connectedCandidateValuesFor(pos, filter, astRoot); if (result != null) { return result; } 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 b563179d7c..ec505b2f52 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 @@ -14,6 +14,7 @@ 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.jdt.core.dom.TypeLiteral; import org.eclipse.jpt.core.internal.IMappingKeys; import org.eclipse.jpt.core.internal.IPersistentAttribute; import org.eclipse.jpt.core.internal.jdtutility.AnnotationAdapter; @@ -66,13 +67,13 @@ public class JavaMappedSuperclass extends JavaTypeMapping private final AnnotationAdapter idClassAnnotationAdapter; - private final AnnotationElementAdapter idClassValueAdapter; + private final AnnotationElementAdapter<String> 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(); + private static final DeclarationAnnotationElementAdapter<String> ID_CLASS_VALUE_ADAPTER = buildIdClassValueAdapter(); protected JavaMappedSuperclass() { throw new UnsupportedOperationException("Use JavaMappedSuperclass(Type) instead"); @@ -81,7 +82,7 @@ public class JavaMappedSuperclass extends JavaTypeMapping 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); + this.idClassValueAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.getType(), ID_CLASS_VALUE_ADAPTER); } @Override @@ -101,12 +102,12 @@ public class JavaMappedSuperclass extends JavaTypeMapping super.notifyChanged(notification); switch (notification.getFeatureID(IMappedSuperclass.class)) { case JpaCoreMappingsPackage.IMAPPED_SUPERCLASS__ID_CLASS : - String idClass = (String) notification.getNewValue(); - if (idClass == null) { + String newIdClass = (String) notification.getNewValue(); + if (newIdClass == null) { this.idClassAnnotationAdapter.removeAnnotation(); } else { - this.idClassValueAdapter.setValue(idClass); + this.idClassValueAdapter.setValue(newIdClass); } default : break; @@ -318,12 +319,12 @@ public class JavaMappedSuperclass extends JavaTypeMapping this.setIdClass(null); } else { - this.setIdClass((String) this.idClassValueAdapter.getValue(astRoot)); + this.setIdClass(this.idClassValueAdapter.getValue(astRoot)); } } // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildIdClassValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(ID_CLASS_ADAPTER, JPA.ID_CLASS__VALUE, false, SimpleTypeStringExpressionConverter.instance()); + private static DeclarationAnnotationElementAdapter<String> buildIdClassValueAdapter() { + return new ConversionDeclarationAnnotationElementAdapter<String, TypeLiteral>(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/JavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java index ce7736548f..d04fa5881b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java @@ -29,10 +29,10 @@ import org.eclipse.jpt.core.internal.jdtutility.ShortCircuitAnnotationElementAda import org.eclipse.jpt.core.internal.mappings.INamedColumn; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; import org.eclipse.jpt.db.internal.Column; -import org.eclipse.jpt.db.internal.ConnectionProfile; import org.eclipse.jpt.db.internal.Table; import org.eclipse.jpt.utility.internal.Filter; import org.eclipse.jpt.utility.internal.StringTools; +import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; /** @@ -483,11 +483,6 @@ public abstract class JavaNamedColumn extends JavaEObject this.setColumnDefinition(this.columnDefinitionAdapter.getValue(astRoot)); } - public boolean isConnected() { - ConnectionProfile cp = this.getJpaProject().connectionProfile(); - return cp != null && cp.isConnected(); - } - public Column dbColumn() { Table table = this.dbTable(); return (table == null) ? null : table.columnNamed(this.getName()); @@ -507,22 +502,14 @@ public abstract class JavaNamedColumn extends JavaEObject } /** - * name - */ - public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { - if (this.isConnected()) { - Iterator<String> result = this.connectedCandidateValuesFor(pos, filter, astRoot); - if (result != null) { - return result; - } - } - return null; - } - - /** * called if the database is connected */ - protected Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + @Override + public Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } if (this.nameTouches(pos, astRoot)) { return this.quotedCandidateNames(filter); } @@ -530,7 +517,8 @@ public abstract class JavaNamedColumn extends JavaEObject } private Iterator<String> candidateNames() { - return this.dbTable().columnNames(); + Table dbTable = this.dbTable(); + return (dbTable != null) ? dbTable.columnNames() : EmptyIterator.<String>instance(); } private Iterator<String> candidateNames(Filter<String> filter) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedNativeQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedNativeQuery.java index fd2161bae3..9d11ae678c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedNativeQuery.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedNativeQuery.java @@ -81,9 +81,9 @@ public class JavaNamedNativeQuery extends JavaAbstractQuery public static final SimpleDeclarationAnnotationAdapter MULTIPLE_DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.NAMED_NATIVE_QUERIES); - private final AnnotationElementAdapter resultClassAdapter; + private final AnnotationElementAdapter<String> resultClassAdapter; - private final AnnotationElementAdapter resultSetMappingAdapter; + private final AnnotationElementAdapter<String> resultSetMappingAdapter; protected JavaNamedNativeQuery() { throw new UnsupportedOperationException("Use JavaNamedNativeQuery(Member) instead"); @@ -96,11 +96,11 @@ public class JavaNamedNativeQuery extends JavaAbstractQuery } // ********** initialization ********** - protected DeclarationAnnotationElementAdapter resultClassAdapter(DeclarationAnnotationAdapter daa) { + protected DeclarationAnnotationElementAdapter<String> resultClassAdapter(DeclarationAnnotationAdapter daa) { return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.NAMED_NATIVE_QUERY__RESULT_CLASS); } - protected DeclarationAnnotationElementAdapter resultSetMappingAdapter(DeclarationAnnotationAdapter daa) { + protected DeclarationAnnotationElementAdapter<String> resultSetMappingAdapter(DeclarationAnnotationAdapter daa) { return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.NAMED_NATIVE_QUERY__RESULT_SET_MAPPING); } @@ -119,10 +119,10 @@ public class JavaNamedNativeQuery extends JavaAbstractQuery super.notifyChanged(notification); switch (notification.getFeatureID(INamedNativeQuery.class)) { case JpaCoreMappingsPackage.INAMED_NATIVE_QUERY__RESULT_CLASS : - this.resultClassAdapter.setValue(notification.getNewValue()); + this.resultClassAdapter.setValue((String) notification.getNewValue()); break; case JpaCoreMappingsPackage.INAMED_NATIVE_QUERY__RESULT_SET_MAPPING : - this.resultSetMappingAdapter.setValue(notification.getNewValue()); + this.resultSetMappingAdapter.setValue((String) notification.getNewValue()); break; default : break; @@ -334,10 +334,11 @@ public class JavaNamedNativeQuery extends JavaAbstractQuery @Override protected void updateFromJava(CompilationUnit astRoot) { super.updateFromJava(astRoot); - this.setResultClass((String) this.resultClassAdapter.getValue(astRoot)); - this.setResultSetMapping((String) this.resultSetMappingAdapter.getValue(astRoot)); + this.setResultClass(this.resultClassAdapter.getValue(astRoot)); + this.setResultSetMapping(this.resultSetMappingAdapter.getValue(astRoot)); } + @Override protected JavaQueryHint createJavaQueryHint(int index) { return JavaQueryHint.createNamedNativeQueryQueryHint(this, this.getMember(), index); } @@ -350,4 +351,4 @@ public class JavaNamedNativeQuery extends JavaAbstractQuery private static IndexedDeclarationAnnotationAdapter buildAnnotationAdapter(int index) { return new CombinationIndexedDeclarationAnnotationAdapter(SINGLE_DECLARATION_ANNOTATION_ADAPTER, MULTIPLE_DECLARATION_ANNOTATION_ADAPTER, index, JPA.NAMED_NATIVE_QUERY); } -} // JavaNamedNativeQuery +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedQuery.java index 30195c4c01..12fcd5925b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedQuery.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedQuery.java @@ -60,6 +60,7 @@ public class JavaNamedQuery extends JavaAbstractQuery implements INamedQuery return JpaJavaMappingsPackage.Literals.JAVA_NAMED_QUERY; } + @Override protected JavaQueryHint createJavaQueryHint(int index) { return JavaQueryHint.createNamedQueryQueryHint(this, this.getMember(), index); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOrderBy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOrderBy.java index 6384532b73..e26c8a72ef 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOrderBy.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOrderBy.java @@ -89,11 +89,11 @@ public class JavaOrderBy extends JavaEObject implements IOrderBy private final AnnotationAdapter annotationAdapter; - private final AnnotationElementAdapter valueAdapter; + private final AnnotationElementAdapter<String> valueAdapter; public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.ORDER_BY); - private static final DeclarationAnnotationElementAdapter VALUE_ADAPTER = buildValueAdapter(); + private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); protected JavaOrderBy() { throw new UnsupportedOperationException("User JavaOrderBy(Member) instead"); @@ -103,7 +103,7 @@ public class JavaOrderBy extends JavaEObject implements IOrderBy super(); this.member = member; this.annotationAdapter = this.buildOrderByAnnotationAdapter(); - this.valueAdapter = new ShortCircuitAnnotationElementAdapter(this.member, VALUE_ADAPTER); + this.valueAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, VALUE_ADAPTER); } private AnnotationAdapter buildOrderByAnnotationAdapter() { @@ -116,7 +116,7 @@ public class JavaOrderBy extends JavaEObject implements IOrderBy switch (notification.getFeatureID(IOrderBy.class)) { case JpaJavaMappingsPackage.JAVA_ORDER_BY__VALUE : if (getType() == OrderingType.CUSTOM) { - this.valueAdapter.setValue(notification.getNewValue()); + this.valueAdapter.setValue((String) notification.getNewValue()); } break; case JpaJavaMappingsPackage.JAVA_ORDER_BY__TYPE : @@ -415,7 +415,7 @@ public class JavaOrderBy extends JavaEObject implements IOrderBy else { throw new IllegalStateException("unknown annotation type: " + annotation); } - setValue((String) this.valueAdapter.getValue(astRoot)); + setValue(this.valueAdapter.getValue(astRoot)); } /** @@ -431,7 +431,7 @@ public class JavaOrderBy extends JavaEObject implements IOrderBy } // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildValueAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { return ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA.ORDER_BY__VALUE, false); } } // JavaOrderBy diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOverride.java index 98317300a7..56c394de6c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOverride.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOverride.java @@ -8,6 +8,7 @@ *******************************************************************************/ 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; @@ -17,6 +18,7 @@ import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.content.java.JavaEObject; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.ConversionDeclarationAnnotationElementAdapter; +import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.IndexedAnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.IndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.Member; @@ -24,6 +26,9 @@ import org.eclipse.jpt.core.internal.jdtutility.MemberIndexedAnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.ShortCircuitAnnotationElementAdapter; import org.eclipse.jpt.core.internal.mappings.IOverride; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; +import org.eclipse.jpt.utility.internal.Filter; +import org.eclipse.jpt.utility.internal.StringTools; +import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; /** * <!-- begin-user-doc --> @@ -65,7 +70,9 @@ public abstract class JavaOverride extends JavaEObject implements IOverride private final IndexedAnnotationAdapter annotationAdapter; - private final AnnotationElementAdapter nameAdapter; + private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter; + + private final AnnotationElementAdapter<String> nameAdapter; protected JavaOverride() { throw new UnsupportedOperationException("use JavaAttributeOverride(Owner, Member, IndexedDeclarationAnnotationAdapter)"); @@ -77,15 +84,12 @@ public abstract class JavaOverride extends JavaEObject implements IOverride this.member = member; this.daa = daa; this.annotationAdapter = new MemberIndexedAnnotationAdapter(member, daa); - this.nameAdapter = this.buildAdapter(JPA.ATTRIBUTE_OVERRIDE__NAME); + this.nameDeclarationAdapter = ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, this.nameElementName()); + this.nameAdapter = new ShortCircuitAnnotationElementAdapter<String>(this.member, this.nameDeclarationAdapter); } protected abstract String nameElementName(); - private AnnotationElementAdapter buildAdapter(String elementName) { - return new ShortCircuitAnnotationElementAdapter(this.member, ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, elementName)); - } - /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -269,8 +273,38 @@ public abstract class JavaOverride extends JavaEObject implements IOverride return this.annotationAdapter.getAnnotation(astRoot); } + protected boolean elementTouches(DeclarationAnnotationElementAdapter<?> elementAdapter, int pos, CompilationUnit astRoot) { + return this.elementTouches(this.member.annotationElementTextRange(elementAdapter, astRoot), pos); + } + + public boolean nameTouches(int pos, CompilationUnit astRoot) { + return this.elementTouches(this.nameDeclarationAdapter, pos, astRoot); + } + + protected abstract Iterator<String> candidateNames(); + + private Iterator<String> candidateNames(Filter<String> filter) { + return new FilteringIterator<String>(this.candidateNames(), filter); + } + + private Iterator<String> quotedCandidateNames(Filter<String> filter) { + return StringTools.quote(this.candidateNames(filter)); + } + + @Override + public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.candidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + if (this.nameTouches(pos, astRoot)) { + return this.quotedCandidateNames(filter); + } + return null; + } + public void updateFromJava(CompilationUnit astRoot) { - setName((String) this.nameAdapter.getValue(astRoot)); + setName(this.nameAdapter.getValue(astRoot)); } // ********** persistence model -> java annotations ********** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaPrimaryKeyJoinColumn.java index 299a02312f..deaf777ead 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaPrimaryKeyJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaPrimaryKeyJoinColumn.java @@ -405,7 +405,7 @@ public class JavaPrimaryKeyJoinColumn extends JavaNamedColumn } @Override - protected Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + public Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterator<String> result = super.connectedCandidateValuesFor(pos, filter, astRoot); if (result != null) { return result; diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaQueryHint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaQueryHint.java index d9a5c63692..d36040724b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaQueryHint.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaQueryHint.java @@ -48,9 +48,9 @@ public class JavaQueryHint extends JavaEObject implements IQueryHint private final IndexedAnnotationAdapter annotationAdapter; - private final AnnotationElementAdapter nameAdapter; + private final AnnotationElementAdapter<String> nameAdapter; - private final AnnotationElementAdapter valueAdapter; + private final AnnotationElementAdapter<String> valueAdapter; /** * The default value of the '{@link #getName() <em>Name</em>}' attribute. @@ -106,15 +106,15 @@ public class JavaQueryHint extends JavaEObject implements IQueryHint } // ********** initialization ********** - protected AnnotationElementAdapter buildAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitAnnotationElementAdapter(this.member, daea); + protected AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { + return new ShortCircuitAnnotationElementAdapter<String>(this.member, daea); } - protected DeclarationAnnotationElementAdapter nameAdapter(DeclarationAnnotationAdapter daa) { + protected DeclarationAnnotationElementAdapter<String> nameAdapter(DeclarationAnnotationAdapter daa) { return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.QUERY_HINT__NAME); } - protected DeclarationAnnotationElementAdapter valueAdapter(DeclarationAnnotationAdapter daa) { + protected DeclarationAnnotationElementAdapter<String> valueAdapter(DeclarationAnnotationAdapter daa) { return ConversionDeclarationAnnotationElementAdapter.forStrings(daa, JPA.QUERY_HINT__VALUE); } @@ -123,10 +123,10 @@ public class JavaQueryHint extends JavaEObject implements IQueryHint super.notifyChanged(notification); switch (notification.getFeatureID(IQueryHint.class)) { case JpaCoreMappingsPackage.IQUERY_HINT__NAME : - this.nameAdapter.setValue(notification.getNewValue()); + this.nameAdapter.setValue((String) notification.getNewValue()); break; case JpaCoreMappingsPackage.IQUERY_HINT__VALUE : - this.valueAdapter.setValue(notification.getNewValue()); + this.valueAdapter.setValue((String) notification.getNewValue()); break; default : break; @@ -341,8 +341,8 @@ public class JavaQueryHint extends JavaEObject implements IQueryHint } protected void updateFromJava(CompilationUnit astRoot) { - this.setName((String) this.nameAdapter.getValue(astRoot)); - this.setValue((String) this.valueAdapter.getValue(astRoot)); + this.setName(this.nameAdapter.getValue(astRoot)); + this.setValue(this.valueAdapter.getValue(astRoot)); } /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSecondaryTable.java index 52e3c6595f..7dda449087 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSecondaryTable.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSecondaryTable.java @@ -10,6 +10,7 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Collection; +import java.util.Iterator; import java.util.List; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; @@ -33,6 +34,7 @@ import org.eclipse.jpt.core.internal.mappings.IAbstractJoinColumn; import org.eclipse.jpt.core.internal.mappings.IPrimaryKeyJoinColumn; import org.eclipse.jpt.core.internal.mappings.ISecondaryTable; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; +import org.eclipse.jpt.utility.internal.Filter; /** * <!-- begin-user-doc --> @@ -525,6 +527,21 @@ public class JavaSecondaryTable extends AbstractJavaTable ((JavaPrimaryKeyJoinColumn) joinColumn).moveAnnotation(index); } + @Override + public Iterator<String> connectedCandidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { + Iterator<String> result = super.connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + for (IPrimaryKeyJoinColumn column : this.getPrimaryKeyJoinColumns()) { + result = ((JavaPrimaryKeyJoinColumn) column).connectedCandidateValuesFor(pos, filter, astRoot); + if (result != null) { + return result; + } + } + return null; + } + // ********** static methods ********** static JavaSecondaryTable createJavaSecondaryTable(Owner owner, Member member, int index) { return JpaJavaMappingsFactory.eINSTANCE.createJavaSecondaryTable(owner, member, buildDeclarationAnnotationAdapter(index)); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSequenceGenerator.java index 05a946a8bf..28bce2778d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSequenceGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSequenceGenerator.java @@ -34,17 +34,17 @@ import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; public class JavaSequenceGenerator extends JavaGenerator implements ISequenceGenerator { - private final AnnotationElementAdapter sequenceNameAdapter; + private final AnnotationElementAdapter<String> sequenceNameAdapter; public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.SEQUENCE_GENERATOR); - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__NAME); + private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__NAME); - private static final DeclarationAnnotationElementAdapter INITIAL_VALUE_ADAPTER = buildNumberAdapter(JPA.SEQUENCE_GENERATOR__INITIAL_VALUE); + private static final DeclarationAnnotationElementAdapter<String> INITIAL_VALUE_ADAPTER = buildNumberAdapter(JPA.SEQUENCE_GENERATOR__INITIAL_VALUE); - private static final DeclarationAnnotationElementAdapter ALLOCATION_SIZE_ADAPTER = buildNumberAdapter(JPA.SEQUENCE_GENERATOR__ALLOCATION_SIZE); + private static final DeclarationAnnotationElementAdapter<String> ALLOCATION_SIZE_ADAPTER = buildNumberAdapter(JPA.SEQUENCE_GENERATOR__ALLOCATION_SIZE); - private static final DeclarationAnnotationElementAdapter SEQUENCE_NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__SEQUENCE_NAME); + private static final DeclarationAnnotationElementAdapter<String> SEQUENCE_NAME_ADAPTER = buildAdapter(JPA.SEQUENCE_GENERATOR__SEQUENCE_NAME); /** * The default value of the '{@link #getSequenceName() <em>Sequence Name</em>}' attribute. @@ -110,7 +110,7 @@ public class JavaSequenceGenerator extends JavaGenerator super.notifyChanged(notification); switch (notification.getFeatureID(ISequenceGenerator.class)) { case JpaJavaMappingsPackage.JAVA_SEQUENCE_GENERATOR__SPECIFIED_SEQUENCE_NAME : - this.sequenceNameAdapter.setValue(notification.getNewIntValue()); + this.sequenceNameAdapter.setValue((String) notification.getNewValue()); break; default : break; @@ -118,19 +118,23 @@ public class JavaSequenceGenerator extends JavaGenerator } // ********** initialization ********** + @Override protected DeclarationAnnotationAdapter annotationAdapter() { return DECLARATION_ANNOTATION_ADAPTER; } - protected DeclarationAnnotationElementAdapter nameAdapter() { + @Override + protected DeclarationAnnotationElementAdapter<String> nameAdapter() { return NAME_ADAPTER; } - protected DeclarationAnnotationElementAdapter initialValueAdapter() { + @Override + protected DeclarationAnnotationElementAdapter<String> initialValueAdapter() { return INITIAL_VALUE_ADAPTER; } - protected DeclarationAnnotationElementAdapter allocationSizeAdapter() { + @Override + protected DeclarationAnnotationElementAdapter<String> allocationSizeAdapter() { return ALLOCATION_SIZE_ADAPTER; } @@ -330,15 +334,15 @@ public class JavaSequenceGenerator extends JavaGenerator @Override public void updateFromJava(CompilationUnit astRoot) { super.updateFromJava(astRoot); - setSpecifiedSequenceName((String) this.sequenceNameAdapter.getValue(astRoot)); + setSpecifiedSequenceName(this.sequenceNameAdapter.getValue(astRoot)); } // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildAdapter(String elementName) { + private static DeclarationAnnotationElementAdapter<String> buildAdapter(String elementName) { return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); } - private static DeclarationAnnotationElementAdapter buildNumberAdapter(String elementName) { + private static DeclarationAnnotationElementAdapter<String> buildNumberAdapter(String elementName) { return buildNumberAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); } } // JavaSequenceGenerator diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTableGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTableGenerator.java index a73b9a8311..f42a7ab6b1 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTableGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTableGenerator.java @@ -44,37 +44,37 @@ import org.eclipse.jpt.core.internal.platform.DefaultsContext; public class JavaTableGenerator extends JavaGenerator implements ITableGenerator { - private final AnnotationElementAdapter tableAdapter; + private final AnnotationElementAdapter<String> tableAdapter; - private final AnnotationElementAdapter catalogAdapter; + private final AnnotationElementAdapter<String> catalogAdapter; - private final AnnotationElementAdapter schemaAdapter; + private final AnnotationElementAdapter<String> schemaAdapter; - private final AnnotationElementAdapter pkColumnNameAdapter; + private final AnnotationElementAdapter<String> pkColumnNameAdapter; - private final AnnotationElementAdapter valueColumnNameAdapter; + private final AnnotationElementAdapter<String> valueColumnNameAdapter; - private final AnnotationElementAdapter pkColumnValueAdapter; + private final AnnotationElementAdapter<String> pkColumnValueAdapter; public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.TABLE_GENERATOR); - private static final DeclarationAnnotationElementAdapter NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__NAME); + private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__NAME); - private static final DeclarationAnnotationElementAdapter INITIAL_VALUE_ADAPTER = buildNumberAdapter(JPA.TABLE_GENERATOR__INITIAL_VALUE); + private static final DeclarationAnnotationElementAdapter<String> INITIAL_VALUE_ADAPTER = buildNumberAdapter(JPA.TABLE_GENERATOR__INITIAL_VALUE); - private static final DeclarationAnnotationElementAdapter ALLOCATION_SIZE_ADAPTER = buildNumberAdapter(JPA.TABLE_GENERATOR__ALLOCATION_SIZE); + private static final DeclarationAnnotationElementAdapter<String> ALLOCATION_SIZE_ADAPTER = buildNumberAdapter(JPA.TABLE_GENERATOR__ALLOCATION_SIZE); - private static final DeclarationAnnotationElementAdapter TABLE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__TABLE); + private static final DeclarationAnnotationElementAdapter<String> TABLE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__TABLE); - private static final DeclarationAnnotationElementAdapter CATALOG_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__CATALOG); + private static final DeclarationAnnotationElementAdapter<String> CATALOG_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__CATALOG); - private static final DeclarationAnnotationElementAdapter SCHEMA_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__SCHEMA); + private static final DeclarationAnnotationElementAdapter<String> SCHEMA_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__SCHEMA); - private static final DeclarationAnnotationElementAdapter PK_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_NAME); + private static final DeclarationAnnotationElementAdapter<String> PK_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_NAME); - private static final DeclarationAnnotationElementAdapter VALUE_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__VALUE_COLUMN_NAME); + private static final DeclarationAnnotationElementAdapter<String> VALUE_COLUMN_NAME_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__VALUE_COLUMN_NAME); - private static final DeclarationAnnotationElementAdapter PK_COLUMN_VALUE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_VALUE); + private static final DeclarationAnnotationElementAdapter<String> PK_COLUMN_VALUE_ADAPTER = buildAdapter(JPA.TABLE_GENERATOR__PK_COLUMN_VALUE); /** * The default value of the '{@link #getTable() <em>Table</em>}' attribute. @@ -405,22 +405,22 @@ public class JavaTableGenerator extends JavaGenerator super.notifyChanged(notification); switch (notification.getFeatureID(ITableGenerator.class)) { case JpaJavaMappingsPackage.JAVA_TABLE_GENERATOR__SPECIFIED_TABLE : - this.tableAdapter.setValue(notification.getNewValue()); + this.tableAdapter.setValue((String) notification.getNewValue()); break; case JpaJavaMappingsPackage.JAVA_TABLE_GENERATOR__SPECIFIED_CATALOG : - this.catalogAdapter.setValue(notification.getNewValue()); + this.catalogAdapter.setValue((String) notification.getNewValue()); break; case JpaJavaMappingsPackage.JAVA_TABLE_GENERATOR__SPECIFIED_SCHEMA : - this.schemaAdapter.setValue(notification.getNewValue()); + this.schemaAdapter.setValue((String) notification.getNewValue()); break; case JpaJavaMappingsPackage.JAVA_TABLE_GENERATOR__SPECIFIED_VALUE_COLUMN_NAME : - this.valueColumnNameAdapter.setValue(notification.getNewValue()); + this.valueColumnNameAdapter.setValue((String) notification.getNewValue()); break; case JpaJavaMappingsPackage.JAVA_TABLE_GENERATOR__SPECIFIED_PK_COLUMN_NAME : - this.pkColumnNameAdapter.setValue(notification.getNewValue()); + this.pkColumnNameAdapter.setValue((String) notification.getNewValue()); break; case JpaJavaMappingsPackage.JAVA_TABLE_GENERATOR__SPECIFIED_PK_COLUMN_VALUE : - this.pkColumnValueAdapter.setValue(notification.getNewValue()); + this.pkColumnValueAdapter.setValue((String) notification.getNewValue()); break; case JpaJavaMappingsPackage.JAVA_TABLE_GENERATOR__UNIQUE_CONSTRAINTS : uniqueConstraintsChanged(notification); @@ -430,6 +430,7 @@ public class JavaTableGenerator extends JavaGenerator } } + @SuppressWarnings("unchecked") void uniqueConstraintsChanged(Notification notification) { switch (notification.getEventType()) { case Notification.ADD : @@ -467,19 +468,23 @@ public class JavaTableGenerator extends JavaGenerator } // ********** initialization ********** + @Override protected DeclarationAnnotationAdapter annotationAdapter() { return DECLARATION_ANNOTATION_ADAPTER; } - protected DeclarationAnnotationElementAdapter nameAdapter() { + @Override + protected DeclarationAnnotationElementAdapter<String> nameAdapter() { return NAME_ADAPTER; } - protected DeclarationAnnotationElementAdapter initialValueAdapter() { + @Override + protected DeclarationAnnotationElementAdapter<String> initialValueAdapter() { return INITIAL_VALUE_ADAPTER; } - protected DeclarationAnnotationElementAdapter allocationSizeAdapter() { + @Override + protected DeclarationAnnotationElementAdapter<String> allocationSizeAdapter() { return ALLOCATION_SIZE_ADAPTER; } @@ -1177,12 +1182,12 @@ public class JavaTableGenerator extends JavaGenerator @Override public void updateFromJava(CompilationUnit astRoot) { super.updateFromJava(astRoot); - setSpecifiedTable((String) this.tableAdapter.getValue(astRoot)); - setSpecifiedCatalog((String) this.catalogAdapter.getValue(astRoot)); - setSpecifiedSchema((String) this.schemaAdapter.getValue(astRoot)); - setSpecifiedPkColumnName((String) this.pkColumnNameAdapter.getValue(astRoot)); - setSpecifiedValueColumnName((String) this.valueColumnNameAdapter.getValue(astRoot)); - setSpecifiedPkColumnValue((String) this.pkColumnValueAdapter.getValue(astRoot)); + setSpecifiedTable(this.tableAdapter.getValue(astRoot)); + setSpecifiedCatalog(this.catalogAdapter.getValue(astRoot)); + setSpecifiedSchema(this.schemaAdapter.getValue(astRoot)); + setSpecifiedPkColumnName(this.pkColumnNameAdapter.getValue(astRoot)); + setSpecifiedValueColumnName(this.valueColumnNameAdapter.getValue(astRoot)); + setSpecifiedPkColumnValue(this.pkColumnValueAdapter.getValue(astRoot)); this.updateUniqueConstraintsFromJava(astRoot); } @@ -1192,12 +1197,12 @@ public class JavaTableGenerator extends JavaGenerator */ private void updateUniqueConstraintsFromJava(CompilationUnit astRoot) { // synchronize the model join columns with the Java source - List<IUniqueConstraint> uniqueConstraints = this.getUniqueConstraints(); - int persSize = uniqueConstraints.size(); + List<IUniqueConstraint> constraints = this.getUniqueConstraints(); + int persSize = constraints.size(); int javaSize = 0; boolean allJavaAnnotationsFound = false; for (int i = 0; i < persSize; i++) { - JavaUniqueConstraint uniqueConstraint = (JavaUniqueConstraint) uniqueConstraints.get(i); + JavaUniqueConstraint uniqueConstraint = (JavaUniqueConstraint) constraints.get(i); if (uniqueConstraint.annotation(astRoot) == null) { allJavaAnnotationsFound = true; break; // no need to go any further @@ -1209,7 +1214,7 @@ public class JavaTableGenerator extends JavaGenerator // remove any model join columns beyond those that correspond to the Java annotations while (persSize > javaSize) { persSize--; - uniqueConstraints.remove(persSize); + constraints.remove(persSize); } } else { @@ -1255,12 +1260,12 @@ public class JavaTableGenerator extends JavaGenerator } // bjv look at this - public void uniqueConstraintsAdded(int index, List<IUniqueConstraint> uniqueConstraints) { + public void uniqueConstraintsAdded(int index, List<IUniqueConstraint> constraints) { // JoinColumn was added to jpa model when updating from java, do not need // to edit the java in this case. TODO is there a better way to handle this?? - if (!uniqueConstraints.isEmpty() && ((JavaUniqueConstraint) uniqueConstraints.get(0)).annotation(getMember().astRoot()) == null) { - this.synchUniqueConstraintAnnotationsAfterAdd(index + uniqueConstraints.size()); - for (IUniqueConstraint uniqueConstraint : uniqueConstraints) { + if (!constraints.isEmpty() && ((JavaUniqueConstraint) constraints.get(0)).annotation(getMember().astRoot()) == null) { + this.synchUniqueConstraintAnnotationsAfterAdd(index + constraints.size()); + for (IUniqueConstraint uniqueConstraint : constraints) { ((JavaUniqueConstraint) uniqueConstraint).newAnnotation(); } } @@ -1271,15 +1276,15 @@ public class JavaTableGenerator extends JavaGenerator this.synchUniqueConstraintAnnotationsAfterRemove(index); } - public void uniqueConstraintsRemoved(int[] indexes, List<IUniqueConstraint> uniqueConstraints) { - for (IUniqueConstraint uniqueConstraint : uniqueConstraints) { + public void uniqueConstraintsRemoved(int[] indexes, List<IUniqueConstraint> constraints) { + for (IUniqueConstraint uniqueConstraint : constraints) { ((JavaUniqueConstraint) uniqueConstraint).removeAnnotation(); } this.synchUniqueConstraintAnnotationsAfterRemove(indexes[0]); } - public void uniqueConstraintsCleared(List<IUniqueConstraint> uniqueConstraints) { - for (IUniqueConstraint uniqueConstraint : uniqueConstraints) { + public void uniqueConstraintsCleared(List<IUniqueConstraint> constraints) { + for (IUniqueConstraint uniqueConstraint : constraints) { ((JavaUniqueConstraint) uniqueConstraint).removeAnnotation(); } } @@ -1289,11 +1294,11 @@ public class JavaTableGenerator extends JavaGenerator } public void uniqueConstraintMoved(int sourceIndex, int targetIndex, IUniqueConstraint uniqueConstraint) { - List<IUniqueConstraint> uniqueConstraints = this.getUniqueConstraints(); + List<IUniqueConstraint> constraints = this.getUniqueConstraints(); int begin = Math.min(sourceIndex, targetIndex); int end = Math.max(sourceIndex, targetIndex); for (int i = begin; i-- > end;) { - this.synch(uniqueConstraints.get(i), i); + this.synch(constraints.get(i), i); } } @@ -1302,9 +1307,9 @@ public class JavaTableGenerator extends JavaGenerator * starting at the end of the list to prevent overlap */ private void synchUniqueConstraintAnnotationsAfterAdd(int index) { - List<IUniqueConstraint> uniqueConstraints = this.getUniqueConstraints(); - for (int i = uniqueConstraints.size(); i-- > index;) { - this.synch(uniqueConstraints.get(i), i); + List<IUniqueConstraint> constraints = this.getUniqueConstraints(); + for (int i = constraints.size(); i-- > index;) { + this.synch(constraints.get(i), i); } } @@ -1324,11 +1329,11 @@ public class JavaTableGenerator extends JavaGenerator } // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildAdapter(String elementName) { + private static DeclarationAnnotationElementAdapter<String> buildAdapter(String elementName) { return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); } - private static DeclarationAnnotationElementAdapter buildNumberAdapter(String elementName) { + private static DeclarationAnnotationElementAdapter<String> buildNumberAdapter(String elementName) { return buildNumberAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); } } // JavaTableGenerator diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTypeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTypeMapping.java index 0103f316d3..fcf699ac6e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTypeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaTypeMapping.java @@ -23,7 +23,6 @@ import org.eclipse.jpt.core.internal.jdtutility.Type; import org.eclipse.jpt.core.internal.mappings.ITable; import org.eclipse.jpt.db.internal.Schema; import org.eclipse.jpt.db.internal.Table; -import org.eclipse.jpt.utility.internal.Filter; import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; /** @@ -243,10 +242,6 @@ public abstract class JavaTypeMapping extends JavaEObject return EmptyIterator.instance(); } - public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) { - return EmptyIterator.instance(); - } - public Iterator<String> overridableAssociationNames() { return EmptyIterator.instance(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java index c2d24fa8c8..e5b573e9c5 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java @@ -15,6 +15,7 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; import org.eclipse.jdt.core.dom.Annotation; +import org.eclipse.jdt.core.dom.ArrayInitializer; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.content.java.JavaEObject; @@ -66,9 +67,9 @@ public class JavaUniqueConstraint extends JavaEObject private final IndexedAnnotationAdapter annotationAdapter; - private final DeclarationAnnotationElementAdapter columnNamesDeclarationAdapter; + private final DeclarationAnnotationElementAdapter<String[]> columnNamesDeclarationAdapter; - private final AnnotationElementAdapter columnNamesAdapter; + private final AnnotationElementAdapter<String[]> columnNamesAdapter; protected JavaUniqueConstraint() { super(); @@ -84,16 +85,16 @@ public class JavaUniqueConstraint extends JavaEObject this.columnNamesAdapter = this.buildAnnotationElementAdapter(this.columnNamesDeclarationAdapter); } - protected AnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter daea) { - return new ShortCircuitArrayAnnotationElementAdapter(this.member, daea); + protected AnnotationElementAdapter<String[]> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String[]> daea) { + return new ShortCircuitArrayAnnotationElementAdapter<String>(this.member, daea); } - protected static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return buildAnnotationElementAdapter(annotationAdapter, elementName, StringArrayExpressionConverter.forStringLiterals()); + protected static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, StringArrayExpressionConverter.forStringLiterals()); } - protected static DeclarationAnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); + protected static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String[], ArrayInitializer> converter) { + return new ConversionDeclarationAnnotationElementAdapter<String[], ArrayInitializer>(annotationAdapter, elementName, false, converter); } @Override @@ -101,7 +102,7 @@ public class JavaUniqueConstraint extends JavaEObject super.notifyChanged(notification); switch (notification.getFeatureID(IUniqueConstraint.class)) { case JpaJavaMappingsPackage.JAVA_UNIQUE_CONSTRAINT__COLUMN_NAMES : - this.columnNamesAdapter.setValue(getColumnNames().toArray()); + this.columnNamesAdapter.setValue((String[]) getColumnNames().toArray()); break; default : break; @@ -267,7 +268,7 @@ public class JavaUniqueConstraint extends JavaEObject } private void updateColumnNamesFromJava(CompilationUnit astRoot) { - String[] javaColumnNames = (String[]) this.columnNamesAdapter.getValue(astRoot); + String[] javaColumnNames = this.columnNamesAdapter.getValue(astRoot); CollectionTools.retainAll(getColumnNames(), javaColumnNames); for (int i = 0; i < javaColumnNames.length; i++) { String columnName = javaColumnNames[i]; @@ -322,4 +323,4 @@ public class JavaUniqueConstraint extends JavaEObject private static IndexedDeclarationAnnotationAdapter buildTableGeneratorUniqueConstraintAnnotationAdapter(int index) { return new NestedIndexedDeclarationAnnotationAdapter(JavaTableGenerator.DECLARATION_ANNOTATION_ADAPTER, JPA.TABLE_GENERATOR__UNIQUE_CONSTRAINTS, index, JPA.UNIQUE_CONSTRAINT); } -} // JavaUniqueConstraint +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaVersion.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaVersion.java index 88d2a3fa57..4153281e73 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaVersion.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaVersion.java @@ -47,13 +47,13 @@ public class JavaVersion extends JavaAttributeMapping implements IVersion { private final AnnotationAdapter temporalAnnotationAdapter; - private final AnnotationElementAdapter temporalValueAdapter; + private final AnnotationElementAdapter<String> temporalValueAdapter; public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.VERSION); private static final DeclarationAnnotationAdapter TEMPORAL_ADAPTER = new SimpleDeclarationAnnotationAdapter(JPA.TEMPORAL); - private static final DeclarationAnnotationElementAdapter TEMPORAL_VALUE_ADAPTER = buildTemporalValueAdapter(); + private static final DeclarationAnnotationElementAdapter<String> TEMPORAL_VALUE_ADAPTER = buildTemporalValueAdapter(); /** * The cached value of the '{@link #getColumn() <em>Column</em>}' containment reference. @@ -94,7 +94,7 @@ public class JavaVersion extends JavaAttributeMapping implements IVersion this.column = JavaColumn.createColumnMappingColumn(buildColumnOwner(), getAttribute()); ((InternalEObject) this.column).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JpaJavaMappingsPackage.JAVA_VERSION__COLUMN, null, null); this.temporalAnnotationAdapter = new MemberAnnotationAdapter(this.getAttribute(), TEMPORAL_ADAPTER); - this.temporalValueAdapter = new ShortCircuitAnnotationElementAdapter(attribute, TEMPORAL_VALUE_ADAPTER); + this.temporalValueAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, TEMPORAL_VALUE_ADAPTER); } /** @@ -390,7 +390,7 @@ public class JavaVersion extends JavaAttributeMapping implements IVersion } // ********** static methods ********** - private static DeclarationAnnotationElementAdapter buildTemporalValueAdapter() { + private static DeclarationAnnotationElementAdapter<String> buildTemporalValueAdapter() { return new EnumDeclarationAnnotationElementAdapter(TEMPORAL_ADAPTER, JPA.TEMPORAL__VALUE, false); } } |