summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNan Li2013-05-15 17:13:42 (EDT)
committerNeil Hauge2013-05-16 11:22:21 (EDT)
commit0e80b193eca03a5a2342382c729b50967a18cb35 (patch)
tree3ac97cf508ef1fb52436711b8a3ff02242980ddd
parent16dfc3ace6419973df539984aa6714c7b5940fd0 (diff)
downloadwebtools.dali-0e80b193eca03a5a2342382c729b50967a18cb35.zip
webtools.dali-0e80b193eca03a5a2342382c729b50967a18cb35.tar.gz
webtools.dali-0e80b193eca03a5a2342382c729b50967a18cb35.tar.bz2
404941, 305593 - improve sync class list for persistence.xmlv201305161638
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
index 2a0155f..3677e64 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
@@ -12,6 +12,7 @@ package org.eclipse.jpt.jpa.core.internal.context.persistence;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
@@ -29,6 +30,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.emf.common.util.ECollections;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -2046,13 +2048,14 @@ public abstract class AbstractPersistenceUnit
// ********** synchronize classes **********
public void synchronizeClasses(IProgressMonitor monitor) {
- SubMonitor sm = SubMonitor.convert(monitor, 3);
+ SubMonitor sm = SubMonitor.convert(monitor, 4);
- // calculate the refs to remove and add
+ // newTypes collection only includes those that are annotated
HashSet<JavaResourceAbstractType> newTypes = CollectionTools.set(this.getJpaProject().getPotentialJavaSourceTypes());
ArrayList<ClassRef> deadClassRefs = new ArrayList<ClassRef>();
HashSet<String> mappingFileTypeNames = this.getMappingFileTypeNames();
+ // collect those class refs that need to be removed from persistence.xml
for (ClassRef classRef : this.getSpecifiedClassRefs()) {
JavaManagedType specifiedJMT = classRef.getJavaManagedType();
if (specifiedJMT == null) {
@@ -2069,6 +2072,14 @@ public abstract class AbstractPersistenceUnit
}
}
}
+
+ // if a type is included in a mapping file, remove it from the newTypes collection
+ for (java.util.Iterator<JavaResourceAbstractType> iterator = newTypes.iterator(); iterator.hasNext();) {
+ JavaResourceAbstractType type = iterator.next();
+ if (mappingFileTypeNames.contains(type.getTypeBinding().getQualifiedName())) {
+ iterator.remove();
+ }
+ }
if (sm.isCanceled()) {
return;
}
@@ -2082,6 +2093,16 @@ public abstract class AbstractPersistenceUnit
this.addSpecifiedClassRefs(newTypes);
sm.worked(1);
+
+ // sort the list of class refs within the persistence.xml
+ ECollections.sort(this.getXmlPersistenceUnit().getClasses(), new XmlJavaClassRefNameComp());
+ sm.worked(1);
+ }
+
+ public class XmlJavaClassRefNameComp implements Comparator<XmlJavaClassRef>{
+ public int compare(XmlJavaClassRef xjcr1, XmlJavaClassRef xjcr2) {
+ return xjcr1.getJavaClass().compareTo(xjcr2.getJavaClass());
+ }
}
/**