summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-12-21 16:34:09 (EST)
committerKaren Butzke2012-12-21 16:34:09 (EST)
commitaf3682710f55886d8021926c34bc3d0bf4f8628b (patch)
tree680110fa06e87bb796326222e32393b04dd8dbfc
parent772b069618ae3f1fa1b8e1546b9fe14afc79f50d (diff)
downloadwebtools.dali-af3682710f55886d8021926c34bc3d0bf4f8628b.zip
webtools.dali-af3682710f55886d8021926c34bc3d0bf4f8628b.tar.gz
webtools.dali-af3682710f55886d8021926c34bc3d0bf4f8628b.tar.bz2
changed getAnnotatedJavaSourceClassNames() to getAnnotatedJavaSourceTypes(), first for performance since it leads to less follow-up lookups of JavaResoursAbstractType by name and second to match the change to getMappedJavaSourceTypes().
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java31
3 files changed, 19 insertions, 29 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
index af56e52..de869a3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
@@ -223,10 +223,10 @@ public interface JpaProject
// ********** Java resources **********
/**
- * Return the names of the JPA project's annotated Java classes
+ * Return the resource types of the JPA project's annotated Java classes
* (ignoring classes in JARs referenced in the <code>persistence.xml</code>).
*/
- Iterable<String> getAnnotatedJavaSourceClassNames();
+ Iterable<JavaResourceAbstractType> getAnnotatedJavaSourceTypes();
/**
* Return only the types of those valid <em>mapped</em> (i.e. annotated with
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
index ab44b0e..51d770f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
@@ -818,22 +818,13 @@ public abstract class AbstractJpaProject
// ********** annotated Java source classes **********
- public Iterable<String> getAnnotatedJavaSourceClassNames() {
- return new TransformationIterable<JavaResourceAbstractType, String>(this.getInternalAnnotatedSourceJavaResourceTypes()) {
- @Override
- protected String transform(JavaResourceAbstractType jraType) {
- return jraType.getTypeBinding().getQualifiedName();
- }
- };
- }
-
/**
* Return only those valid annotated Java resource types that are
* directly part of the JPA project, ignoring those in JARs referenced in
* <code>persistence.xml</code>.
* @see JavaResourceAbstractType#isAnnotated()
*/
- protected Iterable<JavaResourceAbstractType> getInternalAnnotatedSourceJavaResourceTypes() {
+ public Iterable<JavaResourceAbstractType> getAnnotatedJavaSourceTypes() {
return new FilteringIterable<JavaResourceAbstractType>(this.getInternalSourceJavaResourceTypes()) {
@Override
protected boolean accept(JavaResourceAbstractType jraType) {
@@ -860,7 +851,7 @@ public abstract class AbstractJpaProject
*/
protected Iterable<JavaResourceAbstractType> getInternalMappedSourceJavaResourceTypes() {
final Iterable<String> typeMappingAnnotationNames = this.getTypeMappingAnnotationNames();
- return new FilteringIterable<JavaResourceAbstractType>(this.getInternalAnnotatedSourceJavaResourceTypes()) {
+ return new FilteringIterable<JavaResourceAbstractType>(this.getAnnotatedJavaSourceTypes()) {
@Override
protected boolean accept(JavaResourceAbstractType jraType) {
return jraType.isAnnotatedWithAnyOf(typeMappingAnnotationNames);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java
index 4d8be66..60f8ca6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java
@@ -283,28 +283,27 @@ public class GenericRootContextNode
}
PersistenceUnit persistenceUnit = persistence.getPersistenceUnits().iterator().next();
- HashBag<String> annotatedClassNames = CollectionTools.bag(this.jpaProject.getAnnotatedJavaSourceClassNames());
- HashBag<String> orphans = annotatedClassNames.clone();
- for (String annotatedClassName : annotatedClassNames) {
- if (persistenceUnit.specifiesPersistentType(annotatedClassName)) {
- orphans.remove(annotatedClassName);
+ HashBag<JavaResourceAbstractType> annotatedTypes = CollectionTools.bag(this.jpaProject.getAnnotatedJavaSourceTypes());
+ HashBag<JavaResourceAbstractType> orphans = annotatedTypes.clone();
+ for (JavaResourceAbstractType jrat : annotatedTypes) {
+ if (persistenceUnit.specifiesPersistentType(jrat.getTypeBinding().getQualifiedName())) {
+ orphans.remove(jrat);
}
- else if (MetamodelSynchronizer.MetamodelTools.isMetamodel(getJpaProject().getJavaResourceType(annotatedClassName))) {
- orphans.remove(annotatedClassName);
+ else if (MetamodelSynchronizer.MetamodelTools.isMetamodel(jrat)) {
+ orphans.remove(jrat);
}
}
Iterable<String> typeMappingAnnotationNames = this.jpaProject.getTypeMappingAnnotationNames();
- for (String orphan : orphans) {
- JavaResourceAbstractType jrt = this.jpaProject.getJavaResourceType(orphan);
- if (jrt.isAnnotatedWithAnyOf(typeMappingAnnotationNames)) {
+ for (JavaResourceAbstractType jrat : annotatedTypes) {
+ if (jrat.isAnnotatedWithAnyOf(typeMappingAnnotationNames)) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
JpaValidationMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT,
- new String[] {jrt.getTypeBinding().getQualifiedName()},
- jrt.getFile(),
- jrt.getNameTextRange()
+ new String[] {jrat.getTypeBinding().getQualifiedName()},
+ jrat.getFile(),
+ jrat.getNameTextRange()
)
);
}
@@ -313,9 +312,9 @@ public class GenericRootContextNode
DefaultJpaValidationMessages.buildMessage(
IMessage.NORMAL_SEVERITY,
JpaValidationMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT,
- new String[] {jrt.getName()},
- jrt.getFile(),
- jrt.getNameTextRange()
+ new String[] {jrat.getName()},
+ jrat.getFile(),
+ jrat.getNameTextRange()
)
);
}