Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/IJpaValidationMessages.java104
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaHelper.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java54
4 files changed, 260 insertions, 0 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/IJpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/IJpaValidationMessages.java
new file mode 100644
index 0000000000..7f3158dcc0
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/IJpaValidationMessages.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Oracle. All rights reserved. This program and
+ * the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.core.internal.validation;
+
+public interface IJpaValidationMessages
+{
+ public static final String BUNDLE = "jpa_validation";
+
+
+ public static final String PROJECT_NO_CONNECTION = "PROJECT_NO_CONNECTION";
+
+ public static final String PROJECT_INACTIVE_CONNECTION = "PROJECT_INACTIVE_CONNECTION";
+
+ public static final String PROJECT_NO_PERSISTENCE_XML = "PROJECT_NO_PERSISTENCE_XML";
+
+ public static final String PROJECT_MULTIPLE_PERSISTENCE_XML = "PROJECT_MULTIPLE_PERSISTENCE_XML";
+
+ public static final String PERSISTENCE_XML_INVALID_CONTENT = "PERSISTENCE_XML_INVALID_CONTENT";
+
+ public static final String PERSISTENCE_NO_PERSISTENCE_UNIT = "PERSISTENCE_NO_PERSISTENCE_UNIT";
+
+ public static final String PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS = "PERSISTENCE_MULTIPLE_PERSISTENCE_UNITS";
+
+ public static final String PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE = "PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE";
+
+ public static final String PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE = "PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE";
+
+ public static final String PERSISTENCE_UNIT_INVALID_MAPPING_FILE = "PERSISTENCE_UNIT_INVALID_MAPPING_FILE";
+
+ public static final String PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE = "PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE";
+
+ public static final String PERSISTENCE_UNIT_UNSPECIFIED_CLASS = "PERSISTENCE_UNIT_UNSPECIFIED_CLASS";
+
+ public static final String PERSISTENCE_UNIT_NONEXISTENT_CLASS = "PERSISTENCE_UNIT_NONEXISTENT_CLASS";
+
+ public static final String PERSISTENCE_UNIT_INVALID_CLASS = "PERSISTENCE_UNIT_INVALID_CLASS";
+
+ public static final String PERSISTENCE_UNIT_DUPLICATE_CLASS = "PERSISTENCE_UNIT_DUPLICATE_CLASS";
+
+ public static final String ENTITY_MAPPINGS_MULTIPLE_METADATA = "ENTITY_MAPPINGS_MULTIPLE_METADATA";
+
+ public static final String PERSISTENT_TYPE_UNSPECIFIED_CLASS = "PERSISTENT_TYPE_UNSPECIFIED_CLASS";
+
+ public static final String PERSISTENT_TYPE_UNRESOLVED_CLASS = "PERSISTENT_TYPE_UNRESOLVED_CLASS";
+
+ public static final String ENTITY_NO_ID = "ENTITY_NO_ID";
+
+ public static final String PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME = "PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME";
+
+ public static final String PERSISTENT_ATTRIBUTE_UNRESOLVED_NAME = "PERSISTENT_ATTRIBUTE_UNRESOLVED_NAME";
+
+ public static final String PERSISTENT_ATTRIBUTE_INVALID_MAPPING = "PERSISTENT_ATTRIBUTE_INVALID_MAPPING";
+
+ public static final String TABLE_UNRESOLVED_SCHEMA = "TABLE_UNRESOLVED_SCHEMA";
+
+ public static final String TABLE_UNRESOLVED_NAME = "TABLE_UNRESOLVED_NAME";
+
+ public static final String JOIN_TABLE_UNRESOLVED_SCHEMA = "JOIN_TABLE_UNRESOLVED_SCHEMA";
+
+ public static final String VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA = "VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_SCHEMA";
+
+ public static final String JOIN_TABLE_UNRESOLVED_NAME = "JOIN_TABLE_UNRESOLVED_NAME";
+
+ public static final String VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME = "VIRTUAL_ATTRIBUTE_JOIN_TABLE_UNRESOLVED_NAME";
+
+ public static final String COLUMN_UNRESOLVED_TABLE = "COLUMN_UNRESOLVED_TABLE";
+
+ public static final String VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_TABLE = "VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_TABLE";
+
+ public static final String VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_TABLE = "VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_TABLE";
+
+ public static final String COLUMN_UNRESOLVED_NAME = "COLUMN_UNRESOLVED_NAME";
+
+ public static final String VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME = "VIRTUAL_ATTRIBUTE_COLUMN_UNRESOLVED_NAME";
+
+ public static final String VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME = "VIRTUAL_ATTRIBUTE_OVERRIDE_COLUMN_UNRESOLVED_NAME";
+
+ public static final String JOIN_COLUMN_UNRESOLVED_TABLE = "JOIN_COLUMN_UNRESOLVED_TABLE";
+
+ public static final String VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_TABLE = "VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_TABLE";
+
+ public static final String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_TABLE = "VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_TABLE";
+
+ public static final String JOIN_COLUMN_UNRESOLVED_NAME = "JOIN_COLUMN_UNRESOLVED_NAME";
+
+ public static final String VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME = "VIRTUAL_ATTRIBUTE_JOIN_COLUMN_UNRESOLVED_NAME";
+
+ public static final String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME = "VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_UNRESOLVED_NAME";
+
+ public static final String JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME = "JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME";
+
+ public static final String VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME = "VIRTUAL_ATTRIBUTE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME";
+
+ public static final String VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME = "VIRTUAL_ASSOCIATION_OVERRIDE_JOIN_COLUMN_REFERENCED_COLUMN_UNRESOLVED_NAME";
+
+ public static final String GENERATED_VALUE_UNRESOLVED_GENERATOR = "GENERATED_VALUE_UNRESOLVED_GENERATOR";
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaHelper.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaHelper.java
new file mode 100644
index 0000000000..98f704f49e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaHelper.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0, which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.core.internal.validation;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jpt.core.internal.IJpaEObject;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.jpt.core.internal.JpaCorePlugin;
+import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
+
+public class JpaHelper extends WorkbenchContext
+{
+ IJpaProject getJpaProject() {
+ return JpaCorePlugin.getJpaProject(getProject());
+ }
+
+ @Override
+ public IResource getResource(Object obj) {
+ return ((IJpaEObject) obj).getResource();
+ }
+
+ /*
+ * This is used when no line number is set. We generally use line numbers.
+ * Therefore, when this is called, we will use the default location, i.e.
+ * null.
+ */
+ @Override
+ public String getLocation(Object object) {
+ return null;
+ }
+} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
new file mode 100644
index 0000000000..f3cf3de1d6
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 Oracle. All rights reserved. This program and
+ * the accompanying materials are made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.core.internal.validation;
+
+import org.eclipse.jpt.core.internal.ITextRange;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+
+public class JpaValidationMessages
+ implements IJpaValidationMessages
+{
+ private static String[] DEFAULT_PARAMS = new String[0];
+
+ private static ITextRange DEFAULT_TEXT_RANGE =
+ new ITextRange() {
+ public int getLength() {
+ return 0;
+ }
+
+ public int getLineNumber() {
+ return 0;
+ }
+
+ public int getOffset() {
+ return 0;
+ }
+ };
+
+ public static IMessage buildMessage(
+ int severity, String messageId, Object targetObject) {
+ return buildMessage(severity, messageId, DEFAULT_PARAMS, targetObject);
+ }
+
+ public static IMessage buildMessage(
+ int severity, String messageId, String[] params, Object targetObject) {
+ return buildMessage(severity, messageId, params, targetObject, DEFAULT_TEXT_RANGE);
+ }
+
+ public static IMessage buildMessage(
+ int severity, String messageId, Object targetObject, ITextRange textRange) {
+ return buildMessage(severity, messageId, DEFAULT_PARAMS, targetObject, textRange);
+ }
+
+ public static IMessage buildMessage(
+ int severity, String messageId, String[] params, Object targetObject, ITextRange textRange) {
+ IMessage message = new Message(BUNDLE, severity, messageId, params, targetObject);
+ message.setLineNo(textRange.getLineNumber());
+ message.setOffset(textRange.getOffset());
+ message.setLength(textRange.getLength());
+ return message;
+ }
+
+
+ private JpaValidationMessages() {
+ super();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
new file mode 100644
index 0000000000..4f5b65a735
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0, which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.core.internal.validation;
+
+import java.util.Iterator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.jpt.core.internal.IJpaProject;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.core.ValidationException;
+import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
+import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
+
+public class JpaValidator implements IValidatorJob
+{
+ public ISchedulingRule getSchedulingRule(IValidationContext helper) {
+ // don't know what to return here. my guess is that we want to return
+ // the resource that is possibly being changed during our validation,
+ // and since many resources in the project may be changed during this
+ // validation, returning the project makes the most sense.
+ return ((IWorkbenchContext) helper).getProject();
+ }
+
+ public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws ValidationException {
+ JpaHelper jpaHelper = (JpaHelper) helper;
+ IJpaProject jpaProject = jpaHelper.getJpaProject();
+
+ reporter.removeAllMessages(this);
+
+ for (Iterator stream = jpaProject.validationMessages(); stream.hasNext(); ) {
+ reporter.addMessage(this, (Message) stream.next());
+ }
+
+ return OK_STATUS;
+ }
+
+ public void cleanup(IReporter reporter) {
+ // TODO Auto-generated method stub
+ return;
+ }
+
+ public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
+ validateInJob(helper, reporter);
+ }
+}

Back to the top