Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Taal2011-05-16 06:51:09 +0000
committerMartin Taal2011-05-16 06:51:09 +0000
commit1f79c21019edb7d3fef642a80539af7bd8caa658 (patch)
tree639cf4b3c775c56b00fca4111c5ad203fcd472a0 /plugins/org.eclipse.emf.cdo.server.hibernate
parentf8bd167da591f80f2ecf29feea86d72da93335fd (diff)
downloadcdo-1f79c21019edb7d3fef642a80539af7bd8caa658.tar.gz
cdo-1f79c21019edb7d3fef642a80539af7bd8caa658.tar.xz
cdo-1f79c21019edb7d3fef642a80539af7bd8caa658.zip
Make use of standard getSourceCandidates api, remove unnecessary code
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.hibernate')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java58
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java7
2 files changed, 3 insertions, 62 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
index 1035c69aa5..1554bc5d48 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
@@ -12,9 +12,7 @@
package org.eclipse.emf.cdo.server.internal.hibernate;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.internal.server.XRefsQueryHandler;
import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext;
import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
@@ -26,10 +24,7 @@ import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
import org.eclipse.net4j.util.om.trace.ContextTracer;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.hibernate.Criteria;
@@ -44,7 +39,6 @@ import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -150,8 +144,6 @@ public class HibernatePackageHandler extends Lifecycle
private boolean doDropSchema;
- private Map<EClass, Map<EClass, List<EReference>>> sourceCandidates = new HashMap<EClass, Map<EClass, List<EReference>>>();
-
/**
* TODO Necessary to pass/store/dump the properties from the store?
*/
@@ -209,7 +201,6 @@ public class HibernatePackageHandler extends Lifecycle
{
reset();
hibernateStore.reInitialize();
- sourceCandidates = null;
}
}
@@ -219,55 +210,6 @@ public class HibernatePackageHandler extends Lifecycle
return packageUnits;
}
- public Map<EClass, List<EReference>> getSourceCandidates(EClass targetEClass)
- {
- if (sourceCandidates == null)
- {
- computeSourceCandidates();
- }
-
- final Map<EClass, List<EReference>> sourceCandidateList = sourceCandidates.get(targetEClass);
- if (sourceCandidateList == null)
- {
- return new HashMap<EClass, List<EReference>>();
- }
-
- return sourceCandidateList;
- }
-
- private synchronized void computeSourceCandidates()
- {
- if (sourceCandidates != null)
- {
- return;
- }
-
- sourceCandidates = new HashMap<EClass, Map<EClass, List<EReference>>>();
-
- for (EPackage ePackage : getEPackages())
- {
- for (EClassifier eClassifier : ePackage.getEClassifiers())
- {
- if (eClassifier instanceof EClass)
- {
- sourceCandidates.put((EClass)eClassifier, computeSourceCandidatesByEClass((EClass)eClassifier));
- }
- }
- }
- }
-
- private Map<EClass, List<EReference>> computeSourceCandidatesByEClass(EClass targetType)
- {
- final Map<EClass, List<EReference>> localSourceCandidates = new HashMap<EClass, List<EReference>>();
- final Collection<EClass> targetTypes = Collections.singletonList(targetType);
- for (CDOPackageInfo packageInfo : hibernateStore.getRepository().getPackageRegistry(false).getPackageInfos())
- {
- XRefsQueryHandler.collectSourceCandidates(packageInfo, targetTypes, localSourceCandidates);
- }
-
- return localSourceCandidates;
- }
-
public EPackage[] loadPackageUnit(InternalCDOPackageUnit packageUnit)
{
final String nsUri = packageUnit.getTopLevelPackageInfo().getPackageURI();
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index e2b8ca9a70..9461df8ced 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -535,12 +535,11 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
final CDORevision revision = HibernateUtil.getInstance().getCDORevision(targetCdoId);
final EClass targetEClass = context.getTargetObjects().get(targetCdoId);
final String targetEntityName = getStore().getEntityName(targetEClass);
- final Map<EClass, List<EReference>> sourceReferences = getStore().getPackageHandler().getSourceCandidates(
- targetEClass);
- for (EClass sourceEClass : sourceReferences.keySet())
+ final Map<EClass, List<EReference>> sourceCandidates = context.getSourceCandidates();
+ for (EClass sourceEClass : sourceCandidates.keySet())
{
final String sourceEntityName = getStore().getEntityName(sourceEClass);
- for (EReference eref : sourceReferences.get(sourceEClass))
+ for (EReference eref : sourceCandidates.get(sourceEClass))
{
final String hql;
if (eref.isMany())

Back to the top