Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornhauge2011-01-21 22:50:00 +0000
committernhauge2011-01-21 22:50:00 +0000
commit2afdf8a237e5b9dbf35e9584d49647d15f6f8a94 (patch)
tree6bc356bd9cd81dd8869e1fdd21f507788e72d7d4
parentaaef87eba5fe900472d890be97dfe18af72f04f0 (diff)
downloadwebtools.dali-2afdf8a237e5b9dbf35e9584d49647d15f6f8a94.tar.gz
webtools.dali-2afdf8a237e5b9dbf35e9584d49647d15f6f8a94.tar.xz
webtools.dali-2afdf8a237e5b9dbf35e9584d49647d15f6f8a94.zip
[256003] [331610] - added validation for queries, generators, and converters. Patch from Nan.
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/.classpath2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties5
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmVersionMapping.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaQueryContainer.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties3
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConvert.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityImpl.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlEntityMappings.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlNamedConverter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_details.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkConversionValueStateObject.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkUiDetailsMessages.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterDialog.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterStateObject.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/OrmEclipseLinkConvertersComposite.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details_orm.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryDialog.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryStateObject.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JptUiDetailsMessages.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorDialog.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorStateObject.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/JptUiDetailsOrmMessages.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/NewNameStateObject.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/ValidatingDialog.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AbstractNode.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/DefaultProblem.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Problem.java5
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/AbstractNodeTests.java2
44 files changed, 541 insertions, 101 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/.classpath b/jpa/plugins/org.eclipse.jpt.core/.classpath
index 5ee7c76127..652b298a08 100644
--- a/jpa/plugins/org.eclipse.jpt.core/.classpath
+++ b/jpa/plugins/org.eclipse.jpt.core/.classpath
@@ -2,12 +2,12 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="property_files"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
<accessrules>
<accessrule kind="accessible" pattern="org/eclipse/wst/**"/>
<accessrule kind="accessible" pattern="org/eclipse/jst/**"/>
</accessrules>
</classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre6"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
index 4693939c89..bd137902a5 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
@@ -19,6 +19,7 @@ PERSISTENCE_XML_INVALID_CONTENT=The persistence.xml file does not have recognize
PERSISTENCE_XML_UNSUPPORTED_CONTENT=The persistence.xml file does not have supported content for this JPA platform.
PERSISTENCE_NO_PERSISTENCE_UNIT=No persistence unit defined
PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS=Multiple persistence units defined - only the first persistence unit will be recognized
+PERSISTENCE_UNIT_ENTITY_NAME_ATTRIBUTE_MISSING=Duplicate entity \"{0}\" found in this persistence unit. Each entity must have a unique name within a persistent unit.
PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE=Unspecified mapping file
PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT=Mapping file {0} does not have supported content for this JPA platform.
PERSISTENCE_UNIT_INVALID_MAPPING_FILE=Mapping file {0} does not have recognized content.
@@ -34,7 +35,10 @@ PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE=Unspecified JAR file
PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING=The path to the JAR file will vary on your runtime environment. Please make sure the specified path fits your particular environment.
PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE=JAR file \"{0}\" cannot be resolved
GENERATOR_DUPLICATE_NAME=Duplicate generator named \"{0}\" defined in this persistence unit
+GENERATOR_NAME_UNDEFINED=Generator is unnamed. All generators require a name.
QUERY_DUPLICATE_NAME=Duplicate query named \"{0}\" defined in this persistence unit
+QUERY_STATEMENT_UNDEFINED=Query \"{0}\" has no query statement. All queries require a query statement.
+QUERY_NAME_UNDEFINED=Query is unnamed. All queries require a name.
MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA=Extraneous persistence unit metadata found for mapping file \"{0}\". These metadata will not be used.
PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT=Class \"{0}\" is mapped, but is not included in any persistence unit
PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT=Class \"{0}\" is annotated, but is not included in any persistence unit
@@ -64,6 +68,7 @@ ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE=No table should be defined for non-
ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE=No table should be defined for abstract entity \"{0}\" using table-per-concrete-class inheritance
ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED=No discriminator value should be defined for abstract entity \"{0}\"
ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED=No discriminator value should be defined for entity \"{0}\" using table-per-concrete-class inheritance
+ENTITY_NAME_MISSING=The given name of the entity \"{0}\" is empty
ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED=No discriminator column should be defined for non-root entity \"{0}\"
ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED=No discriminator column should be defined for entity \"{0}\" using table-per-concrete-class inheritance
PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME=Unspecified name
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java
index e6923d3789..e7506c8db2 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.context.orm;
+import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@@ -48,6 +49,7 @@ import org.eclipse.jpt.db.Catalog;
import org.eclipse.jpt.db.Schema;
import org.eclipse.jpt.db.SchemaContainer;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.Tools;
import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
@@ -167,7 +169,7 @@ public abstract class AbstractEntityMappings
return (OrmXml) super.getParent();
}
- protected OrmXml getOrmXml() {
+ public OrmXml getOrmXml() {
return this.getParent();
}
@@ -902,17 +904,31 @@ public abstract class AbstractEntityMappings
protected void validateGenerators(List<IMessage> messages) {
for (OrmGenerator localGenerator : this.getGenerators()) {
- for (Iterator<Generator> globalGenerators = this.getPersistenceUnit().generators(); globalGenerators.hasNext(); ) {
- if (localGenerator.duplicates(globalGenerators.next())) {
- messages.add(
+ String name = localGenerator.getName();
+ if (StringTools.stringIsEmpty(name)) {
+ messages.add(
DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
- new String[] {localGenerator.getName()},
- localGenerator,
- localGenerator.getNameTextRange()
- )
- );
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.GENERATOR_NAME_UNDEFINED,
+ new String[] {},
+ localGenerator,
+ localGenerator.getNameTextRange()
+ ));
+ } else {
+ List<String> reportedNames = new ArrayList<String>();
+ for (Iterator<Generator> globalGenerators = this.getPersistenceUnit().generators(); globalGenerators.hasNext(); ) {
+ if (localGenerator.duplicates(globalGenerators.next()) && !reportedNames.contains(name)) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
+ new String[] {localGenerator.getName()},
+ localGenerator,
+ localGenerator.getNameTextRange()
+ )
+ );
+ reportedNames.add(name);
+ }
}
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java
index c9f493a8f3..1973d958c7 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java
@@ -471,6 +471,7 @@ public abstract class AbstractOrmIdMapping<X extends XmlId>
this.generatedValue.validate(messages, reporter);
}
this.generatorContainer.validate(messages, reporter);
+ this.converter.validate(messages, reporter);
}
protected IMessage buildMappedByRelationshipAndColumnSpecifiedMessage() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmVersionMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmVersionMapping.java
index 9864ae181d..aed79ed89a 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmVersionMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmVersionMapping.java
@@ -316,6 +316,7 @@ public abstract class AbstractOrmVersionMapping<X extends XmlVersion>
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
this.column.validate(messages, reporter);
+ this.converter.validate(messages, reporter);
}
public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java
index 9ca7c2ca8e..e82a626cb6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/GenericRootContextNode.java
@@ -271,7 +271,7 @@ public class GenericRootContextNode
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
JpaValidationMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT,
- new String[] {jrpt.getName()},
+ new String[] {jrpt.getQualifiedName()},
jrpt.getFile(),
jrpt.getNameTextRange(jrcu.buildASTRoot())
)
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java
index 4cbc7b3cff..6fcf794920 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java
@@ -27,6 +27,7 @@ import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.utility.Filter;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -229,17 +230,32 @@ public class GenericJavaGeneratorContainer
protected void validateGenerators(List<IMessage> messages, CompilationUnit astRoot) {
for (JavaGenerator localGenerator : this.getGenerators()) {
- for (Iterator<Generator> globalGenerators = this.getPersistenceUnit().generators(); globalGenerators.hasNext(); ) {
- if (localGenerator.duplicates(globalGenerators.next())) {
- messages.add(
+ String name = localGenerator.getName();
+ if (StringTools.stringIsEmpty(name)){
+ messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
- new String[] {localGenerator.getName()},
+ JpaValidationMessages.GENERATOR_NAME_UNDEFINED,
+ new String[] {},
localGenerator,
localGenerator.getNameTextRange(astRoot)
)
);
+ } else {
+ List<String> reportedNames = new ArrayList<String>();
+ for (Iterator<Generator> globalGenerators = this.getPersistenceUnit().generators(); globalGenerators.hasNext(); ) {
+ if (localGenerator.duplicates(globalGenerators.next()) && !reportedNames.contains(name)) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
+ new String[] {name},
+ localGenerator,
+ localGenerator.getNameTextRange(astRoot)
+ )
+ );
+ reportedNames.add(name);
+ }
}
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaQueryContainer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaQueryContainer.java
index 579a6551af..2aae2790fd 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaQueryContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaQueryContainer.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.jpa1.context.java;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -33,6 +34,7 @@ import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation;
import org.eclipse.jpt.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable;
import org.eclipse.jpt.utility.internal.iterables.SubIterableWrapper;
@@ -312,19 +314,46 @@ public class GenericJavaQueryContainer
protected void validateQueries(List<IMessage> messages, CompilationUnit astRoot) {
for (Iterator<JavaQuery> localQueries = this.queries(); localQueries.hasNext(); ) {
JavaQuery localQuery = localQueries.next();
- for (Iterator<Query> globalQueries = this.getPersistenceUnit().queries(); globalQueries.hasNext(); ) {
- if (localQuery.duplicates(globalQueries.next())) {
- messages.add(
+ String name = localQuery.getName();
+ if (StringTools.stringIsEmpty(name)){
+ messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JpaValidationMessages.QUERY_DUPLICATE_NAME,
- new String[] {localQuery.getName()},
+ JpaValidationMessages.QUERY_NAME_UNDEFINED,
+ new String[] {},
localQuery,
localQuery.getNameTextRange(astRoot)
)
);
+ } else {
+ List<String> reportedNames = new ArrayList<String>();
+ for (Iterator<Query> globalQueries = this.getPersistenceUnit().queries(); globalQueries.hasNext(); ) {
+ if (localQuery.duplicates(globalQueries.next()) && !reportedNames.contains(name)) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.QUERY_DUPLICATE_NAME,
+ new String[] {name},
+ localQuery,
+ localQuery.getNameTextRange(astRoot)
+ )
+ );
+ reportedNames.add(name);
+ }
}
}
+ String query = localQuery.getQuery();
+ if (StringTools.stringIsEmpty(query)){
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.QUERY_STATEMENT_UNDEFINED,
+ new String[] {name},
+ localQuery,
+ localQuery.getNameTextRange(astRoot)
+ )
+ );
+ }
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java
index 8b63115043..6377636667 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java
@@ -27,6 +27,7 @@ import org.eclipse.jpt.core.resource.orm.XmlGeneratorContainer;
import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator;
import org.eclipse.jpt.core.resource.orm.XmlTableGenerator;
import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -208,17 +209,32 @@ public class GenericOrmGeneratorContainer
protected void validateGenerators(List<IMessage> messages) {
for (OrmGenerator localGenerator : this.getGenerators()) {
- for (Iterator<Generator> globalGenerators = this.getPersistenceUnit().generators(); globalGenerators.hasNext(); ) {
- if (localGenerator.duplicates(globalGenerators.next())) {
- messages.add(
+ String name = localGenerator.getName();
+ if (StringTools.stringIsEmpty(name)){
+ messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
- new String[] {localGenerator.getName()},
+ JpaValidationMessages.GENERATOR_NAME_UNDEFINED,
+ new String[] {},
localGenerator,
localGenerator.getNameTextRange()
)
);
+ } else {
+ List<String> reportedNames = new ArrayList<String>();
+ for (Iterator<Generator> globalGenerators = this.getPersistenceUnit().generators(); globalGenerators.hasNext(); ) {
+ if (localGenerator.duplicates(globalGenerators.next()) && !reportedNames.contains(name)) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
+ new String[] {name},
+ localGenerator,
+ localGenerator.getNameTextRange()
+ )
+ );
+ reportedNames.add(name);
+ }
}
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java
index cf6dd6c18e..2720e23461 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.jpa1.context.orm;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -31,6 +32,7 @@ import org.eclipse.jpt.core.resource.orm.XmlNamedNativeQuery;
import org.eclipse.jpt.core.resource.orm.XmlNamedQuery;
import org.eclipse.jpt.core.resource.orm.XmlQueryContainer;
import org.eclipse.jpt.core.utility.TextRange;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
import org.eclipse.jpt.utility.internal.iterables.ListIterable;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
@@ -303,19 +305,46 @@ public class GenericOrmQueryContainer
protected void validateQueries(List<IMessage> messages) {
for (OrmQuery localQuery : this.getQueries()) {
- for (Iterator<Query> globalQueries = this.getPersistenceUnit().queries(); globalQueries.hasNext(); ) {
- if (localQuery.duplicates(globalQueries.next())) {
- messages.add(
+ String name = localQuery.getName();
+ if (StringTools.stringIsEmpty(name)){
+ messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JpaValidationMessages.QUERY_DUPLICATE_NAME,
- new String[] {localQuery.getName()},
+ JpaValidationMessages.QUERY_NAME_UNDEFINED,
+ new String[] {},
localQuery,
localQuery.getNameTextRange()
)
);
+ } else {
+ List<String> reportedNames = new ArrayList<String>();
+ for (Iterator<Query> globalQueries = this.getPersistenceUnit().queries(); globalQueries.hasNext(); ) {
+ Query globalQuery = globalQueries.next();
+ if (localQuery.duplicates(globalQuery) && !reportedNames.contains(name)) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.QUERY_DUPLICATE_NAME,
+ new String[] {name},
+ localQuery,
+ localQuery.getNameTextRange())
+ );
+ reportedNames.add(name);
+ }
}
}
+ String query = localQuery.getQuery();
+ if (StringTools.stringIsEmpty(query)){
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.QUERY_STATEMENT_UNDEFINED,
+ new String[] {name},
+ localQuery,
+ localQuery.getNameTextRange()
+ )
+ );
+ }
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
index 0286740367..6de7c7201f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
@@ -25,6 +25,7 @@ public interface JpaValidationMessages {
public static final String PERSISTENCE_XML_UNSUPPORTED_CONTENT = "PERSISTENCE_XML_UNSUPPORTED_CONTENT";
public static final String PERSISTENCE_NO_PERSISTENCE_UNIT = "PERSISTENCE_NO_PERSISTENCE_UNIT";
public static final String PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS = "PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS";
+ public static final String PERSISTENCE_UNIT_ENTITY_NAME_ATTRIBUTE_MISSING = "PERSISTENCE_UNIT_ENTITY_NAME_ATTRIBUTE_MISSING";
public static final String PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE = "PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE";
public static final String PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT = "PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT";
public static final String PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE = "PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE";
@@ -40,7 +41,10 @@ public interface JpaValidationMessages {
public static final String PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING = "PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING";
public static final String PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE = "PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE";
public static final String GENERATOR_DUPLICATE_NAME = "GENERATOR_DUPLICATE_NAME";
+ public static final String GENERATOR_NAME_UNDEFINED = "GENERATOR_NAME_UNDEFINED";
public static final String QUERY_DUPLICATE_NAME = "QUERY_DUPLICATE_NAME";
+ public static final String QUERY_NAME_UNDEFINED = "QUERY_NAME_UNDEFINED";
+ public static final String QUERY_STATEMENT_UNDEFINED = "QUERY_STATEMENT_UNDEFINED";
public static final String MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA = "MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA";
public static final String PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT = "PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT";
public static final String PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT = "PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT";
@@ -70,6 +74,7 @@ public interface JpaValidationMessages {
public static final String ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE = "ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE";
public static final String ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED = "ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED";
public static final String ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED = "ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED";
+ public static final String ENTITY_NAME_MISSING = "ENTITY_NAME_MISSING";
public static final String ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED = "ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED";
public static final String ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED = "ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED";
public static final String PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME = "PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME";
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties
index f0d62e8670..b8756f6c35 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/property_files/eclipselink_jpa_validation.properties
@@ -12,7 +12,10 @@ CACHE_EXPIRY_AND_EXPIRY_TIME_OF_DAY_BOTH_SPECIFIED=The @Cache annotation on enti
CONVERTER_CLASS_EXISTS=The converter class \"{0}\" does not exist on the project classpath
CONVERTER_CLASS_DEFINED=The converter class must be defined.
CONVERTER_CLASS_IMPLEMENTS_CONVERTER=The converter class \"{0}\" does not implement the org.eclipse.persistence.mappings.converters.Converter interface
+CONVERTER_DUPLICATE_NAME=Duplicate converter \"{0}\" defined in this persistence unit
+CONVERTER_NAME_UNDEFINED=Converter is unnamed. All converters require a name.
CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER=The customizer class \"{0}\" does not implement the org.eclipse.persistence.config.DescriptorCustomizer interface
+ID_MAPPING_UNRESOLVED_CONVERTER_NAME=The specified converter \"{0}\" for mapping \"{1}\" cannot be resolved
MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE=Multiple object values are specified for the data value \"{0}\"
PERSISTENCE_UNIT_LEGACY_DESCRIPTOR_CUSTOMIZER=\"{0}\" is a legacy descriptor customizer property. Consider migration to the EclipseLink customizer settings via annotation or XML mapping file
PERSISTENCE_UNIT_LEGACY_ENTITY_CACHING=\"{0}\" is a legacy entity caching property. Consider migration to JPA 2.0 and EclipseLink cache settings via annotation or XML mapping file
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java
index 0800974d84..1b3abcd3c9 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java
@@ -17,12 +17,18 @@ public interface EclipseLinkJpaValidationMessages {
public static final String CACHE_EXPIRY_AND_EXPIRY_TIME_OF_DAY_BOTH_SPECIFIED = "CACHE_EXPIRY_AND_EXPIRY_TIME_OF_DAY_BOTH_SPECIFIED";
public static final String CONVERTER_CLASS_IMPLEMENTS_CONVERTER = "CONVERTER_CLASS_IMPLEMENTS_CONVERTER";
+
+ public static final String CONVERTER_DUPLICATE_NAME = "CONVERTER_DUPLICATE_NAME";
+
+ public static final String CONVERTER_NAME_UNDEFINED = "CONVERTER_NAME_UNDEFINED";
public static final String CONVERTER_CLASS_EXISTS = "CONVERTER_CLASS_EXISTS";
public static final String CONVERTER_CLASS_DEFINED = "CONVERTER_CLASS_DEFINED";
public static final String CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER = "CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER";
+
+ public static final String ID_MAPPING_UNRESOLVED_CONVERTER_NAME = "ID_MAPPING_UNRESOLVED_CONVERTER_NAME";
public static final String MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE = "MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE";
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java
index 3d26bdef34..3a037dff3e 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConvert.java
@@ -22,6 +22,8 @@ import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkConvert;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkConverter;
+import org.eclipse.jpt.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages;
+import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaValidationMessages;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit;
import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkConvertAnnotation;
import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkNamedConverterAnnotation;
@@ -289,8 +291,32 @@ public class JavaEclipseLinkConvert
if (this.converter != null) {
this.converter.validate(messages, reporter, astRoot);
}
+ this.validateConvertValue(messages, astRoot);
}
-
+
+ private void validateConvertValue(List<IMessage> messages, CompilationUnit astRoot) {
+ String converter = this.getConverterName();
+ if (converter == null) {
+ return;
+ }
+
+ for (Iterator<EclipseLinkConverter> converters = this.getEclipseLinkPersistenceUnit().allConverters(); converters.hasNext(); ) {
+ if (converter.equals(converters.next().getName())) {
+ return;
+ }
+ }
+
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.ID_MAPPING_UNRESOLVED_CONVERTER_NAME,
+ new String[] {converter, this.getParent().getName()},
+ this.getParent(),
+ this.getValidationTextRange(astRoot)
+ )
+ );
+ }
+
public TextRange getValidationTextRange(CompilationUnit astRoot) {
return this.convertAnnotation.getTextRange(astRoot);
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java
index 68c13f7049..1f1c410d94 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkConverter.java
@@ -9,16 +9,23 @@
******************************************************************************/
package org.eclipse.jpt.eclipselink.core.internal.context.java;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkConverter;
+import org.eclipse.jpt.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages;
+import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaValidationMessages;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit;
import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLinkNamedConverterAnnotation;
import org.eclipse.jpt.utility.internal.ClassName;
import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public abstract class JavaEclipseLinkConverter<A extends EclipseLinkNamedConverterAnnotation>
extends AbstractJavaJpaContextNode
@@ -208,4 +215,43 @@ public abstract class JavaEclipseLinkConverter<A extends EclipseLinkNamedConvert
return StringTools.buildToStringFor(this, ClassName.getSimpleName(this.getAnnotationName()));
}
}
+
+ public TextRange getNameTextRange(CompilationUnit astRoot){
+ return getConverterAnnotation().getNameTextRange(astRoot);
+ }
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ this.validateConverterNames(messages, astRoot);
+ }
+
+ protected void validateConverterNames(List<IMessage> messages, CompilationUnit astRoot){
+ String name = this.getName();
+ if (StringTools.stringIsEmpty(name)) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.CONVERTER_NAME_UNDEFINED,
+ new String[] {},
+ this,
+ this.getNameTextRange(astRoot)
+ ));
+ } else {
+ List<String> reportedNames = new ArrayList<String>();
+ for (ListIterator<EclipseLinkConverter> globalConverters = this.getPersistenceUnit ().allConverters(); globalConverters.hasNext(); ) {
+ if ( this.duplicates( globalConverters.next()) && !reportedNames.contains(name)){
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.CONVERTER_DUPLICATE_NAME,
+ new String[] {name},
+ this,
+ this.getNameTextRange(astRoot)
+ ));
+ reportedNames.add(name);
+ }
+ }
+ }
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java
index 9646ba338c..986e555e98 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java
@@ -102,6 +102,11 @@ public class JavaEclipseLinkCustomConverter
}
protected void validateConverterClass(List<IMessage> messages, CompilationUnit astRoot) {
+ if (this.converterClass == null) {
+ //Annotation itself will have compile error if converter class not defined
+ return;
+ }
+
if (StringTools.stringIsEmpty(this.converterClass)) {
messages.add(
DefaultEclipseLinkJpaValidationMessages.buildMessage(
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConvert.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConvert.java
index 43fb48f686..0c85bc76d0 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConvert.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConvert.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.eclipselink.core.internal.context.orm;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
@@ -22,6 +23,9 @@ import org.eclipse.jpt.core.internal.jpa1.context.orm.AbstractOrmConverter;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkConvert;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkConverter;
+import org.eclipse.jpt.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages;
+import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaValidationMessages;
+import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlConvertibleMapping;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlNamedConverter;
import org.eclipse.jpt.utility.internal.Association;
@@ -59,6 +63,11 @@ public class OrmEclipseLinkConvert
// ********** synchronize/update **********
@Override
+ public EclipseLinkPersistenceUnit getPersistenceUnit(){
+ return (EclipseLinkPersistenceUnit) super.getPersistenceUnit();
+ }
+
+ @Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
this.setSpecifiedConverterName_(this.getXmlConvertibleMapping().getConvert());
@@ -260,6 +269,30 @@ public class OrmEclipseLinkConvert
if (this.converter != null) {
this.converter.validate(messages, reporter);
}
+ this.validateConvertValue(messages);
+ }
+
+ private void validateConvertValue(List<IMessage> messages) {
+ String converter = this.getConverterName();
+ if (converter == null) {
+ return;
+ }
+
+ for (Iterator<EclipseLinkConverter> converters = this.getPersistenceUnit().allConverters(); converters.hasNext(); ) {
+ if (converter.equals(converters.next().getName())) {
+ return;
+ }
+ }
+
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.ID_MAPPING_UNRESOLVED_CONVERTER_NAME,
+ new String[] {converter, this.getParent().getName()},
+ this.getParent(),
+ this.getValidationTextRange()
+ )
+ );
}
public TextRange getValidationTextRange() {
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java
index 9d3699fefa..07138defc3 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkConverter.java
@@ -9,20 +9,27 @@
******************************************************************************/
package org.eclipse.jpt.eclipselink.core.internal.context.orm;
-import org.eclipse.jpt.core.context.XmlContextNode;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jpt.core.context.XmlContextNode;
import org.eclipse.jpt.core.context.orm.EntityMappings;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkConverter;
+import org.eclipse.jpt.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages;
+import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaValidationMessages;
import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaEclipseLinkConverter;
import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlConverterHolder;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlNamedConverter;
import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public abstract class OrmEclipseLinkConverter<X extends XmlNamedConverter>
extends AbstractOrmXmlContextNode
@@ -109,6 +116,42 @@ public abstract class OrmEclipseLinkConverter<X extends XmlNamedConverter>
// ********** validation **********
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ super.validate(messages, reporter);
+ this.validateConverterNames(messages);
+ }
+
+ protected void validateConverterNames(List<IMessage> messages){
+ String name = this.getName();
+ if (StringTools.stringIsEmpty(name)) {
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.CONVERTER_NAME_UNDEFINED,
+ new String[] {},
+ this,
+ this.getNameTextRange()
+ ));
+ } else {
+ List<String> reportedNames = new ArrayList<String>();
+ for (ListIterator<EclipseLinkConverter> globalConverters = this.getPersistenceUnit().allConverters(); globalConverters.hasNext(); ) {
+ if ( this.duplicates(globalConverters.next()) && !reportedNames.contains(name) ){
+ messages.add(
+ DefaultEclipseLinkJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ EclipseLinkJpaValidationMessages.CONVERTER_DUPLICATE_NAME,
+ new String[] {name},
+ this,
+ this.getNameTextRange()
+ )
+ );
+ reportedNames.add(name);
+ }
+ }
+ }
+ }
+
public boolean overrides(EclipseLinkConverter converter) {
if (this.name == null) {
return false;
@@ -130,6 +173,9 @@ public abstract class OrmEclipseLinkConverter<X extends XmlNamedConverter>
return this.xmlConverter.getValidationTextRange();
}
+ public TextRange getNameTextRange() {
+ return this.xmlConverter.getNameTextRange();
+ }
// ********** adapter **********
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityImpl.java
index 5c8b9fd221..018c9307a0 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityImpl.java
@@ -10,16 +10,12 @@
package org.eclipse.jpt.eclipselink.core.internal.context.orm;
import java.util.List;
+
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jpt.core.context.orm.EntityMappings;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkTypeMappingValidator;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.jpt.core.internal.context.orm.AbstractOrmEntity;
import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheable2_0;
import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheableHolder2_0;
@@ -33,8 +29,13 @@ import org.eclipse.jpt.eclipselink.core.context.orm.OrmEclipseLinkCaching;
import org.eclipse.jpt.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
import org.eclipse.jpt.eclipselink.core.context.orm.OrmEclipseLinkEntity;
import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkEntityPrimaryKeyValidator;
+import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkTypeMappingValidator;
import org.eclipse.jpt.eclipselink.core.resource.orm.XmlEntity;
import org.eclipse.jpt.eclipselink.core.v2_0.resource.java.EclipseLinkClassExtractorAnnotation2_1;
+import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
+import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
+import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
+import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java
index b977728657..1ca1a5f047 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.eclipselink.core.internal.context.orm;
import java.util.List;
+
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jpt.core.context.orm.OrmPersistentType;
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlEntityMappings.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlEntityMappings.java
index 3fe01090c7..0513176840 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlEntityMappings.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlEntityMappings.java
@@ -11,9 +11,9 @@
package org.eclipse.jpt.eclipselink.core.resource.orm;
import java.util.Collection;
-import org.eclipse.emf.common.notify.Notification;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
@@ -21,17 +21,6 @@ import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_1.XmlEntityMappings_2_1;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.EclipseLinkOrmV2_2Package;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlEntityMappings_2_2;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlHashPartitioning_2_2;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlPartitioning_2_2;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlPinnedPartitioning_2_2;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlRangePartitioning_2_2;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlReplicationPartitioning_2_2;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlRoundRobinPartitioning_2_2;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlUnionPartitioning_2_2;
-import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlValuePartitioning_2_2;
import org.eclipse.jpt.core.internal.utility.translators.SimpleRootTranslator;
import org.eclipse.jpt.core.resource.orm.JPA;
import org.eclipse.jpt.core.resource.orm.OrmPackage;
@@ -43,7 +32,18 @@ import org.eclipse.jpt.eclipselink.core.resource.orm.v1_1.EclipseLink1_1;
import org.eclipse.jpt.eclipselink.core.resource.orm.v1_2.EclipseLink1_2;
import org.eclipse.jpt.eclipselink.core.resource.orm.v2_0.EclipseLink2_0;
import org.eclipse.jpt.eclipselink.core.resource.orm.v2_1.EclipseLink2_1;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_1.XmlEntityMappings_2_1;
import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.EclipseLink2_2;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.EclipseLinkOrmV2_2Package;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlEntityMappings_2_2;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlHashPartitioning_2_2;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlPartitioning_2_2;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlPinnedPartitioning_2_2;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlRangePartitioning_2_2;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlReplicationPartitioning_2_2;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlRoundRobinPartitioning_2_2;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlUnionPartitioning_2_2;
+import org.eclipse.jpt.eclipselink.core.resource.orm.v2_2.XmlValuePartitioning_2_2;
import org.eclipse.wst.common.internal.emf.resource.Translator;
/**
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlNamedConverter.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlNamedConverter.java
index 37260468ad..86b96212ca 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlNamedConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/resource/orm/XmlNamedConverter.java
@@ -13,8 +13,10 @@ package org.eclipse.jpt.eclipselink.core.resource.orm;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.jpt.core.resource.orm.JPA;
import org.eclipse.jpt.core.resource.xml.AbstractJpaEObject;
import org.eclipse.jpt.core.resource.xml.JpaEObject;
+import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.wst.common.internal.emf.resource.Translator;
/**
@@ -203,6 +205,10 @@ public class XmlNamedConverter extends AbstractJpaEObject implements JpaEObject
return result.toString();
}
+ public TextRange getNameTextRange() {
+ return getAttributeTextRange(JPA.NAME);
+ }
+
// ********** translators **********
protected static Translator buildNameTranslator() {
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_details.properties b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_details.properties
index e218cf9f93..2de82863cf 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_details.properties
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/property_files/eclipselink_ui_details.properties
@@ -147,6 +147,7 @@ EclipseLinkConverterDialog_converterType=Type:
EclipseLinkConverterDialog_addConverter=Add Converter
EclipseLinkConverterDialog_addConverterDescriptionTitle=Create new converter
EclipseLinkConverterDialog_addConverterDescription=Create a new converter setting both the 'name' and the 'type'
+EclipseLinkConverterStateObject_nameExists =The given name already exists. This converter may override the existing one(s) with the same name.
EclipseLinkConverterStateObject_nameMustBeSpecified = A name must be specified.
EclipseLinkConverterStateObject_typeMustBeSpecified = A converter type must be specified.
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkConversionValueStateObject.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkConversionValueStateObject.java
index 7117d9eb51..c2308e0bfe 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkConversionValueStateObject.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkConversionValueStateObject.java
@@ -11,6 +11,8 @@ package org.eclipse.jpt.eclipselink.ui.internal.details;
import java.util.Collection;
import java.util.List;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jpt.ui.internal.widgets.NewNameDialog;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.node.AbstractNode;
import org.eclipse.jpt.utility.internal.node.Node;
@@ -76,16 +78,16 @@ final class EclipseLinkConversionValueStateObject extends AbstractNode
private void addDataValueProblemsTo(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(this.dataValue)) {
- currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConversionValueStateObject_dataValueMustBeSpecified));
+ currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConversionValueStateObject_dataValueMustBeSpecified, IMessageProvider.ERROR));
}
else if (this.dataValues.contains(this.dataValue)) {
- currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConversionValueStateObject_dataValueAlreadyExists));
+ currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConversionValueStateObject_dataValueAlreadyExists, IMessageProvider.ERROR));
}
}
private void addObjectValueProblemsTo(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(this.objectValue)) {
- currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConversionValueStateObject_objectValueMustBeSpecified));
+ currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConversionValueStateObject_objectValueMustBeSpecified, IMessageProvider.ERROR));
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkUiDetailsMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkUiDetailsMessages.java
index d0a3bec929..79d2d9f357 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkUiDetailsMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/EclipseLinkUiDetailsMessages.java
@@ -155,6 +155,7 @@ public class EclipseLinkUiDetailsMessages extends NLS {
public static String EclipseLinkConverterDialog_addConverter;
public static String EclipseLinkConverterDialog_addConverterDescriptionTitle;
public static String EclipseLinkConverterDialog_addConverterDescription;
+ public static String EclipseLinkConverterStateObject_nameExists;
public static String EclipseLinkConverterStateObject_nameMustBeSpecified;
public static String EclipseLinkConverterStateObject_typeMustBeSpecified;
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterDialog.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterDialog.java
index 2be3673475..e89cb1dd7c 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterDialog.java
@@ -14,6 +14,7 @@ import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCustomConverter;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkObjectTypeConverter;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkStructConverter;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkTypeConverter;
+import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit;
import org.eclipse.jpt.eclipselink.ui.internal.details.EclipseLinkUiDetailsMessages;
import org.eclipse.jpt.ui.internal.widgets.DialogPane;
import org.eclipse.jpt.ui.internal.widgets.ValidatingDialog;
@@ -29,19 +30,24 @@ import org.eclipse.swt.widgets.Text;
public class EclipseLinkConverterDialog
extends ValidatingDialog<EclipseLinkConverterStateObject>
{
+ /**
+ * The associated persistence unit
+ */
+ EclipseLinkPersistenceUnit pUnit;
// ********** constructors **********
/**
* Use this constructor to edit an existing conversion value
*/
- public EclipseLinkConverterDialog(Shell parent) {
+ public EclipseLinkConverterDialog(Shell parent, EclipseLinkPersistenceUnit pUnit) {
super(parent);
+ this.pUnit = pUnit;
}
@Override
protected EclipseLinkConverterStateObject buildStateObject() {
- return new EclipseLinkConverterStateObject();
+ return new EclipseLinkConverterStateObject(pUnit);
}
// ********** open **********
@@ -131,6 +137,9 @@ public class EclipseLinkConverterDialog
private StringConverter<Class<? extends EclipseLinkConverter>> buildStringConverter() {
return new StringConverter<Class<? extends EclipseLinkConverter>>() {
public String convertToString(Class<? extends EclipseLinkConverter> value) {
+ if (value == null) {
+ return null;
+ }
if (value == EclipseLinkCustomConverter.class) {
return EclipseLinkUiDetailsMessages.EclipseLinkConvertersComposite_customConverter;
}
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterStateObject.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterStateObject.java
index bddb701124..a80f9c87d8 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterStateObject.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/EclipseLinkConverterStateObject.java
@@ -9,8 +9,12 @@
******************************************************************************/
package org.eclipse.jpt.eclipselink.ui.internal.details.orm;
+import java.util.ArrayList;
import java.util.List;
+import java.util.ListIterator;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkConverter;
+import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit;
import org.eclipse.jpt.eclipselink.ui.internal.details.EclipseLinkUiDetailsMessages;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.node.AbstractNode;
@@ -42,6 +46,11 @@ final class EclipseLinkConverterStateObject extends AbstractNode
* The <code>Validator</code> used to validate this state object.
*/
private Validator validator;
+
+ /**
+ * The associated persistence unit
+ */
+ private EclipseLinkPersistenceUnit pUnit;
/**
* Notifies a change in the data value property.
@@ -54,20 +63,23 @@ final class EclipseLinkConverterStateObject extends AbstractNode
static final String CONVERTER_TYPE_PROPERTY = "converterType"; //$NON-NLS-1$
- EclipseLinkConverterStateObject() {
+ EclipseLinkConverterStateObject(EclipseLinkPersistenceUnit pUnit) {
super(null);
-
+ this.pUnit = pUnit;
}
private void addNameProblemsTo(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(this.name)) {
- currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConverterStateObject_nameMustBeSpecified));
+ currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConverterStateObject_nameMustBeSpecified, IMessageProvider.ERROR));
+ }
+ else if (names().contains(this.name)) {
+ currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConverterStateObject_nameExists, IMessageProvider.WARNING));
}
}
private void addConverterTypeProblemsTo(List<Problem> currentProblems) {
if (this.converterType == null) {
- currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConverterStateObject_typeMustBeSpecified));
+ currentProblems.add(buildProblem(EclipseLinkUiDetailsMessages.EclipseLinkConverterStateObject_typeMustBeSpecified, IMessageProvider.ERROR));
}
}
@@ -77,6 +89,15 @@ final class EclipseLinkConverterStateObject extends AbstractNode
addNameProblemsTo(currentProblems);
addConverterTypeProblemsTo(currentProblems);
}
+
+ private List<String> names() {
+ List<String> names = new ArrayList<String>();
+ for (ListIterator<EclipseLinkConverter> converters = this.pUnit.allConverters(); converters.hasNext();){
+ String name = converters.next().getName();
+ names.add(name);
+ }
+ return names ;
+ }
@Override
protected void checkParent(Node parentNode) {
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/OrmEclipseLinkConvertersComposite.java b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/OrmEclipseLinkConvertersComposite.java
index 96073a9efa..bfe0ac55eb 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/OrmEclipseLinkConvertersComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.ui/src/org/eclipse/jpt/eclipselink/ui/internal/details/orm/OrmEclipseLinkConvertersComposite.java
@@ -17,20 +17,26 @@ import java.util.ListIterator;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.core.context.NamedNativeQuery;
+import org.eclipse.jpt.core.context.NamedQuery;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkConverter;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkCustomConverter;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkObjectTypeConverter;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkStructConverter;
import org.eclipse.jpt.eclipselink.core.context.EclipseLinkTypeConverter;
import org.eclipse.jpt.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
+import org.eclipse.jpt.eclipselink.core.internal.context.persistence.EclipseLinkPersistenceUnit;
import org.eclipse.jpt.eclipselink.ui.internal.details.EclipseLinkCustomConverterComposite;
import org.eclipse.jpt.eclipselink.ui.internal.details.EclipseLinkObjectTypeConverterComposite;
import org.eclipse.jpt.eclipselink.ui.internal.details.EclipseLinkStructConverterComposite;
import org.eclipse.jpt.eclipselink.ui.internal.details.EclipseLinkTypeConverterComposite;
+import org.eclipse.jpt.ui.internal.details.AbstractEntityComposite;
+import org.eclipse.jpt.ui.internal.details.NamedNativeQueryPropertyComposite;
+import org.eclipse.jpt.ui.internal.details.NamedQueryPropertyComposite;
import org.eclipse.jpt.ui.internal.util.ControlSwitcher;
import org.eclipse.jpt.ui.internal.widgets.AddRemoveListPane;
-import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.ui.internal.widgets.AddRemovePane.Adapter;
+import org.eclipse.jpt.ui.internal.widgets.Pane;
import org.eclipse.jpt.utility.internal.Transformer;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
import org.eclipse.jpt.utility.internal.model.value.CompositeListValueModel;
@@ -205,7 +211,7 @@ public class OrmEclipseLinkConvertersComposite extends Pane<OrmEclipseLinkConver
}
protected EclipseLinkConverterDialog buildEclipseLinkConverterDialog() {
- return new EclipseLinkConverterDialog(getShell());
+ return new EclipseLinkConverterDialog(getShell(), (EclipseLinkPersistenceUnit)this.getSubject().getPersistenceUnit());
}
protected void addEclipseLinkConverterFromDialog(EclipseLinkConverterDialog dialog) {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details.properties
index 2313f78572..b62b2ba5dc 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details.properties
@@ -80,6 +80,7 @@ AddQueryDialog_descriptionTitle=Create new query
AddQueryDialog_namedQuery=Named Query
AddQueryDialog_namedNativeQuery= Named Native Query
AddQueryDialog_description=Create a new query setting both the 'name' and the 'type'
+AddQueryDialog_nameExists=The given name exists. This query may be overridden by or override the one(s) with the same name.
QueryStateObject_nameMustBeSpecified=A name must be specified.
QueryStateObject_typeMustBeSpecified=A query type must be specified
AddQueryDialog_name=Name:
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details_orm.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details_orm.properties
index 28bb243eb8..41e618830d 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details_orm.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_details_orm.properties
@@ -47,6 +47,7 @@ AddGeneratorDialog_descriptionTitle=Create new generator
AddGeneratorDialog_description=Create a new generator setting both the 'name' and the 'type'
AddGeneratorDialog_tableGenerator=Table Generator
AddGeneratorDialog_sequenceGenerator=Sequence Generator
+GeneratorStateObject_nameExists=The given name already exists. This generator may override the existing one(s) with the same name.
GeneratorStateObject_nameMustBeSpecified=A name must be specified.
GeneratorStateObject_typeMustBeSpecified=A generator type must be specified.
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryDialog.java
index c71e01616f..b3cad5fc9e 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryDialog.java
@@ -12,6 +12,7 @@ package org.eclipse.jpt.ui.internal.details;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.ui.internal.widgets.DialogPane;
import org.eclipse.jpt.ui.internal.widgets.ValidatingDialog;
import org.eclipse.jpt.utility.internal.StringConverter;
@@ -36,19 +37,25 @@ public class AddQueryDialog extends ValidatingDialog<AddQueryStateObject> {
public static final String NAMED_QUERY = "namedQuery"; //$NON-NLS-1$
public static final String NAMED_NATIVE_QUERY = "namedNativeQuery"; //$NON-NLS-1$
-
+ /**
+ * The associated persistence unit
+ */
+ private PersistenceUnit pUnit;
+
// ********** constructors **********
/**
* Use this constructor to edit an existing conversion value
+ * @param pUnit
*/
- public AddQueryDialog(Shell parent) {
+ public AddQueryDialog(Shell parent, PersistenceUnit pUnit) {
super(parent);
+ this.pUnit = pUnit;
}
@Override
protected AddQueryStateObject buildStateObject() {
- return new AddQueryStateObject();
+ return new AddQueryStateObject(this.pUnit);
}
// ********** open **********
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryStateObject.java
index 9dd862cff1..9e239f54cb 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryStateObject.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/AddQueryStateObject.java
@@ -9,7 +9,12 @@
******************************************************************************/
package org.eclipse.jpt.ui.internal.details;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jpt.core.context.Query;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.node.AbstractNode;
import org.eclipse.jpt.utility.internal.node.Node;
@@ -42,6 +47,11 @@ final class AddQueryStateObject extends AbstractNode
private Validator validator;
/**
+ * The associated persistence unit
+ */
+ private PersistenceUnit pUnit;
+
+ /**
* Notifies a change in the data value property.
*/
static final String NAME_PROPERTY = "nameProperty"; //$NON-NLS-1$
@@ -59,20 +69,23 @@ final class AddQueryStateObject extends AbstractNode
* @param names The collection of names that can't be used or an empty
* collection if none are available
*/
- AddQueryStateObject() {
+ AddQueryStateObject(PersistenceUnit pUnit) {
super(null);
-
+ this.pUnit = pUnit;
}
private void addNameProblemsTo(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(this.name)) {
- currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_nameMustBeSpecified));
+ currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_nameMustBeSpecified, IMessageProvider.ERROR));
+ }
+ else if (names().contains(this.name)){
+ currentProblems.add(buildProblem(JptUiDetailsMessages.AddQueryDialog_nameExists, IMessageProvider.WARNING));
}
}
private void addQueryTypeProblemsTo(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(this.queryType)) {
- currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_typeMustBeSpecified));
+ currentProblems.add(buildProblem(JptUiDetailsMessages.QueryStateObject_typeMustBeSpecified, IMessageProvider.ERROR));
}
}
@@ -83,6 +96,15 @@ final class AddQueryStateObject extends AbstractNode
addQueryTypeProblemsTo(currentProblems);
}
+ private List<String> names(){
+ List<String> names = new ArrayList<String>();
+ for (Iterator<Query> queries = this.pUnit.queries(); queries.hasNext();){
+ String name = queries.next().getName();
+ names.add(name);
+ }
+ return names;
+ }
+
@Override
protected void checkParent(Node parentNode) {
//no parent
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JptUiDetailsMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JptUiDetailsMessages.java
index 59f357dd46..e7b5973590 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JptUiDetailsMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/JptUiDetailsMessages.java
@@ -25,6 +25,7 @@ public class JptUiDetailsMessages {
public static String AddQueryDialog_title;
public static String AddQueryDialog_descriptionTitle;
public static String AddQueryDialog_description;
+ public static String AddQueryDialog_nameExists;
public static String AddQueryDialog_namedQuery;
public static String AddQueryDialog_namedNativeQuery;
public static String QueryStateObject_nameMustBeSpecified;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java
index cd7dd7a4f8..bbee04bacc 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/QueriesComposite.java
@@ -92,7 +92,7 @@ public class QueriesComposite extends Pane<QueryContainer>
}
protected AddQueryDialog buildAddQueryDialog() {
- return new AddQueryDialog(getShell());
+ return new AddQueryDialog(getShell(), this.getSubject().getPersistenceUnit());
}
protected void addQueryFromDialog(AddQueryDialog dialog) {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorDialog.java
index 275dbcdd25..97f2178582 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorDialog.java
@@ -12,6 +12,7 @@ package org.eclipse.jpt.ui.internal.details.orm;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.ui.internal.widgets.DialogPane;
import org.eclipse.jpt.ui.internal.widgets.ValidatingDialog;
import org.eclipse.jpt.utility.internal.StringConverter;
@@ -36,19 +37,24 @@ public class AddGeneratorDialog extends ValidatingDialog<AddGeneratorStateObject
public static final String SEQUENCE_GENERATOR = "sequenceGenerator"; //$NON-NLS-1$
public static final String TABLE_GENERATOR = "tableGenerator"; //$NON-NLS-1$
+ /**
+ * The associated persistence unit
+ */
+ private PersistenceUnit pUnit;
// ********** constructors **********
/**
* Use this constructor to edit an existing conversion value
*/
- public AddGeneratorDialog(Shell parent) {
+ public AddGeneratorDialog(Shell parent, PersistenceUnit pUnit) {
super(parent);
+ this.pUnit = pUnit;
}
@Override
protected AddGeneratorStateObject buildStateObject() {
- return new AddGeneratorStateObject();
+ return new AddGeneratorStateObject(this.pUnit);
}
// ********** open **********
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorStateObject.java
index cd10f5d91e..cc6c8ba9f4 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorStateObject.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/AddGeneratorStateObject.java
@@ -9,7 +9,12 @@
******************************************************************************/
package org.eclipse.jpt.ui.internal.details.orm;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jpt.core.context.Generator;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.node.AbstractNode;
import org.eclipse.jpt.utility.internal.node.Node;
@@ -42,6 +47,11 @@ final class AddGeneratorStateObject extends AbstractNode
private Validator validator;
/**
+ * The associated persistence unit
+ */
+ private PersistenceUnit pUnit;
+
+ /**
* Notifies a change in the data value property.
*/
static final String NAME_PROPERTY = "nameProperty"; //$NON-NLS-1$
@@ -59,19 +69,23 @@ final class AddGeneratorStateObject extends AbstractNode
* @param names The collection of names that can't be used or an empty
* collection if none are available
*/
- AddGeneratorStateObject() {
+ AddGeneratorStateObject(PersistenceUnit pUnit) {
super(null);
+ this.pUnit = pUnit;
}
private void addNameProblemsTo(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(this.name)) {
- currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_nameMustBeSpecified));
- }
+ currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_nameMustBeSpecified, IMessageProvider.ERROR));
+ }
+ else if (names().contains(this.name)){
+ currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_nameExists, IMessageProvider.WARNING));
+ }
}
private void addGeneratorTypeProblemsTo(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(this.generatorType)) {
- currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_typeMustBeSpecified));
+ currentProblems.add(buildProblem(JptUiDetailsOrmMessages.GeneratorStateObject_typeMustBeSpecified, IMessageProvider.ERROR));
}
}
@@ -81,6 +95,15 @@ final class AddGeneratorStateObject extends AbstractNode
addNameProblemsTo(currentProblems);
addGeneratorTypeProblemsTo(currentProblems);
}
+
+ private List<String> names() {
+ List<String> names = new ArrayList<String>();
+ for (Iterator<Generator> generators = this.pUnit.generators(); generators.hasNext();){
+ String name = generators.next().getName();
+ names.add(name);
+ }
+ return names;
+ }
@Override
protected void checkParent(Node parentNode) {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java
index 1a295f3688..2eb84cb01e 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/EntityMappingsGeneratorsComposite.java
@@ -104,7 +104,7 @@ public class EntityMappingsGeneratorsComposite extends Pane<EntityMappings>
}
protected AddGeneratorDialog buildAddGeneratorDialog() {
- return new AddGeneratorDialog(getShell());
+ return new AddGeneratorDialog(getShell(), this.getSubject().getPersistenceUnit());
}
protected void addGeneratorFromDialog(ObjectListSelectionModel listSelectionModel, AddGeneratorDialog dialog) {
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/JptUiDetailsOrmMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/JptUiDetailsOrmMessages.java
index 88ed63435e..6cf26c8e02 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/JptUiDetailsOrmMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/details/orm/JptUiDetailsOrmMessages.java
@@ -59,6 +59,7 @@ public class JptUiDetailsOrmMessages {
public static String AddGeneratorDialog_description;
public static String AddGeneratorDialog_tableGenerator;
public static String AddGeneratorDialog_sequenceGenerator;
+ public static String GeneratorStateObject_nameExists;
public static String GeneratorStateObject_nameMustBeSpecified;
public static String GeneratorStateObject_typeMustBeSpecified;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/NewNameStateObject.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/NewNameStateObject.java
index b82525566b..d1d1ebf15a 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/NewNameStateObject.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/NewNameStateObject.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.ui.internal.widgets;
import java.util.Collection;
import java.util.List;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jpt.ui.internal.details.JptUiDetailsMessages;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.node.AbstractNode;
@@ -75,10 +76,10 @@ final class NewNameStateObject extends AbstractNode
private void addNameProblems(List<Problem> currentProblems) {
if (StringTools.stringIsEmpty(name)) {
- currentProblems.add(buildProblem(JptUiDetailsMessages.NewNameStateObject_nameMustBeSpecified));
+ currentProblems.add(buildProblem(JptUiDetailsMessages.NewNameStateObject_nameMustBeSpecified, IMessageProvider.ERROR));
}
else if (names.contains(name.trim())) {
- currentProblems.add(buildProblem(JptUiDetailsMessages.NewNameStateObject_nameAlreadyExists));
+ currentProblems.add(buildProblem(JptUiDetailsMessages.NewNameStateObject_nameAlreadyExists, IMessageProvider.ERROR));
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/ValidatingDialog.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/ValidatingDialog.java
index d7e6da104a..45970b48bf 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/ValidatingDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/widgets/ValidatingDialog.java
@@ -9,6 +9,8 @@
******************************************************************************/
package org.eclipse.jpt.ui.internal.widgets;
+import java.util.ListIterator;
+import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jpt.utility.internal.node.Node;
import org.eclipse.jpt.utility.internal.node.Problem;
import org.eclipse.osgi.util.NLS;
@@ -70,6 +72,13 @@ public abstract class ValidatingDialog<T extends Node> extends Dialog<T> {
}
/**
+ * Clears the messages from the description pane
+ */
+ protected final void clearMessage(){
+ setMessage(getDescription());
+ }
+
+ /**
* Clears the error message from the description pane.
*/
protected final void clearErrorMessage() {
@@ -166,25 +175,51 @@ public abstract class ValidatingDialog<T extends Node> extends Dialog<T> {
}
/**
+ * Updates the description pane by showing the given warning message and format
+ * the text with the given list of arguments if any exists.
+ *
+ * @param warningMessage The warning message to show in the description pane
+ * @param arguments The list of arguments used to format the error message
+ */
+
+ protected final void setWarningMessage(String warningMessage, Object... arguments) {
+ setMessage(NLS.bind(warningMessage, arguments), IMessageProvider.WARNING);
+ }
+
+ /**
* Updates the error message, either shows the first error problem or hides
* the error pane. If the progress bar is shown, then the error message will
* not be shown.
*/
- private void updateErrorMessage() {
- if (getSubject().hasBranchProblems()) {
- Problem problem = getSubject().branchProblems().next();
- setErrorMessage(problem.messageKey(), problem.messageArguments());
+ private void updateMessage() {
+ if (getSubject().branchProblemsSize() == 0) {
+ clearMessage();
+ } else {
+ for (ListIterator<Problem> problems = getSubject().branchProblems(); problems.hasNext();){
+ Problem problem = problems.next();
+ if (problem.messageType() == IMessageProvider.ERROR){
+ this.setErrorMessage(problem.messageKey(), problem.messageArguments());
+ }
+ else if (problem.messageType() == IMessageProvider.WARNING){
+ this.setWarningMessage(problem.messageKey(), problem.messageArguments());
+ }
+ }
}
- // TODO: It would be nice to add warnings to the model
-// else if (this.subject().hasBranchWarnings()) {
-// Problem problem = this.subject().branchWarnings().next();
-// this.setWarningMessageKey(problem.getMessageKey(), problem.getMessageArguments());
-// }
- else {
+ if (!this.containsErrorMessage()){
clearErrorMessage();
}
}
-
+
+ public final boolean containsErrorMessage(){
+ boolean error = false;
+ for (ListIterator<Problem> problems = getSubject().branchProblems(); problems.hasNext();){
+ Problem problem = problems.next();
+ if (problem.messageType() ==IMessageProvider.ERROR){
+ error = true;
+ }
+ }
+ return error;
+ }
/**
* Validates the state object and based on its status, update the description
* pane to show the first error if any exists and update the enablement of
@@ -192,7 +227,7 @@ public abstract class ValidatingDialog<T extends Node> extends Dialog<T> {
*/
private void validate() {
getSubject().validateBranch();
- updateErrorMessage();
- getButton(OK).setEnabled(!getSubject().hasBranchProblems());
+ updateMessage();
+ getButton(OK).setEnabled(!containsErrorMessage());
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AbstractNode.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AbstractNode.java
index 9508820121..0b385ecea6 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AbstractNode.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/AbstractNode.java
@@ -706,12 +706,12 @@ public abstract class AbstractNode
return this.branchProblems.contains(problem);
}
- protected final Problem buildProblem(String messageKey, Object... messageArguments) {
- return new DefaultProblem(this, messageKey, messageArguments);
+ protected final Problem buildProblem(String messageKey, int messageType, Object... messageArguments) {
+ return new DefaultProblem(this, messageKey, messageType, messageArguments);
}
- protected final Problem buildProblem(String messageKey) {
- return this.buildProblem(messageKey, EMPTY_PROBLEM_MESSAGE_ARGUMENTS);
+ protected final Problem buildProblem(String messageKey, int messageType) {
+ return this.buildProblem(messageKey, messageType, EMPTY_PROBLEM_MESSAGE_ARGUMENTS);
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/DefaultProblem.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/DefaultProblem.java
index 079693adea..87ee4d2722 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/DefaultProblem.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/DefaultProblem.java
@@ -20,13 +20,15 @@ public class DefaultProblem
{
private final Node source;
private final String messageKey;
+ private final int messageType;
private final Object[] messageArguments;
- DefaultProblem(Node source, String messageKey, Object[] messageArguments) {
+ DefaultProblem(Node source, String messageKey, int messageType, Object[] messageArguments) {
super();
this.source = source;
this.messageKey = messageKey;
+ this.messageType = messageType;
this.messageArguments = messageArguments;
}
@@ -41,6 +43,10 @@ public class DefaultProblem
return this.messageKey;
}
+ public int messageType() {
+ return this.messageType;
+ }
+
public Object[] messageArguments() {
return this.messageArguments;
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Problem.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Problem.java
index 4f8e730362..f9f77aad71 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Problem.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/node/Problem.java
@@ -28,6 +28,11 @@ public interface Problem {
* Return the arguments associate with the problem's message.
*/
Object[] messageArguments();
+
+ /**
+ * Return the type of the identified problem's message
+ */
+ int messageType();
/**
* Return whether the problem is equal to the specified object.
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/AbstractNodeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/AbstractNodeTests.java
index 8171433be6..d642ee29f4 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/AbstractNodeTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/node/AbstractNodeTests.java
@@ -469,7 +469,7 @@ public class AbstractNodeTests extends TestCase {
for (int i = this.name.length(); i-- > 0; ) {
char c = this.name.charAt(i);
if (Character.isLetter(c) && ! Character.isLowerCase(c)) {
- currentProblems.add(this.buildProblem("NAME_MUST_BE_LOWERCASE", this.name));
+ currentProblems.add(this.buildProblem("NAME_MUST_BE_LOWERCASE", 3 ,this.name));
return;
}
}

Back to the top