summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2012-11-30 14:50:51 (EST)
committerKaren Butzke2012-11-30 14:50:51 (EST)
commit458e06606716ddf865a96dbed1298615c0f443d9 (patch)
tree1eb9df5ef00456ad78147db54b38e5a54ffae082
parentbef576bcc297542b320d39f5ffc8c75fd3726f14 (diff)
downloadwebtools.dali-458e06606716ddf865a96dbed1298615c0f443d9.zip
webtools.dali-458e06606716ddf865a96dbed1298615c0f443d9.tar.gz
webtools.dali-458e06606716ddf865a96dbed1298615c0f443d9.tar.bz2
another refactoring to remove an instanceof related to validationv201212040155
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/Entity.java18
-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/orm/AbstractOrmEntity.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java13
4 files changed, 22 insertions, 17 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 a26d22f..b7ae57f 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
@@ -278,6 +278,19 @@ public interface Entity
String DESCENDANTS_COLLECTION = "descendants"; //$NON-NLS-1$
+ // ********** validation **********
+
+ /**
+ * Returns the {@link TextRange} of the name property.
+ */
+ TextRange getNameTextRange();
+
+ /**
+ * Return whether this entity should be validated and have validation messages displayed
+ */
+ boolean supportsValidationMessages();
+
+
// ********** misc **********
/**
@@ -292,9 +305,4 @@ public interface Entity
*/
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/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 0bbc1c7..85cc9db 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 boolean supportsValidationMessages() {
+ return MappingTools.nodeIsInternalSource(this, this.getJavaResourceType());
+ }
+
public TextRange getNameTextRange() {
return this.getMappingAnnotation().getNameTextRange();
}
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 0640626..741b438 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,10 @@ public abstract class AbstractOrmEntity<X extends XmlEntity>
}
}
+ public boolean supportsValidationMessages() {
+ return true;
+ }
+
@Override
public TextRange getNameTextRange() {
return this.getXmlTypeMapping().getNameTextRange();
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 853f681..bade179 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
@@ -66,13 +66,11 @@ import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
import org.eclipse.jpt.jpa.core.context.java.JavaGenerator;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
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.OrmQueryContainer;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef;
@@ -83,7 +81,6 @@ import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistentTypeContainer;
import org.eclipse.jpt.jpa.core.internal.JptCoreMessages;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
import org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
@@ -2622,7 +2619,7 @@ public abstract class AbstractPersistenceUnit
protected void validateEntitiesWithSameName(String entityName, ArrayList<Entity> dups, List<IMessage> messages) {
String[] parms = new String[] {entityName};
for (Entity dup : dups) {
- if (this.entitySupportsValidationMessages(dup)) {
+ if (dup.supportsValidationMessages()) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
@@ -2636,14 +2633,6 @@ public abstract class AbstractPersistenceUnit
}
}
- protected boolean entitySupportsValidationMessages(Entity entity) {
- return (entity instanceof OrmEntity) || this.entitySupportsValidationMessages((JavaEntity) entity);
- }
-
- protected boolean entitySupportsValidationMessages(JavaEntity javaEntity) {
- return MappingTools.nodeIsInternalSource(javaEntity, javaEntity.getJavaResourceType());
- }
-
public boolean validatesAgainstDatabase() {
return this.connectionProfileIsActive();
}