Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-10-18 09:50:51 -0400
committerEike Stepper2008-10-18 09:50:51 -0400
commit51e3f0c7a5b272b7ee8e0e90bc05475b69399df0 (patch)
tree07cfcc38addad01fa0d91d4d9f219020102e5d7b
parent1cb3eb34332142be96d8f24fa248058663fc2dd4 (diff)
downloadcdo-51e3f0c7a5b272b7ee8e0e90bc05475b69399df0.tar.gz
cdo-51e3f0c7a5b272b7ee8e0e90bc05475b69399df0.tar.xz
cdo-51e3f0c7a5b272b7ee8e0e90bc05475b69399df0.zip
[249847] Store resources in a hierarchical structure
https://bugs.eclipse.org/bugs/show_bug.cgi?id=249847
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java28
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java27
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java12
6 files changed, 70 insertions, 22 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
index 7c77284e4f..397e0559d1 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionImpl.java
@@ -73,6 +73,16 @@ public class CDORevisionImpl implements InternalCDORevision
public CDORevisionImpl(CDOClass cdoClass, CDOID id)
{
+ if (cdoClass.isAbstract())
+ {
+ throw new IllegalArgumentException("CDOClass is abstract: " + cdoClass);
+ }
+
+ if (id == null || id.isNull())
+ {
+ throw new IllegalArgumentException("CDIID is null");
+ }
+
this.cdoClass = cdoClass;
this.id = id;
version = 0;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java
index 9efa80867d..0342bb3af3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassServerInfo.java
@@ -27,7 +27,7 @@ public final class ClassServerInfo extends ServerInfo
public static final int CDO_RESOURCE_NODE_CLASS_DBID = -3;
- public static final int CDO_RESOURCE_FOLDERCLASS_DBID = -4;
+ public static final int CDO_RESOURCE_FOLDER_CLASS_DBID = -4;
private IClassMapping classMapping;
@@ -72,17 +72,18 @@ public final class ClassServerInfo extends ServerInfo
{
serverInfo = setDBID(cdoClass, CDO_OBJECT_CLASS_DBID);
}
- else if (cdoClass.isResourceNode())
+ else if (cdoClass.isResource())
{
- serverInfo = setDBID(cdoClass, CDO_RESOURCE_NODE_CLASS_DBID);
+ serverInfo = setDBID(cdoClass, CDO_RESOURCE_CLASS_DBID);
}
else if (cdoClass.isResourceFolder())
{
- serverInfo = setDBID(cdoClass, CDO_RESOURCE_FOLDERCLASS_DBID);
+ serverInfo = setDBID(cdoClass, CDO_RESOURCE_FOLDER_CLASS_DBID);
}
- else if (cdoClass.isResource())
+ else if (cdoClass.isResourceNode())
{
- serverInfo = setDBID(cdoClass, CDO_RESOURCE_CLASS_DBID);
+ // Important to check the abstract class *after* the concrete ones!
+ serverInfo = setDBID(cdoClass, CDO_RESOURCE_NODE_CLASS_DBID);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
index aa62d0f497..ab33e3a74f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
@@ -127,7 +127,7 @@ public abstract class MappingStrategy extends Lifecycle implements IMappingStrat
break;
}
- case ClassServerInfo.CDO_RESOURCE_FOLDERCLASS_DBID:
+ case ClassServerInfo.CDO_RESOURCE_FOLDER_CLASS_DBID:
{
CDOResourcePackage resourcePackage = getStore().getRepository().getPackageManager().getCDOResourcePackage();
classRef = resourcePackage.getCDOResourceFolderClass().createClassRef();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index c5888ccaac..5c4b21981f 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.internal.ui.dialogs.RollbackTransactionDialog;
import org.eclipse.emf.cdo.ui.CDOEventHandler;
import org.eclipse.emf.cdo.ui.CDOLabelProvider;
import org.eclipse.emf.cdo.util.CDOURIUtil;
+import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.internal.cdo.CDOLegacyWrapper;
import org.eclipse.emf.internal.cdo.CDOStateMachine;
@@ -85,7 +86,6 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
@@ -1330,7 +1330,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* This accesses a cached version of the content outliner. <!-- begin-user-doc --> <!-- end-user-doc -->
*
- * @generated
+ * @generated NOT
*/
public IContentOutlinePage getContentOutlinePage()
{
@@ -1357,12 +1357,12 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
//
createContextMenuFor(contentOutlineViewer);
- if (!editingDomain.getResourceSet().getResources().isEmpty())
+ if (!CDOUtil.getResources(editingDomain.getResourceSet()).isEmpty())
{
// Select the root object in the view.
//
- contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources()
- .get(0)), true);
+ contentOutlineViewer.setSelection(new StructuredSelection(CDOUtil.getResources(
+ editingDomain.getResourceSet()).get(0)), true);
}
}
@@ -1569,7 +1569,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
// Save the resources to the file system.
//
boolean first = true;
- for (Resource resource : editingDomain.getResourceSet().getResources())
+ for (Resource resource : CDOUtil.getResources(editingDomain.getResourceSet()))
{
if ((first || !resource.getContents().isEmpty() || isPersisted(resource))
&& !editingDomain.isReadOnly(resource))
@@ -1700,16 +1700,18 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
- * @generated
+ * @generated NOT
*/
protected void doSaveAs(URI uri, IEditorInput editorInput)
{
- editingDomain.getResourceSet().getResources().get(0).setURI(uri);
- setInputWithNotify(editorInput);
- setPartName(editorInput.getName());
- IProgressMonitor progressMonitor = getActionBars().getStatusLineManager() != null ? getActionBars()
- .getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
- doSave(progressMonitor);
+ throw new UnsupportedOperationException();
+
+ // CDOUtil.getResources(editingDomain.getResourceSet()).get(0).setURI(uri);
+ // setInputWithNotify(editorInput);
+ // setPartName(editorInput.getName());
+ // IProgressMonitor progressMonitor = getActionBars().getStatusLineManager() != null ? getActionBars()
+ // .getStatusLineManager().getProgressMonitor() : new NullProgressMonitor();
+ // doSave(progressMonitor);
}
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
index 2811efd78f..e7291133c9 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.CDOViewSet;
import org.eclipse.emf.cdo.CDOXATransaction;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.internal.cdo.CDOCollectionLoadingPolicyImpl;
import org.eclipse.emf.internal.cdo.CDORevisionPrefetchingPolicyImpl;
@@ -34,6 +35,7 @@ import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
@@ -46,6 +48,7 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import java.util.Iterator;
@@ -273,4 +276,28 @@ public final class CDOUtil
{
return FSMUtil.adaptMeta(object, view);
}
+
+ /**
+ * @since 2.0
+ */
+ public static EList<Resource> getResources(ResourceSet resourceSet)
+ {
+ EList<Resource> result = new BasicEList<Resource>();
+ EList<Resource> resources = resourceSet.getResources();
+ for (Resource resource : resources)
+ {
+ if (resource instanceof CDOResource)
+ {
+ CDOResource cdoResource = (CDOResource)resource;
+ if (cdoResource.isRoot())
+ {
+ continue;
+ }
+ }
+
+ result.add(resource);
+ }
+
+ return result;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 5c683fcb57..ab86ac3b6f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -453,12 +453,20 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement
List<CDOID> ids = resourceQuery.getResult(CDOID.class);
if (ids.isEmpty())
{
- throw new CDOException("No top level ResourceNode with the name " + name);
+ if (name == null)
+ {
+ throw new CDOException("No root ResourceNode");
+ }
+ else
+ {
+ throw new CDOException("No top level ResourceNode with the name " + name);
+ }
}
if (ids.size() > 1)
{
- throw new ImplementationError("Duplicate root ResourceNodes");
+ // TODO is this still needed since the is resourceQuery.setMaxResults(1) ??
+ throw new ImplementationError("Duplicate top-level ResourceNodes");
}
return ids.get(0);

Back to the top