Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2014-05-26 15:36:42 +0000
committerEsteban DUGUEPEROUX2014-08-06 13:56:44 +0000
commit18a888d14cf7a35b26e04e973af4cd5953fd9ce9 (patch)
treebb818d586d182acee470e313c5e5f8a52a44a635 /plugins/org.eclipse.emf.cdo.server
parenta0062f9d3da3a8d449a877e650f116e11d35963b (diff)
downloadcdo-18a888d14cf7a35b26e04e973af4cd5953fd9ce9.tar.gz
cdo-18a888d14cf7a35b26e04e973af4cd5953fd9ce9.tar.xz
cdo-18a888d14cf7a35b26e04e973af4cd5953fd9ce9.zip
[417782] queryXRefs returns no matches where items are set in an
EReference with the EType 'EObject' Update XRefsQueryHandler to support reference to EObject and have system EPackages initialized in DB to avoid NPE on query Bug: 417782 Change-Id: I533339e80a75c2f476626417809c3bd9dd18123f Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server')
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java2
3 files changed, 24 insertions, 10 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index e99a19d4ff..8c059fa02e 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -50,7 +50,6 @@ import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
import org.eclipse.emf.cdo.common.util.RepositoryStateChangedEvent;
import org.eclipse.emf.cdo.common.util.RepositoryTypeChangedEvent;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.etypes.EtypesPackage;
import org.eclipse.emf.cdo.internal.common.model.CDOPackageRegistryImpl;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.IQueryHandler;
@@ -95,6 +94,8 @@ import org.eclipse.emf.cdo.spi.server.InternalTransaction;
import org.eclipse.emf.cdo.spi.server.InternalView;
import org.eclipse.emf.internal.cdo.object.CDOFactoryImpl;
+import org.eclipse.emf.internal.cdo.util.CompletePackageClosure;
+import org.eclipse.emf.internal.cdo.util.IPackageClosure;
import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
import org.eclipse.net4j.util.StringUtil;
@@ -128,6 +129,7 @@ import java.io.OutputStream;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -1851,13 +1853,6 @@ public class Repository extends Container<Object> implements InternalRepository
try
{
List<InternalCDOPackageUnit> list = new ArrayList<InternalCDOPackageUnit>();
- if (firstStart)
- {
- list.add(initPackage(EcorePackage.eINSTANCE));
- list.add(initPackage(EresourcePackage.eINSTANCE));
- list.add(initPackage(EtypesPackage.eINSTANCE));
- }
-
boolean nonSystemPackages = false;
if (initialPackages != null)
{
@@ -1946,6 +1941,7 @@ public class Repository extends Container<Object> implements InternalRepository
};
commitContext.setNewObjects(new InternalCDORevision[] { rootResource });
+ commitContext.setNewPackageUnits(getNewPackageUnitsForRootResource(commitContext.getPackageRegistry()));
commitContext.preWrite();
commitContext.write(new Monitor());
@@ -1963,6 +1959,23 @@ public class Repository extends Container<Object> implements InternalRepository
session.close();
}
+ private InternalCDOPackageUnit[] getNewPackageUnitsForRootResource(
+ InternalCDOPackageRegistry commitContextPackageRegistry)
+ {
+ Collection<InternalCDOPackageUnit> newPackageUnitsForRootResource = new ArrayList<InternalCDOPackageUnit>();
+ IPackageClosure closure = new CompletePackageClosure();
+ Set<EPackage> ePackages = closure.calculate(Collections.<EPackage> singletonList(EresourcePackage.eINSTANCE));
+ for (EPackage ePackage : ePackages)
+ {
+ InternalCDOPackageUnit packageUnit = commitContextPackageRegistry.getPackageUnit(ePackage);
+ if (packageUnit != null)
+ {
+ newPackageUnitsForRootResource.add(packageUnit);
+ }
+ }
+ return newPackageUnitsForRootResource.toArray(new InternalCDOPackageUnit[0]);
+ }
+
protected CDOID createRootResourceID()
{
if (getIDGenerationLocation() == IDGenerationLocation.STORE)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
index 2ff431c8ea..06e3878564 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/XRefsQueryHandler.java
@@ -42,6 +42,7 @@ 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.EcorePackage;
import java.util.ArrayList;
import java.util.Collection;
@@ -182,7 +183,7 @@ public class XRefsQueryHandler implements IQueryHandler
{
for (EClass concreteType : concreteTypes)
{
- if (declaredType.isSuperTypeOf(concreteType))
+ if (declaredType == EcorePackage.Literals.EOBJECT || declaredType.isSuperTypeOf(concreteType))
{
return true;
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java
index 4e75e1795e..dec715ce73 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java
@@ -125,7 +125,7 @@ public abstract class CDOServerExporter<OUT>
protected void exportPackages(OUT out) throws Exception
{
InternalCDOPackageRegistry packageRegistry = repository.getPackageRegistry(false);
- InternalCDOPackageUnit[] packageUnits = packageRegistry.getPackageUnits(false);
+ InternalCDOPackageUnit[] packageUnits = packageRegistry.getPackageUnits(true);
for (InternalCDOPackageUnit packageUnit : packageUnits)
{
String id = packageUnit.getID();

Back to the top