Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IPersistentType.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToMany.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToOne.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToMany.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToOne.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlMultiRelationshipMappingInternal.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlPersistentType.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlRelationshipMapping.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IMultiRelationshipMapping.java6
12 files changed, 91 insertions, 38 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IPersistentType.java
index 6b1077eaa1..c246ba09e3 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IPersistentType.java
@@ -85,17 +85,19 @@ public interface IPersistentType extends IJpaContentNode
/**
* Return a read-only iterator of the contained IPersistentAttributes
- * @return
*/
Iterator<IPersistentAttribute> attributes();
+ Iterator<String> attributeNames();
+
/**
* Return a read-only iterator of the all the IPersistentAttributes
* in the hierarchy
- * @return
*/
Iterator<IPersistentAttribute> allAttributes();
+ Iterator<String> allAttributeNames();
+
/**
* Return the attribute named <code>attributeName</code> if
* it exists locally on this type
@@ -114,4 +116,4 @@ public interface IPersistentType extends IJpaContentNode
* Return the corresponding JDT IType, if it resolves to a single IType
*/
IType findJdtType();
-} \ No newline at end of file
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java
index a843a4e905..2924fafe49 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java
@@ -819,6 +819,19 @@ public class JavaPersistentType extends JavaEObject implements IPersistentType
return new ReadOnlyIterator<IPersistentAttribute>(getAttributes());
}
+ public Iterator<String> attributeNames() {
+ return this.attributeNames(this.attributes());
+ }
+
+ private Iterator<String> attributeNames(Iterator<IPersistentAttribute> attrs) {
+ return new TransformationIterator<IPersistentAttribute, String>(attrs) {
+ @Override
+ protected String transform(IPersistentAttribute attribute) {
+ return attribute.getName();
+ }
+ };
+ }
+
public Iterator<IPersistentAttribute> allAttributes() {
return new CompositeIterator<IPersistentAttribute>(new TransformationIterator<IPersistentType, Iterator<IPersistentAttribute>>(this.inheritanceHierarchy()) {
@Override
@@ -828,6 +841,10 @@ public class JavaPersistentType extends JavaEObject implements IPersistentType
});
}
+ public Iterator<String> allAttributeNames() {
+ return this.attributeNames(this.allAttributes());
+ }
+
public Iterator<IPersistentType> inheritanceHierarchy() {
// using a chain iterator to traverse up the inheritance tree
return new ChainIterator<IPersistentType>(this) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToMany.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToMany.java
index e3c503c3f9..28f5a1e604 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToMany.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToMany.java
@@ -74,6 +74,7 @@ public class JavaManyToMany extends JavaMultiRelationshipMapping
return TARGET_ENTITY_ADAPTER;
}
+ @Override
protected DeclarationAnnotationElementAdapter<String[]> cascadeAdapter() {
return CASCADE_ADAPTER;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToOne.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToOne.java
index c338197fa9..e54bf3f6fc 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToOne.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaManyToOne.java
@@ -59,6 +59,7 @@ public class JavaManyToOne extends JavaSingleRelationshipMapping
return TARGET_ENTITY_ADAPTER;
}
+ @Override
protected DeclarationAnnotationElementAdapter<String[]> cascadeAdapter() {
return CASCADE_ADAPTER;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java
index 968928a8b7..557f9e6d66 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMultiRelationshipMapping.java
@@ -36,6 +36,8 @@ import org.eclipse.jpt.core.internal.mappings.IOrderBy;
import org.eclipse.jpt.core.internal.mappings.ITable;
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 -->
@@ -147,7 +149,7 @@ public abstract class JavaMultiRelationshipMapping
protected JavaMultiRelationshipMapping(Attribute attribute) {
super(attribute);
this.mappedByAdapter = this.buildAnnotationElementAdapter(this.mappedByAdapter());
- this.mapKeyAnnotationAdapter = new MemberAnnotationAdapter(this.getAttribute(), MAP_KEY_ADAPTER);
+ this.mapKeyAnnotationAdapter = new MemberAnnotationAdapter(attribute, MAP_KEY_ADAPTER);
this.mapKeyNameAdapter = new ShortCircuitAnnotationElementAdapter<String>(attribute, MAP_KEY_NAME_ADAPTER);
this.joinTable = JpaJavaMappingsFactory.eINSTANCE.createJavaJoinTable(buildOwner(), attribute);
((InternalEObject) this.joinTable).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - JpaJavaMappingsPackage.JAVA_MULTI_RELATIONSHIP_MAPPING__JOIN_TABLE, null, null);
@@ -586,12 +588,7 @@ public abstract class JavaMultiRelationshipMapping
}
private void updateMapKeyFromJava(CompilationUnit astRoot) {
- if (this.mapKeyAnnotationAdapter.getAnnotation(astRoot) == null) {
- this.setMapKey(null);
- }
- else {
- this.setMapKey(this.mapKeyNameAdapter.getValue(astRoot));
- }
+ this.setMapKey(this.mapKeyNameAdapter.getValue(astRoot));
}
private JavaJoinTable getJavaJoinTable() {
@@ -607,10 +604,26 @@ public abstract class JavaMultiRelationshipMapping
setFetch(DefaultLazyFetchType.fromJavaAnnotationValue(this.getFetchAdapter().getValue(astRoot)));
}
- public boolean mappedByTouches(int pos, CompilationUnit astRoot) {
+ private boolean mappedByTouches(int pos, CompilationUnit astRoot) {
return this.elementTouches(this.mappedByAdapter(), pos, astRoot);
}
+ private boolean mapKeyNameTouches(int pos, CompilationUnit astRoot) {
+ return this.elementTouches(MAP_KEY_NAME_ADAPTER, pos, astRoot);
+ }
+
+ public Iterator<String> candidateMapKeyNames() {
+ return this.allTargetEntityAttributeNames();
+ }
+
+ protected Iterator<String> candidateMapKeyNames(Filter<String> filter) {
+ return new FilteringIterator<String>(this.candidateMapKeyNames(), filter);
+ }
+
+ protected Iterator<String> quotedCandidateMapKeyNames(Filter<String> filter) {
+ return StringTools.quote(this.candidateMapKeyNames(filter));
+ }
+
@Override
public Iterator<String> candidateValuesFor(int pos, Filter<String> filter, CompilationUnit astRoot) {
Iterator<String> result = super.candidateValuesFor(pos, filter, astRoot);
@@ -624,6 +637,9 @@ public abstract class JavaMultiRelationshipMapping
if (this.mappedByTouches(pos, astRoot)) {
return this.quotedCandidateMappedByAttributeNames(filter);
}
+ if (this.mapKeyNameTouches(pos, astRoot)) {
+ return this.quotedCandidateMapKeyNames(filter);
+ }
return null;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToMany.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToMany.java
index 42f5df0155..83359ca2f4 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToMany.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToMany.java
@@ -74,6 +74,7 @@ public class JavaOneToMany extends JavaMultiRelationshipMapping
return TARGET_ENTITY_ADAPTER;
}
+ @Override
protected DeclarationAnnotationElementAdapter<String[]> cascadeAdapter() {
return CASCADE_ADAPTER;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToOne.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToOne.java
index 7303472eca..7c21f6d8fd 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToOne.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaOneToOne.java
@@ -106,6 +106,7 @@ public class JavaOneToOne extends JavaSingleRelationshipMapping
return TARGET_ENTITY_ADAPTER;
}
+ @Override
protected DeclarationAnnotationElementAdapter<String[]> cascadeAdapter() {
return CASCADE_ADAPTER;
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java
index 26bd4be0fb..757ada9d1b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java
@@ -19,7 +19,6 @@ import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.core.internal.IPersistentAttribute;
import org.eclipse.jpt.core.internal.IPersistentType;
import org.eclipse.jpt.core.internal.ITypeMapping;
import org.eclipse.jpt.core.internal.content.java.JavaPersistentType;
@@ -46,7 +45,6 @@ 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;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
/**
* <!-- begin-user-doc -->
@@ -622,18 +620,13 @@ public abstract class JavaRelationshipMapping extends JavaAttributeMapping
setResolvedTargetEntity(null);
}
- public Iterator<String> candidateMappedByAttributeNames() {
+ public Iterator<String> allTargetEntityAttributeNames() {
IEntity targetEntity = this.getResolvedTargetEntity();
- return (targetEntity == null) ? EmptyIterator.<String> instance() : this.attributeNames(targetEntity.getPersistentType().attributes());
+ return (targetEntity == null) ? EmptyIterator.<String> instance() : targetEntity.getPersistentType().allAttributeNames();
}
- private Iterator<String> attributeNames(Iterator<IPersistentAttribute> attributes) {
- return new TransformationIterator<IPersistentAttribute, String>(attributes) {
- @Override
- protected String transform(IPersistentAttribute attribute) {
- return attribute.getName();
- }
- };
+ public Iterator<String> candidateMappedByAttributeNames() {
+ return this.allTargetEntityAttributeNames();
}
protected Iterator<String> candidateMappedByAttributeNames(Filter<String> filter) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlMultiRelationshipMappingInternal.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlMultiRelationshipMappingInternal.java
index 9f341360d0..6d5c9564fe 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlMultiRelationshipMappingInternal.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlMultiRelationshipMappingInternal.java
@@ -8,6 +8,7 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.content.orm;
+import java.util.Iterator;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
@@ -263,8 +264,8 @@ public abstract class XmlMultiRelationshipMappingInternal
}
public boolean isJoinTableSpecified() {
- XmlJoinTable joinTable = getJoinTableForXml();
- return joinTable != null && joinTable.isSpecified();
+ XmlJoinTable table = getJoinTableForXml();
+ return table != null && table.isSpecified();
}
/**
@@ -635,4 +636,8 @@ public abstract class XmlMultiRelationshipMappingInternal
super.initializeFromXmlMulitRelationshipMapping(oldMapping);
setFetch(oldMapping.getFetch());
}
-} // XmlMultiRelationshipMapping \ No newline at end of file
+
+ public Iterator<String> candidateMapKeyNames() {
+ return this.allTargetEntityAttributeNames();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlPersistentType.java
index 649ef721b3..b6cf816843 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlPersistentType.java
@@ -799,6 +799,19 @@ public class XmlPersistentType extends XmlEObject implements IPersistentType
return new ReadOnlyIterator(getPersistentAttributes());
}
+ public Iterator<String> attributeNames() {
+ return this.attributeNames(this.attributes());
+ }
+
+ private Iterator<String> attributeNames(Iterator<IPersistentAttribute> attrs) {
+ return new TransformationIterator<IPersistentAttribute, String>(attrs) {
+ @Override
+ protected String transform(IPersistentAttribute attribute) {
+ return attribute.getName();
+ }
+ };
+ }
+
public Iterator<IPersistentAttribute> allAttributes() {
return new CompositeIterator(new TransformationIterator(this.inheritanceHierarchy()) {
protected Object transform(Object next) {
@@ -807,6 +820,10 @@ public class XmlPersistentType extends XmlEObject implements IPersistentType
});
}
+ public Iterator<String> allAttributeNames() {
+ return this.attributeNames(this.allAttributes());
+ }
+
public Iterator<IPersistentType> inheritanceHierarchy() {
// using a chain iterator to traverse up the inheritance tree
return new ChainIterator(this) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlRelationshipMapping.java
index 15d1a09c16..7954567202 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlRelationshipMapping.java
@@ -14,7 +14,6 @@ import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
-import org.eclipse.jpt.core.internal.IPersistentAttribute;
import org.eclipse.jpt.core.internal.IPersistentType;
import org.eclipse.jpt.core.internal.mappings.ICascade;
import org.eclipse.jpt.core.internal.mappings.IEntity;
@@ -24,7 +23,6 @@ import org.eclipse.jpt.core.internal.mappings.RelationshipMappingTools;
import org.eclipse.jpt.core.internal.platform.BaseJpaPlatform;
import org.eclipse.jpt.core.internal.platform.DefaultsContext;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
/**
* <!-- begin-user-doc -->
@@ -524,16 +522,13 @@ public abstract class XmlRelationshipMapping extends XmlAttributeMapping
return getTargetEntity().lastIndexOf('.') != -1;
}
+ public Iterator<String> allTargetEntityAttributeNames() {
+ IEntity targetEntity = this.getResolvedTargetEntity();
+ return (targetEntity == null) ? EmptyIterator.<String> instance() : targetEntity.getPersistentType().allAttributeNames();
+ }
+
public Iterator<String> candidateMappedByAttributeNames() {
- IEntity targetEntity = getResolvedTargetEntity();
- if (targetEntity == null) {
- return EmptyIterator.instance();
- }
- return new TransformationIterator<IPersistentAttribute, String>(targetEntity.getPersistentType().attributes()) {
- protected String transform(IPersistentAttribute attribute) {
- return attribute.getName();
- }
- };
+ return this.allTargetEntityAttributeNames();
}
@Override
@@ -552,4 +547,4 @@ public abstract class XmlRelationshipMapping extends XmlAttributeMapping
}
setResolvedTargetEntity(null);
}
-} // XmlRelationshipMapping
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IMultiRelationshipMapping.java
index dcfa7dda6c..5e5f0bcfd0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IMultiRelationshipMapping.java
@@ -9,6 +9,8 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.mappings;
+import java.util.Iterator;
+
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>IMulti Relationship Mapping</b></em>'.
@@ -121,4 +123,6 @@ public interface IMultiRelationshipMapping extends INonOwningMapping
* @generated
*/
void setMapKey(String value);
-} // IMultiRelationshipMapping
+
+ Iterator<String> candidateMapKeyNames();
+}

Back to the top