summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-11-30 14:30:56 (EST)
committerKaren Butzke2012-11-30 14:30:56 (EST)
commitbef576bcc297542b320d39f5ffc8c75fd3726f14 (patch)
tree2a0dc8489bc2a661d2bb55cda4d8441d8e063bb2
parent90285ff9e3617b446fd0da4c992d66e2ba1ca36e (diff)
downloadwebtools.dali-bef576bcc297542b320d39f5ffc8c75fd3726f14.zip
webtools.dali-bef576bcc297542b320d39f5ffc8c75fd3726f14.tar.gz
webtools.dali-bef576bcc297542b320d39f5ffc8c75fd3726f14.tar.bz2
refactored validation of query/generator/converter to remove instanceof TODOs, possible after the major validation refactoring made Java/Orm have the same API
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Generator.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Query.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaQuery.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmQuery.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java51
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverter.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java4
16 files changed, 78 insertions, 82 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java
index a95e8dc..a26d22f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.context;
+import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.iterable.ListIterable;
/**
@@ -290,4 +291,10 @@ public interface Entity
* Else return null.
*/
PersistentAttribute getIdAttribute();
+
+ /**
+ * Returns the {@link TextRange} of the name property.
+ */
+ TextRange getNameTextRange();
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Generator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Generator.java
index 63673d8..984760e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Generator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Generator.java
@@ -42,6 +42,11 @@ public interface Generator
TextRange getNameTextRange();
/**
+ * Return whether this generator should be validated and have validation messages displayed
+ */
+ boolean supportsValidationMessages();
+
+ /**
* Return the generator's type.
*/
Class<? extends Generator> getType();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Query.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Query.java
index 0656d9c..9308187 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Query.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Query.java
@@ -13,6 +13,9 @@ import java.util.List;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.utility.internal.iterable.ArrayIterable;
import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
/**
* Named and named native queries.
* <p>
@@ -95,6 +98,16 @@ public interface Query
QueryHint getHint(int i);
+
+ // ********** validation **********
+
+ void validate(JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter);
+
+ /**
+ * Return whether this query should be validated and have validation messages displayed
+ */
+ boolean supportsValidationMessages();
+
/**
* Returns the {@link TextRange} of the name property.
*/
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaQuery.java
index 0ac9368..d0dca59 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaQuery.java
@@ -9,14 +9,10 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.context.java;
-import java.util.List;
import org.eclipse.jpt.common.utility.iterable.ListIterable;
import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
-import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper;
import org.eclipse.jpt.jpa.core.resource.java.QueryAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
/**
* Java named and named native queries
@@ -45,10 +41,6 @@ public interface JavaQuery
JavaQueryHint addHint(int index);
- // ********** validation **********
-
- void validate(JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter);
-
// ********** metadata conversion *********
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmQuery.java
index 0cf8fd4..8531bae 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmQuery.java
@@ -9,13 +9,9 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.context.orm;
-import java.util.List;
import org.eclipse.jpt.common.utility.iterable.ListIterable;
import org.eclipse.jpt.jpa.core.context.Query;
-import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper;
import org.eclipse.jpt.jpa.core.resource.orm.XmlQuery;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
/**
* <code>orm.xml</code> named and named native queries
@@ -43,9 +39,4 @@ public interface OrmQuery
OrmQueryHint addHint(int index);
-
- // ********** validation **********
-
- void validate(JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter);
-
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
index 3f664b5..0bbc1c7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
@@ -1341,6 +1341,10 @@ public abstract class AbstractJavaEntity
}
}
+ public TextRange getNameTextRange() {
+ return this.getMappingAnnotation().getNameTextRange();
+ }
+
protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter) {
this.buildPrimaryKeyValidator().validate(messages, reporter);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java
index 20178da..7b9e308 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java
@@ -17,6 +17,7 @@ import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
import org.eclipse.jpt.jpa.core.context.java.JavaGenerator;
import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
+import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.jpa.core.resource.java.GeneratorAnnotation;
@@ -71,6 +72,10 @@ public abstract class AbstractJavaGenerator<A extends GeneratorAnnotation>
// ********** validation **********
+ public boolean supportsValidationMessages() {
+ return MappingTools.nodeIsInternalSource(this, this.getGeneratorAnnotation());
+ }
+
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java
index 913d78f..f4cba84 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java
@@ -23,6 +23,7 @@ import org.eclipse.jpt.jpa.core.context.QueryHint;
import org.eclipse.jpt.jpa.core.context.java.JavaQuery;
import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
import org.eclipse.jpt.jpa.core.context.java.JavaQueryHint;
+import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.jpa.core.jpql.JpaJpqlQueryHelper;
@@ -190,6 +191,10 @@ public abstract class AbstractJavaQuery<A extends QueryAnnotation>
// ********** validation **********
+ public boolean supportsValidationMessages() {
+ return MappingTools.nodeIsInternalSource(this, this.getQueryAnnotation());
+ }
+
public void validate(JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
this.validateName(messages);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
index 191a903..0640626 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
@@ -1783,6 +1783,11 @@ public abstract class AbstractOrmEntity<X extends XmlEntity>
}
}
+ @Override
+ public TextRange getNameTextRange() {
+ return this.getXmlTypeMapping().getNameTextRange();
+ }
+
protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter) {
this.buildPrimaryKeyValidator().validate(messages, reporter);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
index c56a77f..ab5fa20 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
@@ -73,6 +73,10 @@ public abstract class AbstractOrmGenerator<X extends XmlGenerator>
// ********** validation **********
+ public boolean supportsValidationMessages() {
+ return true;
+ }
+
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java
index 7ef5d2f..8402392 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java
@@ -211,6 +211,10 @@ public abstract class AbstractOrmQuery<X extends XmlQuery>
// ********** validation **********
+ public boolean supportsValidationMessages() {
+ return true;
+ }
+
public void validate(JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
this.validateName(messages);
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 f3e3208..853f681 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
@@ -73,8 +73,6 @@ import org.eclipse.jpt.jpa.core.context.java.JavaQuery;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmGenerator;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQuery;
import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef;
@@ -2519,7 +2517,7 @@ public abstract class AbstractPersistenceUnit
protected void validateGeneratorsWithSameName(String generatorName, ArrayList<Generator> dups, List<IMessage> messages) {
String[] parms = new String[] {generatorName};
for (Generator dup : dups) {
- if (this.generatorSupportsValidationMessages(dup)) {
+ if (dup.supportsValidationMessages()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -2533,23 +2531,9 @@ public abstract class AbstractPersistenceUnit
}
}
- protected boolean generatorSupportsValidationMessages(Generator generator) {
- return (generator instanceof OrmGenerator) || this.generatorSupportsValidationMessages((JavaGenerator) generator);
- }
-
- protected boolean generatorSupportsValidationMessages(JavaGenerator javaGenerator) {
- return MappingTools.nodeIsInternalSource(javaGenerator, javaGenerator.getGeneratorAnnotation());
- }
-
- // TODO bjv isn't it obvious?
protected void validate(Generator generator, List<IMessage> messages, IReporter reporter) {
- if (generator instanceof OrmGenerator) {
- ((OrmGenerator) generator).validate(messages, reporter);
- } else {
- JavaGenerator javaGenerator = (JavaGenerator) generator;
- if (this.generatorSupportsValidationMessages(javaGenerator)) {
- javaGenerator.validate(messages, reporter);
- }
+ if (generator.supportsValidationMessages()) {
+ generator.validate(messages, reporter);
}
}
@@ -2583,7 +2567,7 @@ public abstract class AbstractPersistenceUnit
protected void validateQueriesWithSameName(String queryName, ArrayList<Query> dups, List<IMessage> messages) {
String[] parms = new String[] {queryName};
for (Query dup : dups) {
- if (this.querySupportsValidationMessages(dup)) {
+ if (dup.supportsValidationMessages()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -2597,23 +2581,9 @@ public abstract class AbstractPersistenceUnit
}
}
- protected boolean querySupportsValidationMessages(Query query) {
- return (query instanceof OrmQuery) || this.querySupportsValidationMessages((JavaQuery) query);
- }
-
- protected boolean querySupportsValidationMessages(JavaQuery javaQuery) {
- return MappingTools.nodeIsInternalSource(javaQuery, javaQuery.getQueryAnnotation());
- }
-
- // TODO bjv isn't it obvious?
protected void validate(Query query, JpaJpqlQueryHelper queryHelper, List<IMessage> messages, IReporter reporter) {
- if (query instanceof OrmQuery) {
- ((OrmQuery) query).validate(queryHelper, messages, reporter);
- } else {
- JavaQuery javaQuery = (JavaQuery) query;
- if (this.querySupportsValidationMessages(javaQuery)) {
- javaQuery.validate(queryHelper, messages, reporter);
- }
+ if (query.supportsValidationMessages()) {
+ query.validate(queryHelper, messages, reporter);
}
}
@@ -2659,7 +2629,7 @@ public abstract class AbstractPersistenceUnit
JpaValidationMessages.ENTITY_NAME_DUPLICATED,
parms,
dup,
- this.extractNameTextRange(dup)
+ dup.getNameTextRange()
)
);
}
@@ -2674,13 +2644,6 @@ public abstract class AbstractPersistenceUnit
return MappingTools.nodeIsInternalSource(javaEntity, javaEntity.getJavaResourceType());
}
- // TODO bjv isn't it obvious?
- protected TextRange extractNameTextRange(Entity entity) {
- return (entity instanceof OrmEntity) ?
- ((OrmEntity) entity).getXmlTypeMapping().getNameTextRange():
- ((JavaEntity) entity).getMappingAnnotation().getNameTextRange();
- }
-
public boolean validatesAgainstDatabase() {
return this.connectionProfileIsActive();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverter.java
index f4a450a..07b2c33 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverter.java
@@ -52,6 +52,11 @@ public interface EclipseLinkConverter
*/
char getEnclosingTypeSeparator();
+ /**
+ * Return whether this query should be validated and have validation messages displayed
+ */
+ boolean supportsValidationMessages();
+
TextRange getNameTextRange();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java
index 441f8fa..2a68606 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/persistence/EclipseLinkPersistenceUnit.java
@@ -53,7 +53,6 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.internal.JptCoreMessages;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.VirtualOrmXmlRef;
import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.SharedCacheMode;
@@ -72,7 +71,6 @@ import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkJpaJpqlQueryHelp
import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLinkJpaValidationMessages;
import org.eclipse.jpt.jpa.eclipselink.core.internal.JptJpaEclipseLinkCoreMessages;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.JavaEclipseLinkConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkConverter;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm.OrmEclipseLinkPersistenceUnitMetadata;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.persistence.EclipseLinkCaching;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.persistence.EclipseLinkCustomization;
@@ -1006,7 +1004,7 @@ public class EclipseLinkPersistenceUnit
String[] parms = new String[] {converterName};
if (this.anyNodesAreInequivalent(dups)) {
for (EclipseLinkConverter dup : dups) {
- if (this.converterSupportsValidationMessages(dup)) {
+ if (dup.supportsValidationMessages()) {
messages.add(
DefaultEclipseLinkJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -1043,23 +1041,9 @@ public class EclipseLinkPersistenceUnit
return false;
}
- protected boolean converterSupportsValidationMessages(EclipseLinkConverter converter) {
- return (converter instanceof OrmEclipseLinkConverter<?>) || this.converterSupportsValidationMessages((JavaEclipseLinkConverter<?>) converter);
- }
-
- protected boolean converterSupportsValidationMessages(JavaEclipseLinkConverter<?> javaConverter) {
- return MappingTools.nodeIsInternalSource(javaConverter, javaConverter.getConverterAnnotation());
- }
-
- // TODO bjv isn't it obvious?
protected void validate(EclipseLinkConverter converter, List<IMessage> messages, IReporter reporter) {
- if (converter instanceof OrmEclipseLinkConverter<?>) {
- ((OrmEclipseLinkConverter<?>) converter).validate(messages, reporter);
- } else {
- JavaEclipseLinkConverter<?> javaConverter = (JavaEclipseLinkConverter<?>) converter;
- if (this.converterSupportsValidationMessages(javaConverter)) {
- javaConverter.validate(messages, reporter);
- }
+ if (converter.supportsValidationMessages()) {
+ converter.validate(messages, reporter);
}
}
@@ -1072,7 +1056,7 @@ public class EclipseLinkPersistenceUnit
if (this.allNodesAreEquivalent(dups)) {
String[] parms = new String[] {generatorName};
for (Generator dup : dups) {
- if (this.generatorSupportsValidationMessages(dup)) {
+ if (dup.supportsValidationMessages()) {
messages.add(
DefaultEclipseLinkJpaValidationMessages.buildMessage(
IMessage.LOW_SEVERITY,
@@ -1097,7 +1081,7 @@ public class EclipseLinkPersistenceUnit
if (this.allNodesAreEquivalent(dups)) {
String[] parms = new String[] {queryName};
for (Query dup : dups) {
- if (this.querySupportsValidationMessages(dup)) {
+ if (dup.supportsValidationMessages()) {
messages.add(
DefaultEclipseLinkJpaValidationMessages.buildMessage(
IMessage.LOW_SEVERITY,
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java
index 2feb3a3..0d44312 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java
@@ -17,6 +17,7 @@ import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
+import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConvert;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConverter;
@@ -115,6 +116,10 @@ public abstract class JavaEclipseLinkConverter<A extends EclipseLinkNamedConvert
// ********** validation **********
+ public boolean supportsValidationMessages() {
+ return MappingTools.nodeIsInternalSource(this, this.getConverterAnnotation());
+ }
+
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java
index 21c0567..d7b2bf1 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java
@@ -105,6 +105,10 @@ public abstract class OrmEclipseLinkConverter<X extends XmlNamedConverter>
// ********** validation **********
+ public boolean supportsValidationMessages() {
+ return true;
+ }
+
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);