Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authortle2007-05-08 22:44:47 +0000
committertle2007-05-08 22:44:47 +0000
commitc4b6d710d6ac8cc29d7ee67b7e2c0cf52a250dcc (patch)
tree4c28b3d3a3c8da6924175d248d08213bf7d05223 /jpa
parent79075e6b8703b48bf29da82d090236ec09614c94 (diff)
downloadwebtools.dali-c4b6d710d6ac8cc29d7ee67b7e2c0cf52a250dcc.tar.gz
webtools.dali-c4b6d710d6ac8cc29d7ee67b7e2c0cf52a250dcc.tar.xz
webtools.dali-c4b6d710d6ac8cc29d7ee67b7e2c0cf52a250dcc.zip
Added accessor to the Persistence Unit.
Diffstat (limited to 'jpa')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/PersistenceUnitContext.java10
4 files changed, 79 insertions, 1 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java
index 95df73fa83..5aca5d495c 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaPlatform.java
@@ -15,6 +15,7 @@ import java.util.List;
import org.eclipse.jpt.core.internal.content.java.IJavaAttributeMapping;
import org.eclipse.jpt.core.internal.content.java.IJavaTypeMapping;
+import org.eclipse.jpt.core.internal.content.persistence.PersistenceUnit;
import org.eclipse.jpt.core.internal.platform.IContext;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -55,6 +56,17 @@ public interface IJpaPlatform
*/
void setProject(IJpaProject jpaProject);
+ // ********** Persistence Unit **********
+
+ boolean containsPersistenceUnitNamed(String name);
+
+ PersistenceUnit persistenceUnitNamed(String name);
+
+ Iterator<PersistenceUnit> persistenceUnits();
+
+ int persistenceUnitSize();
+
+ // **********
/**
* Get the valid persistence XML files from the project
*/
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java
index ede0e25ac1..367e29bce5 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaPlatform.java
@@ -14,7 +14,6 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.resources.IFile;
import org.eclipse.jpt.core.internal.IJpaFile;
import org.eclipse.jpt.core.internal.IJpaFileContentProvider;
import org.eclipse.jpt.core.internal.IJpaPlatform;
@@ -39,6 +38,7 @@ import org.eclipse.jpt.core.internal.content.java.mappings.JavaOneToOne;
import org.eclipse.jpt.core.internal.content.java.mappings.JavaTransient;
import org.eclipse.jpt.core.internal.content.java.mappings.JavaVersion;
import org.eclipse.jpt.core.internal.content.orm.OrmXmlJpaFileContentProvider;
+import org.eclipse.jpt.core.internal.content.persistence.PersistenceUnit;
import org.eclipse.jpt.core.internal.content.persistence.PersistenceXmlJpaFileContentProvider;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
@@ -88,6 +88,26 @@ public abstract class BaseJpaPlatform implements IJpaPlatform
public void setProject(IJpaProject jpaProject) {
this.project = jpaProject;
}
+
+ // ********** Persistence Unit **********
+
+ public boolean containsPersistenceUnitNamed(String name) {
+ return ((BaseJpaProjectContext)this.context).containsPersistenceUnitNamed(name);
+ }
+
+ public PersistenceUnit persistenceUnitNamed(String name) {
+ return ((BaseJpaProjectContext)this.context).persistenceUnitNamed(name);
+ }
+
+ public Iterator<PersistenceUnit> persistenceUnits() {
+ return ((BaseJpaProjectContext)this.context).persistenceUnits();
+ }
+
+ public int persistenceUnitSize() {
+ return ((BaseJpaProjectContext)this.context).persistenceUnitContextsSize();
+ }
+
+ // **********
public Collection<IJpaFileContentProvider> jpaFileContentProviders() {
if (this.contentProviders == null) {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java
index 65f9023326..bdf3988906 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/BaseJpaProjectContext.java
@@ -34,6 +34,8 @@ import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.db.internal.Connection;
import org.eclipse.jpt.db.internal.ConnectionProfile;
+import org.eclipse.jpt.utility.internal.StringTools;
+import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
/**
@@ -198,6 +200,36 @@ public class BaseJpaProjectContext extends BaseContext
}
return false;
}
+
+ private Iterator<PersistenceUnitContext> persistenceUnitContexts() {
+ return this.persistenceUnitContexts.iterator();
+ }
+
+ int persistenceUnitContextsSize() {
+ return this.persistenceUnitContexts.size();
+ }
+
+ Iterator<PersistenceUnit> persistenceUnits() {
+ return new TransformationIterator<PersistenceUnitContext, PersistenceUnit>(this.persistenceUnitContexts()) {
+ @Override
+ protected PersistenceUnit transform(PersistenceUnitContext next) {
+ return next.persistenceUnit();
+ }
+ };
+ }
+
+ public boolean containsPersistenceUnitNamed(String name) {
+ return this.persistenceUnitNamed(name) != null;
+ }
+
+ PersistenceUnit persistenceUnitNamed(String name) {
+ for (PersistenceUnitContext context : this.persistenceUnitContexts) {
+ if( context.persistenceUnit().getName().equals(name)) {
+ return context.persistenceUnit();
+ }
+ }
+ return null;
+ }
// public IGeneratorRepository generatorRepository(IPersistentType persistentType) {
// for (PersistenceUnitContext context : this.persistenceUnitContexts) {
@@ -352,4 +384,8 @@ public class BaseJpaProjectContext extends BaseContext
}
}
}
+
+ public String toString() {
+ return StringTools.buildToStringFor( this, this.project.getJavaProject().getProject().getName());
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/PersistenceUnitContext.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/PersistenceUnitContext.java
index 0923a92de4..366ca4d58b 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/PersistenceUnitContext.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/platform/PersistenceUnitContext.java
@@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+
import org.eclipse.jdt.core.IType;
import org.eclipse.jem.java.JavaClass;
import org.eclipse.jpt.core.internal.AccessType;
@@ -33,6 +34,7 @@ import org.eclipse.jpt.core.internal.validation.IJpaValidationMessages;
import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.HashBag;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
@@ -209,6 +211,10 @@ public class PersistenceUnitContext extends BaseContext
return this.persistenceUnit.getJpaProject();
}
+ PersistenceUnit persistenceUnit() {
+ return this.persistenceUnit;
+ }
+
public void refreshDefaults(DefaultsContext parentDefaults) {
super.refreshDefaults(parentDefaults);
for (JavaTypeContext context : this.duplicateJavaPersistentTypes) {
@@ -523,4 +529,8 @@ public class PersistenceUnitContext extends BaseContext
}
}
}
+
+ public String toString() {
+ return StringTools.buildToStringFor( this, this.persistenceUnit.getName());
+ }
}

Back to the top