Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2009-12-02 12:24:43 -0500
committerbvosburgh2009-12-02 12:24:43 -0500
commitcd2e875b54dbf8057b431165ddb11c790d6127cf (patch)
treebe9e0ee3b66b3e6c413e4c0af1a5e9fdc533ef8a
parentc1fec439b4a1bd2d9a5574d8877462e7d9feff7e (diff)
downloadwebtools.dali-cd2e875b54dbf8057b431165ddb11c790d6127cf.tar.gz
webtools.dali-cd2e875b54dbf8057b431165ddb11c790d6127cf.tar.xz
webtools.dali-cd2e875b54dbf8057b431165ddb11c790d6127cf.zip
[296664] metamodel generation overwrites non-Dali generated files
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericPersistentTypeMetamodelSynchronizer.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryGeneratedAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/JpaProject2_0.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/GeneratedAnnotation.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentType.java47
11 files changed, 159 insertions, 101 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java
index d087ef979c..4f63da8621 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JpaProject.java
@@ -172,13 +172,6 @@ public interface JpaProject
// ********** Java resources **********
/**
- * Return the Java resource compilation unit corresponding to the specified
- * file. Return null if the file is not part of the JPA project or if the
- * file's content is not Java source code.
- */
- JavaResourceCompilationUnit getJavaResourceCompilationUnit(IFile file);
-
- /**
* Return the names of the JPA project's annotated Java classes
* (ignoring classes in JARs referenced in the persistence.xml).
*/
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java
index 489eedc8ae..97545531dd 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/AbstractJpaProject.java
@@ -817,26 +817,6 @@ public abstract class AbstractJpaProject
}
- // ********** metamodel **********
-
- public Iterable<JavaResourcePersistentType> getGeneratedMetamodelTypes() {
- if (this.metamodelSourceFolderName == null) {
- return EmptyIterable.instance();
- }
- final IPackageFragmentRoot genSourceFolder = this.getMetamodelPackageFragmentRoot();
- return new FilteringIterable<JavaResourcePersistentType, JavaResourcePersistentType>(this.getInternalSourceJavaResourcePersistentTypes()) {
- @Override
- protected boolean accept(JavaResourcePersistentType jrpt) {
- return jrpt.isGeneratedMetamodel(genSourceFolder);
- }
- };
- }
-
- public JavaResourceCompilationUnit getJavaResourceCompilationUnit(IFile file) {
- return (JavaResourceCompilationUnit) this.getResourceModel(file, JptCorePlugin.JAVA_SOURCE_CONTENT_TYPE);
- }
-
-
// ********** Java resource persistent type look-up **********
public JavaResourcePersistentType getJavaResourcePersistentType(String typeName) {
@@ -935,6 +915,39 @@ public abstract class AbstractJpaProject
// ********** metamodel **********
+ public Iterable<JavaResourcePersistentType> getGeneratedMetamodelTypes() {
+ if (this.metamodelSourceFolderName == null) {
+ return EmptyIterable.instance();
+ }
+ final IPackageFragmentRoot genSourceFolder = this.getMetamodelPackageFragmentRoot();
+ return new FilteringIterable<JavaResourcePersistentType, JavaResourcePersistentType>(this.getInternalSourceJavaResourcePersistentTypes()) {
+ @Override
+ protected boolean accept(JavaResourcePersistentType jrpt) {
+ return jrpt.isGeneratedMetamodel(genSourceFolder);
+ }
+ };
+ }
+
+ public JavaResourcePersistentType getGeneratedMetamodelType(IFile file) {
+ JavaResourceCompilationUnit jrcu = this.getJavaResourceCompilationUnit(file);
+ if (jrcu == null) {
+ return null; // hmmm...
+ }
+ Iterator<JavaResourcePersistentType> types = jrcu.persistentTypes();
+ if ( ! types.hasNext()) {
+ return null; // no types in the file
+ }
+ JavaResourcePersistentType jrpt = types.next();
+ if (types.hasNext()) {
+ return null; // should have only a single type in the file
+ }
+ return jrpt.isGeneratedMetamodel() ? jrpt : null;
+ }
+
+ protected JavaResourceCompilationUnit getJavaResourceCompilationUnit(IFile file) {
+ return (JavaResourceCompilationUnit) this.getResourceModel(file, JptCorePlugin.JAVA_SOURCE_CONTENT_TYPE);
+ }
+
public String getMetamodelSourceFolderName() {
return this.metamodelSourceFolderName;
}
@@ -1018,7 +1031,14 @@ public abstract class AbstractJpaProject
return new TransformationIterable<IPackageFragmentRoot, String>(this.getJavaSourceFolders()) {
@Override
protected String transform(IPackageFragmentRoot pfr) {
- return pfr.getElementName();
+ try {
+ return this.transform_(pfr);
+ } catch (JavaModelException ex) {
+ return "Error: " + pfr.getPath(); //$NON-NLS-1$
+ }
+ }
+ private String transform_(IPackageFragmentRoot pfr) throws JavaModelException {
+ return pfr.getUnderlyingResource().getProjectRelativePath().toString();
}
};
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
index 2db8dd80d9..a158cfe75d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
@@ -19,10 +19,6 @@ import java.util.ListIterator;
import java.util.Set;
import java.util.Vector;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.core.jpa2.context.persistence.options.SharedCacheMode;
-import org.eclipse.jpt.core.jpa2.context.persistence.options.ValidationMode;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jpt.core.JpaStructureNode;
@@ -41,13 +37,16 @@ import org.eclipse.jpt.core.context.persistence.MappingFileRef;
import org.eclipse.jpt.core.context.persistence.Persistence;
import org.eclipse.jpt.core.context.persistence.PersistenceStructureNodes;
import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.core.context.persistence.PersistenceUnitProperties;
import org.eclipse.jpt.core.context.persistence.PersistenceUnitTransactionType;
import org.eclipse.jpt.core.context.persistence.PersistentTypeContainer;
import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.core.jpa2.JpaProject2_0;
import org.eclipse.jpt.core.jpa2.context.PersistentType2_0;
-import org.eclipse.jpt.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.core.jpa2.context.persistence.PersistenceUnit2_0;
+import org.eclipse.jpt.core.jpa2.context.persistence.options.SharedCacheMode;
+import org.eclipse.jpt.core.jpa2.context.persistence.options.ValidationMode;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
import org.eclipse.jpt.core.resource.persistence.XmlJarFileRef;
@@ -1726,19 +1725,7 @@ public abstract class AbstractPersistenceUnit
}
protected boolean fileIsGeneratedMetamodel(IFile file) {
- JavaResourceCompilationUnit jrcu = this.getJpaProject().getJavaResourceCompilationUnit(file);
- if (jrcu == null) {
- return false; // hmmm...
- }
- Iterator<JavaResourcePersistentType> types = jrcu.persistentTypes();
- if ( ! types.hasNext()) {
- return false; // no types in the file
- }
- JavaResourcePersistentType jrpt = types.next();
- if (types.hasNext()) {
- return false; // should have only a single type in the file
- }
- return jrpt.isGeneratedMetamodel();
+ return ((JpaProject2_0) this.getJpaProject()).getGeneratedMetamodelType(file) != null;
}
public void disposeMetamodel() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericPersistentTypeMetamodelSynchronizer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericPersistentTypeMetamodelSynchronizer.java
index a0253c63cf..e7de5dbca6 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericPersistentTypeMetamodelSynchronizer.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericPersistentTypeMetamodelSynchronizer.java
@@ -88,7 +88,7 @@ public class GenericPersistentTypeMetamodelSynchronizer
ICompilationUnit compilationUnit = pkg.getCompilationUnit(fileName);
if (compilationUnit.exists()) {
// overwrite existing file if it has changed (ignoring the timestamp)
- String newSource = this.buildSource(compilationUnit.getSource());
+ String newSource = this.buildSource(compilationUnit);
if (newSource != null) {
pkg.createCompilationUnit(fileName, newSource, true, null); // true=force
}
@@ -102,21 +102,19 @@ public class GenericPersistentTypeMetamodelSynchronizer
}
/**
- * return null if the old source should not be replaced
+ * pre-condition: the compilation unit exists
+ *
+ * return null if the old source is not to be replaced
*/
- protected String buildSource(String oldSource) {
- int oldLength = oldSource.length();
-
- int oldDateBegin = oldSource.indexOf(DATE_TAG);
- if (oldDateBegin == -1) {
- return null; // hmmm...
+ protected String buildSource(ICompilationUnit compilationUnit) throws JavaModelException {
+ IFile file = (IFile) compilationUnit.getResource();
+ JavaResourcePersistentType genType = this.getJpaProject().getGeneratedMetamodelType(file);
+ if (genType == null) {
+ return null; // the file exists, but its source is not a generated metamodel class
}
- oldDateBegin += DATE_TAG_LENGTH;
- int oldDateEnd = oldSource.indexOf('"', oldDateBegin);
- if (oldDateEnd == -1) {
- return null; // hmmm...
- }
+ String oldSource = compilationUnit.getSource();
+ int oldLength = oldSource.length();
String newSource = this.buildSource();
int newLength = newSource.length();
@@ -124,26 +122,23 @@ public class GenericPersistentTypeMetamodelSynchronizer
return newSource;
}
- int newDateBegin = newSource.indexOf(DATE_TAG) + DATE_TAG_LENGTH;
- if (newDateBegin != oldDateBegin) {
- return newSource;
+ String date = genType.getGeneratedAnnotation().getDate(); // if we get here, this will be non-empty
+ int dateBegin = oldSource.indexOf(date);
+ if (dateBegin == -1) {
+ return null; // hmmm...
}
-
- int newDateEnd = newSource.indexOf('"', newDateBegin);
- if (newDateEnd != oldDateEnd) {
- return newSource;
+ int dateEnd = dateBegin + date.length();
+ if (dateEnd > oldLength) {
+ return null; // hmmm...
}
- if (newSource.regionMatches(0, oldSource, 0, oldDateBegin) &&
- newSource.regionMatches(oldDateEnd, oldSource, oldDateEnd, oldLength - oldDateEnd)) {
+ if (newSource.regionMatches(0, oldSource, 0, dateBegin) &&
+ newSource.regionMatches(dateEnd, oldSource, dateEnd, oldLength - dateEnd)) {
return null;
}
return newSource;
}
- protected static final String DATE_TAG = "date=\"";
- protected static final int DATE_TAG_LENGTH = DATE_TAG.length();
-
// ********** package/file **********
@@ -169,11 +164,11 @@ public class GenericPersistentTypeMetamodelSynchronizer
return ClassTools.shortNameForClassNamed(this.getMetamodelClassName()) + ".java";
}
- // TODO
protected String getMetamodelClassName() {
return this.buildMetamodelClassName(this.persistentType.getName());
}
+ // TODO
protected String buildMetamodelClassName(String className) {
// the default is to simply append an underscore to the model class name
return className + '_';
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryGeneratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryGeneratedAnnotation.java
index 7454a7336a..e9f51b48b7 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryGeneratedAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryGeneratedAnnotation.java
@@ -66,6 +66,10 @@ public final class BinaryGeneratedAnnotation
return this.values.size();
}
+ public String getValue(int index) {
+ return this.values.get(index);
+ }
+
private Vector<String> buildValues() {
Object[] jdtValues = this.getJdtMemberValues(VALUE_ELEMENT_NAME);
Vector<String> result = new Vector<String>(jdtValues.length);
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java
index 1bd2b22915..9de575883c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java
@@ -102,6 +102,10 @@ public final class SourceGeneratedAnnotation
return this.values.size();
}
+ public String getValue(int index) {
+ return this.values.get(index);
+ }
+
public void addValue(String value) {
this.addValue(this.values.size(), value);
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java
index b0aeffd4d4..8edbaf60f8 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/binary/BinaryPersistentType.java
@@ -21,6 +21,7 @@ import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.core.internal.utility.jdt.JPTTools;
+import org.eclipse.jpt.core.jpa2.resource.java.GeneratedAnnotation;
import org.eclipse.jpt.core.resource.java.AccessType;
import org.eclipse.jpt.core.resource.java.Annotation;
import org.eclipse.jpt.core.resource.java.JavaResourceNode;
@@ -549,4 +550,8 @@ final class BinaryPersistentType
throw new UnsupportedOperationException();
}
+ public GeneratedAnnotation getGeneratedAnnotation() {
+ throw new UnsupportedOperationException();
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java
index 468917f2ba..268c44ce44 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/resource/java/source/SourcePersistentType.java
@@ -42,6 +42,7 @@ import org.eclipse.jpt.core.utility.jdt.Type;
import org.eclipse.jpt.utility.MethodSignature;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.IntReference;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
@@ -140,6 +141,11 @@ final class SourcePersistentType
this.access = this.buildAccess();
}
+ /**
+ * Handle the <code>StaticMetamodel</code> and <code>Generated</code>
+ * annotations differently, since they are not really JPA "mapping"
+ * annotations....
+ */
@Override
void addInitialAnnotation(String jdtAnnotationName, CompilationUnit astRoot) {
if (jdtAnnotationName.equals(STATIC_METAMODEL_ANNOTATION_DEFINITION.getAnnotationName())) {
@@ -174,6 +180,11 @@ final class SourcePersistentType
this.setAccess(this.buildAccess());
}
+ /**
+ * Handle the <code>StaticMetamodel</code> and <code>Generated</code>
+ * annotations differently, since they are not really JPA "mapping"
+ * annotations....
+ */
@Override
void addOrUpdateAnnotation(String jdtAnnotationName, CompilationUnit astRoot, Set<Annotation> annotationsToRemove) {
if (jdtAnnotationName.equals(STATIC_METAMODEL_ANNOTATION_DEFINITION.getAnnotationName())) {
@@ -516,6 +527,12 @@ final class SourcePersistentType
return SourcePersistentAttribute.newInstance(this, this.member, fieldName, occurrence, this.getJavaResourceCompilationUnit(), astRoot);
}
+ // minimize scope of suppressed warnings
+ @SuppressWarnings("unchecked")
+ private static List<VariableDeclarationFragment> fragments(FieldDeclaration fd) {
+ return fd.fragments();
+ }
+
// ********** methods **********
@@ -627,7 +644,11 @@ final class SourcePersistentType
}
- // ********** misc **********
+ // ********** metamodel **********
+
+ public GeneratedAnnotation getGeneratedAnnotation() {
+ return this.generatedAnnotation;
+ }
/**
* The type must be:<ul>
@@ -648,7 +669,7 @@ final class SourcePersistentType
* The type must be:<ul>
* <li>annotated with <code>&#64;javax.persistence.metamodel.StaticMetamodel</code>
* <li>annotated with <code>&#64;javax.annotation.Generated</code> with the appropriate
- * <code>value</code>
+ * <code>value</code> and <code>date</code>
* </ul>
*/
public boolean isGeneratedMetamodel() {
@@ -658,22 +679,22 @@ final class SourcePersistentType
if (this.generatedAnnotation == null) {
return false;
}
- if (this.generatedAnnotation.valuesSize() == 0) {
+ if (this.generatedAnnotation.valuesSize() != 1) {
+ return false;
+ }
+ if ( ! this.generatedAnnotation.getValue(0).equals(METAMODEL_GENERATED_ANNOTATION_VALUE)) {
return false;
}
- return this.generatedAnnotation.values().next().equals(METAMODEL_GENERATED_ANNOTATION_VALUE);
+ if (StringTools.stringIsEmpty(this.generatedAnnotation.getDate())) {
+ return false;
+ }
+ return true;
}
private IPackageFragmentRoot getSourceFolder() {
return (IPackageFragmentRoot) this.getJavaResourceCompilationUnit().getCompilationUnit().getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
}
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private static List<VariableDeclarationFragment> fragments(FieldDeclaration fd) {
- return fd.fragments();
- }
-
// ********** CounterMap **********
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/JpaProject2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/JpaProject2_0.java
index 37e2d7bafc..71f1b5e711 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/JpaProject2_0.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/JpaProject2_0.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.core.jpa2;
+import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
@@ -65,6 +66,19 @@ public interface JpaProject2_0
*/
Iterable<JavaResourcePersistentType> getGeneratedMetamodelTypes();
+ /**
+ * Return the generated metamodel Java resource persistent type in the
+ * specified file. Return null if any of the following is true:<ul>
+ * <li>the file is not a Java source file
+ * <li>the file does not contain the source for one and only one Java class
+ * <li>the Java class is not annotated with the appropriate
+ * <code>javax.persistence.metamodel.StaticMetamodel</code> annotation
+ * <li>the Java class is not annotated with the appropriate
+ * <code>javax.annotation.Generated</code> annotation
+ * <ul>
+ */
+ JavaResourcePersistentType getGeneratedMetamodelType(IFile file);
+
// ********** construction config **********
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/GeneratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/GeneratedAnnotation.java
index 2746c539ff..fe65b85bdf 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/GeneratedAnnotation.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/jpa2/resource/java/GeneratedAnnotation.java
@@ -52,6 +52,12 @@ public interface GeneratedAnnotation
* Corresponds to the <code>value<code> element of the <code>Generated</code>
* annotation.
*/
+ String getValue(int index);
+
+ /**
+ * Corresponds to the <code>value<code> element of the <code>Generated</code>
+ * annotation.
+ */
void addValue(String value);
/**
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentType.java
index 58b53c14fb..e0bb621c80 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/resource/java/JavaResourcePersistentType.java
@@ -12,6 +12,7 @@ package org.eclipse.jpt.core.resource.java;
import java.util.Iterator;
import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jpt.core.jpa2.resource.java.GeneratedAnnotation;
/**
* Java source code or binary persistent type.
@@ -67,25 +68,6 @@ public interface JavaResourcePersistentType
*/
boolean hasAnyAnnotatedAttributes();
- /**
- * Return whether the type is a metamodel type generated in the specified
- * source folder.
- */
- boolean isGeneratedMetamodel(IPackageFragmentRoot sourceFolder);
-
- /**
- * Return whether the type is a generated metamodel type.
- */
- boolean isGeneratedMetamodel();
-
- /**
- * The value used to tag a generated type:
- * <pre>
- * &#64;javax.annotation.Generated(value="Dali", date="2009-11-23T13:56:06.171-0500")
- * </pre>
- */
- String METAMODEL_GENERATED_ANNOTATION_VALUE = "Dali"; //$NON-NLS-1$
-
// ********** types **********
@@ -160,4 +142,31 @@ public interface JavaResourcePersistentType
*/
Iterator<JavaResourcePersistentAttribute> persistableAttributes(AccessType specifiedAccess);
+
+ // ********** metamodel **********
+
+ /**
+ * Return the <code>javax.annotation.Generated</code> annotation.
+ */
+ GeneratedAnnotation getGeneratedAnnotation();
+
+ /**
+ * Return whether the type is a metamodel type generated in the specified
+ * source folder.
+ */
+ boolean isGeneratedMetamodel(IPackageFragmentRoot sourceFolder);
+
+ /**
+ * Return whether the type is a generated metamodel type.
+ */
+ boolean isGeneratedMetamodel();
+
+ /**
+ * The value used to tag a generated type:
+ * <pre>
+ * &#64;javax.annotation.Generated(value="Dali", date="2009-11-23T13:56:06.171-0500")
+ * </pre>
+ */
+ String METAMODEL_GENERATED_ANNOTATION_VALUE = "Dali"; //$NON-NLS-1$
+
}

Back to the top