Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IContextModel.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaNode.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaNode.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java83
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/BaseJpaContent.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ClassRef.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IClassRef.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IPersistentType.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ITable.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/Persistence.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceUnit.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceXml.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaColumn.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaJoinColumn.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaPersistentType.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaAttributeMapping.java76
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMapping.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMapping.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMapping.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntity.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMapping.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumn.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMapping.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMapping.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMultiRelationshipMapping.java160
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumn.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullAttributeMapping.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMapping.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMapping.java72
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttribute.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentType.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaSingleRelationshipMapping.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMapping.java9
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMapping.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmXmlImpl.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlEntity.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlPersistentType.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlTable.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/base/BaseJpaPlatform.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentAttributeResource.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentTypeResource.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF3
45 files changed, 1250 insertions, 47 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IContextModel.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IContextModel.java
index 2e30775009..fb074eec17 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IContextModel.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IContextModel.java
@@ -9,7 +9,11 @@
******************************************************************************/
package org.eclipse.jpt.core.internal;
+import java.util.List;
+
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public interface IContextModel
{
@@ -17,4 +21,12 @@ public interface IContextModel
* Update the context model with the content of the JPA project
*/
void update(IProgressMonitor monitor);
-}
+
+ // ********** validation **********
+
+ /**
+ * All subclass implementations {@link #addToMessages(List<IMessage>, CompilationUnit astRoot)}
+ * should be preceded by a "super" call to this method
+ */
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot);
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaNode.java
index 62ff11b02b..c467ec0ebe 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaNode.java
@@ -9,9 +9,13 @@
******************************************************************************/
package org.eclipse.jpt.core.internal;
+import java.util.List;
+
import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jpt.utility.internal.node.Node;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
/**
* Tweak the node interface with JPA-specific protocol.
@@ -29,7 +33,14 @@ public interface IJpaNode extends Node, IAdaptable
* This is used by JpaHelper.
*/
IResource resource();
-
+
+
+ // ********** validation **********
+
+ /**
+ * Adds to the list of current messages
+ */
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot);
// ********** covariant overrides **********
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java
index eaf83068fe..7ca4796b38 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java
@@ -91,9 +91,9 @@ public interface IJpaPlatform
// *************************************************************************
/**
- * Adds validation messages to the growing list of messages
+ * Adds validation messages to the growing list of messages for a given project
*/
- void addToMessages(List<IMessage> messages);
+ void addToMessages(IJpaProject project, List<IMessage> messages);
// ********** XmlPersistence Unit ********************************************
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaNode.java
index 23c78d4d97..3216115fbf 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaNode.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaNode.java
@@ -12,14 +12,17 @@ package org.eclipse.jpt.core.internal;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.db.internal.ConnectionProfile;
import org.eclipse.jpt.db.internal.Database;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
import org.eclipse.jpt.utility.internal.node.AbstractNode;
import org.eclipse.jpt.utility.internal.node.Node;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
/**
*
@@ -48,7 +51,7 @@ public abstract class JpaNode
// ********** IJpaNodeModel implementation **********
public IResource resource() {
- return this.jpaProject().project();
+ return parent().resource();
}
public IJpaProject jpaProject() {
@@ -72,7 +75,6 @@ public abstract class JpaNode
return (IJpaProject) super.root();
}
-
// ********** convenience methods **********
public Iterator<IJpaNode> jpaChildren() {
@@ -100,11 +102,10 @@ public abstract class JpaNode
return this.connectionProfile().getDatabase();
}
- protected boolean isConnected() {
+ public boolean isConnected() {
return this.connectionProfile().isConnected();
}
-
// ********** update model **********
private static final HashMap<Class<? extends AbstractNode>, HashSet<String>> nonUpdateAspectNameSets = new HashMap<Class<? extends AbstractNode>, HashSet<String>>();
@@ -146,5 +147,14 @@ public abstract class JpaNode
// when you override this method, don't forget to include:
// super.addNonUpdateAspectNamesTo(nonUpdateAspectNames);
}
+
+ // ********** validation **********
+
+ /**
+ * All subclass implementations {@link #addToMessages(List<IMessage>)}
+ * should be preceded by a "super" call to this method
+ */
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java
index ad32038d7b..ae14a02355 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java
@@ -28,9 +28,12 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.ElementChangedEvent;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.resource.java.JavaPersistentTypeResource;
import org.eclipse.jpt.core.internal.resource.java.JavaResourceModel;
import org.eclipse.jpt.core.internal.resource.java.JpaCompilationUnitResource;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.internal.ConnectionProfile;
import org.eclipse.jpt.db.internal.Schema;
import org.eclipse.jpt.utility.internal.CollectionTools;
@@ -151,6 +154,11 @@ public class JpaProject extends JpaNode implements IJpaProject {
throw new IllegalArgumentException("The parent node must be null");
}
}
+
+ @Override
+ public IResource resource() {
+ return project();
+ }
protected Vector<IJpaFile> buildEmptyJpaFiles() {
return new Vector<IJpaFile>();
@@ -374,14 +382,85 @@ public class JpaProject extends JpaNode implements IJpaProject {
// ********** validation **********
-
+
+
public Iterator<IMessage> validationMessages() {
List<IMessage> messages = new ArrayList<IMessage>();
- this.jpaPlatform.addToMessages(messages);
+ this.jpaPlatform.addToMessages(this, messages);
return messages.iterator();
}
+
+ /* If this is true, it may be assumed that all the requirements are valid
+ * for further validation. For example, if this is true at the point we
+ * are validating persistence units, it may be assumed that there is a
+ * single persistence.xml and that it has valid content down to the
+ * persistence unit level. */
+ private boolean okToContinueValidation = true;
+
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+ //start with the project - then down
+ //project validation
+ addProjectLevelMessages(messages);
+
+ //context model validation
+ contextModel().addToMessages(messages, astRoot);
+ }
+ protected void addProjectLevelMessages(List<IMessage> messages) {
+ addConnectionMessages(messages);
+ addMultiplePersistenceXmlMessage(messages);
+ }
+
+ protected void addConnectionMessages(List<IMessage> messages) {
+ addNoConnectionMessage(messages);
+ addInactiveConnectionMessage(messages);
+ }
+
+ protected boolean okToProceedForConnectionValidation = true;
+
+ protected void addNoConnectionMessage(List<IMessage> messages) {
+ if (! this.dataSource().hasAConnection()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.NORMAL_SEVERITY,
+ IJpaValidationMessages.PROJECT_NO_CONNECTION,
+ this)
+ );
+ okToProceedForConnectionValidation = false;
+ }
+ }
+
+ protected void addInactiveConnectionMessage(List<IMessage> messages) {
+ if (okToProceedForConnectionValidation && ! this.dataSource().isConnected()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.NORMAL_SEVERITY,
+ IJpaValidationMessages.PROJECT_INACTIVE_CONNECTION,
+ new String[] {this.dataSource().connectionProfileName()},
+ this)
+ );
+ }
+ okToProceedForConnectionValidation = true;
+ }
+
+ protected void addMultiplePersistenceXmlMessage(List<IMessage> messages) {
+// if (validPersistenceXmlFiles.size() > 1) {
+// messages.add(
+// JpaValidationMessages.buildMessage(
+// IMessage.HIGH_SEVERITY,
+// IJpaValidationMessages.PROJECT_MULTIPLE_PERSISTENCE_XML,
+// jpaProject)
+// );
+// okToContinueValidation = false;
+// }
+ }
+
+
+
// ********** root deploy location **********
protected static final String WEB_PROJECT_ROOT_DEPLOY_LOCATION = J2EEConstants.WEB_INF_CLASSES;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/BaseJpaContent.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/BaseJpaContent.java
index 96930fbb26..5398ed38e5 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/BaseJpaContent.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/BaseJpaContent.java
@@ -10,16 +10,27 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.context.base;
+import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.IJpaFile;
+import org.eclipse.jpt.core.internal.IJpaNode;
import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.core.internal.JpaNode;
import org.eclipse.jpt.core.internal.JptCorePlugin;
import org.eclipse.jpt.core.internal.context.orm.EntityMappings;
import org.eclipse.jpt.core.internal.context.orm.XmlPersistentType;
import org.eclipse.jpt.core.internal.resource.persistence.PersistenceArtifactEdit;
import org.eclipse.jpt.core.internal.resource.persistence.PersistenceResource;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.utility.internal.node.Node;
import org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class BaseJpaContent extends JpaContextNode
implements IBaseJpaContent
@@ -132,4 +143,56 @@ public class BaseJpaContent extends JpaContextNode
public IPersistenceUnit persistenceUnit() {
throw new UnsupportedOperationException("No PersistenceUnit in this context");
}
+
+
+ //******** Validation *************************************************
+
+ /* If this is true, it may be assumed that all the requirements are valid
+ * for further validation. For example, if this is true at the point we
+ * are validating persistence units, it may be assumed that there is a
+ * single persistence.xml and that it has valid content down to the
+ * persistence unit level. */
+ private boolean okToContinueValidation = true;
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+ addNoPersistenceXmlMessage(messages);
+ addOrphanedJavaClassMessages(messages);
+
+ if(okToContinueValidation) {
+ getPersistenceXml().addToMessages(messages, astRoot);
+ }
+
+ }
+
+ protected void addNoPersistenceXmlMessage(List<IMessage> messages) {
+ if (persistenceXml == null) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.PROJECT_NO_PERSISTENCE_XML,
+ this)
+ );
+ okToContinueValidation = false;
+ }
+ }
+
+
+
+
+ protected void addOrphanedJavaClassMessages(List<IMessage> messages) {
+// for (Iterator<JavaPersistentType> stream = jpaProject.javaPersistentTypes(); stream.hasNext(); ) {
+// JavaPersistentType jpType = stream.next();
+// if (jpType.getMappingKey() != IMappingKeys.NULL_TYPE_MAPPING_KEY && ! contains(jpType)) {
+// messages.add(
+// JpaValidationMessages.buildMessage(
+// IMessage.HIGH_SEVERITY,
+// IJpaValidationMessages.PERSISTENT_TYPE_UNSPECIFIED_CONTEXT,
+// jpType.getMapping(), jpType.getMapping().validationTextRange())
+// );
+// }
+// }
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ClassRef.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ClassRef.java
index 53449ccefa..fed69cef0e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ClassRef.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ClassRef.java
@@ -10,10 +10,14 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.context.base;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.context.java.IJavaPersistentType;
import org.eclipse.jpt.core.internal.resource.java.JavaPersistentTypeResource;
import org.eclipse.jpt.core.internal.resource.persistence.XmlJavaClassRef;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
/**
* This is the context model object which corresponds to the
@@ -113,6 +117,16 @@ public class ClassRef extends JpaContextNode implements IClassRef
// *************************************************************************
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ //classRef might have been empty
+ if(javaPersistentType != null){
+ javaPersistentType.addToMessages(messages, astRoot);
+ }
+ }
public ITextRange validationTextRange() {
return this.xmlJavaClassRef.validationTextRange();
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IClassRef.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IClassRef.java
index 05ee115eff..852e36b8ab 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IClassRef.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IClassRef.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.context.base;
+import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.context.java.IJavaPersistentType;
import org.eclipse.jpt.core.internal.resource.persistence.XmlJavaClassRef;
@@ -59,4 +60,9 @@ public interface IClassRef extends IJpaContextNode
void initialize(XmlJavaClassRef classRef);
void update(XmlJavaClassRef classRef);
+
+ // *************************************************************************
+
+ ITextRange validationTextRange();
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IPersistentType.java
index 103bf31a37..18dd4c116d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/IPersistentType.java
@@ -60,12 +60,14 @@ public interface IPersistentType extends IJpaContextNode
*/
IPersistentAttribute attributeNamed(String attributeName);
-// /**
-// * Resolve and return the attribute named <code>attributeName</code> if it
-// * is distinct and exists within the context of this type
-// */
-// IPersistentAttribute resolveAttribute(String attributeName);
+ /**
+ * Resolve and return the attribute named <code>attributeName</code> if it
+ * is distinct and exists within the context of this type
+ */
+ IPersistentAttribute resolveAttribute(String attributeName);
Iterator<IPersistentType> inheritanceHierarchy();
+
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ITable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ITable.java
index 52401a807a..fc3fc5449b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ITable.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/ITable.java
@@ -50,6 +50,11 @@ public interface ITable extends IJpaContextNode
org.eclipse.jpt.db.internal.Table dbTable();
Schema dbSchema();
+
+ /**
+ * Return true if this table is connected to a datasource
+ */
+ boolean isConnected();
/**
* Return true if this table's schema can be resolved to a schema on the active connection
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/Persistence.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/Persistence.java
index 30480690fb..f4645e44d4 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/Persistence.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/Persistence.java
@@ -14,11 +14,16 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.resource.persistence.PersistenceFactory;
import org.eclipse.jpt.core.internal.resource.persistence.XmlPersistence;
import org.eclipse.jpt.core.internal.resource.persistence.XmlPersistenceUnit;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class Persistence extends JpaContextNode
implements IPersistence
@@ -133,4 +138,42 @@ public class Persistence extends JpaContextNode
public ITextRange validationTextRange() {
return this.xmlPersistence.validationTextRange();
}
+
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ //persistence root validation
+ addNoPersistenceUnitMessage(messages);
+ addMultiplePersistenceUnitMessage(messages);
+
+
+ //persistence unit validation
+ for (IPersistenceUnit pu : persistenceUnits){
+ pu.addToMessages(messages, astRoot);
+ }
+ }
+
+ protected void addNoPersistenceUnitMessage(List<IMessage> messages) {
+ if (persistenceUnits.size() == 0) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.PERSISTENCE_NO_PERSISTENCE_UNIT,
+ this, this.validationTextRange())
+ );
+ }
+ }
+
+ protected void addMultiplePersistenceUnitMessage(List<IMessage> messages) {
+ if (persistenceUnits.size() > 1) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS,
+ this, this.validationTextRange())
+ );
+ }
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceUnit.java
index 6a1c576130..8f430e34ab 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceUnit.java
@@ -18,6 +18,7 @@ import java.util.List;
import java.util.ListIterator;
import java.util.NoSuchElementException;
import org.eclipse.emf.common.util.EList;
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.JptCorePlugin;
import org.eclipse.jpt.core.internal.context.orm.PersistenceUnitDefaults;
@@ -32,10 +33,15 @@ import org.eclipse.jpt.core.internal.resource.persistence.XmlPersistenceUnitTran
import org.eclipse.jpt.core.internal.resource.persistence.XmlProperties;
import org.eclipse.jpt.core.internal.resource.persistence.XmlProperty;
import org.eclipse.jpt.db.internal.Schema;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.ReadOnlyCompositeListIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.xml.core.internal.catalog.NextCatalog;
public class PersistenceUnit extends JpaContextNode
implements IPersistenceUnit
@@ -871,6 +877,78 @@ public class PersistenceUnit extends JpaContextNode
return persistenceUnitDefaults == null ? false : persistenceUnitDefaults.isCascadePersist();
}
// *************************************************************************
+
+ // ********** Validation ***********************************************
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ addMappingFileMessages(messages, astRoot);
+ addClassMessages(messages, astRoot);
+ }
+
+ protected void addMappingFileMessages(List<IMessage> messages, CompilationUnit astRoot) {
+// addMultipleMetadataMessages(messages);
+// addUnspecifiedMappingFileMessages(messages);
+// addUnresolvedMappingFileMessages(messages);
+// addInvalidMappingFileContentMessage(messages);
+// addDuplicateMappingFileMessages(messages);
+
+ for (Iterator<IMappingFileRef> stream = mappingFileRefs(); stream.hasNext();) {
+ stream.next().addToMessages(messages, astRoot);
+ }
+ }
+
+ protected void addClassMessages(List<IMessage> messages, CompilationUnit astRoot) {
+// addUnspecifiedClassMessages(messages);
+ addUnresolvedClassMessages(messages);
+// addInvalidClassContentMessages(messages);
+// addDuplicateClassMessages(messages);
+
+ //need to have support for non-annotated mode
+ //can't just go down the class-ref list
+ //also need to think about
+
+ for (IClassRef classRef : classRefs) {
+ //temporary
+ classRef.addToMessages(messages, astRoot);
+ }
+ }
+
+ protected void addUnresolvedClassMessages(List<IMessage> messages) {
+ for (IClassRef javaClassRef : this.classRefs) {
+ String javaClass = javaClassRef.getClassName();
+ if (! StringTools.stringIsEmpty(javaClass) && javaClassRef.getJavaPersistentType() == null) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS,
+ new String[] {javaClass},
+ javaClassRef, javaClassRef.validationTextRange())
+ );
+ }
+ }
+ }
+
+// protected void addDuplicateClassMessages(List<IMessage> messages) {
+// HashBag<String> classNameBag = this.classNameBag();
+// for (JavaClassRef javaClassRef : persistenceUnit.getClasses()) {
+// if (javaClassRef.getJavaClass() != null
+// && classNameBag.count(javaClassRef.getJavaClass()) > 1) {
+// messages.add(
+// JpaValidationMessages.buildMessage(
+// IMessage.HIGH_SEVERITY,
+// IJpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_CLASS,
+// new String[] {javaClassRef.getJavaClass()},
+// javaClassRef, javaClassRef.validationTextRange())
+// );
+// }
+// }
+// }
+
+
+ //*************************************
public IPersistentType persistentType(String fullyQualifiedTypeName) {
for (IMappingFileRef mappingFileRef : CollectionTools.iterable(mappingFileRefs())) {
@@ -896,4 +974,5 @@ public class PersistenceUnit extends JpaContextNode
super.toString(sb);
sb.append(getName());
}
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceXml.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceXml.java
index 9839c9bf21..ab8e4e4117 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceXml.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/base/PersistenceXml.java
@@ -10,10 +10,15 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.context.base;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.resource.persistence.PersistenceFactory;
import org.eclipse.jpt.core.internal.resource.persistence.PersistenceResource;
import org.eclipse.jpt.core.internal.resource.persistence.XmlPersistence;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class PersistenceXml extends JpaContextNode
implements IPersistenceXml
@@ -27,6 +32,10 @@ public class PersistenceXml extends JpaContextNode
super(baseJpaContent);
}
+ @Override
+ public IResource resource() {
+ return persistenceResource.getFile();
+ }
// **************** persistence ********************************************
@@ -110,4 +119,15 @@ public class PersistenceXml extends JpaContextNode
public ITextRange validationTextRange() {
return ITextRange.Empty.instance();
}
+
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+// addInvalidPersistenceXmlContentMessage(messages);
+
+ getPersistence().addToMessages(messages, astRoot);
+
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java
index 4358f073d2..401ba1dfdc 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java
@@ -158,7 +158,8 @@ public abstract class AbstractJavaTable extends JavaContextModel
// ********** ITable implementation **********
public ITextRange nameTextRange(CompilationUnit astRoot) {
- return tableResource().nameTextRange(astRoot);
+ ITextRange textRange = tableResource().nameTextRange(astRoot);
+ return (textRange != null) ? textRange : this.parent().validationTextRange(astRoot);
}
public boolean nameTouches(int pos, CompilationUnit astRoot) {
@@ -166,7 +167,8 @@ public abstract class AbstractJavaTable extends JavaContextModel
}
public ITextRange schemaTextRange(CompilationUnit astRoot) {
- return tableResource().schemaTextRange(astRoot);
+ ITextRange textRange = tableResource().schemaTextRange(astRoot);
+ return (textRange != null) ? textRange : this.parent().validationTextRange(astRoot);
}
public boolean schemaTouches(int pos, CompilationUnit astRoot) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaColumn.java
index 91cd1c8f7f..8d7ca17781 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaColumn.java
@@ -19,6 +19,8 @@ public interface IJavaColumn extends IJavaNamedColumn, IColumn
void update(Column columnResource);
+ boolean isConnected();
+
Owner owner();
/**
* interface allowing columns to be used in multiple places
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaJoinColumn.java
index 18fb017f08..be95f96bd5 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaJoinColumn.java
@@ -16,6 +16,8 @@ public interface IJavaJoinColumn extends IJoinColumn, IJavaNamedColumn
{
void initializeFromResource(JoinColumn joinColumn);
+ boolean isConnected();
+
void update(JoinColumn joinColumn);
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaPersistentType.java
index bacadc6681..d7714aee9f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/IJavaPersistentType.java
@@ -10,6 +10,8 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.ListIterator;
+
+import org.eclipse.jpt.core.internal.context.base.IPersistentAttribute;
import org.eclipse.jpt.core.internal.context.base.IPersistentType;
import org.eclipse.jpt.core.internal.resource.java.JavaPersistentTypeResource;
@@ -21,6 +23,12 @@ public interface IJavaPersistentType extends IPersistentType, IJavaJpaContextNod
ListIterator<IJavaPersistentAttribute> attributes();
IJavaPersistentAttribute attributeNamed(String attributeName);
+
+ /**
+ * Resolve and return the attribute named <code>attributeName</code> if it
+ * is distinct and exists within the context of this type
+ */
+ IPersistentAttribute resolveAttribute(String attributeName);
void initializeFromResource(JavaPersistentTypeResource persistentTypeResource);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaAttributeMapping.java
index 13031e2429..276f45977f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaAttributeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaAttributeMapping.java
@@ -9,11 +9,19 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.context.java;
+import java.util.List;
+
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.context.base.ITypeMapping;
import org.eclipse.jpt.core.internal.resource.java.JavaPersistentAttributeResource;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.internal.Table;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public abstract class JavaAttributeMapping extends JavaContextModel
@@ -42,6 +50,14 @@ public abstract class JavaAttributeMapping extends JavaContextModel
return this.persistentAttribute().mappingIsDefault();
}
+ protected boolean embeddableOwned() {
+ return this.typeMapping().getKey() == IMappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
+ }
+
+ protected boolean entityOwned() {
+ return this.typeMapping().getKey() == IMappingKeys.ENTITY_TYPE_MAPPING_KEY;
+ }
+
public ITypeMapping typeMapping() {
return this.persistentAttribute().typeMapping();
}
@@ -78,4 +94,64 @@ public abstract class JavaAttributeMapping extends JavaContextModel
public boolean isIdMapping() {
return false;
}
+
+ //************ Validation *************************
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ addModifierMessages(messages, astRoot);
+ addInvalidMappingMessage(messages, astRoot);
+
+ }
+
+ protected void addModifierMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ JavaPersistentAttribute attribute = this.persistentAttribute();
+ if (attribute.getMapping().getKey() != IMappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY
+ && persistentAttributeResource.isForField()) {
+ int flags;
+
+ try {
+ flags = persistentAttributeResource.getMember().getJdtMember().getFlags();
+ } catch (JavaModelException jme) {
+ /* no error to log, in that case */
+ return;
+ }
+
+ if (Flags.isFinal(flags)) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.PERSISTENT_ATTRIBUTE_FINAL_FIELD,
+ new String[] {attribute.getName()},
+ attribute, attribute.validationTextRange(astRoot))
+ );
+ }
+
+ if (Flags.isPublic(flags)) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.PERSISTENT_ATTRIBUTE_PUBLIC_FIELD,
+ new String[] {attribute.getName()},
+ attribute, attribute.validationTextRange(astRoot))
+ );
+
+ }
+ }
+ }
+
+ protected void addInvalidMappingMessage(List<IMessage> messages, CompilationUnit astRoot) {
+ if (! typeMapping().attributeMappingKeyAllowed(this.getKey())) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING,
+ new String[] {this.persistentAttribute().getName()},
+ this, this.validationTextRange(astRoot))
+ );
+ }
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMapping.java
index 18f09a383c..bdc240d9b1 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMapping.java
@@ -10,6 +10,8 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.context.base.EnumType;
@@ -18,6 +20,7 @@ import org.eclipse.jpt.core.internal.context.base.IBasicMapping;
import org.eclipse.jpt.core.internal.context.base.IColumnMapping;
import org.eclipse.jpt.core.internal.context.base.IFetchable;
import org.eclipse.jpt.core.internal.context.base.INullable;
+import org.eclipse.jpt.core.internal.context.base.ITypeMapping;
import org.eclipse.jpt.core.internal.context.base.TemporalType;
import org.eclipse.jpt.core.internal.resource.java.Basic;
import org.eclipse.jpt.core.internal.resource.java.Column;
@@ -26,8 +29,11 @@ import org.eclipse.jpt.core.internal.resource.java.JPA;
import org.eclipse.jpt.core.internal.resource.java.JavaPersistentAttributeResource;
import org.eclipse.jpt.core.internal.resource.java.Lob;
import org.eclipse.jpt.core.internal.resource.java.Temporal;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.utility.internal.Filter;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaBasicMapping extends JavaAttributeMapping implements IJavaBasicMapping
@@ -292,4 +298,39 @@ public class JavaBasicMapping extends JavaAttributeMapping implements IJavaBasic
}
return null;
}
+
+ // ************** Validation *************************************
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages ,astRoot);
+
+ addColumnMessages(messages, astRoot);
+ }
+
+ protected void addColumnMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ IJavaColumn column = this.getColumn();
+ String table = column.getTable();
+ boolean doContinue = entityOwned() && column.isConnected();
+
+ if (doContinue && this.typeMapping().tableNameIsInvalid(table)) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.COLUMN_UNRESOLVED_TABLE,
+ new String[] {table, column.getName()},
+ column, column.tableTextRange(astRoot))
+ );
+ doContinue = false;
+ }
+
+ if (doContinue && ! column.isResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.COLUMN_UNRESOLVED_NAME,
+ new String[] {column.getName()},
+ column, column.nameTextRange(astRoot))
+ );
+ }
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMapping.java
index 5d5f86fac2..6b122c7e2a 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMapping.java
@@ -38,6 +38,7 @@ import org.eclipse.jpt.utility.internal.iterators.CompositeListIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaEmbeddedIdMapping extends JavaAttributeMapping
@@ -301,6 +302,12 @@ public class JavaEmbeddedIdMapping extends JavaAttributeMapping
return null;
}
+ //******** Validation ******************
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+ }
+
//******* static methods *********
protected static IEmbeddable embeddableFor(IJavaPersistentAttribute persistentAttribute) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMapping.java
index 64d71a2a07..379c0c2b05 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMapping.java
@@ -38,6 +38,7 @@ import org.eclipse.jpt.utility.internal.iterators.CompositeListIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaEmbeddedMapping extends JavaAttributeMapping implements IJavaEmbeddedMapping
@@ -291,6 +292,17 @@ public class JavaEmbeddedMapping extends JavaAttributeMapping implements IJavaEm
}
return null;
}
+
+
+ //******** Validation ******************
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ for (Iterator<IJavaAttributeOverride> stream = attributeOverrides(); stream.hasNext();) {
+ stream.next().addToMessages(messages, astRoot);
+ }
+ }
//******* static methods *********
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntity.java
index adfa9a7d16..02d9e89b23 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntity.java
@@ -19,6 +19,7 @@ import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.context.base.DiscriminatorType;
import org.eclipse.jpt.core.internal.context.base.IAbstractJoinColumn;
+import org.eclipse.jpt.core.internal.context.base.IAttributeOverride;
import org.eclipse.jpt.core.internal.context.base.IColumnMapping;
import org.eclipse.jpt.core.internal.context.base.IDiscriminatorColumn;
import org.eclipse.jpt.core.internal.context.base.IEntity;
@@ -27,6 +28,7 @@ import org.eclipse.jpt.core.internal.context.base.IOverride;
import org.eclipse.jpt.core.internal.context.base.IPersistentAttribute;
import org.eclipse.jpt.core.internal.context.base.IPersistentType;
import org.eclipse.jpt.core.internal.context.base.IPrimaryKeyJoinColumn;
+import org.eclipse.jpt.core.internal.context.base.ISecondaryTable;
import org.eclipse.jpt.core.internal.context.base.ITable;
import org.eclipse.jpt.core.internal.context.base.ITypeMapping;
import org.eclipse.jpt.core.internal.context.base.InheritanceType;
@@ -55,6 +57,8 @@ import org.eclipse.jpt.core.internal.resource.java.SecondaryTable;
import org.eclipse.jpt.core.internal.resource.java.SecondaryTables;
import org.eclipse.jpt.core.internal.resource.java.SequenceGenerator;
import org.eclipse.jpt.core.internal.resource.java.TableGenerator;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.internal.Schema;
import org.eclipse.jpt.db.internal.Table;
import org.eclipse.jpt.utility.internal.CollectionTools;
@@ -66,6 +70,8 @@ import org.eclipse.jpt.utility.internal.iterators.CompositeListIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
+import org.eclipse.jpt.utility.internal.node.Node;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaEntity extends JavaTypeMapping implements IJavaEntity
@@ -1464,6 +1470,85 @@ public class JavaEntity extends JavaTypeMapping implements IJavaEntity
}
+ //********** Validation ********************************************
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ addTableMessages(messages, astRoot);
+ addIdMessages(messages, astRoot);
+
+ for (IJavaSecondaryTable context : specifiedSecondaryTables) {
+ context.addToMessages(messages, astRoot);
+ }
+
+ for (Iterator<IJavaAttributeOverride> stream = this.attributeOverrides(); stream.hasNext();) {
+ stream.next().addToMessages(messages, astRoot);
+ }
+
+ for (Iterator<IJavaAssociationOverride> stream = this.associationOverrides(); stream.hasNext();) {
+ stream.next().addToMessages(messages, astRoot);
+ }
+
+ }
+
+ protected void addTableMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ boolean doContinue = table.isConnected();
+ String schema = table.getSchema();
+
+ if (doContinue && ! table.hasResolvedSchema()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.TABLE_UNRESOLVED_SCHEMA,
+ new String[] {schema, table.getName()},
+ table, table.schemaTextRange(astRoot))
+ );
+ doContinue = false;
+ }
+
+ if (doContinue && ! table.isResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.TABLE_UNRESOLVED_NAME,
+ new String[] {table.getName()},
+ table, table.nameTextRange(astRoot))
+ );
+ }
+ }
+
+
+ protected void addIdMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ addNoIdMessage(messages, astRoot);
+
+ }
+
+ protected void addNoIdMessage(List<IMessage> messages, CompilationUnit astRoot) {
+ if (entityHasNoId()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.ENTITY_NO_ID,
+ new String[] {this.getName()},
+ this, this.validationTextRange(astRoot))
+ );
+ }
+ }
+
+ private boolean entityHasNoId() {
+ return ! this.entityHasId();
+ }
+
+ private boolean entityHasId() {
+ for (Iterator<IPersistentAttribute> stream = persistentType().allAttributes(); stream.hasNext(); ) {
+ if (stream.next().isIdAttribute()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
class PrimaryKeyJoinColumnOwner implements IAbstractJoinColumn.Owner
{
public ITextRange validationTextRange(CompilationUnit astRoot) {
@@ -1560,6 +1645,5 @@ public class JavaEntity extends JavaTypeMapping implements IJavaEntity
// TODO Auto-generated method stub
return null;
}
-
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMapping.java
index ec5dead556..650c3982a0 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMapping.java
@@ -10,6 +10,8 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.context.base.IColumnMapping;
@@ -22,8 +24,11 @@ import org.eclipse.jpt.core.internal.resource.java.JavaPersistentAttributeResour
import org.eclipse.jpt.core.internal.resource.java.SequenceGenerator;
import org.eclipse.jpt.core.internal.resource.java.TableGenerator;
import org.eclipse.jpt.core.internal.resource.java.Temporal;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.utility.internal.Filter;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaIdMapping extends JavaAttributeMapping implements IJavaIdMapping
@@ -360,4 +365,66 @@ public class JavaIdMapping extends JavaAttributeMapping implements IJavaIdMappin
return true;
}
+ //*********** Validation ************
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ addColumnMessages(messages, astRoot);
+
+ //TODO njh there is no generator repos yet
+// addGeneratorMessages(messages);
+ }
+
+ protected void addColumnMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ IJavaColumn column = this.getColumn();
+ String table = column.getTable();
+ boolean doContinue = entityOwned() && column.isConnected();
+
+ if (doContinue && this.typeMapping().tableNameIsInvalid(table)) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.COLUMN_UNRESOLVED_TABLE,
+ new String[] {table, column.getName()},
+ column, column.tableTextRange(astRoot))
+ );
+ doContinue = false;
+ }
+
+ if (doContinue && ! column.isResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.COLUMN_UNRESOLVED_NAME,
+ new String[] {column.getName()},
+ column, column.nameTextRange(astRoot))
+ );
+ }
+ }
+
+ protected void addGeneratorMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ IJavaGeneratedValue generatedValue = this.getGeneratedValue();
+ if (generatedValue == null) {
+ return;
+ }
+ String generatorName = generatedValue.getGenerator();
+ if (generatorName == null) {
+ return;
+ }
+// IGeneratorRepository generatorRepository = persistenceUnit().getGeneratorRepository();
+// IJavaGenerator generator = generatorRepository.generator(generatorName);
+//
+// if (generator == null) {
+// messages.add(
+// JpaValidationMessages.buildMessage(
+// IMessage.HIGH_SEVERITY,
+// IJpaValidationMessages.GENERATED_VALUE_UNRESOLVED_GENERATOR,
+// new String[] {generatorName},
+// generatedValue, generatedValue.generatorTextRange())
+// );
+// }
+ }
+
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumn.java
index 05fd005013..0042ccb670 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumn.java
@@ -125,7 +125,8 @@ public class JavaJoinColumn extends AbstractJavaColumn<JoinColumn> implements IJ
}
public ITextRange referencedColumnNameTextRange(CompilationUnit astRoot) {
- return columnResource().referencedColumnNameTextRange(astRoot);
+ ITextRange textRange = columnResource().referencedColumnNameTextRange(astRoot);
+ return (textRange != null) ? textRange : owner().validationTextRange(astRoot);
}
public ITextRange validationTextRange(CompilationUnit astRoot) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMapping.java
index 38069ded61..0fa529246d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMapping.java
@@ -10,6 +10,8 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.ITextRange;
@@ -17,6 +19,7 @@ import org.eclipse.jpt.core.internal.context.base.IAttributeMapping;
import org.eclipse.jpt.core.internal.resource.java.JPA;
import org.eclipse.jpt.core.internal.resource.java.ManyToMany;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaManyToManyMapping extends JavaMultiRelationshipMapping<ManyToMany>
@@ -75,4 +78,8 @@ public class JavaManyToManyMapping extends JavaMultiRelationshipMapping<ManyToMa
public ITextRange mappedByTextRange(CompilationUnit astRoot) {
return this.relationshipMapping().mappedByTextRange(astRoot);
}
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+ }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMapping.java
index 3e62e0e6c7..eb3e579d8b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMapping.java
@@ -10,11 +10,15 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
import java.util.ListIterator;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.resource.java.JPA;
import org.eclipse.jpt.core.internal.resource.java.ManyToOne;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaManyToOneMapping extends JavaSingleRelationshipMapping<ManyToOne>
implements IJavaManyToOneMapping
@@ -59,6 +63,14 @@ public class JavaManyToOneMapping extends JavaSingleRelationshipMapping<ManyToOn
return relationshipMapping.getOptional();
}
+ //ManyToOne mapping is always the owning side
+ protected boolean isOwningSide() {
+ return true;
+ }
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+ }
//***************** ISingleRelationshipMapping implementation *****************
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMultiRelationshipMapping.java
index 26d7485fe7..ed1f5d7a57 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMultiRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMultiRelationshipMapping.java
@@ -10,17 +10,24 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.context.base.FetchType;
+import org.eclipse.jpt.core.internal.context.base.IEntity;
import org.eclipse.jpt.core.internal.context.base.IMultiRelationshipMapping;
import org.eclipse.jpt.core.internal.context.base.INonOwningMapping;
+import org.eclipse.jpt.core.internal.context.base.IPersistentAttribute;
import org.eclipse.jpt.core.internal.resource.java.JavaPersistentAttributeResource;
import org.eclipse.jpt.core.internal.resource.java.MapKey;
import org.eclipse.jpt.core.internal.resource.java.OrderBy;
import org.eclipse.jpt.core.internal.resource.java.RelationshipMapping;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.utility.internal.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;
public abstract class JavaMultiRelationshipMapping<T extends RelationshipMapping>
@@ -350,4 +357,157 @@ public abstract class JavaMultiRelationshipMapping<T extends RelationshipMapping
protected abstract String mappedBy(T relationshipMapping);
+ //******** Validation ***********************************
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ if (this.isJoinTableSpecified()) {
+ addJoinTableMessages(messages, astRoot);
+ }
+ if (this.getMappedBy() != null) {
+ addMappedByMessages(messages, astRoot);
+ }
+ }
+
+ protected void addJoinTableMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ IJavaJoinTable joinTable = this.getJoinTable();
+
+ boolean doContinue = joinTable.isConnected();
+ String schema = joinTable.getSchema();
+
+ if (doContinue && ! joinTable.hasResolvedSchema()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.JOIN_TABLE_UNRESOLVED_SCHEMA,
+ new String[] {schema, joinTable.getName()},
+ joinTable, joinTable.schemaTextRange(astRoot))
+ );
+ doContinue = false;
+ }
+
+ if (doContinue && ! joinTable.isResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.JOIN_TABLE_UNRESOLVED_NAME,
+ new String[] {joinTable.getName()},
+ joinTable, joinTable.nameTextRange(astRoot))
+ );
+ doContinue = false;
+ }
+
+ for (Iterator<IJavaJoinColumn> stream = joinTable.joinColumns(); stream.hasNext(); ) {
+ IJavaJoinColumn joinColumn = stream.next();
+
+ if (doContinue && ! joinColumn.isResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.JOIN_COLUMN_UNRESOLVED_NAME,
+ new String[] {joinColumn.getName()},
+ joinColumn, joinColumn.nameTextRange(astRoot))
+ );
+ }
+
+ if (doContinue && ! joinColumn.isReferencedColumnResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME,
+ new String[] {joinColumn.getReferencedColumnName(), joinColumn.getName()},
+ joinColumn, joinColumn.referencedColumnNameTextRange(astRoot))
+ );
+ }
+ }
+
+ for (Iterator<IJavaJoinColumn> stream = joinTable.inverseJoinColumns(); stream.hasNext(); ) {
+ IJavaJoinColumn joinColumn = stream.next();
+
+ if (doContinue && ! joinColumn.isResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.JOIN_COLUMN_UNRESOLVED_NAME,
+ new String[] {joinColumn.getName()},
+ joinColumn, joinColumn.nameTextRange(astRoot))
+ );
+ }
+
+ if (doContinue && ! joinColumn.isReferencedColumnResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME,
+ new String[] {joinColumn.getReferencedColumnName(), joinColumn.getName()},
+ joinColumn, joinColumn.referencedColumnNameTextRange(astRoot))
+ );
+ }
+ }
+ }
+
+ protected void addMappedByMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ String mappedBy = this.getMappedBy();
+
+ if (this.isJoinTableSpecified()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.MAPPING_MAPPED_BY_WITH_JOIN_TABLE,
+ this.getJoinTable(), this.getJoinTable().validationTextRange(astRoot))
+ );
+
+ }
+
+ IEntity targetEntity = this.getResolvedTargetEntity();
+
+ if (targetEntity == null) {
+ // already have validation messages for that
+ return;
+ }
+
+ IPersistentAttribute attribute = targetEntity.persistentType().resolveAttribute(mappedBy);
+
+ if (attribute == null) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY,
+ new String[] {mappedBy},
+ this, this.mappedByTextRange(astRoot))
+ );
+ return;
+ }
+
+ if (! this.mappedByIsValid(attribute.getMapping())) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.MAPPING_INVALID_MAPPED_BY,
+ new String[] {mappedBy},
+ this, this.mappedByTextRange(astRoot))
+ );
+ return;
+ }
+
+ INonOwningMapping mappedByMapping;
+ try {
+ mappedByMapping = (INonOwningMapping) attribute.getMapping();
+ } catch (ClassCastException cce) {
+ // there is no error then
+ return;
+ }
+
+ if (mappedByMapping.getMappedBy() != null) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES,
+ this, this.mappedByTextRange(astRoot))
+ );
+ }
+ }
+
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumn.java
index 4b463c6c71..3112ad316e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumn.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumn.java
@@ -117,7 +117,8 @@ public abstract class JavaNamedColumn<T extends NamedColumn> extends JavaContext
}
public ITextRange nameTextRange(CompilationUnit astRoot) {
- return this.columnResource().nameTextRange(astRoot);
+ ITextRange textRange = this.columnResource().nameTextRange(astRoot);
+ return (textRange != null) ? textRange : this.owner().validationTextRange(astRoot);
}
public boolean nameTouches(int pos, CompilationUnit astRoot) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullAttributeMapping.java
index 259f5c1a7c..1d23d838f7 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullAttributeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullAttributeMapping.java
@@ -10,8 +10,12 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -32,4 +36,8 @@ public class JavaNullAttributeMapping extends JavaAttributeMapping
public Iterator<String> correspondingAnnotationNames() {
return EmptyIterator.instance();
}
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+ }
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java
index 360159b65d..97f9c4ffb8 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java
@@ -10,8 +10,12 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaNullTypeMapping extends JavaTypeMapping
@@ -35,4 +39,8 @@ public class JavaNullTypeMapping extends JavaTypeMapping
public Iterator<String> correspondingAnnotationNames() {
return EmptyIterator.instance();
}
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ // no-op, nothing to really add
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMapping.java
index d0076d5d92..4d4e786c9e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMapping.java
@@ -10,6 +10,8 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.ITextRange;
@@ -17,6 +19,7 @@ import org.eclipse.jpt.core.internal.context.base.IAttributeMapping;
import org.eclipse.jpt.core.internal.resource.java.JPA;
import org.eclipse.jpt.core.internal.resource.java.OneToMany;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaOneToManyMapping extends JavaMultiRelationshipMapping<OneToMany>
@@ -77,4 +80,9 @@ public class JavaOneToManyMapping extends JavaMultiRelationshipMapping<OneToMany
public ITextRange mappedByTextRange(CompilationUnit astRoot) {
return this.relationshipMapping().mappedByTextRange(astRoot);
}
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+ }
+
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMapping.java
index fc31764dcb..118fe3c008 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMapping.java
@@ -10,16 +10,22 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
import java.util.ListIterator;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.context.base.IAttributeMapping;
+import org.eclipse.jpt.core.internal.context.base.IEntity;
import org.eclipse.jpt.core.internal.context.base.INonOwningMapping;
+import org.eclipse.jpt.core.internal.context.base.IPersistentAttribute;
import org.eclipse.jpt.core.internal.resource.java.JPA;
import org.eclipse.jpt.core.internal.resource.java.OneToOne;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.utility.internal.Filter;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaOneToOneMapping extends JavaSingleRelationshipMapping<OneToOne>
implements IJavaOneToOneMapping
@@ -116,6 +122,72 @@ public class JavaOneToOneMapping extends JavaSingleRelationshipMapping<OneToOne>
return relationshipMapping.getOptional();
}
+ @Override
+ protected boolean isOwningSide() {
+ return this.getMappedBy() == null;
+ }
+
+ //***************** Validation ***********************************
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ if (this.getMappedBy() != null) {
+ addMappedByMessages(messages ,astRoot);
+ }
+ }
+
+ protected void addMappedByMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ String mappedBy = this.getMappedBy();
+ IEntity targetEntity = this.getResolvedTargetEntity();
+
+ if (targetEntity == null) {
+ // already have validation messages for that
+ return;
+ }
+
+ IPersistentAttribute attribute = targetEntity.persistentType().resolveAttribute(mappedBy);
+
+ if (attribute == null) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY,
+ new String[] {mappedBy},
+ this, this.mappedByTextRange(astRoot))
+ );
+ return;
+ }
+
+ if (! this.mappedByIsValid(attribute.getMapping())) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.MAPPING_INVALID_MAPPED_BY,
+ new String[] {mappedBy},
+ this, this.mappedByTextRange(astRoot))
+ );
+ return;
+ }
+
+ INonOwningMapping mappedByMapping;
+ try {
+ mappedByMapping = (INonOwningMapping) attribute.getMapping();
+ } catch (ClassCastException cce) {
+ // there is no error then
+ return;
+ }
+
+ if (mappedByMapping.getMappedBy() != null) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES,
+ this, this.mappedByTextRange(astRoot))
+ );
+ }
+ }
+
//***************** ISingleRelationshipMapping implementation *****************
@Override
@SuppressWarnings("unchecked")
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttribute.java
index 044df289cf..5ab0f27503 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttribute.java
@@ -11,6 +11,8 @@ package org.eclipse.jpt.core.internal.context.java;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.ITextRange;
@@ -19,6 +21,7 @@ import org.eclipse.jpt.core.internal.resource.java.Annotation;
import org.eclipse.jpt.core.internal.resource.java.JavaPersistentAttributeResource;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.Filter;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaPersistentAttribute extends JavaContextModel
implements IJavaPersistentAttribute
@@ -276,5 +279,22 @@ public class JavaPersistentAttribute extends JavaContextModel
}
return this.getMapping().candidateValuesFor(pos, filter, astRoot);
}
+
+ //************* Validation ******************************
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ if (this.specifiedMapping != null) {
+ this.specifiedMapping.addToMessages(messages, astRoot);
+ }
+ else if (this.defaultMapping != null) {
+ this.defaultMapping.addToMessages(messages, astRoot);
+ }
+
+ }
+
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentType.java
index 2eeb369003..6a6d014251 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentType.java
@@ -14,6 +14,8 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
+
+import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.context.base.AccessType;
@@ -31,6 +33,7 @@ import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaPersistentType extends JavaContextModel implements IJavaPersistentType
{
@@ -90,6 +93,11 @@ public class JavaPersistentType extends JavaContextModel implements IJavaPersist
this.attributes.add(createAttribute(resourceAttributes.next()));
}
}
+
+ @Override
+ public IResource resource() {
+ return this.persistentTypeResource.resourceModel().resource().getCompilationUnit().getResource();
+ }
public String getName() {
return this.name;
@@ -164,14 +172,14 @@ public class JavaPersistentType extends JavaContextModel implements IJavaPersist
return (stream.hasNext()) ? stream.next() : null;
}
-// public IPersistentAttribute resolveAttribute(String attributeName) {
-// Iterator<JavaPersistentAttribute> stream = attributesNamed(attributeName);
-// if (stream.hasNext()) {
-// JavaPersistentAttribute attribute = stream.next();
-// return (stream.hasNext()) ? null /*more than one*/: attribute;
-// }
-// return (parentPersistentType() == null) ? null : parentPersistentType().resolveAttribute(attributeName);
-// }
+ public IPersistentAttribute resolveAttribute(String attributeName) {
+ Iterator<JavaPersistentAttribute> stream = attributesNamed(attributeName);
+ if (stream.hasNext()) {
+ JavaPersistentAttribute attribute = stream.next();
+ return (stream.hasNext()) ? null /*more than one*/: attribute;
+ }
+ return (parentPersistentType() == null) ? null : parentPersistentType().resolveAttribute(attributeName);
+ }
public ListIterator<IJavaPersistentAttribute> attributes() {
return new CloneListIterator<IJavaPersistentAttribute>(this.attributes);
@@ -450,6 +458,25 @@ public class JavaPersistentType extends JavaContextModel implements IJavaPersist
protected IPersistentType persistentType(String fullyQualifiedTypeName) {
return persistenceUnit().persistentType(fullyQualifiedTypeName);
}
+
+ //*************** Validation ******************************************
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ //get astRoot here to pass down
+ astRoot = persistentTypeResource.getMember().astRoot();
+ mapping.addToMessages(messages, astRoot);
+
+ addAttributeMessages(messages, astRoot);
+
+ }
+
+ protected void addAttributeMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ for (IJavaPersistentAttribute attributeContext : this.attributes) {
+ attributeContext.addToMessages(messages, astRoot);
+ }
+ }
@Override
public void toString(StringBuilder sb) {
@@ -457,4 +484,6 @@ public class JavaPersistentType extends JavaContextModel implements IJavaPersist
sb.append(getName());
}
+
+
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaSingleRelationshipMapping.java
index 05d8f2ff44..336939042a 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaSingleRelationshipMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaSingleRelationshipMapping.java
@@ -29,11 +29,14 @@ import org.eclipse.jpt.core.internal.resource.java.JoinColumn;
import org.eclipse.jpt.core.internal.resource.java.JoinColumns;
import org.eclipse.jpt.core.internal.resource.java.NullJoinColumn;
import org.eclipse.jpt.core.internal.resource.java.RelationshipMapping;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.internal.Table;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.Filter;
import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public abstract class JavaSingleRelationshipMapping<T extends RelationshipMapping>
@@ -218,6 +221,64 @@ public abstract class JavaSingleRelationshipMapping<T extends RelationshipMappin
}
return null;
}
+
+ //************* Validation **********************************
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ //bug 192287 - do not want joinColumn validation errors on the non-owning side
+ //of a bidirectional relationship. This is a low risk fix for RC3, but a better
+ //solution would be to not have the default joinColumns on the non-owning side.
+ //This would fix another bug that we show default joinColumns in this situation.
+ if (entityOwned() && isOwningSide()) {
+ addJoinColumnMessages(messages, astRoot);
+ }
+ }
+
+ protected abstract boolean isOwningSide();
+
+ protected void addJoinColumnMessages(List<IMessage> messages, CompilationUnit astRoot) {
+
+ for (Iterator<IJavaJoinColumn> stream = this.joinColumns(); stream.hasNext();) {
+ IJavaJoinColumn joinColumn = stream.next();
+ String table = joinColumn.getTable();
+ boolean doContinue = joinColumn.isConnected();
+
+ if (doContinue && this.typeMapping().tableNameIsInvalid(table)) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.JOIN_COLUMN_UNRESOLVED_TABLE,
+ new String[] {table, joinColumn.getName()},
+ joinColumn, joinColumn.tableTextRange(astRoot))
+ );
+ doContinue = false;
+ }
+
+ if (doContinue && ! joinColumn.isResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.JOIN_COLUMN_UNRESOLVED_NAME,
+ new String[] {joinColumn.getName()},
+ joinColumn, joinColumn.nameTextRange(astRoot))
+ );
+ }
+
+ if (doContinue && ! joinColumn.isReferencedColumnResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME,
+ new String[] {joinColumn.getReferencedColumnName(), joinColumn.getName()},
+ joinColumn, joinColumn.referencedColumnNameTextRange(astRoot))
+ );
+ }
+ }
+ }
+
public class JoinColumnOwner implements IJoinColumn.Owner
{
@@ -280,7 +341,10 @@ public abstract class JavaSingleRelationshipMapping<T extends RelationshipMappin
public ITextRange validationTextRange(CompilationUnit astRoot) {
// TODO Auto-generated method stub
- return null;
+ return JavaSingleRelationshipMapping.this.validationTextRange(astRoot);
}
+
+
+
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMapping.java
index ac1c05f8f1..e1e5db6c97 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMapping.java
@@ -10,9 +10,13 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.resource.java.Transient;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaTransientMapping extends JavaAttributeMapping
@@ -34,4 +38,9 @@ public class JavaTransientMapping extends JavaAttributeMapping
return EmptyIterator.instance();
}
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+ }
+
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMapping.java
index 5bc0225be0..0505f203d9 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMapping.java
@@ -10,17 +10,24 @@
package org.eclipse.jpt.core.internal.context.java;
import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
+import org.eclipse.jpt.core.internal.context.base.IColumn;
import org.eclipse.jpt.core.internal.context.base.IColumnMapping;
+import org.eclipse.jpt.core.internal.context.base.ITypeMapping;
import org.eclipse.jpt.core.internal.context.base.TemporalType;
import org.eclipse.jpt.core.internal.resource.java.Column;
import org.eclipse.jpt.core.internal.resource.java.JPA;
import org.eclipse.jpt.core.internal.resource.java.JavaPersistentAttributeResource;
import org.eclipse.jpt.core.internal.resource.java.Temporal;
import org.eclipse.jpt.core.internal.resource.java.Version;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.utility.internal.Filter;
import org.eclipse.jpt.utility.internal.iterators.ArrayIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class JavaVersionMapping extends JavaAttributeMapping implements IJavaVersionMapping
@@ -119,4 +126,41 @@ public class JavaVersionMapping extends JavaAttributeMapping implements IJavaVer
}
return null;
}
+
+ //*********** Validation ******************************
+
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ addColumnMessages(messages, astRoot);
+ }
+
+ protected void addColumnMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ ITypeMapping typeMapping = this.typeMapping();
+ IJavaColumn column = this.getColumn();
+ String table = column.getTable();
+ boolean doContinue = entityOwned() && column.isConnected();
+
+ if (doContinue && this.typeMapping().tableNameIsInvalid(table)) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.COLUMN_UNRESOLVED_TABLE,
+ new String[] {table, column.getName()},
+ column, column.tableTextRange(astRoot))
+ );
+ doContinue = false;
+ }
+
+ if (doContinue && ! column.isResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.COLUMN_UNRESOLVED_NAME,
+ new String[] {column.getName()},
+ column, column.nameTextRange(astRoot))
+ );
+ }
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmXmlImpl.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmXmlImpl.java
index a79f032221..09a1a88ff6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmXmlImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmXmlImpl.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jpt.core.internal.context.orm;
+import org.eclipse.core.resources.IResource;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.context.base.IMappingFileRef;
import org.eclipse.jpt.core.internal.context.base.JpaContextNode;
@@ -35,6 +36,11 @@ public class OrmXmlImpl extends JpaContextNode
return null;
}
+ @Override
+ public IResource resource() {
+ return ormResource.getFile();
+ }
+
// **************** persistence ********************************************
public EntityMappings getEntityMappings() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlEntity.java
index 1d2cfdcaa2..6a39ef4a38 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlEntity.java
@@ -17,6 +17,7 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.ITextRange;
import org.eclipse.jpt.core.internal.context.base.IAbstractJoinColumn;
+import org.eclipse.jpt.core.internal.context.base.IAttributeOverride;
import org.eclipse.jpt.core.internal.context.base.IColumnMapping;
import org.eclipse.jpt.core.internal.context.base.IDiscriminatorColumn;
import org.eclipse.jpt.core.internal.context.base.IEntity;
@@ -24,9 +25,12 @@ import org.eclipse.jpt.core.internal.context.base.INamedColumn;
import org.eclipse.jpt.core.internal.context.base.IOverride;
import org.eclipse.jpt.core.internal.context.base.IPersistentAttribute;
import org.eclipse.jpt.core.internal.context.base.IPersistentType;
+import org.eclipse.jpt.core.internal.context.base.ISecondaryTable;
import org.eclipse.jpt.core.internal.context.base.ITable;
import org.eclipse.jpt.core.internal.context.base.ITypeMapping;
import org.eclipse.jpt.core.internal.context.base.InheritanceType;
+import org.eclipse.jpt.core.internal.context.java.IJavaAssociationOverride;
+import org.eclipse.jpt.core.internal.context.java.IJavaAttributeOverride;
import org.eclipse.jpt.core.internal.context.java.IJavaEntity;
import org.eclipse.jpt.core.internal.context.java.IJavaPersistentType;
import org.eclipse.jpt.core.internal.context.java.IJavaSecondaryTable;
@@ -40,6 +44,8 @@ import org.eclipse.jpt.core.internal.resource.orm.NamedQuery;
import org.eclipse.jpt.core.internal.resource.orm.OrmFactory;
import org.eclipse.jpt.core.internal.resource.orm.PrimaryKeyJoinColumn;
import org.eclipse.jpt.core.internal.resource.orm.SecondaryTable;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.internal.Schema;
import org.eclipse.jpt.db.internal.Table;
import org.eclipse.jpt.utility.internal.ClassTools;
@@ -51,6 +57,7 @@ import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class XmlEntity extends XmlTypeMapping<Entity> implements IEntity
{
@@ -1352,6 +1359,60 @@ public class XmlEntity extends XmlTypeMapping<Entity> implements IEntity
return false;
}
+ //********** Validation **************************
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+ table.addToMessages(messages, astRoot);
+ addIdMessages(messages, astRoot);
+
+
+ for (XmlSecondaryTable context : specifiedSecondaryTables) {
+ context.addToMessages(messages, astRoot);
+ }
+
+ for (Iterator<XmlAttributeOverride> stream = this.attributeOverrides(); stream.hasNext();) {
+ stream.next().addToMessages(messages, astRoot);
+ }
+
+ for (Iterator<XmlAssociationOverride> stream = this.associationOverrides(); stream.hasNext();) {
+ stream.next().addToMessages(messages, astRoot);
+ }
+
+ }
+
+ protected void addIdMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ addNoIdMessage(messages, astRoot);
+
+ }
+
+ protected void addNoIdMessage(List<IMessage> messages, CompilationUnit astRoot) {
+ if (entityHasNoId()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.ENTITY_NO_ID,
+ new String[] {this.getName()},
+ this, this.validationTextRange(astRoot))
+ );
+ }
+ }
+
+ private boolean entityHasNoId() {
+ return ! this.entityHasId();
+ }
+
+ private boolean entityHasId() {
+ for (Iterator<IPersistentAttribute> stream = this.persistentType().allAttributes(); stream.hasNext(); ) {
+ if (stream.next().isIdAttribute()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
public ITextRange validationTextRange(CompilationUnit astRoot) {
// TODO Auto-generated method stub
return null;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlPersistentType.java
index 5d3ef193e3..1c65e4f132 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlPersistentType.java
@@ -15,6 +15,8 @@ import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
+
+import org.eclipse.core.resources.IResource;
import org.eclipse.jpt.core.internal.IMappingKeys;
import org.eclipse.jpt.core.internal.context.base.AccessType;
import org.eclipse.jpt.core.internal.context.base.IPersistentAttribute;
@@ -779,19 +781,19 @@ public class XmlPersistentType extends JpaContextNode implements IPersistentType
// return this;
// }
//
-// public IPersistentAttribute resolveAttribute(String attributeName) {
-// Iterator<XmlPersistentAttribute> attributes = attributesNamed(attributeName);
-// if (attributes.hasNext()) {
-// XmlPersistentAttribute attribute = attributes.next();
-// return attributes.hasNext() ? null /* more than one */: attribute;
-// }
-// else if (parentPersistentType() != null) {
-// return parentPersistentType().resolveAttribute(attributeName);
-// }
-// else {
-// return null;
-// }
-// }
+ public IPersistentAttribute resolveAttribute(String attributeName) {
+ Iterator<XmlPersistentAttribute> attributes = attributesNamed(attributeName);
+ if (attributes.hasNext()) {
+ XmlPersistentAttribute attribute = attributes.next();
+ return attributes.hasNext() ? null /* more than one */: attribute;
+ }
+ else if (parentPersistentType() != null) {
+ return parentPersistentType().resolveAttribute(attributeName);
+ }
+ else {
+ return null;
+ }
+ }
//
// @Override
// public ITextRange validationTextRange() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlTable.java
index c8a8b756f6..f6823a9e9a 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlTable.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/XmlTable.java
@@ -9,6 +9,9 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.context.orm;
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.core.internal.context.base.IEntity;
import org.eclipse.jpt.core.internal.context.base.InheritanceType;
import org.eclipse.jpt.core.internal.context.java.IJavaEntity;
@@ -16,6 +19,9 @@ import org.eclipse.jpt.core.internal.context.java.IJavaTable;
import org.eclipse.jpt.core.internal.resource.orm.AbstractTable;
import org.eclipse.jpt.core.internal.resource.orm.Entity;
import org.eclipse.jpt.core.internal.resource.orm.OrmFactory;
+import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
+import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
public class XmlTable extends AbstractXmlTable
{
@@ -118,4 +124,35 @@ public class XmlTable extends AbstractXmlTable
}
return entityMappings().getCatalog();
}
+
+ //******* Validation *******************************
+
+ @Override
+ public void addToMessages(List<IMessage> messages, CompilationUnit astRoot) {
+ super.addToMessages(messages, astRoot);
+
+ boolean doContinue = isConnected();
+ String schema = this.getSchema();
+
+ if (doContinue && ! this.hasResolvedSchema()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.TABLE_UNRESOLVED_SCHEMA,
+ new String[] {schema, this.getName()},
+ this, this.schemaTextRange(astRoot))
+ );
+ doContinue = false;
+ }
+
+ if (doContinue && ! this.isResolved()) {
+ messages.add(
+ JpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ IJpaValidationMessages.TABLE_UNRESOLVED_NAME,
+ new String[] {this.getName()},
+ this, this.nameTextRange(astRoot))
+ );
+ }
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/base/BaseJpaPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/base/BaseJpaPlatform.java
index 18fa51f597..78f3d4de62 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/base/BaseJpaPlatform.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/base/BaseJpaPlatform.java
@@ -21,6 +21,7 @@ import org.eclipse.jpt.core.internal.IJpaFile;
import org.eclipse.jpt.core.internal.IJpaPlatform;
import org.eclipse.jpt.core.internal.IJpaProject;
import org.eclipse.jpt.core.internal.IResourceModel;
+import org.eclipse.jpt.core.internal.context.base.BaseJpaContent;
import org.eclipse.jpt.core.internal.context.java.IDefaultJavaAttributeMappingProvider;
import org.eclipse.jpt.core.internal.context.java.IJavaAttributeMapping;
import org.eclipse.jpt.core.internal.context.java.IJavaAttributeMappingProvider;
@@ -268,8 +269,7 @@ public abstract class BaseJpaPlatform implements IJpaPlatform
// **************** Validation *********************************************
- public void addToMessages(List<IMessage> messages) {
- // TODO Auto-generated method stub
-
+ public void addToMessages(IJpaProject project, List<IMessage> messages) {
+ project.addToMessages(messages, null);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentAttributeResource.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentAttributeResource.java
index e10cc3343c..0e9573aa70 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentAttributeResource.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentAttributeResource.java
@@ -9,6 +9,8 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.resource.java;
+import org.eclipse.jpt.core.internal.jdtutility.Member;
+
//TODO how do we handle:
// @Basic
@@ -18,6 +20,8 @@ public interface JavaPersistentAttributeResource extends JavaPersistentResource
{
String getName();
+ Member getMember();
+
boolean isForField();
boolean isForProperty();
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentTypeResource.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentTypeResource.java
index 08639a2c45..f9ab8d317c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentTypeResource.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/JavaPersistentTypeResource.java
@@ -11,6 +11,8 @@ package org.eclipse.jpt.core.internal.resource.java;
import java.util.Iterator;
+import org.eclipse.jpt.core.internal.jdtutility.Member;
+
public interface JavaPersistentTypeResource extends JavaPersistentResource
{
/**
@@ -65,7 +67,9 @@ public interface JavaPersistentTypeResource extends JavaPersistentResource
String ACCESS_PROPERTY = "accessProperty";
boolean isAbstract();
- String ABSTRACT_PROPERTY = "abstractProperty";
+ String ABSTRACT_PROPERTY = "abstractProperty";
+
+ Member getMember();
/**
* Return whether any attributes in this persistentType have
diff --git a/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF
index 236aa01085..48f02cedcb 100644
--- a/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF
+++ b/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF
@@ -23,7 +23,8 @@ Require-Bundle: org.eclipse.core.resources,
org.eclipse.wst.common.modulecore,
org.eclipse.wst.common.project.facet.core,
org.junit,
- org.eclipse.wst.xml.core
+ org.eclipse.wst.xml.core,
+ org.eclipse.wst.validation
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: org.eclipse.jpt.core.tests.internal;x-friends:="org.eclipse.jpt.ui.tests",
org.eclipse.jpt.core.tests.internal.context;x-internal:=true,

Back to the top