Author: dgeraskov
Date: 2011-08-01 08:43:50 -0400 (Mon, 01 Aug 2011)
New Revision: 33412
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfoImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaPackageInfo.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernateClassRef.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistence.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/PackageInfoRef.java
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainer.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainerImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistenceXmlContextNodeFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/jpa2/Hibernate2_0PersistenceXmlContextNodeFactory.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0AnnotationDefinitionProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0PlatformProvider.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java
Log:
https://issues.jboss.org/browse/JBIDE-9435
Added package level annotations support
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/META-INF/MANIFEST.MF 2011-08-01
12:43:50 UTC (rev 33412)
@@ -20,7 +20,8 @@
org.eclipse.jpt.jpa.core;bundle-version="3.0.0",
org.eclipse.text;bundle-version="3.5.100",
org.eclipse.jst.j2ee;bundle-version="1.1.500",
- org.eclipse.persistence.jpa.jpql;bundle-version="1.0.0"
+ org.eclipse.persistence.jpa.jpql;bundle-version="1.0.0",
+ org.eclipse.jst.j2ee.core;bundle-version="1.2.100"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor.0
Export-Package: org.jboss.tools.hibernate.jpt.core.internal,
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateAbstractJpaFactory.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -37,6 +37,7 @@
import org.eclipse.jpt.jpa.core.context.java.JavaTable;
import org.eclipse.jpt.jpa.core.internal.AbstractJpaFactory;
import org.eclipse.jpt.jpa.core.resource.java.EntityAnnotation;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackage;
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.SecondaryTableAnnotation;
import org.jboss.tools.hibernate.jpt.core.internal.context.ForeignKey;
@@ -65,18 +66,21 @@
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaTypeDefContainerImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedNativeQueryImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateNamedQueryImpl;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernatePackageInfoImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.IndexImpl;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaDiscriminatorFormula;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaDiscriminatorFormulaImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGenerator;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaGenericGeneratorImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaIndex;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaParameter;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaType;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeConverterImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeDef;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeDefImpl;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.TypeImpl;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernateClassRef;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.DiscriminatorFormulaAnnotation;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.GenericGeneratorAnnotation;
import
org.jboss.tools.hibernate.jpt.core.internal.resource.java.HibernateNamedNativeQueryAnnotation;
@@ -235,4 +239,9 @@
return new JavaTypeConverterImpl(parent, converterAnnotation);
}
+ public JavaPackageInfo buildJavaPackageInfo(
+ HibernateClassRef hibernateClassRef, JavaResourcePackage jrpt) {
+ return new HibernatePackageInfoImpl(hibernateClassRef, jrpt);
+ }
+
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaPlatformProvider.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -25,6 +25,7 @@
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.AbstractJpaPlatformProvider;
import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
+import org.eclipse.jpt.jpa.core.internal.JavaPackageInfoResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
@@ -76,7 +77,9 @@
// ********** resource models **********
public JptResourceType getMostRecentSupportedResourceType(IContentType contentType) {
- if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
+ if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE)) {
+ return JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE;
+ } else if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
return JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
}
else if (contentType.equals(JptCommonCorePlugin.JAR_CONTENT_TYPE)) {
@@ -100,6 +103,7 @@
// order should not be important here
protected static final JpaResourceModelProvider[] RESOURCE_MODEL_PROVIDERS = new
JpaResourceModelProvider[] {
+ JavaPackageInfoResourceModelProvider.instance(),
JavaResourceModelProvider.instance(),
JarResourceModelProvider.instance(),
PersistenceResourceModelProvider.instance(),
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/HibernatePersistenceUnit.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -28,11 +28,15 @@
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
+import org.eclipse.jpt.common.utility.internal.NotNullFilter;
+import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
+import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.GeneratorContainer;
import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.QueryContainer;
+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
@@ -44,7 +48,10 @@
import org.jboss.tools.hibernate.jpt.core.internal.context.basic.Hibernate;
import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernatePersistenceUnitProperties;
import
org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaQueryContainer;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernatePackageInfo;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo;
import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaTypeDef;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernateClassRef;
import
org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernatePersistenceUnitPropertiesBuilder;
/**
@@ -146,6 +153,42 @@
}
}
+ /**
+ * Return the non-<code>null</code> class ref package infos,
+ * both specified and implied.
+ */
+ protected Iterable<JavaPackageInfo> getClassRefPackageInfos() {
+ return new FilteringIterable<JavaPackageInfo>(
+ this.getClassRefPackageInfos_(),
+ NotNullFilter.<JavaPackageInfo>instance()
+ );
+ }
+
+ protected Iterable<JavaPackageInfo> getClassRefPackageInfos_() {
+ return new TransformationIterable<ClassRef, JavaPackageInfo>(this.getClassRefs())
{
+ @Override
+ protected JavaPackageInfo transform(ClassRef classRef) {
+ return ((HibernateClassRef)classRef).getJavaPackageInfo();
+ }
+ };
+ }
+
+ /**
+ * Need to collect also Queries from package-info.java
+ */
+ protected void addJavaQueriesTo(ArrayList<Query> queryList) {
+ super.addJavaQueriesTo(queryList);
+ this.addPackageJavaQueriesTo(this.getClassRefPackageInfos(), queryList);
+ }
+
+ protected void addPackageJavaQueriesTo(Iterable<JavaPackageInfo> packageInfos,
ArrayList<Query> queryList) {
+ for (JavaPackageInfo packageInfo : packageInfos) {
+ if (packageInfo instanceof HibernatePackageInfo) {
+ this.addQueriesTo(((HibernatePackageInfo) packageInfo).getQueryContainer(),
queryList);
+ }
+ }
+ }
+
@Override
protected void addQueriesTo(QueryContainer queryContainer,
ArrayList<Query> queryList) {
@@ -154,9 +197,24 @@
CollectionTools.addAll(queryList,
((HibernateJavaQueryContainer)queryContainer).hibernateNamedQueries());
CollectionTools.addAll(queryList,
((HibernateJavaQueryContainer)queryContainer).hibernateNamedNativeQueries());
}
-
}
+ /**
+ * Include "overridden" Java generators.
+ */
+ protected void addJavaGeneratorsTo(ArrayList<Generator> generatorList) {
+ super.addJavaGeneratorsTo(generatorList);
+ this.addPackageJavaGeneratorsTo(this.getClassRefPackageInfos(), generatorList);
+ }
+
+ protected void addPackageJavaGeneratorsTo(Iterable<JavaPackageInfo> pacakgeInfos,
ArrayList<Generator> generatorList) {
+ for (JavaPackageInfo packageInfo : pacakgeInfos) {
+ if (packageInfo instanceof HibernatePackageInfo) {
+ this.addGeneratorsTo(((HibernatePackageInfo) packageInfo).getGeneratorContainer(),
generatorList);
+ }
+ }
+ }
+
@Override
protected void addGeneratorsTo(GeneratorContainer generatorContainer,
ArrayList<Generator> generatorList) {
@@ -228,5 +286,213 @@
super(Messages.class.getName(), severity, message, strings, resource);
}
}
+//
+// // ********** specified package-info refs **********
+//
+// public ListIterator<PackageInfoRef> specifiedPackageInfoRefs() {
+// return this.getSpecifiedPackageInfoRefs().iterator();
+// }
+//
+// protected ListIterable<PackageInfoRef> getSpecifiedPackageInfoRefs() {
+// return new
LiveCloneListIterable<PackageInfoRef>(this.specifiedPackageInfoRefs);
+// }
+//
+// public int specifiedPackageInfoRefsSize() {
+// return this.specifiedPackageInfoRefs.size();
+// }
+//
+// public PackageInfoRef addSpecifiedPackageInfoRef(String packageName) {
+// return this.addSpecifiedPackageInfoRef(this.specifiedPackageInfoRefs.size(),
packageName);
+// }
+//
+// public PackageInfoRef addSpecifiedPackageInfoRef(int index, String packageName) {
+// XmlPackageInfoRef xmlPackageInfoRef = this.buildXmlPackageInfoRef(packageName);
+// PackageInfoRef classRef = this.addSpecifiedPackageInfoRef_(index,
xmlPackageInfoRef);
+// this.xmlPersistenceUnit.getClasses().add(index, xmlPackageInfoRef);
+// return classRef;
+// }
+//
+// protected XmlPackageInfoRef buildXmlPackageInfoRef(String packageName) {
+// XmlPackageInfoRef ref = PersistenceFactory.eINSTANCE.createXmlPackageInfoRef();
+// ref.setJavaClass(packageName);
+// return ref;
+// }
+//
+// protected PackageInfoRef buildPackageInfoRef(XmlPackageInfoRef xmlPackageInfoRef) {
+// return this.getContextNodeFactory().buildPackageInfoRef(this, xmlPackageInfoRef);
+// }
+//
+// public void removeSpecifiedPackageInfoRef(PackageInfoRef classRef) {
+// this.removeSpecifiedPackageInfoRef(this.specifiedPackageInfoRefs.indexOf(classRef));
+// }
+//
+// public void removeSpecifiedPackageInfoRef(int index) {
+// this.removeSpecifiedPackageInfoRef_(index);
+// this.xmlPersistenceUnit.getClasses().remove(index);
+// }
+//
+// /**
+// * dispose the class ref
+// */
+// protected void removeSpecifiedPackageInfoRef_(int index) {
+// this.removeItemFromList(index, this.specifiedPackageInfoRefs,
SPECIFIED_CLASS_REFS_LIST).dispose();
+// }
+//
+// protected void initializeSpecifiedPackageInfoRefs() {
+// for (XmlPackageInfoRef xmlJavaPackageInfoRef : this.getXmlPackageInfoRefs()) {
+// this.specifiedPackageInfoRefs.add(this.buildPackageInfoRef(xmlJavaPackageInfoRef));
+// }
+// }
+//
+// protected void syncSpecifiedPackageInfoRefs() {
+// ContextContainerTools.synchronizeWithResourceModel(this.specifiedPackageInfoRefContainerAdapter);
+// }
+//
+// protected Iterable<XmlPackageInfoRef> getXmlPackageInfoRefs() {
+// // clone to reduce chance of concurrency problems
+// return new
LiveCloneIterable<XmlPackageInfoRef>(this.xmlPersistenceUnit.getClasses());
+// }
+//
+// protected void moveSpecifiedPackageInfoRef_(int index, PackageInfoRef classRef) {
+// this.moveItemInList(index, classRef, this.specifiedPackageInfoRefs,
SPECIFIED_CLASS_REFS_LIST);
+// }
+//
+// protected PackageInfoRef addSpecifiedPackageInfoRef_(int index, XmlPackageInfoRef
xmlPackageInfoRef) {
+// PackageInfoRef classRef = this.buildPackageInfoRef(xmlPackageInfoRef);
+// this.addItemToList(index, classRef, this.specifiedPackageInfoRefs,
SPECIFIED_CLASS_REFS_LIST);
+// return classRef;
+// }
+//
+// protected void removeSpecifiedPackageInfoRef_(PackageInfoRef classRef) {
+// this.removeSpecifiedPackageInfoRef_(this.specifiedPackageInfoRefs.indexOf(classRef));
+// }
+//
+// /**
+// * specified class ref container adapter
+// */
+// protected class SpecifiedPackageInfoRefContainerAdapter
+// implements ContextContainerTools.Adapter<PackageInfoRef, XmlPackageInfoRef>
+// {
+// public Iterable<PackageInfoRef> getContextElements() {
+// return HibernatePersistenceUnit.this.getSpecifiedPackageInfoRefs();
+// }
+// public Iterable<XmlPackageInfoRef> getResourceElements() {
+// return HibernatePersistenceUnit.this.getXmlPackageInfoRefs();
+// }
+// public XmlPackageInfoRef getResourceElement(PackageInfoRef contextElement) {
+// return contextElement.getXmlPackageInfoRef();
+// }
+// public void moveContextElement(int index, PackageInfoRef element) {
+// HibernatePersistenceUnit.this.moveSpecifiedPackageInfoRef_(index, element);
+// }
+// public void addContextElement(int index, XmlPackageInfoRef resourceElement) {
+// HibernatePersistenceUnit.this.addSpecifiedPackageInfoRef_(index, resourceElement);
+// }
+// public void removeContextElement(PackageInfoRef element) {
+// HibernatePersistenceUnit.this.removeSpecifiedPackageInfoRef_(element);
+// }
+// }
+//
+// // ********** virtual package-info refs **********
+//
+// public Iterator<PackageInfoRef> impliedPackageInfoRefs() {
+// return this.getImpliedPackageInfoRefs().iterator();
+// }
+//
+// protected Iterable<PackageInfoRef> getImpliedPackageInfoRefs() {
+// return new LiveCloneIterable<PackageInfoRef>(this.impliedPackageInfoRefs);
+// }
+//
+// public int impliedPackageInfoRefsSize() {
+// return this.impliedPackageInfoRefs.size();
+// }
+//
+// protected PackageInfoRef addImpliedPackageInfoRef(String packageName) {
+// PackageInfoRef classRef = this.buildPackageInfoRef(packageName);
+// this.addItemToCollection(classRef, this.impliedPackageInfoRefs,
IMPLIED_CLASS_REFS_COLLECTION);
+// return classRef;
+// }
+//
+// protected PackageInfoRef buildPackageInfoRef(String packageName) {
+// return this.getContextNodeFactory().buildPackageInfoRef(this, packageName);
+// }
+//
+// protected void removeImpliedPackageInfoRef(PackageInfoRef classRef) {
+// this.impliedPackageInfoRefs.remove(classRef);
+// classRef.dispose();
+// this.fireItemRemoved(IMPLIED_CLASS_REFS_COLLECTION, classRef);
+// }
+//
+// protected void updateImpliedPackageInfoRefs() {
+// ContextContainerTools.update(this.impliedPackageInfoRefContainerAdapter);
+// }
+//
+// protected Iterable<String> getImpliedClassNames() {
+// return this.excludesUnlistedClasses() ?
+// EmptyIterable.<String>instance() :
+// this.getImpliedClassNames_();
+// }
+//
+// /**
+// * Return the names of all the Java classes in the JPA project that are
+// * mapped (i.e. have the appropriate annotation etc.) but not specified
+// * in the persistence unit.
+// */
+// protected Iterable<String> getImpliedClassNames_() {
+// return new
FilteringIterable<String>(this.getJpaProject().getMappedJavaSourceClassNames()) {
+// @Override
+// protected boolean accept(String mappedClassName) {
+// return ! HibernatePersistenceUnit.this.specifiesPersistentType(mappedClassName);
+// }
+// };
+// }
+//
+// /**
+// * Virtual class ref container adapter.
+// * <p>
+// * <strong>NB:</strong> The context class ref is matched with a resource
+// * class by name.
+// * <p>
+// * This is used during <strong>both</strong> <em>sync</em>
and
+// * <em>update</em> because the list of implied class refs can be modified
+// * in either situation. In particular, we cannot simply rely on
+// * <em>update</em> because there are situations where a
<em>sync</em> is
+// * triggered but a follow-up <em>update</em> is not. (Of course, any
+// * change discovered here will trigger an <em>update</em>.)
+// * <p>
+// * The most obvious example is when the JPA project is configured to
+// * discover annotated classes and a Java class is annotated for the first
+// * time (via code editing, not via the context model). This will trigger
+// * a <em>sync</em>; but, since the unannotated class is not yet in the
+// * context model and, as a result, the context model's state is untouched,
+// * an <em>update</em> will not be triggered.
+// * <p>
+// * Obviously, other context model changes can change this collection (e.g.
+// * setting whether the persistence unit excludes unlisted classes); o the
+// * collection must also be synchronized during <em>update</em>.
+// */
+// protected class ImpliedPackageInfoRefContainerAdapter
+// implements ContextContainerTools.Adapter<PackageInfoRef, String>
+// {
+// public Iterable<PackageInfoRef> getContextElements() {
+// return HibernatePersistenceUnit.this.getImpliedPackageInfoRef();
+// }
+// public Iterable<String> getResourceElements() {
+// return HibernatePersistenceUnit.this.getImpliedPackageInfoNames();
+// }
+// public String getResourceElement(PackageInfoRef contextElement) {
+// return contextElement.getPackageName();
+// }
+// public void moveContextElement(int index, PackageInfoRef element) {
+// // ignore moves - we don't care about the order of the implied package-info
refs
+// }
+// public void addContextElement(int index, String resourceElement) {
+// // ignore the index - we don't care about the order of the implied package-info
refs
+// HibernatePersistenceUnit.this.addImpliedPackageInfoRef(resourceElement);
+// }
+// public void removeContextElement(PackageInfoRef element) {
+// HibernatePersistenceUnit.this.removeImpliedPackageInfoRef(element);
+// }
+// }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainer.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainer.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainer.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -13,7 +13,7 @@
import java.util.ListIterator;
import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
/**
* @author Dmitry Geraskov
@@ -56,12 +56,12 @@
*/
void moveTypeDef(int targetIndex, int sourceIndex);
- void initialize(JavaResourcePersistentMember jrpm);
+ void initialize(JavaResourceAnnotatedElement jrpm);
/**
* Update the JavaGeneratorContainer context model object to match the
JavaResourcePersistentMember
* resource model object. see {@link org.eclipse.jpt.jpa.core.JpaProject#update()}
*/
- void update(JavaResourcePersistentMember jrpm);
+ void update(JavaResourceAnnotatedElement jrpm);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainerImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainerImpl.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernateJavaTypeDefContainerImpl.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -22,7 +22,7 @@
import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -37,7 +37,7 @@
public class HibernateJavaTypeDefContainerImpl extends
AbstractJavaJpaContextNode implements HibernateJavaTypeDefContainer {
- protected JavaResourcePersistentMember javaResourcePersistentMember;
+ protected JavaResourceAnnotatedElement javaResourcePersistentElement;
protected final List<JavaTypeDef> typeDefs;
@@ -50,20 +50,20 @@
return (HibernateAbstractJpaFactory)super.getJpaFactory();
}
- public void initialize(JavaResourcePersistentMember jrpm) {
- this.javaResourcePersistentMember = jrpm;
+ public void initialize(JavaResourceAnnotatedElement jrpe) {
+ this.javaResourcePersistentElement = jrpe;
this.initializeTypeDefs();
}
- public void update(JavaResourcePersistentMember jrpm) {
- this.javaResourcePersistentMember = jrpm;
+ public void update(JavaResourceAnnotatedElement jrpm) {
+ this.javaResourcePersistentElement = jrpm;
this.updateTypeDefs();
}
public JavaTypeDef addTypeDef(int index) {
JavaTypeDef newTypeDef = getJpaFactory().buildJavaTypeDef(this);
this.typeDefs.add(index, newTypeDef);
- TypeDefAnnotation typeDefAnnotation =
(TypeDefAnnotation)this.javaResourcePersistentMember
+ TypeDefAnnotation typeDefAnnotation =
(TypeDefAnnotation)this.javaResourcePersistentElement
.addAnnotation(index, TypeDefAnnotation.ANNOTATION_NAME,
TypeDefsAnnotation.ANNOTATION_NAME);
newTypeDef.initialize(typeDefAnnotation);
fireItemAdded(TYPE_DEFS_LIST, index, newTypeDef);
@@ -88,13 +88,13 @@
public void moveTypeDef(int targetIndex, int sourceIndex) {
CollectionTools.move(this.typeDefs, targetIndex, sourceIndex);
- this.javaResourcePersistentMember.moveAnnotation(targetIndex, sourceIndex,
TypeDefsAnnotation.ANNOTATION_NAME);
+ this.javaResourcePersistentElement.moveAnnotation(targetIndex, sourceIndex,
TypeDefsAnnotation.ANNOTATION_NAME);
fireItemMoved(TYPE_DEFS_LIST, targetIndex, sourceIndex);
}
public void removeTypeDef(int index) {
JavaTypeDef removedTypeDef = this.typeDefs.remove(index);
- this.javaResourcePersistentMember.removeAnnotation(index,
TypeDefAnnotation.ANNOTATION_NAME, TypeDefsAnnotation.ANNOTATION_NAME);
+ this.javaResourcePersistentElement.removeAnnotation(index,
TypeDefAnnotation.ANNOTATION_NAME, TypeDefsAnnotation.ANNOTATION_NAME);
fireItemRemoved(TYPE_DEFS_LIST, index, removedTypeDef);
}
@@ -107,7 +107,7 @@
}
protected void initializeTypeDefs() {
- for (Iterator<NestableAnnotation> stream =
this.javaResourcePersistentMember.annotations(
+ for (Iterator<NestableAnnotation> stream =
this.javaResourcePersistentElement.annotations(
TypeDefAnnotation.ANNOTATION_NAME,
TypeDefsAnnotation.ANNOTATION_NAME);
stream.hasNext(); ) {
@@ -130,7 +130,7 @@
protected void updateTypeDefs() {
ListIterator<JavaTypeDef> typeDefs = typeDefs();
Iterator<NestableAnnotation> resourceTypeDefs =
- this.javaResourcePersistentMember.annotations(
+ this.javaResourcePersistentElement.annotations(
TypeDefAnnotation.ANNOTATION_NAME,
TypeDefsAnnotation.ANNOTATION_NAME);
@@ -183,6 +183,6 @@
}
public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.javaResourcePersistentMember.getTextRange(astRoot);
+ return this.javaResourcePersistentElement.getTextRange(astRoot);
}
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfo.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfo.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
+import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface HibernatePackageInfo extends JavaPackageInfo,
JavaGeneratorContainer.Owner, JavaQueryContainer.Owner{
+
+ JavaQueryContainer getQueryContainer();
+ JavaGeneratorContainer getGeneratorContainer();
+ HibernateJavaTypeDefContainer getTypeDefContainer();
+
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfoImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfoImpl.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/HibernatePackageInfoImpl.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.Filter;
+import org.eclipse.jpt.jpa.core.JpaFile;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
+import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
+import org.eclipse.jpt.jpa.core.context.java.JavaStructureNodes;
+import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode;
+import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceNode;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackage;
+import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
+
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernatePackageInfoImpl extends AbstractJavaJpaContextNode implements
HibernatePackageInfo {
+
+ //FIXME may be need to create "Mapping" class??
+ protected final HibernateJavaTypeDefContainer typeDefContainer;
+ protected final JavaGeneratorContainer generatorContainer;
+ protected final JavaQueryContainer queryContainer;
+
+ private JavaResourcePackage resourcePackage;
+ protected String name;
+
+ /**
+ * @param parent
+ */
+ public HibernatePackageInfoImpl(PersistentType.Owner owner, JavaResourcePackage
resourcePackage) {
+ super(owner);
+ this.resourcePackage = resourcePackage;
+ this.name = resourcePackage.getName();
+ this.typeDefContainer = getJpaFactory().buildJavaTypeDefContainer(this);
+ this.generatorContainer = this.buildGeneratorContainer();
+ this.queryContainer = this.buildQueryContainer();
+ }
+
+ @Override
+ protected HibernateAbstractJpaFactory getJpaFactory() {
+ return (HibernateAbstractJpaFactory) this.getJpaPlatform().getJpaFactory();
+ }
+
+ public HibernateJavaTypeDefContainer getTypeDefContainer() {
+ return this.typeDefContainer;
+ }
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setName(this.resourcePackage.getName());
+ this.typeDefContainer.initialize(this.getResourcePackage());
+ this.generatorContainer.synchronizeWithResourceModel();
+ this.queryContainer.synchronizeWithResourceModel();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.typeDefContainer.update(this.getResourcePackage());
+ this.generatorContainer.update();
+ this.queryContainer.update();
+ }
+
+ // ********** name **********
+
+ public String getName() {
+ return this.name;
+ }
+
+ protected void setName(String name) {
+ String old = this.name;
+ this.name = name;
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ public TextRange getSelectionTextRange() {
+ return this.getSelectionTextRange(this.buildASTRoot());
+ }
+
+ protected TextRange getSelectionTextRange(CompilationUnit astRoot) {
+ return this.resourcePackage.getNameTextRange(astRoot);
+ }
+
+ public TextRange getValidationTextRange(CompilationUnit astRoot) {
+ return this.getSelectionTextRange(astRoot);
+ }
+
+ public TextRange getValidationTextRange() {
+ return this.getSelectionTextRange();
+ }
+
+ // ********** generator container **********
+
+ public JavaGeneratorContainer getGeneratorContainer() {
+ return this.generatorContainer;
+ }
+
+ protected JavaGeneratorContainer buildGeneratorContainer() {
+ return this.getJpaFactory().buildJavaGeneratorContainer(this, this);
+ }
+
+ // ********** query container **********
+
+ public JavaQueryContainer getQueryContainer() {
+ return this.queryContainer;
+ }
+
+ protected JavaQueryContainer buildQueryContainer() {
+ return this.getJpaFactory().buildJavaQueryContainer(this, this);
+ }
+
+ protected CompilationUnit buildASTRoot() {
+ return this.resourcePackage.getJavaResourceCompilationUnit().buildASTRoot();
+ }
+
+ // it would be nice if the we passed in an astRoot here, but then we
+ // would need to pass it to the XML structure nodes too...
+ public JpaStructureNode getStructureNode(int offset) {
+ CompilationUnit astRoot = this.buildASTRoot();
+
+ if (this.contains(offset, astRoot)) {
+ return this;
+ }
+ return null;
+ }
+
+ protected boolean contains(int offset, CompilationUnit astRoot) {
+ TextRange fullTextRange = this.resourcePackage.getTextRange(astRoot);
+ // 'fullTextRange' will be null if the type no longer exists in the java;
+ // the context model can be out of synch with the resource model
+ // when a selection event occurs before the context model has a
+ // chance to synch with the resource model via the update thread
+ return (fullTextRange == null) ? false : fullTextRange.includes(offset);
+ }
+
+
+ public String getId() {
+ //FIXME check this is correct
+ return JavaStructureNodes.COMPILATION_UNIT_ID;
+ }
+
+ public void dispose() {
+ this.unregisterRootStructureNode();
+ }
+
+ protected void unregisterRootStructureNode() {
+ JpaFile jpaFile = this.getJpaFile();
+ // the JPA file can be null if the .java file was deleted
+ // or the resource type is "external"
+ if (jpaFile != null) {
+ jpaFile.removeRootStructureNode(this.name, this);
+ }
+ }
+
+ protected JpaFile getJpaFile() {
+ return this.getJpaFile(this.resourcePackage.getFile());
+ }
+
+ @Override
+ public JavaResourcePackage getResourcePackage() {
+ return this.resourcePackage;
+ }
+
+ @Override
+ public JavaResourceAnnotatedElement getResourceAnnotatedElement() {
+ return this.resourcePackage;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo#validate(java.util.List,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ if (reporter.isCancelled()) {
+ throw new ValidationCancelledException();
+ }
+ // TODO temporary hack since we don't know yet where to put
+ // any messages for types in another project (e.g. referenced by
+ // persistence.xml)
+ IFile file = this.resourcePackage.getFile();
+ // 'file' will be null if the type is "external" and binary;
+ // the file will be in a different project if the type is "external" and
source;
+ // the type will be binary if it is in a JAR in the current project
+ if ((file != null) &&
file.getProject().equals(this.getJpaProject().getProject()) &&
+ (this.resourcePackage instanceof SourceNode)) {
+ // build the AST root here to pass down
+ this.validate(messages, reporter, this.buildASTRoot());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode#validate(java.util.List,
org.eclipse.wst.validation.internal.provisional.core.IReporter,
org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter,
+ CompilationUnit astRoot) {
+ super.validate(messages, reporter, astRoot);
+ this.typeDefContainer.validate(messages, reporter, astRoot);
+ this.generatorContainer.validate(messages, reporter, astRoot);
+ this.queryContainer.validate(messages, reporter, astRoot);
+ }
+
+ @Override
+ public Iterator<String> javaCompletionProposals(int pos,
+ Filter<String> filter, CompilationUnit astRoot) {
+ Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ result = this.typeDefContainer.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ result = this.generatorContainer.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ result = this.queryContainer.javaCompletionProposals(pos, filter, astRoot);
+ if (result != null) {
+ return result;
+ }
+ return null;
+ }
+
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaPackageInfo.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaPackageInfo.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/java/JavaPackageInfo.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.java;
+
+import java.util.List;
+
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackage;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+
+/**
+ * When <class>test.some.pack</class> is used and there is
+ * test.some.pack.package-info.java file it should be included in persistent unit.
+ *
+ * @author Dmitry Geraskov
+ *
+ */
+public interface JavaPackageInfo extends JavaJpaContextNode, JpaContextNode,
JpaStructureNode {
+
+ // ********** name **********
+
+ /**
+ * Return the persistent type's [fully-qualified] name.
+ * The enclosing type separator is <code>'.'</code>,
+ * as opposed to <code>'$'</code>.
+ * @see #getSimpleName()
+ */
+ String getName();
+ String NAME_PROPERTY = "name"; //$NON-NLS-1$
+
+ JavaResourcePackage getResourcePackage();
+
+ // ********** validation **********
+
+ /**
+ * Add to the list of current validation messages
+ */
+ void validate(List<IMessage> messages, IReporter reporter);
+
+ /**
+ * Return the text range to be used with any validation messages related
+ * to the persistent type.
+ */
+ TextRange getValidationTextRange();
+
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernateClassRef.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernateClassRef.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernateClassRef.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.persistence;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericClassRef;
+import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
+import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
+import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.jboss.tools.hibernate.jpt.core.internal.HibernateAbstractJpaFactory;
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernateClassRef extends GenericClassRef implements PackageInfoRef{
+
+ /**
+ * When <code><class>test.some.pack</class></code> is used and
there is
+ * test.some.pack.package-info.java file it should be included in persistent unit.
+ * This can be <code>null</code> if the name is invalid.
+ */
+ protected JavaPackageInfo javaPackageInfo;
+
+
+ /**
+ * Construct a <em>specified</em> class ref; i.e. a class ref with
+ * an explicit entry in the <code>persistence.xml</code>.
+ */
+ public HibernateClassRef(PersistenceUnit parent, XmlJavaClassRef xmlJavaClassRef) {
+ super(parent, xmlJavaClassRef, xmlJavaClassRef.getJavaClass());
+ }
+
+ /**
+ * Construct an <em>virtual</em> class ref; i.e. a class ref without
+ * an explicit entry in the <code>persistence.xml</code>.
+ */
+ public HibernateClassRef(PersistenceUnit parent, String className) {
+ super(parent, null, className);
+ }
+
+ @Override
+ protected HibernateAbstractJpaFactory getJpaFactory() {
+ return (HibernateAbstractJpaFactory) super.getJpaFactory();
+ }
+
+ @Override
+ protected boolean isInPackage(IPackageFragment packageFragment) {
+ // FIXME recheck this method
+ return super.isInPackage(packageFragment);
+ }
+
+ @Override
+ protected String getPackageName() {
+ // FIXME recheck this method
+ return super.getPackageName();
+ }
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ if (this.javaPackageInfo != null) {
+ this.javaPackageInfo.synchronizeWithResourceModel();
+ }
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.updateJavaPackageInfo();
+ }
+
+ // ********** java persistent type **********
+
+ public JavaPackageInfo getJavaPackageInfo() {
+ return this.javaPackageInfo;
+ }
+
+ protected void setJavaPackageInfo(JavaPackageInfo javaPackageInfo) {
+ JavaPackageInfo old = this.javaPackageInfo;
+ this.javaPackageInfo = javaPackageInfo;
+ this.firePropertyChanged(JAVA_PACKAGE_INFO_PROPERTY, old, javaPackageInfo);
+ }
+
+ protected void updateJavaPackageInfo() {
+ JavaResourcePackage resourcePackage = this.resolveJavaResourcePackage();
+ if (resourcePackage == null) {
+ if (this.javaPackageInfo != null) {
+ this.javaPackageInfo.dispose();
+ this.setJavaPackageInfo(null);
+ }
+ } else {
+ if (this.javaPackageInfo == null) {
+ this.setJavaPackageInfo(this.buildJavaPackageInfo(resourcePackage));
+ } else {
+ if (this.javaPackageInfo.getResourcePackage() == resourcePackage) {
+ this.javaPackageInfo.update();
+ } else {
+ this.javaPackageInfo.dispose();
+ this.setJavaPackageInfo(this.buildJavaPackageInfo(resourcePackage));
+ }
+ }
+ }
+ }
+
+ protected String getJavaPackageInfoName() {
+ return getClassName();//the same name should be used!
+ }
+
+ protected JavaResourcePackage resolveJavaResourcePackage() {
+ String javaPackageInfoName = this.getJavaPackageInfoName();
+ return (javaPackageInfoName == null) ? null :
this.getJpaProject().getJavaResourcePackage(javaPackageInfoName);
+ }
+
+ protected JavaPackageInfo buildJavaPackageInfo(JavaResourcePackage jrpt) {
+ return this.getJpaFactory().buildJavaPackageInfo(this, jrpt);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericClassRef#validate(java.util.List,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ if (reporter.isCancelled()) {
+ throw new ValidationCancelledException();
+ }
+ if (StringTools.stringIsEmpty(this.className)) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_CLASS,
+ this,
+ this.getValidationTextRange()
+ )
+ );
+ return;
+ }
+
+ if (this.javaPersistentType == null
+ && this.javaPackageInfo == null) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_CLASS,
+ new String[] {this.getJavaClassName()},
+ this,
+ this.getValidationTextRange()
+ )
+ );
+ return;
+ }
+
+ if (javaPersistentType != null){
+ // 190062 validate Java class only if this is the only reference to it
+ // i.e. the persistence.xml ref is the only ref - none of the mapping
+ // files reference the same class
+ boolean validateJavaPersistentType = true;
+ for (Iterator<MappingFileRef> stream =
this.getPersistenceUnit().mappingFileRefsContaining(this.getJavaClassName());
stream.hasNext(); ) {
+ validateJavaPersistentType = false;
+ MappingFileRef mappingFileRef = stream.next();
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.LOW_SEVERITY,
+ JpaValidationMessages.PERSISTENCE_UNIT_REDUNDANT_CLASS,
+ new String[] {this.getJavaClassName(), mappingFileRef.getFileName()},
+ this,
+ this.getValidationTextRange()
+ )
+ );
+ }
+
+ if (validateJavaPersistentType) {
+ this.validateJavaPersistentType(messages, reporter);
+ }
+ }
+
+ }
+
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistence.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistence.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistence.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.persistence;
+
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistence;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public class HibernatePersistence extends GenericPersistence {
+
+ /**
+ * @param parent
+ * @param xmlPersistence
+ */
+ public HibernatePersistence(PersistenceXml parent,
+ XmlPersistence xmlPersistence) {
+ super(parent, xmlPersistence);
+ }
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistenceXmlContextNodeFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistenceXmlContextNodeFactory.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/HibernatePersistenceXmlContextNodeFactory.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -10,9 +10,13 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.persistence;
+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import
org.eclipse.jpt.jpa.core.internal.context.persistence.GenericPersistenceXmlContextNodeFactory;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernatePersistenceUnitProperties;
@@ -31,4 +35,19 @@
public HibernatePersistenceUnitProperties
buildHibernatePersistenceUnitProperties(PersistenceUnit parent) {
return new HibernatePersistenceUnitProperties(parent);
}
+
+ public Persistence buildPersistence(PersistenceXml parent, XmlPersistence
xmlPersistence) {
+ return new HibernatePersistence(parent, xmlPersistence);
+ }
+
+ @Override
+ public ClassRef buildClassRef(PersistenceUnit parent, String className) {
+ return new HibernateClassRef(parent, className);
+ }
+
+ @Override
+ public ClassRef buildClassRef(PersistenceUnit parent,
+ XmlJavaClassRef classRef) {
+ return new HibernateClassRef(parent, classRef);
+ }
}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/PackageInfoRef.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/PackageInfoRef.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/PackageInfoRef.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.jpt.core.internal.context.persistence;
+
+import org.jboss.tools.hibernate.jpt.core.internal.context.java.JavaPackageInfo;
+
+/**
+ * @author Dmitry Geraskov
+ *
+ */
+public interface PackageInfoRef {
+
+ // ********** java persistent type **********
+
+ /**
+ * String constant associated with changes to the java pacakge info
+ */
+ final static String JAVA_PACKAGE_INFO_PROPERTY = "javaPackageInfo";
//$NON-NLS-1$
+
+ /**
+ * Return the JavaPackageInfo that corresponds to this PackageInfoRef.
+ * This can be null.
+ * This is not settable by users of this API.
+ */
+ JavaPackageInfo getJavaPackageInfo();
+
+}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/jpa2/Hibernate2_0PersistenceXmlContextNodeFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/jpa2/Hibernate2_0PersistenceXmlContextNodeFactory.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/context/persistence/jpa2/Hibernate2_0PersistenceXmlContextNodeFactory.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -10,12 +10,18 @@
******************************************************************************/
package org.jboss.tools.hibernate.jpt.core.internal.context.persistence.jpa2;
+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import
org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.Generic2_0PersistenceXmlContextNodeFactory;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
import org.jboss.tools.hibernate.jpt.core.internal.context.HibernatePersistenceUnit;
import
org.jboss.tools.hibernate.jpt.core.internal.context.basic.HibernatePersistenceUnitProperties;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernateClassRef;
+import
org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernatePersistence;
import
org.jboss.tools.hibernate.jpt.core.internal.context.persistence.HibernatePersistenceUnitPropertiesBuilder;
/**
@@ -32,4 +38,19 @@
public HibernatePersistenceUnitProperties
buildHibernatePersistenceUnitProperties(PersistenceUnit parent) {
return new HibernatePersistenceUnitProperties(parent);
}
+
+ public Persistence buildPersistence(PersistenceXml parent, XmlPersistence
xmlPersistence) {
+ return new HibernatePersistence(parent, xmlPersistence);
+ }
+
+ @Override
+ public ClassRef buildClassRef(PersistenceUnit parent, String className) {
+ return new HibernateClassRef(parent, className);
+ }
+
+ @Override
+ public ClassRef buildClassRef(PersistenceUnit parent,
+ XmlJavaClassRef classRef) {
+ return new HibernateClassRef(parent, classRef);
+ }
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0AnnotationDefinitionProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0AnnotationDefinitionProvider.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0AnnotationDefinitionProvider.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -86,5 +86,13 @@
@Override
protected void addPackageAnnotationDefinitionsTo(
ArrayList<AnnotationDefinition> definitions) {
+ definitions.add(GenericGeneratorAnnotationDefinition.instance());
+ definitions.add(GenericGeneratorsAnnotationDefinition.instance());
+ definitions.add(HibernateNamedQueryAnnotationDefinition.instance());
+ definitions.add(HibernateNamedQueriesAnnotationDefinition.instance());
+ definitions.add(HibernateNamedNativeQueryAnnotationDefinition.instance());
+ definitions.add(HibernateNamedNativeQueriesAnnotationDefinition.instance());
+ definitions.add(TypeDefAnnotationDefinition.instance());
+ definitions.add(TypeDefsAnnotationDefinition.instance());
}
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0PlatformProvider.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0PlatformProvider.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/jpa2/HibernateJpa2_0PlatformProvider.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -25,6 +25,7 @@
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.AbstractJpaPlatformProvider;
import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
+import org.eclipse.jpt.jpa.core.internal.JavaPackageInfoResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
@@ -78,7 +79,10 @@
// ********** resource models **********
public JptResourceType getMostRecentSupportedResourceType(IContentType contentType) {
- if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
+ if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE)) {
+ return JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE;
+ }
+ else if (contentType.equals(JptCommonCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) {
return JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
}
else if (contentType.equals(JptCommonCorePlugin.JAR_CONTENT_TYPE)) {
@@ -102,6 +106,7 @@
// order should not be important here
protected static final JpaResourceModelProvider[] RESOURCE_MODEL_PROVIDERS = new
JpaResourceModelProvider[] {
+ JavaPackageInfoResourceModelProvider.instance(),
JavaResourceModelProvider.instance(),
JarResourceModelProvider.instance(),
PersistenceResourceModelProvider.instance(),
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/GenericGeneratorAnnotationImpl.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -29,7 +29,6 @@
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
@@ -47,7 +46,7 @@
* @author Dmitry Geraskov
*
*/
-public class GenericGeneratorAnnotationImpl extends SourceAnnotation<Member>
+public class GenericGeneratorAnnotationImpl extends
SourceAnnotation<AnnotatedElement>
implements GenericGeneratorAnnotation {
private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -69,7 +68,7 @@
* @param parent
* @param member
*/
- public GenericGeneratorAnnotationImpl(JavaResourceNode parent, Member member,
+ public GenericGeneratorAnnotationImpl(JavaResourceNode parent, AnnotatedElement member,
DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, member, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameDeclarationAdapter();
@@ -363,7 +362,7 @@
}
public static GenericGeneratorAnnotation createNestedGenericGenerator(
- JavaResourceNode parent, Member member,
+ JavaResourceNode parent, AnnotatedElement member,
int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
IndexedDeclarationAnnotationAdapter idaa =
buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
IndexedAnnotationAdapter annotationAdapter = new
ElementIndexedAnnotationAdapter(member, idaa);
@@ -394,7 +393,7 @@
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement
member) {
- return new GenericGeneratorAnnotationImpl(parent, (Member)member,
DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
+ return new GenericGeneratorAnnotationImpl(parent, member,
DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member,
DECLARATION_ANNOTATION_ADAPTER));
}
public String getAnnotationName() {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueriesAnnotationDefinition.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -12,7 +12,6 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
@@ -40,8 +39,8 @@
super();
}
- public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement
member) {
- return new HibernateSourceNamedNativeQueriesAnnotation(parent, (Member) member);
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement
annotatedElement) {
+ return new HibernateSourceNamedNativeQueriesAnnotation(parent, annotatedElement);
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent,
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedNativeQueryAnnotationDefinition.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -12,7 +12,6 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
@@ -43,7 +42,7 @@
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent,
AnnotatedElement annotatedElement) {
- return HibernateSourceNamedNativeQueryAnnotation.createNamedNativeQuery(parent,
(Member) annotatedElement);
+ return HibernateSourceNamedNativeQueryAnnotation.createNamedNativeQuery(parent,
annotatedElement);
}
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotationDefinition.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotationDefinition.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueriesAnnotationDefinition.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -12,7 +12,6 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
@@ -42,7 +41,7 @@
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent,
AnnotatedElement annotatedElement) {
- return new HibernateSourceNamedQueriesAnnotation(parent, (Member) annotatedElement);
+ return new HibernateSourceNamedQueriesAnnotation(parent, annotatedElement);
}
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateNamedQueryAnnotationDefinition.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -12,7 +12,6 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.resource.java.AnnotationDefinition;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceAnnotatedElement;
@@ -44,7 +43,7 @@
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement
annotatedElement) {
- return HibernateSourceNamedQueryAnnotation.createNamedQuery(parent, (Member)
annotatedElement);
+ return HibernateSourceNamedQueryAnnotation.createNamedQuery(parent, annotatedElement);
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent,
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedNativeQueriesAnnotation.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -15,8 +15,8 @@
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import
org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.AnnotationContainerTools;
@@ -29,7 +29,7 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateSourceNamedNativeQueriesAnnotation extends
SourceAnnotation<Member> implements
+public class HibernateSourceNamedNativeQueriesAnnotation extends
SourceAnnotation<AnnotatedElement> implements
HibernateNamedNativeQueriesAnnotation {
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -37,7 +37,7 @@
private final Vector<HibernateNamedNativeQueryAnnotation>
hibernateNamedNativeQueries = new Vector<HibernateNamedNativeQueryAnnotation>();
- public HibernateSourceNamedNativeQueriesAnnotation(JavaResourceNode parent, Member
member) {
+ public HibernateSourceNamedNativeQueriesAnnotation(JavaResourceNode parent,
AnnotatedElement member) {
super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/HibernateSourceNamedQueriesAnnotation.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -15,8 +15,8 @@
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import
org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.AnnotationContainerTools;
@@ -29,7 +29,7 @@
* @author Dmitry Geraskov
*
*/
-public class HibernateSourceNamedQueriesAnnotation extends SourceAnnotation<Member>
implements
+public class HibernateSourceNamedQueriesAnnotation extends
SourceAnnotation<AnnotatedElement> implements
HibernateNamedQueriesAnnotation {
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -37,7 +37,7 @@
private final Vector<HibernateNamedQueryAnnotation> hibernateNamedQueries = new
Vector<HibernateNamedQueryAnnotation>();
- public HibernateSourceNamedQueriesAnnotation(JavaResourceNode parent, Member member) {
+ public HibernateSourceNamedQueriesAnnotation(JavaResourceNode parent, AnnotatedElement
member) {
super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/SourceParameterAnnotation.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -16,12 +16,12 @@
import
org.eclipse.jpt.common.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
import
org.eclipse.jpt.common.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
@@ -31,7 +31,7 @@
* @author Dmitry Geraskov
*
*/
-public class SourceParameterAnnotation extends SourceAnnotation<Member> implements
+public class SourceParameterAnnotation extends SourceAnnotation<AnnotatedElement>
implements
NestableParameterAnnotation {
private final DeclarationAnnotationElementAdapter<String> nameDeclarationAdapter;
@@ -43,7 +43,7 @@
private String value;
- public SourceParameterAnnotation(JavaResourceNode parent, Member member,
IndexedDeclarationAnnotationAdapter idaa) {
+ public SourceParameterAnnotation(JavaResourceNode parent, AnnotatedElement member,
IndexedDeclarationAnnotationAdapter idaa) {
super(parent, member, idaa, new ElementIndexedAnnotationAdapter(member, idaa));
this.nameDeclarationAdapter = this.buildNameAdapter(idaa);
this.nameAdapter = this.buildAdapter(this.nameDeclarationAdapter);
@@ -157,7 +157,7 @@
// ********** static methods **********
- public static SourceParameterAnnotation createParameter(JavaResourceNode parent, Member
member, DeclarationAnnotationAdapter annotationAdapter, String elementName, int index) {
+ public static SourceParameterAnnotation createParameter(JavaResourceNode parent,
AnnotatedElement member, DeclarationAnnotationAdapter annotationAdapter, String
elementName, int index) {
return new SourceParameterAnnotation(parent, member,
buildParameterAnnotationAdapter(annotationAdapter, elementName, index));
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefAnnotationImpl.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -33,7 +33,7 @@
import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
@@ -50,7 +50,7 @@
* @author Dmitry Geraskov
*
*/
-public class TypeDefAnnotationImpl extends SourceAnnotation<Member>
+public class TypeDefAnnotationImpl extends SourceAnnotation<AnnotatedElement>
implements TypeDefAnnotation {
private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -78,7 +78,7 @@
* @param parent
* @param member
*/
- public TypeDefAnnotationImpl(JavaResourceNode parent, Member member,
+ public TypeDefAnnotationImpl(JavaResourceNode parent, AnnotatedElement member,
DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
super(parent, member, daa, annotationAdapter);
this.nameDeclarationAdapter = this.buildNameAdapter(daa);
@@ -367,7 +367,7 @@
}
public static TypeDefAnnotation createNestedTypeDef(
- JavaResourceNode parent, Member member,
+ JavaResourceNode parent, AnnotatedElement member,
int index, DeclarationAnnotationAdapter attributeOverridesAdapter) {
IndexedDeclarationAnnotationAdapter idaa =
buildNestedHibernateDeclarationAnnotationAdapter(index, attributeOverridesAdapter);
IndexedAnnotationAdapter annotationAdapter = new
ElementIndexedAnnotationAdapter(member, idaa);
@@ -417,7 +417,7 @@
}
public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement
annotatedElement) {
- return new TypeDefAnnotationImpl(parent, (Member) annotatedElement,
+ return new TypeDefAnnotationImpl(parent, annotatedElement,
DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(annotatedElement,
DECLARATION_ANNOTATION_ADAPTER));
}
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java 2011-08-01
12:37:29 UTC (rev 33411)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/resource/java/TypeDefsAnnotationImpl.java 2011-08-01
12:43:50 UTC (rev 33412)
@@ -15,8 +15,8 @@
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import
org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
+import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
import org.eclipse.jpt.common.utility.internal.CollectionTools;
import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.jpa.core.internal.resource.java.source.AnnotationContainerTools;
@@ -32,7 +32,7 @@
* @author Dmitry Geraskov
*
*/
-public class TypeDefsAnnotationImpl extends SourceAnnotation<Member> implements
+public class TypeDefsAnnotationImpl extends SourceAnnotation<AnnotatedElement>
implements
TypeDefsAnnotation {
public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new
SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME);
@@ -40,7 +40,7 @@
private final Vector<TypeDefAnnotation> typeDefs = new
Vector<TypeDefAnnotation>();
- public TypeDefsAnnotationImpl(JavaResourceNode parent, Member member) {
+ public TypeDefsAnnotationImpl(JavaResourceNode parent, AnnotatedElement member) {
super(parent, member, DECLARATION_ANNOTATION_ADAPTER);
}
@@ -152,8 +152,8 @@
super();
}
- public Annotation buildAnnotation(JavaResourceAnnotatedElement parent,
org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement member) {
- return new TypeDefsAnnotationImpl(parent, (Member) member);
+ public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement
member) {
+ return new TypeDefsAnnotationImpl(parent, member);
}
public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) {