Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2009-12-01 16:59:49 -0500
committerkmoore2009-12-01 16:59:49 -0500
commit2a102c31492e096d78e825a1a5a5b6d368d53745 (patch)
tree724128b792888e09598b2c235af791a17e2b148a
parenta49132466fdd2c9d7b2137f1a93f6221872dd86f (diff)
downloadwebtools.dali-2a102c31492e096d78e825a1a5a5b6d368d53745.tar.gz
webtools.dali-2a102c31492e096d78e825a1a5a5b6d368d53745.tar.xz
webtools.dali-2a102c31492e096d78e825a1a5a5b6d368d53745.zip
279803 - add validation warning for OrderColumn and OrderBy both used
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaOrderable.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmOrderable.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_validation_preferences.properties10
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiValidationPreferenceMessages.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java13
9 files changed, 81 insertions, 17 deletions
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 7670ad63c7..2226c5f1a4 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
@@ -98,3 +98,5 @@ VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY=In implied attribute \"{0}\", t
DISCRIMINATOR_COLUMN_UNRESOLVED_NAME=Discriminator \"{0}\" column cannot be resolved
ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM=Entity \"{0}\" cannot use table-per-concrete-class inheritance because the chosen JPA platform does not support it
ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM=Entity \"{0}\" uses table-per-concrete-class inheritance which is not portable and may not be supported by the JPA provider
+
+ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED=Attribute \"{0}\" specifies both OrderColumn and OrderBy annotations \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
index 17006f6fbc..0d4eb05fd8 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.core.internal.context.java;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import java.util.Vector;
import org.eclipse.jdt.core.dom.CompilationUnit;
@@ -29,6 +30,8 @@ import org.eclipse.jpt.core.resource.java.RelationshipMappingAnnotation;
import org.eclipse.jpt.utility.Filter;
import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
/**
* Java multi-relationship (m:m, 1:m) mapping
@@ -38,11 +41,6 @@ public abstract class AbstractJavaMultiRelationshipMapping<T extends Relationshi
implements JavaMultiRelationshipMapping
{
protected final JavaOrderable orderable;
-
- protected String specifiedOrderBy = null;
- protected boolean noOrdering = false;
- protected boolean pkOrdering = false;
- protected boolean customOrdering = false;
protected String specifiedMapKey;
protected boolean noMapKey = false;
@@ -329,5 +327,13 @@ public abstract class AbstractJavaMultiRelationshipMapping<T extends Relationshi
public String getMetamodelFieldMapKeyTypeName() {
return MappingTools.getMetamodelFieldMapKeyTypeName(this);
}
+
+ // ********** validation **********
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ this.orderable.validate(messages, reporter, astRoot);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
index 75db97ac5c..8a23c0d862 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.core.internal.context.orm;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.jpt.core.context.FetchType;
import org.eclipse.jpt.core.context.MultiRelationshipMapping;
@@ -23,6 +24,8 @@ import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
import org.eclipse.jpt.core.resource.orm.AbstractXmlMultiRelationshipMapping;
import org.eclipse.jpt.core.resource.orm.MapKey;
import org.eclipse.jpt.core.resource.orm.OrmFactory;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
/**
* ORM multi-relationship (m:m, 1:m) mapping
@@ -257,5 +260,14 @@ public abstract class AbstractOrmMultiRelationshipMapping<T extends AbstractXmlM
public String getMetamodelFieldMapKeyTypeName() {
return MappingTools.getMetamodelFieldMapKeyTypeName(this);
}
+
+
+ // ********** validation **********
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ super.validate(messages, reporter);
+ this.orderable.validate(messages, reporter);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaOrderable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaOrderable.java
index d36965ff79..cb2620dc1a 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaOrderable.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/java/GenericJavaOrderable.java
@@ -10,12 +10,15 @@
package org.eclipse.jpt.core.internal.jpa1.context.java;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.context.TypeMapping;
import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
import org.eclipse.jpt.core.jpa2.context.java.JavaOrderColumn2_0;
import org.eclipse.jpt.core.jpa2.context.java.JavaOrderable2_0;
@@ -25,6 +28,8 @@ import org.eclipse.jpt.core.resource.java.OrderByAnnotation;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.db.Table;
import org.eclipse.jpt.utility.Filter;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
public class GenericJavaOrderable
@@ -330,4 +335,24 @@ public class GenericJavaOrderable
OrderByAnnotation orderByAnnotation = this.getOrderByAnnotation();
return (orderByAnnotation == null) ? null : orderByAnnotation.getTextRange(astRoot);
}
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ if (getOrderColumnAnnotation() != null && getOrderByAnnotation() != null) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED,
+ new String[] {getPersistentAttribute().getName()},
+ this.getParent(),
+ this.getOrderByAnnotationTextRange(astRoot)
+ )
+ );
+ }
+ if (isOrderColumnOrdering()) {
+ //TODO validation message if type is not List
+ }
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmOrderable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmOrderable.java
index 0a8801b6d1..94b9e13562 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmOrderable.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa1/context/orm/GenericOrmOrderable.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.jpa1.context.orm;
+import java.util.List;
import org.eclipse.jpt.core.context.TypeMapping;
import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
@@ -22,6 +23,8 @@ import org.eclipse.jpt.core.resource.orm.XmlOrderable;
import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrderable_2_0;
import org.eclipse.jpt.core.utility.TextRange;
import org.eclipse.jpt.db.Table;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
/**
* ORM multi-relationship (m:m, 1:m) mapping
@@ -253,9 +256,19 @@ public class GenericOrmOrderable
return getPersistentAttribute().getTypeMapping();
}
+
+ // ********** Validation **********
public TextRange getValidationTextRange() {
return getResourceOrderable().getValidationTextRange();
}
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ super.validate(messages, reporter);
+ if (isOrderColumnOrdering()) {
+ //TODO validation message if type is not List
+ }
+ }
}
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 e6eb847088..d9da784469 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
@@ -104,4 +104,8 @@ public interface JpaValidationMessages {
public static final String DISCRIMINATOR_COLUMN_UNRESOLVED_NAME = "DISCRIMINATOR_COLUMN_UNRESOLVED_NAME";
public static final String ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM = "ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM";
public static final String ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM = "ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM";
+
+ //JPA 2.0 validation messages
+ public static final String ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED = "ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED";
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_validation_preferences.properties b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_validation_preferences.properties
index 9f7b968f71..d633283a83 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_validation_preferences.properties
+++ b/jpa/plugins/org.eclipse.jpt.ui/property_files/jpt_ui_validation_preferences.properties
@@ -54,11 +54,11 @@ PERSISTENT_ATTRIBUTE_PUBLIC_FIELD=The java field for attribute is public:
ATTRIBUTE_LEVEL_CATEGORY=Attribute
MAPPING_UNRESOLVED_MAPPED_BY=Cannot resolve attribute name:
-MAPPING_INVALID_MAPPED_BY=Attribute has invalid mapping for this relationship
+MAPPING_INVALID_MAPPED_BY=Attribute has invalid mapping for this relationship:
MAPPING_MAPPED_BY_WITH_JOIN_TABLE=Cannot specify join table if attribute is mapped by another attribute:
MAPPING_MAPPED_BY_ON_BOTH_SIDES=Relationship must have an owner:
TARGET_ENTITY_NOT_DEFINED=Target entity is not defined:
-
+ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED=OrderColumn and OrderBy annotations are both specified:
TARGET_ENTITY_IS_NOT_AN_ENTITY=Target entity is not an Entity:
PHYSICAL_MAPPING_CATEGORY=Database
@@ -73,7 +73,7 @@ JOIN_TABLE_UNRESOLVED_CATALOG=Catalog cannot be resolved for join table:
JOIN_TABLE_UNRESOLVED_SCHEMA=Schema cannot be resolved for join table:
JOIN_TABLE_UNRESOLVED_NAME=Join table cannot be resolved:
COLUMN_UNRESOLVED_TABLE=Table for column cannot be resolved:
-COLUMN_UNRESOLVED_NAME=Column cannot be resolved
+COLUMN_UNRESOLVED_NAME=Column cannot be resolved:
JOIN_COLUMN_UNRESOLVED_TABLE=Table for join column cannot be resolved:
JOIN_COLUMN_UNRESOLVED_NAME=Join column cannot be resolved:
JOIN_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS=Join column name must be specified when there are multiples:
@@ -92,9 +92,9 @@ VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_TABLE=Table for column cannot be re
VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME=Column cannot be resolved:
VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME=Column cannot be resolved:
VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_TABLE=Table for join column cannot be resolved:
-VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME=Join column cannot be resolved
+VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME=Join column cannot be resolved:
VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS=Join column name must be specified when there are multiples:
-VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME=Referenced column in join column cannot be resolved
+VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME=Referenced column in join column cannot be resolved:
VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME_MULTIPLE_JOIN_COLUMNS=Join column referenced column name must be specified when there are multiples:
VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY=Target entity is not an Entity:
VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED=In implied attribute, target entity is not defined:
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiValidationPreferenceMessages.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiValidationPreferenceMessages.java
index 49d098e9d9..ce48f1e003 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiValidationPreferenceMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/JptUiValidationPreferenceMessages.java
@@ -70,7 +70,8 @@ public class JptUiValidationPreferenceMessages {
public static String MAPPING_MAPPED_BY_ON_BOTH_SIDES;
public static String TARGET_ENTITY_NOT_DEFINED;
public static String TARGET_ENTITY_IS_NOT_AN_ENTITY;
-
+ public static String ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED;
+
public static String PHYSICAL_MAPPING_CATEGORY;
public static String TABLE_UNRESOLVED_CATALOG;
public static String TABLE_UNRESOLVED_SCHEMA;
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java
index c73f29e27b..1664355b92 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/preferences/JpaProblemSeveritiesPage.java
@@ -150,12 +150,13 @@ public class JpaProblemSeveritiesPage extends PropertyAndPreferencePage {
parent = addExpandableSection(parent, JptUiValidationPreferenceMessages.ATTRIBUTE_LEVEL_CATEGORY);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_UNRESOLVED_MAPPED_BY, JpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_INVALID_MAPPED_BY, JpaValidationMessages.MAPPING_INVALID_MAPPED_BY);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_MAPPED_BY_WITH_JOIN_TABLE, JpaValidationMessages.MAPPING_MAPPED_BY_WITH_JOIN_TABLE);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES, JpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.TARGET_ENTITY_NOT_DEFINED, JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED);
- addLabeledCombo(parent, JptUiValidationPreferenceMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY, JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_UNRESOLVED_MAPPED_BY, JpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_INVALID_MAPPED_BY, JpaValidationMessages.MAPPING_INVALID_MAPPED_BY);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_MAPPED_BY_WITH_JOIN_TABLE, JpaValidationMessages.MAPPING_MAPPED_BY_WITH_JOIN_TABLE);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES, JpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.TARGET_ENTITY_NOT_DEFINED, JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY, JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY);
+ addLabeledCombo(parent, JptUiValidationPreferenceMessages.ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED, JpaValidationMessages.ORDER_COLUMN_AND_ORDER_BY_BOTH_SPECIFIED);
}
/**

Back to the top