Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2010-11-16 20:02:23 -0500
committerpfullbright2010-11-16 20:02:23 -0500
commitd70598dc561fe6fac9dd828943ef0f214781b40c (patch)
tree443fa56a10e7d26623473323423c43180f45a75d
parent5818fd11a326e6a2f48abcb1626cf9c9dd56fe20 (diff)
downloadwebtools.dali-d70598dc561fe6fac9dd828943ef0f214781b40c.tar.gz
webtools.dali-d70598dc561fe6fac9dd828943ef0f214781b40c.tar.xz
webtools.dali-d70598dc561fe6fac9dd828943ef0f214781b40c.zip
added basic persistent class construction/update
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java4
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java15
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentClass.java (renamed from jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java)6
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRootContextNode.java14
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java7
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java51
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericRootContextNode.java188
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java35
8 files changed, 217 insertions, 103 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java
index 3bbafecc5f..d274d072a4 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbFactory.java
@@ -18,12 +18,14 @@ import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
import org.eclipse.jpt.jaxb.core.context.XmlNs;
import org.eclipse.jpt.jaxb.core.context.XmlSchema;
import org.eclipse.jpt.jaxb.core.context.XmlSchemaType;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlNsAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation;
@@ -93,6 +95,8 @@ public interface JaxbFactory {
JaxbPackageInfo buildJavaPackageInfo(JaxbPackage parent, JavaResourcePackage resourcePackage);
+ JaxbPersistentClass buildPersistentClass(JaxbRootContextNode parent, JavaResourceType resourceType);
+
XmlSchema buildJavaXmlSchema(JaxbPackageInfo parent);
XmlSchemaType buildJavaXmlSchemaType(JaxbContextNode parent, XmlSchemaTypeAnnotation xmlSchemaTypeAnnotation);
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java
index 588cc77009..fef5860eb7 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/JaxbProject.java
@@ -169,9 +169,20 @@ public interface JaxbProject
// JavaResourcePackageFragmentRoot getJavaResourcePackageFragmentRoot(String jarFileName);
/**
- * Return the names of the JAXB project's annotated Java classes
+ * Return all {@link JavaResourceType}s that are represented by java source within this project
*/
- Iterable<String> getAnnotatedJavaSourceClassNames();
+ Iterable<JavaResourceType> getJavaSourceResourceTypes();
+
+ /**
+ * Return all {@link JavaResourceType}s that are represented by java source within this project,
+ * that are also annotated with a recognized annotation (and are persistable)
+ */
+ Iterable<JavaResourceType> getAnnotatedJavaSourceResourceTypes();
+
+// /**
+// * Return the names of the JAXB project's annotated Java classes
+// */
+// Iterable<String> getAnnotatedJavaSourceClassNames();
/**
* Return the Java resource persistent type for the specified type.
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentClass.java
index 8a0cdf5e5b..06c6e13de5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbType.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbPersistentClass.java
@@ -10,8 +10,8 @@
package org.eclipse.jpt.jaxb.core.context;
/**
- * Represents a java class (/enum/interface) of note. The actual variety of class is indicated by
- * the "mapping" (e.g. @XmlType, @XmlRegistry ...) field.
+ * Represents a JAXB persistent class.
+ * (A class with either an explicit or implicit @XmlType annotation)
* <p>
* Provisional API: This interface is part of an interim API that is still
* under development and expected to change significantly before reaching
@@ -22,7 +22,7 @@ package org.eclipse.jpt.jaxb.core.context;
* @version 3.0
* @since 3.0
*/
-public interface JaxbType
+public interface JaxbPersistentClass
extends JaxbContextNode {
/**
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRootContextNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRootContextNode.java
index a0387ee10e..b4979f0753 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRootContextNode.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/context/JaxbRootContextNode.java
@@ -33,13 +33,13 @@ public interface JaxbRootContextNode
int getPackagesSize();
-// /**
-// * The set of classes. These may be explicitly or implicitly included.
-// */
-// Iterable<JaxbType> getClasses();
-// public final static String CLASSES_COLLECTION = "classes"; //$NON-NLS-1$
-//
-// int getClassesSize();
+ /**
+ * The set of persistent classes. These may be explicitly or implicitly included.
+ */
+ Iterable<JaxbPersistentClass> getPersistentClasses();
+ public final static String PERSISTENT_CLASSES_COLLECTION = "persistentClasses"; //$NON-NLS-1$
+
+ int getPersistentClassesSize();
// // ********** validation **********
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
index 80b79aa4c1..7e1f360c4e 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbFactory.java
@@ -19,6 +19,7 @@ import org.eclipse.jpt.jaxb.core.JaxbProject.Config;
import org.eclipse.jpt.jaxb.core.context.JaxbContextNode;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
import org.eclipse.jpt.jaxb.core.context.JaxbPackageInfo;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
import org.eclipse.jpt.jaxb.core.context.XmlJavaTypeAdapter;
import org.eclipse.jpt.jaxb.core.context.XmlNs;
@@ -27,11 +28,13 @@ import org.eclipse.jpt.jaxb.core.context.XmlSchemaType;
import org.eclipse.jpt.jaxb.core.internal.context.GenericPackage;
import org.eclipse.jpt.jaxb.core.internal.context.GenericRootContextNode;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPackageInfo;
+import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaPersistentClass;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlJavaTypeAdapter;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlNs;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlSchema;
import org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlSchemaType;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.jaxb.core.resource.java.XmlJavaTypeAdapterAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlNsAnnotation;
import org.eclipse.jpt.jaxb.core.resource.java.XmlSchemaTypeAnnotation;
@@ -76,6 +79,10 @@ public abstract class AbstractJaxbFactory
return new GenericJavaPackageInfo(parent, resourcePackage);
}
+ public JaxbPersistentClass buildPersistentClass(JaxbRootContextNode parent, JavaResourceType resourceType) {
+ return new GenericJavaPersistentClass(parent, resourceType);
+ }
+
public XmlSchema buildJavaXmlSchema(JaxbPackageInfo parent) {
return new GenericJavaXmlSchema(parent);
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
index 1b7eccca4d..a59486c078 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/AbstractJaxbProject.java
@@ -563,42 +563,39 @@ public abstract class AbstractJaxbProject
// ********** annotated Java source classes **********
- public Iterable<String> getAnnotatedJavaSourceClassNames() {
- return new TransformationIterable<JavaResourceType, String>(this.getInternalAnnotatedSourceJavaResourceTypes()) {
- @Override
- protected String transform(JavaResourceType type) {
- return type.getQualifiedName();
- }
- };
+ /**
+ * Return all {@link JavaResourceType}s that are represented by java source within this project
+ */
+ public Iterable<JavaResourceType> getJavaSourceResourceTypes() {
+ return new CompositeIterable<JavaResourceType>(this.getInternalJavaSourceResourceTypeSets());
}
-
+
/**
- * return only those valid annotated Java resource persistent types that are part of the
- * JPA project, ignoring those in JARs referenced in persistence.xml
- * @see org.eclipse.jpt.core.internal.utility.jdt.JPTTools#typeIsPersistable(org.eclipse.jpt.core.internal.utility.jdt.JPTTools.TypeAdapter)
+ * Return all {@link JavaResourceType}s that are represented by java source within this project,
+ * that are also annotated (and persistable) with a recognized annotation
*/
- protected Iterable<JavaResourceType> getInternalAnnotatedSourceJavaResourceTypes() {
- return new FilteringIterable<JavaResourceType>(this.getInternalSourceJavaResourcePTypes()) {
+ public Iterable<JavaResourceType> getAnnotatedJavaSourceResourceTypes() {
+ return new FilteringIterable<JavaResourceType>(getJavaSourceResourceTypes()) {
@Override
protected boolean accept(JavaResourceType type) {
return type.isPersistable() && type.isAnnotated(); // i.e. the type is valid and has a valid type annotation
}
};
}
-
- /**
- * return only those Java resource persistent types that are
- * part of the JPA project, ignoring those in JARs referenced in persistence.xml
- */
- protected Iterable<JavaResourceType> getInternalSourceJavaResourcePTypes() {
- return new CompositeIterable<JavaResourceType>(this.getInternalSourceJavaResourceTypeSets());
- }
-
- /**
- * return only those Java resource persistent types that are
- * part of the JPA project, ignoring those in JARs referenced in persistence.xml
+
+// public Iterable<String> getAnnotatedJavaSourceClassNames() {
+// return new TransformationIterable<JavaResourceType, String>(this.getInternalAnnotatedSourceJavaResourceTypes()) {
+// @Override
+// protected String transform(JavaResourceType type) {
+// return type.getQualifiedName();
+// }
+// };
+// }
+
+ /*
+ * Return the sets of {@link JavaResourceType}s that are represented by java source within this project
*/
- protected Iterable<Iterable<JavaResourceType>> getInternalSourceJavaResourceTypeSets() {
+ protected Iterable<Iterable<JavaResourceType>> getInternalJavaSourceResourceTypeSets() {
return new TransformationIterable<JavaResourceCompilationUnit, Iterable<JavaResourceType>>(this.getInternalJavaResourceCompilationUnits()) {
@Override
protected Iterable<JavaResourceType> transform(JavaResourceCompilationUnit compilationUnit) {
@@ -606,7 +603,7 @@ public abstract class AbstractJaxbProject
}
};
}
-
+
protected Iterable<JavaResourceCompilationUnit> getInternalJavaResourceCompilationUnits() {
return new TransformationIterable<JaxbFile, JavaResourceCompilationUnit>(this.getJavaSourceJaxbFiles()) {
@Override
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericRootContextNode.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericRootContextNode.java
index af06609c30..e34ec95878 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericRootContextNode.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/GenericRootContextNode.java
@@ -10,17 +10,20 @@
package org.eclipse.jpt.jaxb.core.internal.context;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.context.JaxbPackage;
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
+import org.eclipse.jpt.jaxb.core.resource.java.JAXB;
import org.eclipse.jpt.jaxb.core.resource.java.JavaResourcePackage;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
import org.eclipse.jpt.utility.internal.ClassName;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
@@ -37,8 +40,8 @@ public class GenericRootContextNode
/* The map of package name to JaxbPackage objects */
protected final Map<String, JaxbPackage> packages;
-// /* The map of class name to JaxbType objects */
-// protected final Map<String, JaxbType> classes;
+ /* The map of class name to JaxbPersistentClass objects */
+ protected final Map<String, JaxbPersistentClass> persistentClasses;
public GenericRootContextNode(JaxbProject jaxbProject) {
@@ -48,7 +51,8 @@ public class GenericRootContextNode
}
this.jaxbProject = jaxbProject;
this.packages = new HashMap<String, JaxbPackage>();
-// this.classes = new HashMap<String, JaxbType>();
+ this.persistentClasses = new HashMap<String, JaxbPersistentClass>();
+ initialize();
}
@@ -57,53 +61,84 @@ public class GenericRootContextNode
return false;
}
+ protected void initialize() {
+ // determine initial set of persistent classes
+ // (persistent classes that can be determined purely by resource model)
+ final Set<String> initialPersistentClasses = calculateInitialPersistentClasses();
+
+ // determine initial set of packages
+ final Set<String> initialPackages = calculateInitialPackages(initialPersistentClasses);
+
+ final Set<String> packagesToBuild = CollectionTools.set(initialPackages);
+ final Set<String> persistentClassesToBuild = CollectionTools.set(initialPersistentClasses);
+
+ for (String packageToBuild : packagesToBuild) {
+ this.packages.put(packageToBuild, buildPackage(packageToBuild));
+ }
+
+ for (String classToBuild : persistentClassesToBuild) {
+ this.persistentClasses.put(classToBuild, buildPersistentClass(classToBuild));
+ }
+ }
+
public void synchronizeWithResourceModel() {
for (JaxbPackage each : getPackages()) {
each.synchronizeWithResourceModel();
}
-// for (JaxbType each : getClasses()) {
-// each.synchronizeWithResourceModel();
-// }
+ for (JaxbPersistentClass each : getPersistentClasses()) {
+ each.synchronizeWithResourceModel();
+ }
}
public void update() {
- final Set<String> explicitJaxbContextPackageNames = calculateExplicitJaxbContextPackageNames();
- final Set<String> explicitJaxbContextClassNames = calculateExplicitJaxbContextClassNames();
- final Set<String> implicitJaxbContextClassNames = new HashSet<String>();
+ // determine initial set of persistent classes
+ // (persistent classes that can be determined purely by resource model)
+ final Set<String> initialPersistentClasses = calculateInitialPersistentClasses();
- for (String packageName : explicitJaxbContextPackageNames) {
- if (! this.packages.containsKey(packageName)) {
- addPackage(buildPackage(packageName));
+ // determine initial set of packages
+ final Set<String> initialPackages = calculateInitialPackages(initialPersistentClasses);
+
+ final Set<String> packagesToBuild = CollectionTools.set(initialPackages);
+ final Set<String> packagesToUpdate = CollectionTools.<String>set();
+ final Set<String> persistentClassesToBuild = CollectionTools.set(initialPersistentClasses);
+ final Set<String> persistentClassesToUpdate = CollectionTools.<String>set();
+
+ for (String packageToBuild : packagesToBuild) {
+ if (this.packages.containsKey(packageToBuild)) {
+ packagesToUpdate.add(packageToBuild);
+ }
+ else {
+ this.packages.put(packageToBuild, buildPackage(packageToBuild));
}
}
- for (String className : explicitJaxbContextClassNames) {
- String packageName = ClassName.getPackageName(className);
- if (! this.packages.containsKey(packageName)) {
- addPackage(buildPackage(packageName));
+ for (String classToBuild : persistentClassesToBuild) {
+ if (this.persistentClasses.containsKey(classToBuild)) {
+ persistentClassesToUpdate.add(classToBuild);
+ }
+ else {
+ this.persistentClasses.put(classToBuild, buildPersistentClass(classToBuild));
}
-// if (! this.classes.containsKey(className)) {
-// addClass(buildClass(className));
-// }
}
- for (JaxbPackage each : getPackages()) {
- each.update();
+ for (String packageToUpdate : packagesToUpdate) {
+ this.packages.get(packageToUpdate).update();
}
-// for (JaxbType each : getClasses()) {
-// each.update();
-// }
-
- for (JaxbPackage each : getPackages()) {
- if (isEmpty(each)) {
- removePackage(each);
- }
+ for (String classToUpdate : persistentClassesToUpdate) {
+ this.persistentClasses.get(classToUpdate).update();
}
}
- protected Set<String> calculateExplicitJaxbContextPackageNames() {
- return CollectionTools.set(
+ /*
+ * calculate set of packages that can be determined purely by resource model and the given
+ * set of classes.
+ * This should include:
+ * - any annotated package
+ * - any package containing an included class
+ */
+ protected Set<String> calculateInitialPackages(final Set<String> initialClasses) {
+ final Set<String> packages = CollectionTools.set(
new TransformationIterable<JavaResourcePackage, String>(
getJaxbProject().getAnnotatedJavaResourcePackages()) {
@Override
@@ -111,10 +146,31 @@ public class GenericRootContextNode
return o.getName();
}
});
+ for (String className : initialClasses) {
+ packages.add(ClassName.getPackageName(className));
+ }
+ return packages;
}
- protected Set<String> calculateExplicitJaxbContextClassNames() {
- return new HashSet<String>();
+ /*
+ * calculate set of persistent classes that can be determined purely by resource model
+ * (so far, this should be all persistentClasses with the @XmlType annotation)
+ */
+ protected Set<String> calculateInitialPersistentClasses() {
+ return CollectionTools.set(
+ new TransformationIterable<JavaResourceType, String>(
+ new FilteringIterable<JavaResourceType>(
+ getJaxbProject().getJavaSourceResourceTypes()) {
+ @Override
+ protected boolean accept(JavaResourceType o) {
+ return o.getAnnotation(JAXB.XML_TYPE) != null;
+ }
+ }) {
+ @Override
+ protected String transform(JavaResourceType o) {
+ return o.getName();
+ }
+ });
}
@@ -171,34 +227,38 @@ public class GenericRootContextNode
}
- // ************* classes ***************
-
-// public Iterable<JaxbType> getClasses() {
-// return new LiveCloneIterable<JaxbType>(this.classes.values());
-// }
-//
-// public int getClassesSize() {
-// return this.classes.size();
-// }
-//
-// protected JaxbType addClass(JaxbType jaxbClass) {
-// if (this.classes.containsKey(jaxbClass.getName())) {
-// throw new IllegalArgumentException("Class with that name already exists.");
-// }
-// this.classes.put(jaxbClass.getName(), jaxbClass);
-// fireItemAdded(CLASSES_COLLECTION, jaxbClass);
-// return jaxbClass;
-// }
-//
-// protected void removeClass(JaxbType jaxbClass) {
-// if (! this.classes.containsKey(jaxbClass.getName())) {
-// throw new IllegalArgumentException("No class with that name exists.");
-// }
-// this.classes.remove(jaxbClass.getName());
-// fireItemRemoved(CLASSES_COLLECTION, jaxbClass);
-// }
-//
-// protected JaxbType buildClass(String className) {
-// return this.getFactory().buildClass(this, className);
-// }
+ // ************* persistentClasses ***************
+
+ public Iterable<JaxbPersistentClass> getPersistentClasses() {
+ return new LiveCloneIterable<JaxbPersistentClass>(this.persistentClasses.values());
+ }
+
+ public int getPersistentClassesSize() {
+ return this.persistentClasses.size();
+ }
+
+ protected JaxbPersistentClass addPersistentClass(JaxbPersistentClass persistentClass) {
+ if (this.persistentClasses.containsKey(persistentClass.getName())) {
+ throw new IllegalArgumentException("Class with that name already exists.");
+ }
+ this.persistentClasses.put(persistentClass.getName(), persistentClass);
+ fireItemAdded(PERSISTENT_CLASSES_COLLECTION, persistentClass);
+ return persistentClass;
+ }
+
+ protected void removePersistentClass(JaxbPersistentClass persistentClass) {
+ if (! this.persistentClasses.containsKey(persistentClass.getName())) {
+ throw new IllegalArgumentException("No class with that name exists.");
+ }
+ this.persistentClasses.remove(persistentClass.getName());
+ fireItemRemoved(PERSISTENT_CLASSES_COLLECTION, persistentClass);
+ }
+
+ protected JaxbPersistentClass buildPersistentClass(String className) {
+ JavaResourceType resourceType = getJaxbProject().getJavaResourceType(className);
+ if (resourceType == null) {
+ throw new IllegalArgumentException("No resource type exists for class named " + className);
+ }
+ return this.getFactory().buildPersistentClass(this, resourceType);
+ }
}
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java
new file mode 100644
index 0000000000..1be0fd9ca2
--- /dev/null
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/context/java/GenericJavaPersistentClass.java
@@ -0,0 +1,35 @@
+package org.eclipse.jpt.jaxb.core.internal.context.java;
+
+import org.eclipse.jpt.jaxb.core.context.JaxbPersistentClass;
+import org.eclipse.jpt.jaxb.core.context.JaxbRootContextNode;
+import org.eclipse.jpt.jaxb.core.internal.context.AbstractJaxbContextNode;
+import org.eclipse.jpt.jaxb.core.resource.java.JavaResourceType;
+
+
+public class GenericJavaPersistentClass
+ extends AbstractJaxbContextNode
+ implements JaxbPersistentClass {
+
+ protected final JavaResourceType resourceType;
+
+
+ public GenericJavaPersistentClass(JaxbRootContextNode parent, JavaResourceType resourceType) {
+ super(parent);
+ this.resourceType = resourceType;
+ }
+
+
+ // ********** synchronize/update **********
+
+ public void synchronizeWithResourceModel() {
+ }
+
+ public void update() {
+ }
+
+ // ********** JaxbPersistentClass impl **********
+
+ public String getName() {
+ return this.resourceType.getName();
+ }
+}

Back to the top