Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-19 08:22:04 +0000
committerEike Stepper2012-07-19 08:22:04 +0000
commit1460904fd3c193ffaf809913b2983a400fce9d94 (patch)
tree72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity
parent5f360965ae87478e0681899bf310a210cafc2c44 (diff)
downloadcdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityFeatureDeltaWriter.java218
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityQueryHandler.java68
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStore.java802
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java3976
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java130
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreConfig.java316
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreFactory.java124
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/bundle/OM.java102
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManager.java48
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerImpl.java108
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java494
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/FdManager.java1138
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClass.java270
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java486
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyCommitInfoHandler.java224
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyConnection.java878
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java3384
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java562
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPackageHandler.java510
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPropertyMapHandler.java252
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySchema.java1014
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyScope.java484
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySession.java368
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BasicTypeMapper.java124
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigDecimalTypeMapper.java196
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigIntegerTypeMapper.java182
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ByteArrayTypeMapper.java364
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataManyTypeMapper.java92
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataTypeMapper.java194
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/EnumTypeMapper.java106
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/FeatureMapTypeMapper.java344
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IManyTypeMapper.java128
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ISingleTypeMapper.java60
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ITypeMapper.java98
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IndexesReferenceMapper.java230
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ManyReferenceMapper.java684
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/MultipleTypeMapper.java318
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericManyTypeMapper.java1402
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericTypeMapper.java1046
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java384
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleContainementReferenceMapper.java196
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleReferenceMapper.java310
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringManyTypeMapper.java382
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringTypeMapper.java272
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayList.java512
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListId.java500
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListLong.java188
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListString.java812
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBase.java294
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranch.java300
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranchManager.java458
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyCommitInfo.java136
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapArrayList.java258
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapEntry.java242
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java334
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockAreaManager.java160
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageInfo.java246
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageUnit.java286
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProperty.java100
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProxy.java222
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyResourceList.java566
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyStoreInfo.java82
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/OBJYCDOIDUtil.java284
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/ObjyDb.java486
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/SmartLock.java388
-rw-r--r--plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/TypeConvert.java236
66 files changed, 15079 insertions, 15079 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityFeatureDeltaWriter.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityFeatureDeltaWriter.java
index dfe9124f0d..74ee9c8b59 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityFeatureDeltaWriter.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityFeatureDeltaWriter.java
@@ -1,109 +1,109 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity;
-
-import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author Simon McDuff
- */
-public class ObjectivityFeatureDeltaWriter implements CDOFeatureDeltaVisitor
-{
- private ObjyObject objyObject = null;
-
- private EStructuralFeature eFeature = null;
-
- public ObjectivityFeatureDeltaWriter(ObjyObject objyObject)
- {
- this.objyObject = objyObject;
- }
-
- public void nextFeature()
- {
- eFeature = null;
- }
-
- protected void fillStructuralFeature(CDOFeatureDelta delta)
- {
- eFeature = delta.getFeature();
- }
-
- public void visit(CDOMoveFeatureDelta delta)
- {
- fillStructuralFeature(delta);
- objyObject.move(eFeature, delta.getNewPosition(), delta.getOldPosition());
-
- }
-
- public void visit(CDOAddFeatureDelta delta)
- {
- fillStructuralFeature(delta);
- objyObject.add(eFeature, delta.getIndex(), delta.getValue());
- }
-
- public void visit(CDORemoveFeatureDelta delta)
- {
- fillStructuralFeature(delta);
- objyObject.remove(eFeature, delta.getIndex());
- }
-
- public void visit(CDOSetFeatureDelta delta)
- {
- fillStructuralFeature(delta);
- Object value = delta.getValue();
- /**
- * TODO - verify if this is needed for 2.x if (delta.getType()== CDOType.CUSTOM) { value =
- * EcoreUtil.createFromString((EDataType)eFeature.getEType(), (String)value); }
- */
- objyObject.set(eFeature, delta.getIndex(), value);
- }
-
- public void visit(CDOUnsetFeatureDelta delta)
- {
- fillStructuralFeature(delta);
- objyObject.unset(eFeature);
- }
-
- public void visit(CDOListFeatureDelta deltas)
- {
- for (CDOFeatureDelta delta : deltas.getListChanges())
- {
- delta.accept(this);
- }
- }
-
- public void visit(CDOClearFeatureDelta delta)
- {
- fillStructuralFeature(delta);
- objyObject.clear(eFeature);
-
- }
-
- public void visit(CDOContainerFeatureDelta delta)
- {
- objyObject.setEContainer(delta.getContainerID());
- objyObject.setEContainingFeature(delta.getContainerFeatureID());
- objyObject.setEResource(delta.getResourceID());
-
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity;
+
+import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
+import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * @author Simon McDuff
+ */
+public class ObjectivityFeatureDeltaWriter implements CDOFeatureDeltaVisitor
+{
+ private ObjyObject objyObject = null;
+
+ private EStructuralFeature eFeature = null;
+
+ public ObjectivityFeatureDeltaWriter(ObjyObject objyObject)
+ {
+ this.objyObject = objyObject;
+ }
+
+ public void nextFeature()
+ {
+ eFeature = null;
+ }
+
+ protected void fillStructuralFeature(CDOFeatureDelta delta)
+ {
+ eFeature = delta.getFeature();
+ }
+
+ public void visit(CDOMoveFeatureDelta delta)
+ {
+ fillStructuralFeature(delta);
+ objyObject.move(eFeature, delta.getNewPosition(), delta.getOldPosition());
+
+ }
+
+ public void visit(CDOAddFeatureDelta delta)
+ {
+ fillStructuralFeature(delta);
+ objyObject.add(eFeature, delta.getIndex(), delta.getValue());
+ }
+
+ public void visit(CDORemoveFeatureDelta delta)
+ {
+ fillStructuralFeature(delta);
+ objyObject.remove(eFeature, delta.getIndex());
+ }
+
+ public void visit(CDOSetFeatureDelta delta)
+ {
+ fillStructuralFeature(delta);
+ Object value = delta.getValue();
+ /**
+ * TODO - verify if this is needed for 2.x if (delta.getType()== CDOType.CUSTOM) { value =
+ * EcoreUtil.createFromString((EDataType)eFeature.getEType(), (String)value); }
+ */
+ objyObject.set(eFeature, delta.getIndex(), value);
+ }
+
+ public void visit(CDOUnsetFeatureDelta delta)
+ {
+ fillStructuralFeature(delta);
+ objyObject.unset(eFeature);
+ }
+
+ public void visit(CDOListFeatureDelta deltas)
+ {
+ for (CDOFeatureDelta delta : deltas.getListChanges())
+ {
+ delta.accept(this);
+ }
+ }
+
+ public void visit(CDOClearFeatureDelta delta)
+ {
+ fillStructuralFeature(delta);
+ objyObject.clear(eFeature);
+
+ }
+
+ public void visit(CDOContainerFeatureDelta delta)
+ {
+ objyObject.setEContainer(delta.getContainerID());
+ objyObject.setEContainingFeature(delta.getContainerFeatureID());
+ objyObject.setEResource(delta.getResourceID());
+
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityQueryHandler.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityQueryHandler.java
index 7c754985ce..63e04fca3e 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityQueryHandler.java
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity;
-
-import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
-import org.eclipse.emf.cdo.server.IQueryContext;
-import org.eclipse.emf.cdo.server.IQueryHandler;
-
-public class ObjectivityQueryHandler implements IQueryHandler
-{
-
- public static final String QUERY_LANGUAGE = "OBJY";
-
- protected ObjectivityStoreAccessor storeAccessor = null;
-
- public ObjectivityQueryHandler(ObjectivityStoreAccessor storeAccessor)
- {
- this.storeAccessor = storeAccessor;
- }
-
- public void executeQuery(CDOQueryInfo info, IQueryContext context)
- {
- // TODO
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity;
+
+import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
+import org.eclipse.emf.cdo.server.IQueryContext;
+import org.eclipse.emf.cdo.server.IQueryHandler;
+
+public class ObjectivityQueryHandler implements IQueryHandler
+{
+
+ public static final String QUERY_LANGUAGE = "OBJY";
+
+ protected ObjectivityStoreAccessor storeAccessor = null;
+
+ public ObjectivityQueryHandler(ObjectivityStoreAccessor storeAccessor)
+ {
+ this.storeAccessor = storeAccessor;
+ }
+
+ public void executeQuery(CDOQueryInfo info, IQueryContext context)
+ {
+ // TODO
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStore.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStore.java
index 4191a340f4..6a34a62253 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStore.java
@@ -1,401 +1,401 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.IStoreAccessor;
-import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.emf.cdo.server.IView;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyCommitInfoHandler;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyConnection;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPackageHandler;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPropertyMapHandler;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyStoreInfo;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
-import org.eclipse.emf.cdo.server.objectivity.IObjectivityStore;
-import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreConfig;
-import org.eclipse.emf.cdo.spi.server.LongIDStore;
-import org.eclipse.emf.cdo.spi.server.Store;
-import org.eclipse.emf.cdo.spi.server.StoreAccessorPool;
-
-import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.db.app.Connection;
-import com.objy.db.app.oo;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-public class ObjectivityStore extends Store implements IObjectivityStore
-{
-
- public static final String TYPE = "objectivity"; // $NON-NLS, DurableLocking-1$
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjectivityStore.class);
-
- protected ConcurrentLinkedQueue<ObjectivityStoreAccessor> writers = new ConcurrentLinkedQueue<ObjectivityStoreAccessor>();
-
- @ExcludeFromDump
- private transient StoreAccessorPool readerPool = new StoreAccessorPool(this, null);
-
- @ExcludeFromDump
- private transient StoreAccessorPool writerPool = new StoreAccessorPool(this, null);
-
- private ObjyConnection objyConnection = null;
-
- private IObjectivityStoreConfig storeConfig = null;
-
- private boolean firstTime = false;
-
- private int nActivate = 0;
-
- private boolean requiredToSupportAudits;
-
- private boolean requiredToSupportBranches;
-
- private ObjyCommitInfoHandler objyCommitInfoHandler = null;
-
- private ObjyPropertyMapHandler objyPropertyMapHandler = null;
-
- private ObjyPackageHandler objyPackageHandler = null;
-
- private boolean storeInitialized = false;
-
- private long creationTime = CDORevision.UNSPECIFIED_DATE;
-
- // private boolean resetData = false;
-
- public ObjectivityStore(IObjectivityStoreConfig config)
- {
- // super(TYPE, set(ChangeFormat.REVISION, ChangeFormat.DELTA), set(
- // RevisionTemporality.NONE, RevisionTemporality.AUDITING),
- // set(RevisionParallelism.NONE));
- // setRevisionTemporality(RevisionTemporality.AUDITING);
- super(TYPE, LongIDStore.OBJECT_ID_TYPES, set(ChangeFormat.REVISION, ChangeFormat.DELTA), set(
- RevisionTemporality.NONE, RevisionTemporality.AUDITING), set(RevisionParallelism.NONE,
- RevisionParallelism.BRANCHING));
- storeConfig = config;
- }
-
- private void initStore()
- {
- // the caller already used the StoreConfig to open the connection
- // to the FD so, get the current here.
- objyConnection = ObjyConnection.INSTANCE;
- objyConnection.setSessionMinCacheSize(storeConfig.getSessionMinCacheSize());
- objyConnection.setSessionMaxCacheSize(storeConfig.getSessionMaxCacheSize());
-
- // -----------------------------------------------------------------------
- // Initialize schema as needed, and also any other config information
-
- // connection to the FD.
- objyConnection.connect(storeConfig);
- Connection.current().setUserClassLoader(this.getClass().getClassLoader());
-
- objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyStoreInfo"); //$NON-NLS-1$
- objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageInfo"); //$NON-NLS-1$
- objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageUnit"); //$NON-NLS-1$
- objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyCommitInfo"); //$NON-NLS-1$
- objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProperty"); //$NON-NLS-1$
- objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranch"); //$NON-NLS-1$
- objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager"); //$NON-NLS-1$
- objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockArea"); //$NON-NLS-1$
- objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager"); //$NON-NLS-1$
-
- ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName()); //$NON-NLS-1$
- objySession.setRecoveryAutomatic(true);
- objySession.setOpenMode(oo.openReadWrite); // we are initializing stuff, we need the read/write.
- objySession.begin();
-
- ObjySchema.createBaseSchema();
-
- try
- {
- String repositoryName = getRepository().getName();
- // check if we initialized the store for the first time.
- {
- // we have one-to-one mapping between a store and a repository. In Objectivity, we
- // can still use one federation to store multiple repository, each will have its
- // own ObjyStoreInfo object in the default container.
- ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.DEFAULT_CONT_NAME);
- ObjyStoreInfo objyStoreInfo = null;
- try
- {
- objyStoreInfo = (ObjyStoreInfo)objyScope.lookupObject(ObjyDb.OBJYSTOREINFO_NAME);
- creationTime = objyStoreInfo.getCreationTime();
- }
- catch (Exception ex)
- {
- // create the ObjyStoreInfo.
- objyStoreInfo = new ObjyStoreInfo(System.currentTimeMillis(), "...");
- objyScope.getContainerObj().cluster(objyStoreInfo);
- objyScope.nameObj(ObjyDb.OBJYSTOREINFO_NAME, objyStoreInfo);
-
- // flag as first time.
- firstTime = true;
- }
-
- creationTime = objyStoreInfo.getCreationTime();
- }
-
- // This is used for the package storage, it could be lazily done though!!! (verify)
- // ObjyScope.insureScopeExist(objySession, ObjyDb.CONFIGDB_NAME, ObjyDb.PACKAGESTORE_CONT_NAME);
-
- // make sure we have the root resource created.
- // ObjyDb.getOrCreateResourceList();
- objyCommitInfoHandler = new ObjyCommitInfoHandler(repositoryName);
- objyPropertyMapHandler = new ObjyPropertyMapHandler(repositoryName);
- objyPackageHandler = new ObjyPackageHandler(repositoryName);
-
- // more initializations, this will ensure that we have Manager objects created.
- objySession.getLockAreaManager(repositoryName);
- objySession.getBranchManager(repositoryName);
- objySession.getResourceList(repositoryName);
-
- objySession.commit();
-
- storeInitialized = true;
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- objySession.abort();
- }
- finally
- {
- objySession.returnSessionToPool();
- }
- }
-
- @Override
- protected IStoreAccessor createReader(ISession session)
- {
- // System.out
- // .println(">>>>IS:<<<< ObjectivityStore.createRead() - " + (session == null ? "null" : session.toString()));
- return new ObjectivityStoreAccessor(this, session);
- }
-
- @Override
- protected IStoreAccessor createWriter(ITransaction transaction)
- {
- // if (transaction == null)
- // {
- // System.out.println(">>>>IS:<<<< ObjectivityStore.createWriter() - transaction: null");
- // }
- // else
- // {
- // System.out.println(">>>>IS:<<<< ObjectivityStore.createWriter() - "
- // + (transaction.getSession() == null ? "null" : transaction.getSession().toString()));
- // }
- return new ObjectivityStoreAccessor(this, transaction);
- }
-
- @Override
- protected StoreAccessorPool getReaderPool(ISession session, boolean forReleasing)
- {
- // return readerPool;
- return null;
- }
-
- @Override
- protected StoreAccessorPool getWriterPool(IView view, boolean forReleasing)
- {
- // return writerPool;
- return null;
- }
-
- public boolean isLocal(CDOID id)
- {
- return false;
- }
-
- /**
- * @since 4.0
- */
- public CDOID createObjectID(String val)
- {
- Long id = Long.valueOf(val);
- return CDOIDUtil.createLong(id);
- }
-
- public long getCreationTime()
- {
- return creationTime;
- }
-
- public void setCreationTime(long creationTime)
- {
- // TODO: implement ObjectivityStore.setCreationTime(creationTime)
- throw new UnsupportedOperationException();
- }
-
- public boolean isFirstStart()
- {
- return firstTime;
- }
-
- public ObjyConnection getConnection()
- {
- return objyConnection;
-
- }
-
- public boolean isRequiredToSupportAudits()
- {
- return requiredToSupportAudits;
- }
-
- public boolean isRequiredToSupportBranches()
- {
- return requiredToSupportBranches;
- }
-
- @Override
- protected void doBeforeActivate()
- {
- requiredToSupportAudits = getRepository().isSupportingAudits();
- requiredToSupportBranches = getRepository().isSupportingBranches();
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
-
- nActivate++;
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("doActivate - count: " + nActivate);
- }
-
- // lazy initialization of the store.
- if (!storeInitialized)
- {
- // long tStart = System.currentTimeMillis();
- initStore();
- // System.out.println("... ObjyStore initStore() time: " + (System.currentTimeMillis() - tStart));
- }
- else
- {
- ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName());
- objySession.setRecoveryAutomatic(true);
- objySession.begin();
-
- try
- {
- if (!objySession.getFD().hasDB(getRepository().getName()))
- {
- // Create the repo DB.
- ObjyScope.insureScopeExist(objySession, getRepository().getName(), ObjyDb.DEFAULT_CONT_NAME);
- // ...do other initialisation of the repository here.
- // Note that in the current implementation we don't delete DBs by default, only delete
- // the containers (see ObjectivityStoreConfig.resetFD()) so any initialization done here
- // might not be repeated.
- }
-
- objySession.commit();
- }
- catch (RuntimeException ex)
- {
- objySession.abort();
- }
- finally
- {
- objySession.returnSessionToPool();
- }
- }
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- try
- {
- ObjySchema.resetCache();
- // System.out.println(" -------- doDeactivate() ObjectivityStore ----------");
- }
- finally
- {
- ObjyConnection.INSTANCE.disconnect();
- // objyConnection.disconnect();
- }
-
- readerPool.dispose();
- writerPool.dispose();
- readerPool = null;
- writerPool = null;
-
- super.doDeactivate();
-
- }
-
- public Map<String, String> getPersistentProperties(Set<String> names)
- {
- if (names == null || names.isEmpty())
- {
- // Return *all* property values
-
- // TODO: implement ObjectivityStore.getPropertyValues(names)
- throw new UnsupportedOperationException();
- }
-
- ObjySession objySession = objyConnection.getReadSessionFromPool("Main_" + getRepository().getName());
- objySession.begin();
- Map<String, String> properties = objyPropertyMapHandler.getPropertyValues(names);
- objySession.commit();
- return properties;
- }
-
- public void setPersistentProperties(Map<String, String> properties)
- {
- ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName());
- objySession.begin();
- objyPropertyMapHandler.setPropertyValues(properties);
- objySession.commit();
- }
-
- public void removePersistentProperties(Set<String> names)
- {
- ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName());
- objySession.begin();
- objyPropertyMapHandler.removePropertyValues(names);
- objySession.commit();
- }
-
- public ObjyCommitInfoHandler getCommitInfoHandler()
- {
- return objyCommitInfoHandler;
- }
-
- public ObjyPackageHandler getPackageHandler()
- {
- return objyPackageHandler;
- }
-
- public ObjyPlacementManager getGlobalPlacementManager()
- {
- // return ObjyConnection.INSTANCE.getDefaultPlacementManager();
- return objyConnection.getDefaultPlacementManager();
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.server.IStoreAccessor;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyCommitInfoHandler;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyConnection;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPackageHandler;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPropertyMapHandler;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyStoreInfo;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
+import org.eclipse.emf.cdo.server.objectivity.IObjectivityStore;
+import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreConfig;
+import org.eclipse.emf.cdo.spi.server.LongIDStore;
+import org.eclipse.emf.cdo.spi.server.Store;
+import org.eclipse.emf.cdo.spi.server.StoreAccessorPool;
+
+import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.db.app.Connection;
+import com.objy.db.app.oo;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+public class ObjectivityStore extends Store implements IObjectivityStore
+{
+
+ public static final String TYPE = "objectivity"; // $NON-NLS, DurableLocking-1$
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjectivityStore.class);
+
+ protected ConcurrentLinkedQueue<ObjectivityStoreAccessor> writers = new ConcurrentLinkedQueue<ObjectivityStoreAccessor>();
+
+ @ExcludeFromDump
+ private transient StoreAccessorPool readerPool = new StoreAccessorPool(this, null);
+
+ @ExcludeFromDump
+ private transient StoreAccessorPool writerPool = new StoreAccessorPool(this, null);
+
+ private ObjyConnection objyConnection = null;
+
+ private IObjectivityStoreConfig storeConfig = null;
+
+ private boolean firstTime = false;
+
+ private int nActivate = 0;
+
+ private boolean requiredToSupportAudits;
+
+ private boolean requiredToSupportBranches;
+
+ private ObjyCommitInfoHandler objyCommitInfoHandler = null;
+
+ private ObjyPropertyMapHandler objyPropertyMapHandler = null;
+
+ private ObjyPackageHandler objyPackageHandler = null;
+
+ private boolean storeInitialized = false;
+
+ private long creationTime = CDORevision.UNSPECIFIED_DATE;
+
+ // private boolean resetData = false;
+
+ public ObjectivityStore(IObjectivityStoreConfig config)
+ {
+ // super(TYPE, set(ChangeFormat.REVISION, ChangeFormat.DELTA), set(
+ // RevisionTemporality.NONE, RevisionTemporality.AUDITING),
+ // set(RevisionParallelism.NONE));
+ // setRevisionTemporality(RevisionTemporality.AUDITING);
+ super(TYPE, LongIDStore.OBJECT_ID_TYPES, set(ChangeFormat.REVISION, ChangeFormat.DELTA), set(
+ RevisionTemporality.NONE, RevisionTemporality.AUDITING), set(RevisionParallelism.NONE,
+ RevisionParallelism.BRANCHING));
+ storeConfig = config;
+ }
+
+ private void initStore()
+ {
+ // the caller already used the StoreConfig to open the connection
+ // to the FD so, get the current here.
+ objyConnection = ObjyConnection.INSTANCE;
+ objyConnection.setSessionMinCacheSize(storeConfig.getSessionMinCacheSize());
+ objyConnection.setSessionMaxCacheSize(storeConfig.getSessionMaxCacheSize());
+
+ // -----------------------------------------------------------------------
+ // Initialize schema as needed, and also any other config information
+
+ // connection to the FD.
+ objyConnection.connect(storeConfig);
+ Connection.current().setUserClassLoader(this.getClass().getClassLoader());
+
+ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyStoreInfo"); //$NON-NLS-1$
+ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageInfo"); //$NON-NLS-1$
+ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageUnit"); //$NON-NLS-1$
+ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyCommitInfo"); //$NON-NLS-1$
+ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProperty"); //$NON-NLS-1$
+ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranch"); //$NON-NLS-1$
+ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager"); //$NON-NLS-1$
+ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockArea"); //$NON-NLS-1$
+ objyConnection.registerClass("org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager"); //$NON-NLS-1$
+
+ ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName()); //$NON-NLS-1$
+ objySession.setRecoveryAutomatic(true);
+ objySession.setOpenMode(oo.openReadWrite); // we are initializing stuff, we need the read/write.
+ objySession.begin();
+
+ ObjySchema.createBaseSchema();
+
+ try
+ {
+ String repositoryName = getRepository().getName();
+ // check if we initialized the store for the first time.
+ {
+ // we have one-to-one mapping between a store and a repository. In Objectivity, we
+ // can still use one federation to store multiple repository, each will have its
+ // own ObjyStoreInfo object in the default container.
+ ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.DEFAULT_CONT_NAME);
+ ObjyStoreInfo objyStoreInfo = null;
+ try
+ {
+ objyStoreInfo = (ObjyStoreInfo)objyScope.lookupObject(ObjyDb.OBJYSTOREINFO_NAME);
+ creationTime = objyStoreInfo.getCreationTime();
+ }
+ catch (Exception ex)
+ {
+ // create the ObjyStoreInfo.
+ objyStoreInfo = new ObjyStoreInfo(System.currentTimeMillis(), "...");
+ objyScope.getContainerObj().cluster(objyStoreInfo);
+ objyScope.nameObj(ObjyDb.OBJYSTOREINFO_NAME, objyStoreInfo);
+
+ // flag as first time.
+ firstTime = true;
+ }
+
+ creationTime = objyStoreInfo.getCreationTime();
+ }
+
+ // This is used for the package storage, it could be lazily done though!!! (verify)
+ // ObjyScope.insureScopeExist(objySession, ObjyDb.CONFIGDB_NAME, ObjyDb.PACKAGESTORE_CONT_NAME);
+
+ // make sure we have the root resource created.
+ // ObjyDb.getOrCreateResourceList();
+ objyCommitInfoHandler = new ObjyCommitInfoHandler(repositoryName);
+ objyPropertyMapHandler = new ObjyPropertyMapHandler(repositoryName);
+ objyPackageHandler = new ObjyPackageHandler(repositoryName);
+
+ // more initializations, this will ensure that we have Manager objects created.
+ objySession.getLockAreaManager(repositoryName);
+ objySession.getBranchManager(repositoryName);
+ objySession.getResourceList(repositoryName);
+
+ objySession.commit();
+
+ storeInitialized = true;
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ objySession.abort();
+ }
+ finally
+ {
+ objySession.returnSessionToPool();
+ }
+ }
+
+ @Override
+ protected IStoreAccessor createReader(ISession session)
+ {
+ // System.out
+ // .println(">>>>IS:<<<< ObjectivityStore.createRead() - " + (session == null ? "null" : session.toString()));
+ return new ObjectivityStoreAccessor(this, session);
+ }
+
+ @Override
+ protected IStoreAccessor createWriter(ITransaction transaction)
+ {
+ // if (transaction == null)
+ // {
+ // System.out.println(">>>>IS:<<<< ObjectivityStore.createWriter() - transaction: null");
+ // }
+ // else
+ // {
+ // System.out.println(">>>>IS:<<<< ObjectivityStore.createWriter() - "
+ // + (transaction.getSession() == null ? "null" : transaction.getSession().toString()));
+ // }
+ return new ObjectivityStoreAccessor(this, transaction);
+ }
+
+ @Override
+ protected StoreAccessorPool getReaderPool(ISession session, boolean forReleasing)
+ {
+ // return readerPool;
+ return null;
+ }
+
+ @Override
+ protected StoreAccessorPool getWriterPool(IView view, boolean forReleasing)
+ {
+ // return writerPool;
+ return null;
+ }
+
+ public boolean isLocal(CDOID id)
+ {
+ return false;
+ }
+
+ /**
+ * @since 4.0
+ */
+ public CDOID createObjectID(String val)
+ {
+ Long id = Long.valueOf(val);
+ return CDOIDUtil.createLong(id);
+ }
+
+ public long getCreationTime()
+ {
+ return creationTime;
+ }
+
+ public void setCreationTime(long creationTime)
+ {
+ // TODO: implement ObjectivityStore.setCreationTime(creationTime)
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isFirstStart()
+ {
+ return firstTime;
+ }
+
+ public ObjyConnection getConnection()
+ {
+ return objyConnection;
+
+ }
+
+ public boolean isRequiredToSupportAudits()
+ {
+ return requiredToSupportAudits;
+ }
+
+ public boolean isRequiredToSupportBranches()
+ {
+ return requiredToSupportBranches;
+ }
+
+ @Override
+ protected void doBeforeActivate()
+ {
+ requiredToSupportAudits = getRepository().isSupportingAudits();
+ requiredToSupportBranches = getRepository().isSupportingBranches();
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+
+ nActivate++;
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("doActivate - count: " + nActivate);
+ }
+
+ // lazy initialization of the store.
+ if (!storeInitialized)
+ {
+ // long tStart = System.currentTimeMillis();
+ initStore();
+ // System.out.println("... ObjyStore initStore() time: " + (System.currentTimeMillis() - tStart));
+ }
+ else
+ {
+ ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName());
+ objySession.setRecoveryAutomatic(true);
+ objySession.begin();
+
+ try
+ {
+ if (!objySession.getFD().hasDB(getRepository().getName()))
+ {
+ // Create the repo DB.
+ ObjyScope.insureScopeExist(objySession, getRepository().getName(), ObjyDb.DEFAULT_CONT_NAME);
+ // ...do other initialisation of the repository here.
+ // Note that in the current implementation we don't delete DBs by default, only delete
+ // the containers (see ObjectivityStoreConfig.resetFD()) so any initialization done here
+ // might not be repeated.
+ }
+
+ objySession.commit();
+ }
+ catch (RuntimeException ex)
+ {
+ objySession.abort();
+ }
+ finally
+ {
+ objySession.returnSessionToPool();
+ }
+ }
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ try
+ {
+ ObjySchema.resetCache();
+ // System.out.println(" -------- doDeactivate() ObjectivityStore ----------");
+ }
+ finally
+ {
+ ObjyConnection.INSTANCE.disconnect();
+ // objyConnection.disconnect();
+ }
+
+ readerPool.dispose();
+ writerPool.dispose();
+ readerPool = null;
+ writerPool = null;
+
+ super.doDeactivate();
+
+ }
+
+ public Map<String, String> getPersistentProperties(Set<String> names)
+ {
+ if (names == null || names.isEmpty())
+ {
+ // Return *all* property values
+
+ // TODO: implement ObjectivityStore.getPropertyValues(names)
+ throw new UnsupportedOperationException();
+ }
+
+ ObjySession objySession = objyConnection.getReadSessionFromPool("Main_" + getRepository().getName());
+ objySession.begin();
+ Map<String, String> properties = objyPropertyMapHandler.getPropertyValues(names);
+ objySession.commit();
+ return properties;
+ }
+
+ public void setPersistentProperties(Map<String, String> properties)
+ {
+ ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName());
+ objySession.begin();
+ objyPropertyMapHandler.setPropertyValues(properties);
+ objySession.commit();
+ }
+
+ public void removePersistentProperties(Set<String> names)
+ {
+ ObjySession objySession = objyConnection.getWriteSessionFromPool("Main_" + getRepository().getName());
+ objySession.begin();
+ objyPropertyMapHandler.removePropertyValues(names);
+ objySession.commit();
+ }
+
+ public ObjyCommitInfoHandler getCommitInfoHandler()
+ {
+ return objyCommitInfoHandler;
+ }
+
+ public ObjyPackageHandler getPackageHandler()
+ {
+ return objyPackageHandler;
+ }
+
+ public ObjyPlacementManager getGlobalPlacementManager()
+ {
+ // return ObjyConnection.INSTANCE.getDefaultPlacementManager();
+ return objyConnection.getDefaultPlacementManager();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
index 61b15763c6..fcde4b9393 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreAccessor.java
@@ -1,1988 +1,1988 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDExternal;
-import org.eclipse.emf.cdo.common.lob.CDOLobHandler;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea.Handler;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCacheAdder;
-import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
-import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.server.IQueryHandler;
-import org.eclipse.emf.cdo.server.IRepository;
-import org.eclipse.emf.cdo.server.ISession;
-import org.eclipse.emf.cdo.server.IStoreAccessor.DurableLocking;
-import org.eclipse.emf.cdo.server.ITransaction;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManagerLocal;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyCommitInfoHandler;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObjectManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPackageHandler;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBase;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranch;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyCommitInfo;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.SmartLock;
-import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreAccessor;
-import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreChunkReader;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.commit.CDOChangeSetSegment;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
-import org.eclipse.emf.cdo.spi.server.InternalRepository;
-import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
-import org.eclipse.emf.cdo.spi.server.StoreAccessor;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.collection.Pair;
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import com.objy.db.LockNotGrantedException;
-import com.objy.db.app.oo;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-
-/**
- * @author Simon McDuff
- * @author Ibrahim Sallam
- */
-public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectivityStoreAccessor, DurableLocking
-{
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjectivityStoreAccessor.class);
-
- private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjectivityStoreAccessor.class);
-
- protected ObjySession objySession = null;
-
- // protected ObjyObjectManager objectManager = null;
-
- protected boolean isRead = false;
-
- protected int sessionID = 0; // used to tag the Objy session in the session pool
-
- boolean zipped = true; // TODO - might make this configurable...
-
- private HashMap<CDOID, ObjyObject> newObjyObjectsMap = new HashMap<CDOID, ObjyObject>();
-
- private long readRevisionTime = 0;
-
- private int readRevisionCount = 0;
-
- protected ObjectivityStoreAccessor(ObjectivityStore store, ISession cdoSession)
- {
- super(store, cdoSession);
-
- // for debugging...
- // session.getProtocol();
- // org.eclipse.emf.cdo.net4j.CDOSession.Options.getProtocol()
- // [12:42:23 PM] Eike Stepper says: org.eclipse.net4j.signal.ISignalProtocol.setTimeout(long)
- // [12:42:43 PM] Eike Stepper says: commit is different
- // if (cdoSession != null && cdoSession.getProtocol().getSession() instanceof org.eclipse.emf.cdo.net4j.CDOSession)
- // {
- // CDOCommonSession commonSession = cdoSession.getProtocol().getSession();
- // org.eclipse.emf.cdo.net4j.CDOSession tempSession = (org.eclipse.emf.cdo.net4j.CDOSession)commonSession;
- // tempSession.options().setCommitTimeout(60000);
- // }
- // [12:42:45 PM] Eike Stepper says: org.eclipse.emf.cdo.net4j.CDOSession.Options.setCommitTimeout(int)
- // org.eclipse.emf.cdo.net4j.CDOSession.Options.setProgressInterval(int)
-
- /* I believe this is a read session */
- isRead = true;
- if (cdoSession != null)
- {
- sessionID = cdoSession.getSessionID();
- }
- }
-
- public ObjectivityStoreAccessor(ObjectivityStore store, ITransaction transaction)
- {
- super(store, transaction);
-
- // for debugging...
- // if (transaction != null && transaction.getSession().getProtocol().getSession() instanceof
- // org.eclipse.emf.cdo.net4j.CDOSession)
- // {
- // CDOCommonSession commonSession = transaction.getSession().getProtocol().getSession();
- // org.eclipse.emf.cdo.net4j.CDOSession cdoSession = (org.eclipse.emf.cdo.net4j.CDOSession)commonSession;
- // cdoSession.options().setCommitTimeout(60000);
- // }
- /* I believe this is a write session */
- if (transaction != null)
- {
- sessionID = transaction.getSession().getSessionID();
- }
- }
-
- @Override
- protected void detachObjects(CDOID[] detachedObjects, CDOBranch branch, long timeStamp, OMMonitor monitor)
- {
- ensureSessionBegin();
-
- // System.out.println(">>>>IS:<<< detachObjects() " + this + " - objy session: " + objySession.toString());
- // objySession.addToLog("IS:>>>", "detachObjects - begin");
-
- try
- {
- monitor.begin(detachedObjects.length);
- // Find all Objy containers to lock as one unit.
- Set<ooId> containerToLocks = new HashSet<ooId>();
- for (CDOID id : detachedObjects)
- {
- ooId containerID = OBJYCDOIDUtil.getContainerId(id);
- containerToLocks.add(containerID);
- }
- objySession.lockContainers(containerToLocks);
-
- InternalCDORevisionManager revisionManager = getStore().getRepository().getRevisionManager();
-
- long tStart = System.currentTimeMillis();
- for (CDOID id : detachedObjects)
- {
-
- InternalCDORevision revision = revisionManager.getRevision(id, branch.getHead(), CDORevision.UNCHUNKED,
- CDORevision.DEPTH_NONE, true);
- int version = ObjectUtil.equals(branch, revision.getBranch()) ? revision.getVersion()
- : CDOBranchVersion.FIRST_VERSION;
-
- detachObject(id, version, branch, timeStamp);
- }
- // objySession.addToLog("IS:>>>", "detachObjects - end");
- long tDiff = System.currentTimeMillis() - tStart;
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("detach objects: " + detachedObjects.length + " - time: " + tDiff);
- }
-
- }
- finally
- {
- monitor.done();
- }
-
- // System.out.println(">>>>IS:<<< detachObjects() DONE " + this + " - objy session: " + objySession.toString());
- }
-
- /***
- * @param CDOID
- * @param version
- * @param branch
- * @param timeStamp
- */
- private void detachObject(CDOID id, int version, CDOBranch branch, long timeStamp)
- {
- // ensureSessionBegin();
-
- ObjyObject objyObject = getObject(id);
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Detaching id " + id + " - OID: " + objyObject.ooId().getStoreString() + " verions: "
- + version + " in Branch: " + branch.getID() + " and timeStamp: " + timeStamp);
- }
-
- if (getStore().isRequiredToSupportAudits())
- {
- if (version > CDOBranchVersion.FIRST_VERSION)
- {
- // pick the proper version of that branch to revise it. Otherwise, the detached version will
- // be in a different branch.
- ObjyObject objyRevision = objyObject.getRevisionByVersion(version, branch.getID(),
- objySession.getObjectManager());
- if (objyRevision.getVersion() < 0)
- {
- TRACER_DEBUG.trace("... OBJ is already detached...");
- }
- objyRevision.setRevisedTime(timeStamp - 1);
- }
- objyObject.detach(version, branch, timeStamp);
- }
- else
- {
- objyObject.setVersion(-version);
- objyObject.delete(this, objySession.getObjectManager());
- }
-
- // // we'll need to find it's containing object/resource and remove it from there.
- // // TODO - do we need to deal with dependent objects, i.e. delete them as well,
- // // is there a notion of delete propagate?
- // if (ObjySchema.isResource(getStore(), objyObject.objyClass()))
- // {
- // ObjyResourceList resourceList = objySession.getResourceList(getRepositoryName());
- // resourceList.remove(objyObject);
- // }
- objySession.getObjectManager().remove(objyObject); // removed it from the cache.
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- // System.out.println(">>>>IS:<<<< StoreAccessor.doActivate() " + this);
- // getObjySession();
- }
-
- public ObjySession getObjySession()
- {
- int currSessionID = sessionID;
-
- if (!isReader())
- {
- // The only reason we do this is because there was a switching of context in the middle
- // of a transaction, and we want to ensure that we continue with the proper session that
- // is holding the data.
- ITransaction cdoTrx = getTransaction();
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG
- .trace("getObjySession() - context's transaction: " + (cdoTrx == null ? "null" : cdoTrx.toString()));
- }
- if (cdoTrx != null)
- {
- sessionID = cdoTrx.getSession().getSessionID();
- }
- }
-
- if (objySession != null && currSessionID == sessionID)
- {
- return objySession;
- }
-
- // get a session name.
- String sessionName = "Session_" + sessionID;
-
- if (objySession != null)
- {
- objySession.returnSessionToPool();
- }
- if (isReader())
- {
- objySession = getStore().getConnection().getReadSessionFromPool(sessionName + "_" + getRepositoryName());
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(" getObjySession from read pool, session: " + objySession.toString() + " - isOpen: "
- + objySession.isOpen() + " - sessionName:" + objySession.getName());
- }
- }
- else
- {
- objySession = getStore().getConnection().getWriteSessionFromPool(sessionName + "_" + getRepositoryName());
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(" getObjySession from write pool, session: " + objySession.toString() + " - isOpen: "
- + objySession.isOpen() + " - sessionName:" + objySession.getName());
- }
- }
-
- if (!objySession.isOpen())
- {
- objySession.setMrowMode(oo.MROW);
- objySession.setWaitOption(45000);
- objySession.setAllowUnregisterableTypes(true);
- if (isRead)
- {
- objySession.setOpenMode(oo.openReadOnly);
- }
- else
- {
- objySession.setOpenMode(oo.openReadWrite);
- }
- objySession.begin();
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(" calling session.begin() for " + objySession.toString() + " - isRead: " + isRead);
- }
- }
- else
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(" session " + objySession.toString() + " already open.");
- }
- }
-
- return objySession;
- }
-
- private void returnObjySession()
- {
- // System.out.println(">>>>IS:<<<< Returning to pool, session: " + objySession + " - name: " +
- // objySession.getName());
- ensureSessionJoin();
- // testDetachWithoutRevision_CheckMainBranch() is crashing because objySession is null.
- // TBD: verify this case!!!
- if (objySession == null)
- {
- return;
- }
-
- if (objySession.isOpen())
- {
- // System.out.println(">>>>IS:<<<< commiting session: " + objySession + " - name: " + objySession.getName());
- objySession.commit(); // IS: we might need to abort instead.
- }
- objySession.returnSessionToPool();
- objySession = null;
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- // System.out.println(">>>>IS:<<< StoreAccessor.doDeactivate() " + this);
- returnObjySession();
- }
-
- @Override
- protected void doPassivate() throws Exception
- {
- // System.out.println(">>>>IS:<<<< StoreAccessor.doPassivate() " + this);
- returnObjySession();
- }
-
- @Override
- protected void doUnpassivate() throws Exception
- {
- // System.out.println(">>>>IS:<<<< StoreAccessor.doUnpassivate() " + this);
- // IS: don't call this now, in case we don't have a context.
- // getObjySession();
- }
-
- // @Override
- // protected void setContext(Object context)
- // {
- // super.setContext(context);
- // System.out.println(">>>>IS:<<<< StoreAccessor.setContext() " + this + " - context: " + context.toString());
- // }
-
- @Override
- protected void doRollback(CommitContext commitContext)
- {
- try
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Rollback session " + objySession);
- }
- // the rollback could be coming from another thread.
- ensureSessionJoin();
- if (objySession.isOpen())
- {
- objySession.abort();
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("OBJY: session aborted - Session: " + objySession + " - open:" + objySession.isOpen());
- }
- }
- }
- catch (RuntimeException exception)
- {
- TRACER_INFO.trace(exception.getMessage(), exception);
- exception.printStackTrace();
- throw exception;
- }
- }
-
- @Override
- protected void writeRevisionDeltas(InternalCDORevisionDelta[] revisionDeltas, CDOBranch branch, long created,
- OMMonitor monitor)
- {
- // System.out.println(">>>>IS:<<< writeRevisionDeltas() " + this + " - objy session: " + objySession.toString());
- long start = System.nanoTime();
- ensureSessionBegin();
-
- try
- {
- monitor.begin(revisionDeltas.length);
- // Find all Objy containers to lock as one unit.
- Set<ooId> containerToLocks = new HashSet<ooId>();
- for (InternalCDORevisionDelta delta : revisionDeltas)
- {
- ooId containerID = OBJYCDOIDUtil.getContainerId(delta.getID());
- containerToLocks.add(containerID);
- }
- objySession.lockContainers(containerToLocks);
-
- for (InternalCDORevisionDelta revisionDelta : revisionDeltas)
- {
- writeRevisionDelta(revisionDelta, branch, created);
- }
- }
- finally
- {
- monitor.done();
- }
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(" writeRevisionDeltas: " + revisionDeltas.length + " - time: " + (System.nanoTime() - start)
- / 1000000.0);
- }
- }
-
- /**
- * Called for each revision delta.
- *
- * @param delta
- * @param created
- * @param branch
- */
- // private void writeRevisionDelta2(InternalCDORevisionDelta delta, CDOBranch branch, long created)
- // {
- // // ensureSessionBegin();
- //
- // int deltaVersion = delta.getVersion();
- // int newVersion = CDOBranchVersion.FIRST_VERSION;
- //
- // ObjyObject objyObject = getObject(delta.getID());
- // if (TRACER_DEBUG.isEnabled())
- // {
- // TRACER_DEBUG.format("writingRevisionDelta getting Object: {0}, v:{1} - BranchId:{2}", objyObject.ooId()
- // .getStoreString(), deltaVersion, delta.getBranch().getID());
- // }
- // ObjyObject objyOriginalRevision = objyObject.getRevisionByVersion(deltaVersion, delta.getBranch().getID(),
- // objySession.getObjectManager());
- //
- // if (branch.getID() == delta.getBranch().getID())
- // {
- // // Same branch, increase version
- // newVersion = deltaVersion + 1;
- // }
- //
- // if (TRACER_DEBUG.isEnabled())
- // {
- // TRACER_DEBUG.format("Writing revision delta: {0}, v:{1} - OID:{2}, v:{3} - BranchId:{4}", delta, deltaVersion,
- // objyObject.ooId().getStoreString(), objyOriginalRevision.getVersion(), objyOriginalRevision.getBranchId());
- // TRACER_DEBUG.format("... delta branch ID: {0} - revision branch ID: {1}", branch.getID(),
- // objyOriginalRevision.getBranchId());
- // }
- // // System.out.println(">>>IS: Delta Writing: " + delta.getID() + " - oid: " + objyObject.ooId().getStoreString());
- // // System.out.println("\t - old version : " + delta.getVersion());
- // // System.out.println("\t - created : " + created);
- // // System.out.println("\t - delta.branch: " + delta.getBranch().toString());
- // // System.out.println("\t - branch : " + branch.toString());
- // // System.out.println("\t - branch TS : " + branch.getPoint(created).getTimeStamp());
- // // System.out.println("\t - delta : " + delta.toString());
- // // for debugging...
- //
- // if (objyOriginalRevision.getVersion() != deltaVersion)
- // {
- // throw new RuntimeException("ObjecitivityStoreAccessor : Dirty write");
- // }
- //
- // ObjyObject objyNewRevision = null;
- //
- // if (getStore().isRequiredToSupportAudits())
- // {
- // // newObjyRevision = objySession.getObjectManager().copyRevision(this, objyRevision);
- // // objyRevision.setRevisedBranchId(branch.getID();
- // // InternalCDORevision originalRevision = getStore().getRepository().getRevisionManager()
- // // .getRevisionByVersion(delta.getID(), delta, 0, true);
- // InternalCDORevision originalRevision = getStore().getRepository().getRevisionManager()
- // .getRevisionByVersion(delta.getID(), delta.getBranch().getVersion(deltaVersion), 0, true);
- //
- // // 100917-IS: KISS - InternalCDORevision newRevision = originalRevision.copy();
- //
- // // 100917-IS: KISS - newRevision.setVersion(deltaVersion + 1);
- // // 100917-IS: KISS - newRevision.setBranchPoint(delta.getBranch().getPoint(created));
- // // 100917-IS: KISS - newObjyRevision = objySession.getObjectManager().newObject(newRevision.getEClass(),
- // // objyRevision.ooId());
- // // 100917-IS: KISS - objyNewRevision.update(this, newRevision);
- //
- // // create a new object, fill it with the original revision data, then
- // // modify the creation and the branch ID accordingly.
- // objyNewRevision = objySession.getObjectManager().newObject(originalRevision.getEClass(),
- // objyOriginalRevision.ooId());
- // objyNewRevision.update(this, originalRevision);
- // objyNewRevision.setBranchId(delta.getBranch().getID());
- // // the following are done at the end.
- // // objyNewRevision.setVersion(deltaVersion + 1);
- // // objyNewRevision.setCreationTime(created);
- //
- // objyObject.addToRevisions(objyNewRevision);
- //
- // if (getStore().isRequiredToSupportBranches() /* && branch.getID() != CDOBranch.MAIN_BRANCH_ID */)
- // {
- // // add the newObjyRevision to the proper branch.
- // ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(branch.getID());
- // ooObj anObj = ooObj.create_ooObj(objyNewRevision.ooId());
- // objyBranch.addRevision(anObj);
- // }
- // if (newVersion > CDORevision.FIRST_VERSION)
- // {
- // // revise the original revision last, otherwise we can end up with the revised date in the new revision.
- // objyOriginalRevision.setRevisedTime(branch.getPoint(created).getTimeStamp() - 1);
- // }
- // }
- // else
- // {
- // objyNewRevision = objyOriginalRevision;
- // }
- //
- // ObjectivityFeatureDeltaWriter visitor = new ObjectivityFeatureDeltaWriter(objyNewRevision);
- //
- // delta.accept(visitor);
- //
- // objyNewRevision.setCreationTime(branch.getPoint(created).getTimeStamp());
- // objyNewRevision.setVersion(newVersion); // TODO - verify with Eike if this is true!!!
- // }
-
- /**
- * Called for each revision delta.
- *
- * @param delta
- * @param created
- * @param branch
- */
- private void writeRevisionDelta(InternalCDORevisionDelta delta, CDOBranch branch, long created)
- {
- // ensureSessionBegin();
-
- int deltaVersion = delta.getVersion();
- int newVersion = CDOBranchVersion.FIRST_VERSION;
-
- ObjyObject objyObject = getObject(delta.getID());
- TRACER_DEBUG.format("writingRevisionDelta getting Object: {0}, v:{1} - BranchId:{2}", objyObject.ooId()
- .getStoreString(), deltaVersion, delta.getBranch().getID());
- ObjyObject objyOriginalRevision = objyObject.getRevisionByVersion(deltaVersion, delta.getBranch().getID(),
- objySession.getObjectManager());
-
- if (branch.getID() == delta.getBranch().getID())
- {
- // Same branch, increase version
- newVersion = deltaVersion + 1;
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("Writing revision delta: {0}, v:{1} - OID:{2}, v:{3} - BranchId:{4}", delta, deltaVersion,
- objyObject.ooId().getStoreString(), objyOriginalRevision.getVersion(), objyOriginalRevision.getBranchId());
- TRACER_DEBUG.format("... delta branch ID: {0} - revision branch ID: {1}", branch.getID(),
- objyOriginalRevision.getBranchId());
- }
- // System.out.println(">>>IS: Delta Writing: " + delta.getID() + " - oid: " + objyObject.ooId().getStoreString());
- // System.out.println("\t - old version : " + delta.getVersion());
- // System.out.println("\t - created : " + created);
- // System.out.println("\t - delta.branch: " + delta.getBranch().toString());
- // System.out.println("\t - branch : " + branch.toString());
- // System.out.println("\t - branch TS : " + branch.getPoint(created).getTimeStamp());
- // System.out.println("\t - delta : " + delta.toString());
- // for debugging...
-
- if (objyOriginalRevision.getVersion() != deltaVersion)
- {
- throw new RuntimeException("ObjecitivityStoreAccessor : Dirty write");
- }
-
- ObjyObject objyNewRevision = null;
-
- if (getStore().isRequiredToSupportAudits())
- {
-
- ObjyObject objyObjectCopy = objySession.getObjectManager().copyRevision(this, objyOriginalRevision);
- TRACER_DEBUG.format(" created new object:{0} by copying object:{1} - v:{2} - newBranch:{3}", objyObjectCopy
- .ooId().getStoreString(), objyOriginalRevision.ooId().getStoreString(), objyOriginalRevision.getVersion(),
- branch.getID());
-
- // // newObjyRevision = objySession.getObjectManager().copyRevision(this, objyRevision);
- // // objyRevision.setRevisedBranchId(branch.getID();
- // InternalCDORevision originalRevision = getStore().getRepository().getRevisionManager()
- // .getRevisionByVersion(delta.getID(), delta, CDORevision.UNCHUNKED, true);
- //
- // // 100917-IS: KISS - InternalCDORevision newRevision = originalRevision.copy();
- //
- // // 100917-IS: KISS - newRevision.setVersion(deltaVersion + 1);
- // // 100917-IS: KISS - newRevision.setBranchPoint(delta.getBranch().getPoint(created));
- // // 100917-IS: KISS - objyNewRevision = objySession.getObjectManager().newObject(newRevision.getEClass(),
- // // objyOriginalRevision.ooId());
- // // 100917-IS: KISS - objyNewRevision.update(this, newRevision);
- //
- // // create a new object, fill it with the original revision data, then
- // // modify the creation and the branch ID accordingly.
- // objyNewRevision = objySession.getObjectManager().newObject(originalRevision.getEClass(),
- // objyOriginalRevision.ooId());
- // objyNewRevision.update(this, originalRevision);
- objyNewRevision = objyObjectCopy;
- objyNewRevision.setBranchId(branch.getID());
- // the following are done at the end.
- // objyNewRevision.setVersion(deltaVersion + 1);
- // objyNewRevision.setCreationTime(created);
-
- objyObject.addToRevisions(objyNewRevision);
-
- if (getStore().isRequiredToSupportBranches() /* && branch.getID() != CDOBranch.MAIN_BRANCH_ID */)
- {
- // add the newObjyRevision to the proper branch.
- ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(branch.getID());
- ooObj anObj = ooObj.create_ooObj(objyNewRevision.ooId());
- objyBranch.addRevision(anObj);
- }
- // revise the original revision last, otherwise we can end up with the revised date in the new revision.
- // IS: it seems that in CDO 4.0 we don't need to do that anymore!!
- if (newVersion > CDORevision.FIRST_VERSION)
- {
- objyOriginalRevision.setRevisedTime(branch.getPoint(created).getTimeStamp() - 1);
- }
- }
- else
- {
- objyNewRevision = objyOriginalRevision;
- }
-
- ObjectivityFeatureDeltaWriter visitor = new ObjectivityFeatureDeltaWriter(objyNewRevision);
-
- delta.accept(visitor);
-
- objyNewRevision.setCreationTime(branch.getPoint(created).getTimeStamp());
- objyNewRevision.setVersion(newVersion); // TODO - verify with Eike if this is true!!!
- }
-
- @Override
- public ObjectivityStore getStore()
- {
- return (ObjectivityStore)super.getStore();
- }
-
- /**
- * It seems that it will be called for both new objects and dirty objects.
- */
- @Override
- protected void writeRevisions(InternalCDORevision[] revisions, CDOBranch branch, OMMonitor monitor)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- ObjyObjectManager.getObjectTime = 0;
- ObjyObjectManager.updateObjectTime = 0;
- ObjyObjectManager.resourceCheckAndUpdateTime = 0;
- }
- long start = System.nanoTime();
- ensureSessionBegin();
- // objySession.addToLog("IS:>>>", "writeRevisions - begin");
- try
- {
- monitor.begin(revisions.length);
- // Find all Objy containers to lock as one unit.
- Set<ooId> containersToLock = new HashSet<ooId>();
- for (InternalCDORevision revision : revisions)
- {
- ooId containerID = OBJYCDOIDUtil.getContainerId(revision.getID());
- containersToLock.add(containerID);
- }
- // containersToLock.add(objySession.getBranchManager(getRepositoryName()).getContainer().getOid());
- // lockContainers(containersToLock);
- // long tStart = System.currentTimeMillis();
- for (InternalCDORevision revision : revisions)
- {
- writeRevision(revision, monitor.fork());
- }
- // long tDiff = System.currentTimeMillis() - tStart;
- // System.out.println(">>> IS: writing revisions: " + revisions.length + " - time: " + tDiff);
- }
- finally
- {
- newObjyObjectsMap.clear();
- monitor.done();
- }
- // objySession.addToLog("IS:>>>", "writeRevisions - end");
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG
- .trace(" writeRevisions: " + revisions.length + " - time: " + (System.nanoTime() - start) / 1000000.0);
- // TRACER_DEBUG.trace(" getObjectTime: " + ObjyObjectManager.getObjectTime / 1000000.0);
- // TRACER_DEBUG.trace(" updateObjectTime: " + ObjyObjectManager.updateObjectTime / 1000000.0);
- // TRACER_DEBUG.trace(" resourceCheckAndUpdateTime: " + ObjyObjectManager.resourceCheckAndUpdateTime /
- // 1000000.0);
- // ObjyObjectManager.getObjectTime = 0;
- // ObjyObjectManager.updateObjectTime = 0;
- // ObjyObjectManager.resourceCheckAndUpdateTime = 0;
- }
-
- }
-
- /**
- * return an ObjyObject that represent the CDOID base.
- */
- public ObjyObject getObject(CDOID id)
- {
- ObjyObject objyObject = objySession.getObjectManager().getObject(id);
- // make sure we get the base one and not any cached version.
- return objyObject.getBaseObject();
- }
-
- /*****
- * Use this code for heart beat. Async async = null; try { monitor.begin(getListMappings().size() + 1); async =
- * monitor.forkAsync(); reviseObject(accessor, id, timeStamp); } finally { async.stop(); monitor.done(); } [10:07:02
- * AM] Eike Stepper: that one takes care that the heartbeat goes on [10:07:13 AM] Eike Stepper: for indefinite time
- */
-
- private void writeRevision(InternalCDORevision revision, OMMonitor monitor)
- {
- Async async = null;
-
- try
- {
- monitor.begin(1000); // IS: experimental.
- async = monitor.forkAsync();
-
- // EClass eClass = revision.getEClass();
- long __start = System.nanoTime();
- // ObjyObject objyObject = getObject(revision.getID());
- ObjyObject objyObject = newObjyObjectsMap.get(revision.getID());
- if (objyObject == null)
- {
- objyObject = getObject(revision.getID()); // we shouldn't need to come here.
- }
- ObjyObjectManager.getObjectTime += System.nanoTime() - __start;
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("Writing revision: {0} - OID: {1}", revision, objyObject.ooId().getStoreString()); //$NON-NLS-1$
- }
-
- // System.out.println(">>>IS: Writing: " + revision.getID() + " - oid: " + objyObject.ooId().getStoreString());
- // System.out.println("\t - version : " + revision.getVersion());
- // System.out.println("\t - timestamp : " + revision.getTimeStamp());
- // System.out.println("\t - revised : " + revision.getRevised());
- // System.out.println("\t - resourceId : " + revision.getResourceID());
- // System.out.println("\t - containerId: " + revision.getContainerID());
- // System.out.println("\t - branch : " + revision.getBranch().toString());
- // System.out.println("\t - revision : " + revision.toString());
-
- ObjyObject newObjyRevision = objyObject;
-
- if (revision.getVersion() > CDOBranchVersion.FIRST_VERSION) // we're updating other versions...
- {
- // TRACER_DEBUG.format("...Updating other revisions using writeRevision()...");
- ObjyObject oldObjyRevision = objyObject.getRevisionByVersion(revision.getVersion() - 1, revision.getBranch()
- .getID(), objySession.getObjectManager());
-
- if (oldObjyRevision == null)
- {
- new IllegalStateException("Revision with version: " + (revision.getVersion() - 1) + " is not in the store."); //$NON-NLS-1$
- }
- if (getStore().isRequiredToSupportAudits())
- {
- // if we allow versioning, then create a new one here.
- // IS: I'm not sure if we'll be called here we always go to the writeRevisionDelta call.
- newObjyRevision = objySession.getObjectManager().newObject(revision.getEClass(), oldObjyRevision.ooId());
- objyObject.addToRevisions(newObjyRevision);
-
- }
- else
- {
- newObjyRevision = oldObjyRevision;
- }
- }
-
- if (getStore().isRequiredToSupportBranches())
- {
- // add the newObjyRevision to the proper branch.
- ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(
- revision.getBranch().getID());
- ooObj anObj = ooObj.create_ooObj(newObjyRevision.ooId());
- try
- {
- objyBranch.addRevision(anObj);
- }
- catch (LockNotGrantedException ex)
- {
- ex.printStackTrace();
- }
- }
-
- __start = System.nanoTime();
- newObjyRevision.update(this, revision);
- ObjyObjectManager.updateObjectTime += System.nanoTime() - __start;
-
- // if it's a resource, collect it.
- if (revision.isResourceNode())
- {
- __start = System.nanoTime();
- // TODO - this is temp solution to lock the common resource list
- // Add resource to the list
- ObjyResourceList resourceList = objySession.getResourceList(getRepositoryName());
- ooObj anObj = (ooObj)objySession.getFD().objectFrom(resourceList.ooId());
- SmartLock.lock(anObj.getContainer());
-
- // before we update the data into the object we need to check
- // if it's a resource and we're trying to add a duplicate.
- // TODO - do we need to check for Folder and resouce, or is the isResourceNode()
- // check is enough?!!!
- if (revision.isResourceFolder() || revision.isResource())
- {
- // this call will throw exception if we have a duplicate resource we trying to add.
- resourceList.checkDuplicateResources(this, revision);
- }
- SmartLock.lock(newObjyRevision);
- try
- {
- resourceList.add(newObjyRevision);
- }
- catch (LockNotGrantedException ex)
- {
- ex.printStackTrace();
- }
- ObjyObjectManager.resourceCheckAndUpdateTime += System.nanoTime() - __start;
- }
- }
- finally
- {
- async.stop();
- monitor.done();
- }
- }
-
- @Override
- protected void doCommit(OMMonitor monitor)
- {
- // System.out.println(">>>>IS:<<< doCommit() " + this + " - objy session: " + objySession.toString());
-
- long start = System.currentTimeMillis();
- Async async = null;
- monitor.begin();
-
- try
- {
- try
- {
- async = monitor.forkAsync();
- // The commit request might come from a different thread.
- ensureSessionJoin();
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Committing ..." + objySession + " nc:" + objySession.nestCount());
- }
- if (objySession.isOpen() == true)
- {
- objySession.commit();
- }
- else
- {
- TRACER_DEBUG.trace("Error: calling objySession.commit() without having an open trx.");
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Committed");
- }
- }
- finally
- {
- if (async != null)
- {
- async.stop();
- }
- }
- }
- catch (RuntimeException exception)
- {
- TRACER_INFO.trace(exception.getMessage(), exception);
- exception.printStackTrace();
- throw exception;
- }
- finally
- {
- monitor.done();
- }
-
- // 100920 - IS: for debugging
- if (TRACER_DEBUG.isEnabled())
- {
- // TRACER_DEBUG.trace("doCommit() - new objects created: " + ObjyObjectManager.newObjCount + " - Internal: "
- // + ObjyObjectManager.newInternalObjCount);
- // ObjyObjectManager.newObjCount = 0;
- // ObjyObjectManager.newInternalObjCount = 0;
- TRACER_DEBUG.trace(" readRvisions: " + readRevisionCount + " - time: " + readRevisionTime / 1000000.0);
- TRACER_DEBUG.trace(" fetchCount: " + ObjyObject.fetchCount + " - updateCount: " + ObjyObject.updateCount);
- TRACER_DEBUG.trace("\t commit time: " + (System.currentTimeMillis() - start));
- readRevisionTime = 0;
- readRevisionCount = 0;
- ObjyObject.fetchCount = 0;
- ObjyObject.updateCount = 0;
- }
- // System.out.println("IS:>>> ObjyObject.ctor(): count " + ObjyObject.count + " - totalTime: " + ObjyObject.tDiff);
- // for (ooId oid : ObjyObject.oids)
- // {
- // System.out.println("<" + oid.getStoreString() + "> ");
- // }
- // System.out.println();
- // ObjyObject.count = 0;
- // ObjyObject.tDiff = 0;
- // ObjyObject.oids.clear();
- }
-
- public IObjectivityStoreChunkReader createChunkReader(InternalCDORevision revision, EStructuralFeature feature)
- {
- return new ObjectivityStoreChunkReader(this, revision, feature);
- }
-
- public EPackage[] loadPackageUnit(InternalCDOPackageUnit packageUnit)
- {
- // using the packageUnit.getID() we'll read the object from the FD and get the bytes.
- byte[] bytes = null;
-
- ensureSessionBegin();
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("loadPackageUnit for: {0}", packageUnit.getID()); //$NON-NLS-1$
- }
-
- ObjyPackageHandler objyPackageHandler = getStore().getPackageHandler();
-
- bytes = objyPackageHandler.readPackageBytes(packageUnit);
-
- EPackage ePackage = createEPackage(packageUnit, bytes);
-
- return EMFUtil.getAllPackages(ePackage);
- }
-
- private EPackage createEPackage(InternalCDOPackageUnit packageUnit, byte[] bytes)
- {
- ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(getPackageRegistry());
- return EMFUtil.createEPackage(packageUnit.getID(), bytes, zipped, resourceSet, false);
- }
-
- private CDOPackageRegistry getPackageRegistry()
- {
- return getStore().getRepository().getPackageRegistry();
- }
-
- /**
- * TODO - 1) make sure that we return the root resource when we asked for "null" pathPrefix. 2) Create the "null"
- * resource folder if it doesn't exist, perhaps when we initialize the store.
- */
- public void queryResources(QueryResourcesContext context)
- {
- ensureSessionBegin();
-
- String pathPrefix = context.getName();
- boolean exactMatch = context.exactMatch();
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("queryResources() for : " + (pathPrefix == null ? "NULL" : pathPrefix) + " - exactMatch: "
- + exactMatch);
- }
- ObjyResourceList resourceList = objySession.getResourceList(getRepositoryName());
- int size = resourceList.size();
- if (size == 0) // nothing yet.
- {
- CDOID resourceID = OBJYCDOIDUtil.getCDOID(null);
- context.addResource(resourceID);
- }
-
- // TBD: We need to verify the folderID as well!!
- // CDOID folderID = org.eclipse.emf.cdo.common.id.CDOIDUtil.isNull(context.getFolderID()) ? null : context
- // .getFolderID();
- for (int i = 0; i < size; i++)
- {
- ObjyObject resource = resourceList.getResource(i);
- if (resource != null)
- {
- ObjyObject resourceRevision = resource;
- // get the proper revision of the resource (might need to refactor this code, see readRevision())
- if (getStore().isRequiredToSupportBranches())
- {
- try
- {
- resourceRevision = resource.getRevision(context.getTimeStamp(), context.getBranch().getID(),
- objySession.getObjectManager());
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
-
- }
- else if (getStore().isRequiredToSupportAudits())
- {
- try
- {
- resourceRevision = resource.getRevision(context.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID,
- objySession.getObjectManager());
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- if (resourceRevision == null || resourceRevision.getVersion() < 0)
- {
- continue;
- }
-
- String resourceName = ObjyResourceList.getResourceName(resourceRevision);
- CDOID resourceID = OBJYCDOIDUtil.getCDOID(resource.ooId());
- if (exactMatch && pathPrefix != null && pathPrefix.equals(resourceName) || pathPrefix == null
- && resourceName == null)
- {
- if (!context.addResource(resourceID))
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format(" queryResources(1.1) got: " + resource.ooId().getStoreString() + " - version: "
- + resource.getVersion());
- }
- // No more results allowed
- break; // don't continue
- }
- }
- else if (!exactMatch && resourceName != null)
- {
- if (resourceName.startsWith(pathPrefix))
- {
- context.addResource(resourceID);
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format(" queryResources(1.2) got: " + resource.ooId().getStoreString() + " - version: "
- + resource.getVersion());
- }
- }
- }
- /***
- * TODO - verify if we need this code, originally from the old impl. CDOID lookupFolderID = (CDOID)
- * objectManager.getEContainer(resource); if (ObjectUtil.equals(lookupFolderID, folderID)) { boolean match =
- * exactMatch || pathPrefix == null; if (match) { CDOID resourceID = CDOIDUtil.getCDOID(resource.ooId()); if
- * (!context.addResource(resourceID)) { break; } } }
- ***/
- }
- }
-
- }
-
- public void queryXRefs(QueryXRefsContext context)
- {
- ensureSessionBegin();
-
- Set<CDOID> targetIDs = context.getTargetObjects().keySet();
- Map<EClass, List<EReference>> sourceCandidates = context.getSourceCandidates();
-
- // get the context branch.
- CDOBranch branch = context.getBranch();
- ObjyBranchManager branchManager = objySession.getBranchManager(getRepositoryName());
- ObjyBranch objyBranch = branchManager.getBranch(branch.getID());
-
- // iterate over all revision in a branch.
- ObjyObject objyObject = null;
- SortedSet<?> revisions = objyBranch.getRevisions();
- for (Object anObj : revisions)
- {
- // the ooObj we get from revisions is the correct one for that branch.
- objyObject = objySession.getObjectManager().getObject(((ooObj)anObj).getOid());
-
- // InternalCDORevision revision = getRevision(list, context);
- // if (revision == null || revision instanceof SyntheticCDORevision)
- // {
- // continue;
- // }
- //
- EClass eClass = ObjySchema.getEClass(getStore(), objyObject.objyClass());
- CDOID sourceID = objyObject.getRevisionId();
-
- List<EReference> eReferences = sourceCandidates.get(eClass);
- if (eReferences != null)
- {
- for (EReference eReference : eReferences)
- {
- if (eReference.isMany())
- {
- List<Object> results = objyObject.fetchList(this, eReference, 0, CDORevision.UNCHUNKED);
- if (results != null)
- {
- try
- {
- int index = 0;
- for (Object id : results)
- {
- if (!queryXRefs(context, targetIDs, (CDOID)id, sourceID, eReference, index++))
- {
- return;
- }
- }
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
- }
- else
- {
- Object value = objyObject.get(eReference);
- CDOID id = (CDOID)value;
- if (!queryXRefs(context, targetIDs, id, sourceID, eReference, 0))
- {
- return;
- }
- }
- }
- }
- }
- }
-
- private boolean queryXRefs(QueryXRefsContext context, Set<CDOID> targetIDs, CDOID targetID, CDOID sourceID,
- EReference sourceReference, int index)
- {
- for (CDOID id : targetIDs)
- {
- if (id.equals(targetID))
- {
- if (!context.addXRef(targetID, sourceID, sourceReference, index))
- {
- // No more results allowed
- return false;
- }
- }
- }
-
- return true;
- }
-
- /**
- * Read all package units from the store. It's the opposite of writePackageUnits
- */
- public Collection<InternalCDOPackageUnit> readPackageUnits()
- {
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("readPackageUnits()"); //$NON-NLS-1$
- }
-
- ensureSessionBegin();
-
- ObjyPackageHandler objyPackageHandler = getStore().getPackageHandler();
-
- Collection<InternalCDOPackageUnit> packageUnits = objyPackageHandler.readPackageUnits();
-
- return packageUnits;
- }
-
- /**
- *
- */
- public InternalCDORevision readRevision(CDOID id, CDOBranchPoint branchPoint, int listChunk,
- CDORevisionCacheAdder cache)
- {
- long __start = System.nanoTime();
- ensureSessionBegin();
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("RR - Read rev for: {0}, TS:{1}", id, branchPoint.getTimeStamp()); //$NON-NLS-1$
- }
-
- // we shouldn't be doing this!!!
- if (id instanceof CDOIDExternal)
- {
- // 100917 - IS: This must be a bug in CDO, it's throwing a CDOIDExternal at us
- // we'll return null.
- // TRACER_DEBUG.format("objy can't read revision for CDOID: {0}, it's external.", id.toString());
- TRACER_DEBUG.trace("objy can't read revision for external CDOID: " + id.toString());
- return null;
- }
-
- // we might have a proxy object!!!!
-
- ObjyObject objyObject = getObject(id);
-
- if (objyObject == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("RR - objyObject is NULL 4 ID:" + id); //$NON-NLS-1$
- }
- return null;
- }
- // else
- // {
- // TRACER_DEBUG.format("RR - objyObject is ID:" + id + ", :" + objyObject.ooId().getStoreString()); //$NON-NLS-1$
- // }
-
- InternalCDORevision revision = createRevision(objyObject, id);
- revision.setBranchPoint(branchPoint);
-
- ObjyObject objyRevision = objyObject;
-
- if (getStore().isRequiredToSupportBranches())
- {
- try
- {
- objyRevision = objyObject.getRevision(branchPoint.getTimeStamp(), branchPoint.getBranch().getID(),
- objySession.getObjectManager());
- if (objyRevision == null)
- {
- TRACER_DEBUG
- .format(
- "RR - branches ID:{0}, OB:{1}, BPB:{2}, BPTS:{3}", id, objyObject.getBranchId(), branchPoint.getBranch().getID(), branchPoint.getTimeStamp()); //$NON-NLS-1$
- }
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
- else if (getStore().isRequiredToSupportAudits())
- {
- try
- {
- objyRevision = objyObject.getRevision(branchPoint.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID,
- objySession.getObjectManager());
- if (objyRevision == null)
- {
- TRACER_DEBUG
- .format(
- "RR - audit ID:{0}, OB:{1}, BPB:{2}, BPTS:{3}", id, objyObject.getBranchId(), branchPoint.getBranch().getID(), branchPoint.getTimeStamp()); //$NON-NLS-1$
- }
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
-
- }
-
- if (objyRevision == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("RR - objyRevision is NULL 4 ID:" + id); //$NON-NLS-1$
- }
- return null;
- }
-
- // check the version
- if (objyRevision.getVersion() < 0)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG
- .format("RR - ...revision for: {0} - OID: {1} is detached.", id, objyObject.ooId().getStoreString()); //$NON-NLS-1$
- }
- EClass eClass = ObjySchema.getEClass(getStore(), objyObject.objyClass());
- return new DetachedCDORevision(eClass, id, branchPoint.getBranch(), -objyRevision.getVersion(),
- objyRevision.getCreationTime());
- }
-
- CDOBranchPoint branchPoint2 = revision.getBranch().getPoint(objyRevision.getCreationTime());
- revision.setBranchPoint(branchPoint2);
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG
- .format("RR - Fetching revision details for: {0} - OID:{1}", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$
- }
-
- boolean ok = objyRevision.fetch(this, revision, listChunk);
-
- if (!ok)
- {
- TRACER_DEBUG.format("RR - Fetch rev failed 4: {0}, :{1}", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$
- }
-
- readRevisionTime += System.nanoTime() - __start;
- readRevisionCount++;
-
- return ok ? revision : null;
- }
-
- /**
- *
- */
- public InternalCDORevision readRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int listChunk,
- CDORevisionCacheAdder cache)
- {
- long __start = System.nanoTime();
- ensureSessionBegin();
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("RRBV - Read rev 4: {0}, ver: {1}", id, branchVersion.getVersion()); //$NON-NLS-1$
- }
-
- // we might have a proxy object!!!!
-
- ObjyObject objyObject = getObject(id);
- if (objyObject == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("RRBV - objyObject is NULL for ID: " + id); //$NON-NLS-1$
- }
- return null;
- }
-
- // {
- // TRACER_DEBUG.format("RRBV - objyObject 4 ID: " + id + ", :" + objyObject.ooId().getStoreString()); //$NON-NLS-1$
- // }
-
- ObjyObject objyRevision = null;
- objyRevision = objyObject.getRevisionByVersion(branchVersion.getVersion(), branchVersion.getBranch().getID(),
- objySession.getObjectManager());
- // if (getStore().isRequiredToSupportAudits())
- // {
- // objyRevision = objyObject.getRevisionByVersion(branchVersion.getVersion());
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG
- .format(
- "Reading revision by version {0} for: {1} - OID: {2}", branchVersion.getVersion(), id, objyObject.ooId().getStoreString()); //$NON-NLS-1$
- }
-
- // }
- // else
- // {
- // objyRevision = objyObject.getLastRevision();
- //
- // if (TRACER_DEBUG.isEnabled())
- // {
- // TRACER_DEBUG.format(
- // "(None-Audit) Reading revision by version for: {0} - OID: {1}", id, objyObject.ooId().getStoreString()); //$NON-NLS-1$
- // }
- // }
-
- if (objyRevision == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("RRBV - objyRevision is NULL for ID: ", id); //$NON-NLS-1$
- }
- return null;
- }
-
- InternalCDORevision revision = createRevision(objyRevision, id);
-
- revision.setVersion(branchVersion.getVersion());
- revision.setBranchPoint(branchVersion.getBranch().getHead());
-
- // TODO - clean up the following 3 lines...
- // InternalCDOBranchManager branchManager = getStore().getRepository().getBranchManager();
- // CDOBranch mainBranch = branchManager.getBranch(CDOBranch.MAIN_BRANCH_ID);
- // //revision.setBranchPoint(CDOBranchUtil.createBranchPoint(mainBranch, 0));
- // revision.setBranchPoint(mainBranch.getHead());
-
- boolean ok = objyRevision.fetch(this, revision, listChunk);
-
- if (ok && objyRevision.getVersion() != branchVersion.getVersion())
- {
- throw new IllegalStateException("Can only retrieve current version " + revision.getVersion() + " for " + //$NON-NLS-1$ //$NON-NLS-2$
- id + " - version requested was " + branchVersion + "."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // if (!ok)
- // {
- // TRACER_DEBUG.format("RRBV - Fetch rev failed 4: {0}, :", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$
- // }
-
- readRevisionTime += System.nanoTime() - __start;
- readRevisionCount++;
-
- return ok ? revision : null;
- }
-
- public void writePackageUnits(InternalCDOPackageUnit[] packageUnits, OMMonitor monitor)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("writePackageUnits()"); //$NON-NLS-1$
- }
-
- ensureSessionBegin();
-
- ObjyPackageHandler objyPackageHandler = getStore().getPackageHandler();
- CDOPackageRegistry packageRegistry = getStore().getRepository().getPackageRegistry();
-
- for (InternalCDOPackageUnit packageUnit : packageUnits)
- {
- objyPackageHandler.writePackages(packageRegistry, packageUnit, monitor/* .fork() */);
- }
- }
-
- private InternalCDORevision createRevision(ObjyObject objyObject, CDOID id)
- {
- EClass eClass = ObjySchema.getEClass(getStore(), objyObject.objyClass());
-
- if (eClass == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("OBJY: Can't find eClass for id:" + id);
- }
- return null;
- }
-
- return getStore().createRevision(eClass, id);
- }
-
- private String getRepositoryName()
- {
- return getStore().getRepository().getName();
- }
-
- /***
- * For us, this function creates the skeleton objects in Objectivity, to be able to get the new ooId and pass it to
- * the commitContext. The objects data will be updated in the call to writeRevision().
- */
- @Override
- public void addIDMappings(InternalCommitContext commitContext, OMMonitor monitor)
- {
- long __start = System.nanoTime();
- ensureSessionBegin();
- if (commitContext.getNewObjects().length > 0)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("creating " + commitContext.getNewObjects().length + " new objects and assigning new IDs");
- }
- InternalCDORevision[] newObjects = commitContext.getNewObjects();
- try
- {
- monitor.begin(newObjects.length);
-
- ObjyPlacementManagerLocal placementManager = new ObjyPlacementManagerLocal(getStore(), objySession,
- commitContext, newObjyObjectsMap);
-
- // iterate over the list and skip the ones we already have created.
- for (InternalCDORevision revision : newObjects)
- {
- try
- {
- placementManager.processRevision(revision);
- }
- catch (com.objy.db.ObjyRuntimeException ex)
- {
- System.out.println(">>>>IS: Exception<<<< Session: " + objySession + " open status: "
- + objySession.isOpen());
- ex.printStackTrace();
- }
- monitor.worked();
- }
- }
- finally
- {
- monitor.done();
- }
- }
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(" addIDMappings for " + commitContext.getNewObjects().length + " - time: "
- + (System.nanoTime() - __start) / 1000000.0);
- TRACER_DEBUG.trace(" createObjects : " + ObjyObject.createObjectCount + " - time: "
- + ObjyObject.createObjectTime / 1000000.0);
- ObjyObject.createObjectTime = 0;
- ObjyObject.createObjectCount = 0;
- }
- }
-
- @Override
- protected CDOID getNextCDOID(CDORevision revision)
- {
- // Never called
- throw new UnsupportedOperationException();
- }
-
- /***************************
- * Local Utility functions.
- ***************************/
- public void ensureActiveSession()
- {
- ensureSessionBegin();
- }
-
- protected void ensureSessionBegin()
- {
- getObjySession();
- if (!objySession.isJoined())
- {
- objySession.join();
- }
- if (!objySession.isOpen())
- {
- if (isRead)
- {
- objySession.setOpenMode(oo.openReadOnly);
- }
- else
- {
- objySession.setOpenMode(oo.openReadWrite);
- }
- objySession.begin();
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(" ensureBeginSession() called begin() on session: " + objySession + " [name: "
- + objySession.getName() + " - open: " + objySession.isOpen() + "]");
- }
- }
- }
-
- private void ensureSessionJoin()
- {
- // we better have a session for this store.
- assert objySession != null;
- // testSwitchViewTarget() is crashing because objySession is null.
- // TBD: verify this case!!!
- if (objySession != null && !objySession.isJoined())
- {
- objySession.join();
- }
- }
-
- // *********************************************
- // New APIs for CDO 3.0
- // *********************************************
-
- public void loadCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler)
- {
- ensureSessionBegin();
-
- ObjyCommitInfoHandler commitInfoHandler = getStore().getCommitInfoHandler();
- List<ObjyCommitInfo> commitInfoList = commitInfoHandler.getCommitInfo(branch, startTime, endTime);
-
- InternalSessionManager manager = getSession().getManager();
- InternalRepository repository = manager.getRepository();
- InternalCDOBranchManager branchManager = repository.getBranchManager();
- InternalCDOCommitInfoManager commitInfoManager = repository.getCommitInfoManager();
-
- for (ObjyCommitInfo ooCommitInfo : commitInfoList)
- {
- long timeStamp = ooCommitInfo.getTimeStamp();
- long previousTimeStamp = ooCommitInfo.getPreviousTimeStamp();
- String userID = ooCommitInfo.getUserId();
- String comment = ooCommitInfo.getComment();
- CDOBranch infoBranch = branch;
- if (infoBranch == null)
- {
- int id = ooCommitInfo.getBranchId();
- infoBranch = branchManager.getBranch(id);
- }
-
- CDOCommitInfo commitInfo = commitInfoManager.createCommitInfo(infoBranch, timeStamp, previousTimeStamp, userID,
- comment, null);
- handler.handleCommitInfo(commitInfo);
- }
-
- }
-
- @Override
- protected void writeCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID,
- String comment, OMMonitor monitor)
- {
- ensureSessionBegin();
- // we need to write the following...
- // ...branch.getID(), timeStamp, userID, comment.
- try
- {
- ObjyCommitInfoHandler commitInfoHandler = getStore().getCommitInfoHandler();
- commitInfoHandler.writeCommitInfo(branch.getID(), timeStamp, previousTimeStamp, userID, comment);
- }
- catch (com.objy.db.ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- public IQueryHandler getQueryHandler(org.eclipse.emf.cdo.common.util.CDOQueryInfo info)
- {
- if (ObjectivityQueryHandler.QUERY_LANGUAGE.equals(info.getQueryLanguage()))
- {
- return new ObjectivityQueryHandler(this);
- }
-
- return null;
- }
-
- public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo)
- {
- ensureSessionBegin();
- boolean convertToUpdate = false;
- // IS: this is a hack to overcome the issue in cdo core where the Accessor is requested for
- // read but it's trying to create stuff.
- if (isRead)
- {
- TRACER_DEBUG.trace("-->> createBranch() - Hack... Hack... changing read to update.");
- // upgrade the session to update.
- objySession.commit();
- objySession.setOpenMode(oo.openReadWrite);
- convertToUpdate = true;
- objySession.begin();
- }
- Pair<Integer, Long> retValue = objySession.getBranchManager(getRepositoryName()).createBranch(branchID, branchInfo);
- if (convertToUpdate)
- {
- // return the session to read.
- objySession.commit();
- objySession.setOpenMode(oo.openReadOnly);
- objySession.begin();
- }
- return retValue;
- }
-
- public BranchInfo loadBranch(int branchID)
- {
- ensureSessionBegin();
- ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(branchID);
- return objyBranch != null ? objyBranch.getBranchInfo() : null;
- }
-
- public int loadBranches(int startID, int endID, CDOBranchHandler branchHandler)
- {
- int count = 0;
- List<ObjyBranch> branches = objySession.getBranchManager(getRepositoryName()).getBranches(startID, endID);
- InternalCDOBranchManager branchManager = getStore().getRepository().getBranchManager();
-
- for (ObjyBranch objyBranch : branches)
- {
- InternalCDOBranch branch = branchManager
- .getBranch(objyBranch.getBranchId(), new BranchInfo(objyBranch.getBranchName(), objyBranch.getBaseBranchId(),
- objyBranch.getBaseBranchTimeStamp()));
- branchHandler.handleBranch(branch);
- count++;
- }
-
- return count;
-
- }
-
- public SubBranchInfo[] loadSubBranches(int branchID)
- {
- ensureSessionBegin();
- List<SubBranchInfo> result = new ArrayList<SubBranchInfo>();
- List<ObjyBranch> objyBranchList = objySession.getBranchManager(getRepositoryName()).getSubBranches(branchID);
- for (ObjyBranch objyBranch : objyBranchList)
- {
- SubBranchInfo subBranchInfo = new SubBranchInfo(objyBranch.getBranchId(), objyBranch.getBranchName(),
- objyBranch.getBaseBranchTimeStamp());
- result.add(subBranchInfo);
- }
- return result.toArray(new SubBranchInfo[result.size()]);
- }
-
- public void handleRevisions(EClass eClass, CDOBranch branch, long timeStamp, boolean exactTime,
- CDORevisionHandler handler)
- {
- ensureSessionBegin();
- IRepository repository = getStore().getRepository();
- CDORevisionManager revisionManager = repository.getRevisionManager();
- CDOBranchManager branchManager = repository.getBranchManager();
-
- // scan FD for ObjyBase which is the base class for all revisions
- Iterator<?> itr = objySession.getFD().scan(ObjyBase.CLASS_NAME);
- ObjyObject objyObject = null;
- while (itr.hasNext())
- {
- objyObject = objySession.getObjectManager().getObject(((ooObj)itr).getOid());
- if (!handleRevision(objyObject, eClass, branch, timeStamp, exactTime, handler, revisionManager, branchManager))
- {
- return;
- }
- }
- // TODO: implement ObjectivityStoreAccessor.handleRevisions(eClass, branch, timeStamp, exactTime, handler)
- throw new UnsupportedOperationException();
- }
-
- private boolean handleRevision(ObjyObject objyObject, EClass eClass, CDOBranch branch, long timeStamp,
- boolean exactTime, CDORevisionHandler handler, CDORevisionManager revisionManager, CDOBranchManager branchManager)
- {
- if (objyObject.getVersion() < 0) // DetachedCDORevision
- {
- return true;
- }
-
- if (eClass != null && ObjySchema.getEClass(getStore(), objyObject.objyClass()) != eClass)
- {
- return true;
- }
-
- if (branch != null && objyObject.getBranchId() != branch.getID())
- {
- return true;
- }
-
- if (timeStamp != CDOBranchPoint.INVALID_DATE)
- {
- if (exactTime)
- {
- if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE && objyObject.getCreationTime() != timeStamp)
- {
- return true;
- }
- }
- else
- {
- long startTime = objyObject.getCreationTime();
- long endTime = objyObject.getRevisedTime();
- if (!CDOCommonUtil.isValidTimeStamp(timeStamp, startTime, endTime))
- {
- return true;
- }
- }
- }
-
- CDOBranchVersion branchVersion = branchManager.getBranch((int)objyObject.getBranchId()).getVersion(
- Math.abs(objyObject.getVersion()));
- InternalCDORevision revision = (InternalCDORevision)revisionManager.getRevisionByVersion(
- OBJYCDOIDUtil.getCDOID(objyObject.ooId()), branchVersion, CDORevision.UNCHUNKED, true);
-
- return handler.handleRevision(revision);
- }
-
- public Set<CDOID> readChangeSet(OMMonitor monitor, CDOChangeSetSegment... segments)
- {
- monitor.begin(segments.length);
-
- try
- {
- ensureSessionBegin();
-
- ObjyBranchManager objyBranchManager = objySession.getBranchManager(getRepositoryName());
- ObjyObjectManager objyObjectManager = objySession.getObjectManager();
- Set<CDOID> results = new HashSet<CDOID>();
-
- // get all revisions that has branchId, and creation timestamp, and perhaps revised before
- // end timestamp or haven't been revised.
- for (CDOChangeSetSegment segment : segments)
- {
- ObjyBranch objyBranch = objyBranchManager.getBranch(segment.getBranch().getID());
- // query the branch revisions for the time range.
- SortedSet<?> revisions = objyBranch.getRevisions();
- readChangeSet(monitor.fork(), segment, objyObjectManager, revisions, results);
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ChangeSet " + results.toString());
- }
-
- return results;
- }
- finally
- {
- monitor.done();
- }
- }
-
- protected void readChangeSet(OMMonitor monitor, CDOChangeSetSegment segment, ObjyObjectManager objyObjectManager,
- SortedSet<?> revisions, Set<CDOID> results)
- {
- int size = revisions.size();
- monitor.begin(size);
- Async async = null;
- try
- {
- async = monitor.forkAsync();
-
- Iterator<?> objItr = revisions.iterator();
- while (objItr.hasNext())
- {
- ooObj anObj = (ooObj)objItr.next();
- ObjyObject objyObject = objyObjectManager.getObject(anObj.getOid());
- long creationTime = objyObject.getCreationTime();
- long revisedTime = objyObject.getRevisedTime();
- if (creationTime >= segment.getTimeStamp() && (revisedTime <= segment.getEndTime() || revisedTime == 0))
- {
- results.add(objyObject.getRevisionId());
- }
-
- monitor.worked();
- }
- }
- finally
- {
- async.stop();
- monitor.done();
-
- }
- }
-
- public void queryLobs(List<byte[]> ids)
- {
- // TODO: implement ObjectivityStoreAccessor.queryLobs(ids)
- throw new UnsupportedOperationException();
- }
-
- public void handleLobs(long fromTime, long toTime, CDOLobHandler handler) throws IOException
- {
- // TODO: implement ObjectivityStoreAccessor.handleLobs(fromTime, toTime, handler)
- throw new UnsupportedOperationException();
- }
-
- public void loadLob(byte[] id, OutputStream out) throws IOException
- {
- // TODO: implement ObjectivityStoreAccessor.loadLob(id, out)
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void writeBlob(byte[] id, long size, InputStream inputStream) throws IOException
- {
- // TODO: implement ObjectivityStoreAccessor.writeBlob(id, size, inputStream)
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void writeClob(byte[] id, long size, Reader reader) throws IOException
- {
- // TODO: implement ObjectivityStoreAccessor.writeClob(id, size, reader)
- throw new UnsupportedOperationException();
- }
-
- public void rawExport(CDODataOutput out, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime)
- throws IOException
- {
- // TODO: implement ObjectivityStoreAccessor.rawExport();
- throw new UnsupportedOperationException();
- }
-
- public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime,
- OMMonitor monitor) throws IOException
- {
- // TODO: implement ObjectivityStoreAccessor.rawImport
- throw new UnsupportedOperationException();
- }
-
- public void rawStore(InternalCDOPackageUnit[] packageUnits, OMMonitor monitor)
- {
- // TODO: implement ObjectivityStoreAccessor.rawStore
- throw new UnsupportedOperationException();
- }
-
- public void rawStore(InternalCDORevision revision, OMMonitor monitor)
- {
- // TODO: implement ObjectivityStoreAccessor.rawStore
- throw new UnsupportedOperationException();
- }
-
- public void rawStore(byte[] id, long size, InputStream inputStream) throws IOException
- {
- // TODO: implement ObjectivityStoreAccessor.rawStore
- throw new UnsupportedOperationException();
- }
-
- public void rawStore(byte[] id, long size, Reader reader) throws IOException
- {
- // TODO: implement ObjectivityStoreAccessor.rawStore
- throw new UnsupportedOperationException();
- }
-
- public void rawStore(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID, String comment,
- OMMonitor monitor)
- {
- // TODO: implement ObjectivityStoreAccessor.rawStore
- throw new UnsupportedOperationException();
- }
-
- @Deprecated
- public void rawDelete(CDOID id, int version, CDOBranch branch, EClass eClass, OMMonitor monitor)
- {
- throw new UnsupportedOperationException();
- }
-
- public void rawCommit(double commitWork, OMMonitor monitor)
- {
- // TODO: implement ObjectivityStoreAccessor.rawCommit
- throw new UnsupportedOperationException();
- }
-
- public LockArea createLockArea(String userID, CDOBranchPoint branchPoint, boolean readOnly,
- Map<CDOID, LockGrade> locks)
- {
- // TODO: implement ObjectivityStoreAccessor.createLockArea
- throw new UnsupportedOperationException();
- }
-
- public LockArea getLockArea(String durableLockingID) throws LockAreaNotFoundException
- {
- // TODO: implement ObjectivityStoreAccessor.getLockArea
- throw new UnsupportedOperationException();
- }
-
- public void getLockAreas(String userIDPrefix, Handler handler)
- {
- ensureSessionBegin();
-
- InternalCDOBranchManager branchManager = getStore().getRepository().getBranchManager();
- ObjyLockAreaManager objyLockAreaManager = objySession.getLockAreaManager(getRepositoryName());
- objyLockAreaManager.getLockAreas(branchManager, userIDPrefix, handler);
- }
-
- public void deleteLockArea(String durableLockingID)
- {
- // TODO: implement ObjectivityStoreAccessor.deleteLockArea
- throw new UnsupportedOperationException();
- }
-
- public void lock(String durableLockingID, LockType type, Collection<? extends Object> objectsToLock)
- {
- // TODO: implement ObjectivityStoreAccessor.lock
- throw new UnsupportedOperationException();
- }
-
- public void unlock(String durableLockingID, LockType type, Collection<? extends Object> objectsToUnlock)
- {
- // TODO: implement ObjectivityStoreAccessor.unlock
- throw new UnsupportedOperationException();
- }
-
- public void unlock(String durableLockingID)
- {
- // TODO: implement ObjectivityStoreAccessor.unlock
- throw new UnsupportedOperationException();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDExternal;
+import org.eclipse.emf.cdo.common.lob.CDOLobHandler;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea.Handler;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionCacheAdder;
+import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
+import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.server.IQueryHandler;
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.server.ISession;
+import org.eclipse.emf.cdo.server.IStoreAccessor.DurableLocking;
+import org.eclipse.emf.cdo.server.ITransaction;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManagerLocal;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyCommitInfoHandler;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObjectManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPackageHandler;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBase;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranch;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyCommitInfo;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.SmartLock;
+import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreAccessor;
+import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreChunkReader;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
+import org.eclipse.emf.cdo.spi.common.commit.CDOChangeSetSegment;
+import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
+import org.eclipse.emf.cdo.spi.server.InternalRepository;
+import org.eclipse.emf.cdo.spi.server.InternalSessionManager;
+import org.eclipse.emf.cdo.spi.server.StoreAccessor;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.collection.Pair;
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import com.objy.db.LockNotGrantedException;
+import com.objy.db.app.oo;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+/**
+ * @author Simon McDuff
+ * @author Ibrahim Sallam
+ */
+public class ObjectivityStoreAccessor extends StoreAccessor implements IObjectivityStoreAccessor, DurableLocking
+{
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjectivityStoreAccessor.class);
+
+ private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjectivityStoreAccessor.class);
+
+ protected ObjySession objySession = null;
+
+ // protected ObjyObjectManager objectManager = null;
+
+ protected boolean isRead = false;
+
+ protected int sessionID = 0; // used to tag the Objy session in the session pool
+
+ boolean zipped = true; // TODO - might make this configurable...
+
+ private HashMap<CDOID, ObjyObject> newObjyObjectsMap = new HashMap<CDOID, ObjyObject>();
+
+ private long readRevisionTime = 0;
+
+ private int readRevisionCount = 0;
+
+ protected ObjectivityStoreAccessor(ObjectivityStore store, ISession cdoSession)
+ {
+ super(store, cdoSession);
+
+ // for debugging...
+ // session.getProtocol();
+ // org.eclipse.emf.cdo.net4j.CDOSession.Options.getProtocol()
+ // [12:42:23 PM] Eike Stepper says: org.eclipse.net4j.signal.ISignalProtocol.setTimeout(long)
+ // [12:42:43 PM] Eike Stepper says: commit is different
+ // if (cdoSession != null && cdoSession.getProtocol().getSession() instanceof org.eclipse.emf.cdo.net4j.CDOSession)
+ // {
+ // CDOCommonSession commonSession = cdoSession.getProtocol().getSession();
+ // org.eclipse.emf.cdo.net4j.CDOSession tempSession = (org.eclipse.emf.cdo.net4j.CDOSession)commonSession;
+ // tempSession.options().setCommitTimeout(60000);
+ // }
+ // [12:42:45 PM] Eike Stepper says: org.eclipse.emf.cdo.net4j.CDOSession.Options.setCommitTimeout(int)
+ // org.eclipse.emf.cdo.net4j.CDOSession.Options.setProgressInterval(int)
+
+ /* I believe this is a read session */
+ isRead = true;
+ if (cdoSession != null)
+ {
+ sessionID = cdoSession.getSessionID();
+ }
+ }
+
+ public ObjectivityStoreAccessor(ObjectivityStore store, ITransaction transaction)
+ {
+ super(store, transaction);
+
+ // for debugging...
+ // if (transaction != null && transaction.getSession().getProtocol().getSession() instanceof
+ // org.eclipse.emf.cdo.net4j.CDOSession)
+ // {
+ // CDOCommonSession commonSession = transaction.getSession().getProtocol().getSession();
+ // org.eclipse.emf.cdo.net4j.CDOSession cdoSession = (org.eclipse.emf.cdo.net4j.CDOSession)commonSession;
+ // cdoSession.options().setCommitTimeout(60000);
+ // }
+ /* I believe this is a write session */
+ if (transaction != null)
+ {
+ sessionID = transaction.getSession().getSessionID();
+ }
+ }
+
+ @Override
+ protected void detachObjects(CDOID[] detachedObjects, CDOBranch branch, long timeStamp, OMMonitor monitor)
+ {
+ ensureSessionBegin();
+
+ // System.out.println(">>>>IS:<<< detachObjects() " + this + " - objy session: " + objySession.toString());
+ // objySession.addToLog("IS:>>>", "detachObjects - begin");
+
+ try
+ {
+ monitor.begin(detachedObjects.length);
+ // Find all Objy containers to lock as one unit.
+ Set<ooId> containerToLocks = new HashSet<ooId>();
+ for (CDOID id : detachedObjects)
+ {
+ ooId containerID = OBJYCDOIDUtil.getContainerId(id);
+ containerToLocks.add(containerID);
+ }
+ objySession.lockContainers(containerToLocks);
+
+ InternalCDORevisionManager revisionManager = getStore().getRepository().getRevisionManager();
+
+ long tStart = System.currentTimeMillis();
+ for (CDOID id : detachedObjects)
+ {
+
+ InternalCDORevision revision = revisionManager.getRevision(id, branch.getHead(), CDORevision.UNCHUNKED,
+ CDORevision.DEPTH_NONE, true);
+ int version = ObjectUtil.equals(branch, revision.getBranch()) ? revision.getVersion()
+ : CDOBranchVersion.FIRST_VERSION;
+
+ detachObject(id, version, branch, timeStamp);
+ }
+ // objySession.addToLog("IS:>>>", "detachObjects - end");
+ long tDiff = System.currentTimeMillis() - tStart;
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("detach objects: " + detachedObjects.length + " - time: " + tDiff);
+ }
+
+ }
+ finally
+ {
+ monitor.done();
+ }
+
+ // System.out.println(">>>>IS:<<< detachObjects() DONE " + this + " - objy session: " + objySession.toString());
+ }
+
+ /***
+ * @param CDOID
+ * @param version
+ * @param branch
+ * @param timeStamp
+ */
+ private void detachObject(CDOID id, int version, CDOBranch branch, long timeStamp)
+ {
+ // ensureSessionBegin();
+
+ ObjyObject objyObject = getObject(id);
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Detaching id " + id + " - OID: " + objyObject.ooId().getStoreString() + " verions: "
+ + version + " in Branch: " + branch.getID() + " and timeStamp: " + timeStamp);
+ }
+
+ if (getStore().isRequiredToSupportAudits())
+ {
+ if (version > CDOBranchVersion.FIRST_VERSION)
+ {
+ // pick the proper version of that branch to revise it. Otherwise, the detached version will
+ // be in a different branch.
+ ObjyObject objyRevision = objyObject.getRevisionByVersion(version, branch.getID(),
+ objySession.getObjectManager());
+ if (objyRevision.getVersion() < 0)
+ {
+ TRACER_DEBUG.trace("... OBJ is already detached...");
+ }
+ objyRevision.setRevisedTime(timeStamp - 1);
+ }
+ objyObject.detach(version, branch, timeStamp);
+ }
+ else
+ {
+ objyObject.setVersion(-version);
+ objyObject.delete(this, objySession.getObjectManager());
+ }
+
+ // // we'll need to find it's containing object/resource and remove it from there.
+ // // TODO - do we need to deal with dependent objects, i.e. delete them as well,
+ // // is there a notion of delete propagate?
+ // if (ObjySchema.isResource(getStore(), objyObject.objyClass()))
+ // {
+ // ObjyResourceList resourceList = objySession.getResourceList(getRepositoryName());
+ // resourceList.remove(objyObject);
+ // }
+ objySession.getObjectManager().remove(objyObject); // removed it from the cache.
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ // System.out.println(">>>>IS:<<<< StoreAccessor.doActivate() " + this);
+ // getObjySession();
+ }
+
+ public ObjySession getObjySession()
+ {
+ int currSessionID = sessionID;
+
+ if (!isReader())
+ {
+ // The only reason we do this is because there was a switching of context in the middle
+ // of a transaction, and we want to ensure that we continue with the proper session that
+ // is holding the data.
+ ITransaction cdoTrx = getTransaction();
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG
+ .trace("getObjySession() - context's transaction: " + (cdoTrx == null ? "null" : cdoTrx.toString()));
+ }
+ if (cdoTrx != null)
+ {
+ sessionID = cdoTrx.getSession().getSessionID();
+ }
+ }
+
+ if (objySession != null && currSessionID == sessionID)
+ {
+ return objySession;
+ }
+
+ // get a session name.
+ String sessionName = "Session_" + sessionID;
+
+ if (objySession != null)
+ {
+ objySession.returnSessionToPool();
+ }
+ if (isReader())
+ {
+ objySession = getStore().getConnection().getReadSessionFromPool(sessionName + "_" + getRepositoryName());
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(" getObjySession from read pool, session: " + objySession.toString() + " - isOpen: "
+ + objySession.isOpen() + " - sessionName:" + objySession.getName());
+ }
+ }
+ else
+ {
+ objySession = getStore().getConnection().getWriteSessionFromPool(sessionName + "_" + getRepositoryName());
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(" getObjySession from write pool, session: " + objySession.toString() + " - isOpen: "
+ + objySession.isOpen() + " - sessionName:" + objySession.getName());
+ }
+ }
+
+ if (!objySession.isOpen())
+ {
+ objySession.setMrowMode(oo.MROW);
+ objySession.setWaitOption(45000);
+ objySession.setAllowUnregisterableTypes(true);
+ if (isRead)
+ {
+ objySession.setOpenMode(oo.openReadOnly);
+ }
+ else
+ {
+ objySession.setOpenMode(oo.openReadWrite);
+ }
+ objySession.begin();
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(" calling session.begin() for " + objySession.toString() + " - isRead: " + isRead);
+ }
+ }
+ else
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(" session " + objySession.toString() + " already open.");
+ }
+ }
+
+ return objySession;
+ }
+
+ private void returnObjySession()
+ {
+ // System.out.println(">>>>IS:<<<< Returning to pool, session: " + objySession + " - name: " +
+ // objySession.getName());
+ ensureSessionJoin();
+ // testDetachWithoutRevision_CheckMainBranch() is crashing because objySession is null.
+ // TBD: verify this case!!!
+ if (objySession == null)
+ {
+ return;
+ }
+
+ if (objySession.isOpen())
+ {
+ // System.out.println(">>>>IS:<<<< commiting session: " + objySession + " - name: " + objySession.getName());
+ objySession.commit(); // IS: we might need to abort instead.
+ }
+ objySession.returnSessionToPool();
+ objySession = null;
+ }
+
+ @Override
+ protected void doDeactivate() throws Exception
+ {
+ // System.out.println(">>>>IS:<<< StoreAccessor.doDeactivate() " + this);
+ returnObjySession();
+ }
+
+ @Override
+ protected void doPassivate() throws Exception
+ {
+ // System.out.println(">>>>IS:<<<< StoreAccessor.doPassivate() " + this);
+ returnObjySession();
+ }
+
+ @Override
+ protected void doUnpassivate() throws Exception
+ {
+ // System.out.println(">>>>IS:<<<< StoreAccessor.doUnpassivate() " + this);
+ // IS: don't call this now, in case we don't have a context.
+ // getObjySession();
+ }
+
+ // @Override
+ // protected void setContext(Object context)
+ // {
+ // super.setContext(context);
+ // System.out.println(">>>>IS:<<<< StoreAccessor.setContext() " + this + " - context: " + context.toString());
+ // }
+
+ @Override
+ protected void doRollback(CommitContext commitContext)
+ {
+ try
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Rollback session " + objySession);
+ }
+ // the rollback could be coming from another thread.
+ ensureSessionJoin();
+ if (objySession.isOpen())
+ {
+ objySession.abort();
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("OBJY: session aborted - Session: " + objySession + " - open:" + objySession.isOpen());
+ }
+ }
+ }
+ catch (RuntimeException exception)
+ {
+ TRACER_INFO.trace(exception.getMessage(), exception);
+ exception.printStackTrace();
+ throw exception;
+ }
+ }
+
+ @Override
+ protected void writeRevisionDeltas(InternalCDORevisionDelta[] revisionDeltas, CDOBranch branch, long created,
+ OMMonitor monitor)
+ {
+ // System.out.println(">>>>IS:<<< writeRevisionDeltas() " + this + " - objy session: " + objySession.toString());
+ long start = System.nanoTime();
+ ensureSessionBegin();
+
+ try
+ {
+ monitor.begin(revisionDeltas.length);
+ // Find all Objy containers to lock as one unit.
+ Set<ooId> containerToLocks = new HashSet<ooId>();
+ for (InternalCDORevisionDelta delta : revisionDeltas)
+ {
+ ooId containerID = OBJYCDOIDUtil.getContainerId(delta.getID());
+ containerToLocks.add(containerID);
+ }
+ objySession.lockContainers(containerToLocks);
+
+ for (InternalCDORevisionDelta revisionDelta : revisionDeltas)
+ {
+ writeRevisionDelta(revisionDelta, branch, created);
+ }
+ }
+ finally
+ {
+ monitor.done();
+ }
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(" writeRevisionDeltas: " + revisionDeltas.length + " - time: " + (System.nanoTime() - start)
+ / 1000000.0);
+ }
+ }
+
+ /**
+ * Called for each revision delta.
+ *
+ * @param delta
+ * @param created
+ * @param branch
+ */
+ // private void writeRevisionDelta2(InternalCDORevisionDelta delta, CDOBranch branch, long created)
+ // {
+ // // ensureSessionBegin();
+ //
+ // int deltaVersion = delta.getVersion();
+ // int newVersion = CDOBranchVersion.FIRST_VERSION;
+ //
+ // ObjyObject objyObject = getObject(delta.getID());
+ // if (TRACER_DEBUG.isEnabled())
+ // {
+ // TRACER_DEBUG.format("writingRevisionDelta getting Object: {0}, v:{1} - BranchId:{2}", objyObject.ooId()
+ // .getStoreString(), deltaVersion, delta.getBranch().getID());
+ // }
+ // ObjyObject objyOriginalRevision = objyObject.getRevisionByVersion(deltaVersion, delta.getBranch().getID(),
+ // objySession.getObjectManager());
+ //
+ // if (branch.getID() == delta.getBranch().getID())
+ // {
+ // // Same branch, increase version
+ // newVersion = deltaVersion + 1;
+ // }
+ //
+ // if (TRACER_DEBUG.isEnabled())
+ // {
+ // TRACER_DEBUG.format("Writing revision delta: {0}, v:{1} - OID:{2}, v:{3} - BranchId:{4}", delta, deltaVersion,
+ // objyObject.ooId().getStoreString(), objyOriginalRevision.getVersion(), objyOriginalRevision.getBranchId());
+ // TRACER_DEBUG.format("... delta branch ID: {0} - revision branch ID: {1}", branch.getID(),
+ // objyOriginalRevision.getBranchId());
+ // }
+ // // System.out.println(">>>IS: Delta Writing: " + delta.getID() + " - oid: " + objyObject.ooId().getStoreString());
+ // // System.out.println("\t - old version : " + delta.getVersion());
+ // // System.out.println("\t - created : " + created);
+ // // System.out.println("\t - delta.branch: " + delta.getBranch().toString());
+ // // System.out.println("\t - branch : " + branch.toString());
+ // // System.out.println("\t - branch TS : " + branch.getPoint(created).getTimeStamp());
+ // // System.out.println("\t - delta : " + delta.toString());
+ // // for debugging...
+ //
+ // if (objyOriginalRevision.getVersion() != deltaVersion)
+ // {
+ // throw new RuntimeException("ObjecitivityStoreAccessor : Dirty write");
+ // }
+ //
+ // ObjyObject objyNewRevision = null;
+ //
+ // if (getStore().isRequiredToSupportAudits())
+ // {
+ // // newObjyRevision = objySession.getObjectManager().copyRevision(this, objyRevision);
+ // // objyRevision.setRevisedBranchId(branch.getID();
+ // // InternalCDORevision originalRevision = getStore().getRepository().getRevisionManager()
+ // // .getRevisionByVersion(delta.getID(), delta, 0, true);
+ // InternalCDORevision originalRevision = getStore().getRepository().getRevisionManager()
+ // .getRevisionByVersion(delta.getID(), delta.getBranch().getVersion(deltaVersion), 0, true);
+ //
+ // // 100917-IS: KISS - InternalCDORevision newRevision = originalRevision.copy();
+ //
+ // // 100917-IS: KISS - newRevision.setVersion(deltaVersion + 1);
+ // // 100917-IS: KISS - newRevision.setBranchPoint(delta.getBranch().getPoint(created));
+ // // 100917-IS: KISS - newObjyRevision = objySession.getObjectManager().newObject(newRevision.getEClass(),
+ // // objyRevision.ooId());
+ // // 100917-IS: KISS - objyNewRevision.update(this, newRevision);
+ //
+ // // create a new object, fill it with the original revision data, then
+ // // modify the creation and the branch ID accordingly.
+ // objyNewRevision = objySession.getObjectManager().newObject(originalRevision.getEClass(),
+ // objyOriginalRevision.ooId());
+ // objyNewRevision.update(this, originalRevision);
+ // objyNewRevision.setBranchId(delta.getBranch().getID());
+ // // the following are done at the end.
+ // // objyNewRevision.setVersion(deltaVersion + 1);
+ // // objyNewRevision.setCreationTime(created);
+ //
+ // objyObject.addToRevisions(objyNewRevision);
+ //
+ // if (getStore().isRequiredToSupportBranches() /* && branch.getID() != CDOBranch.MAIN_BRANCH_ID */)
+ // {
+ // // add the newObjyRevision to the proper branch.
+ // ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(branch.getID());
+ // ooObj anObj = ooObj.create_ooObj(objyNewRevision.ooId());
+ // objyBranch.addRevision(anObj);
+ // }
+ // if (newVersion > CDORevision.FIRST_VERSION)
+ // {
+ // // revise the original revision last, otherwise we can end up with the revised date in the new revision.
+ // objyOriginalRevision.setRevisedTime(branch.getPoint(created).getTimeStamp() - 1);
+ // }
+ // }
+ // else
+ // {
+ // objyNewRevision = objyOriginalRevision;
+ // }
+ //
+ // ObjectivityFeatureDeltaWriter visitor = new ObjectivityFeatureDeltaWriter(objyNewRevision);
+ //
+ // delta.accept(visitor);
+ //
+ // objyNewRevision.setCreationTime(branch.getPoint(created).getTimeStamp());
+ // objyNewRevision.setVersion(newVersion); // TODO - verify with Eike if this is true!!!
+ // }
+
+ /**
+ * Called for each revision delta.
+ *
+ * @param delta
+ * @param created
+ * @param branch
+ */
+ private void writeRevisionDelta(InternalCDORevisionDelta delta, CDOBranch branch, long created)
+ {
+ // ensureSessionBegin();
+
+ int deltaVersion = delta.getVersion();
+ int newVersion = CDOBranchVersion.FIRST_VERSION;
+
+ ObjyObject objyObject = getObject(delta.getID());
+ TRACER_DEBUG.format("writingRevisionDelta getting Object: {0}, v:{1} - BranchId:{2}", objyObject.ooId()
+ .getStoreString(), deltaVersion, delta.getBranch().getID());
+ ObjyObject objyOriginalRevision = objyObject.getRevisionByVersion(deltaVersion, delta.getBranch().getID(),
+ objySession.getObjectManager());
+
+ if (branch.getID() == delta.getBranch().getID())
+ {
+ // Same branch, increase version
+ newVersion = deltaVersion + 1;
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("Writing revision delta: {0}, v:{1} - OID:{2}, v:{3} - BranchId:{4}", delta, deltaVersion,
+ objyObject.ooId().getStoreString(), objyOriginalRevision.getVersion(), objyOriginalRevision.getBranchId());
+ TRACER_DEBUG.format("... delta branch ID: {0} - revision branch ID: {1}", branch.getID(),
+ objyOriginalRevision.getBranchId());
+ }
+ // System.out.println(">>>IS: Delta Writing: " + delta.getID() + " - oid: " + objyObject.ooId().getStoreString());
+ // System.out.println("\t - old version : " + delta.getVersion());
+ // System.out.println("\t - created : " + created);
+ // System.out.println("\t - delta.branch: " + delta.getBranch().toString());
+ // System.out.println("\t - branch : " + branch.toString());
+ // System.out.println("\t - branch TS : " + branch.getPoint(created).getTimeStamp());
+ // System.out.println("\t - delta : " + delta.toString());
+ // for debugging...
+
+ if (objyOriginalRevision.getVersion() != deltaVersion)
+ {
+ throw new RuntimeException("ObjecitivityStoreAccessor : Dirty write");
+ }
+
+ ObjyObject objyNewRevision = null;
+
+ if (getStore().isRequiredToSupportAudits())
+ {
+
+ ObjyObject objyObjectCopy = objySession.getObjectManager().copyRevision(this, objyOriginalRevision);
+ TRACER_DEBUG.format(" created new object:{0} by copying object:{1} - v:{2} - newBranch:{3}", objyObjectCopy
+ .ooId().getStoreString(), objyOriginalRevision.ooId().getStoreString(), objyOriginalRevision.getVersion(),
+ branch.getID());
+
+ // // newObjyRevision = objySession.getObjectManager().copyRevision(this, objyRevision);
+ // // objyRevision.setRevisedBranchId(branch.getID();
+ // InternalCDORevision originalRevision = getStore().getRepository().getRevisionManager()
+ // .getRevisionByVersion(delta.getID(), delta, CDORevision.UNCHUNKED, true);
+ //
+ // // 100917-IS: KISS - InternalCDORevision newRevision = originalRevision.copy();
+ //
+ // // 100917-IS: KISS - newRevision.setVersion(deltaVersion + 1);
+ // // 100917-IS: KISS - newRevision.setBranchPoint(delta.getBranch().getPoint(created));
+ // // 100917-IS: KISS - objyNewRevision = objySession.getObjectManager().newObject(newRevision.getEClass(),
+ // // objyOriginalRevision.ooId());
+ // // 100917-IS: KISS - objyNewRevision.update(this, newRevision);
+ //
+ // // create a new object, fill it with the original revision data, then
+ // // modify the creation and the branch ID accordingly.
+ // objyNewRevision = objySession.getObjectManager().newObject(originalRevision.getEClass(),
+ // objyOriginalRevision.ooId());
+ // objyNewRevision.update(this, originalRevision);
+ objyNewRevision = objyObjectCopy;
+ objyNewRevision.setBranchId(branch.getID());
+ // the following are done at the end.
+ // objyNewRevision.setVersion(deltaVersion + 1);
+ // objyNewRevision.setCreationTime(created);
+
+ objyObject.addToRevisions(objyNewRevision);
+
+ if (getStore().isRequiredToSupportBranches() /* && branch.getID() != CDOBranch.MAIN_BRANCH_ID */)
+ {
+ // add the newObjyRevision to the proper branch.
+ ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(branch.getID());
+ ooObj anObj = ooObj.create_ooObj(objyNewRevision.ooId());
+ objyBranch.addRevision(anObj);
+ }
+ // revise the original revision last, otherwise we can end up with the revised date in the new revision.
+ // IS: it seems that in CDO 4.0 we don't need to do that anymore!!
+ if (newVersion > CDORevision.FIRST_VERSION)
+ {
+ objyOriginalRevision.setRevisedTime(branch.getPoint(created).getTimeStamp() - 1);
+ }
+ }
+ else
+ {
+ objyNewRevision = objyOriginalRevision;
+ }
+
+ ObjectivityFeatureDeltaWriter visitor = new ObjectivityFeatureDeltaWriter(objyNewRevision);
+
+ delta.accept(visitor);
+
+ objyNewRevision.setCreationTime(branch.getPoint(created).getTimeStamp());
+ objyNewRevision.setVersion(newVersion); // TODO - verify with Eike if this is true!!!
+ }
+
+ @Override
+ public ObjectivityStore getStore()
+ {
+ return (ObjectivityStore)super.getStore();
+ }
+
+ /**
+ * It seems that it will be called for both new objects and dirty objects.
+ */
+ @Override
+ protected void writeRevisions(InternalCDORevision[] revisions, CDOBranch branch, OMMonitor monitor)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ ObjyObjectManager.getObjectTime = 0;
+ ObjyObjectManager.updateObjectTime = 0;
+ ObjyObjectManager.resourceCheckAndUpdateTime = 0;
+ }
+ long start = System.nanoTime();
+ ensureSessionBegin();
+ // objySession.addToLog("IS:>>>", "writeRevisions - begin");
+ try
+ {
+ monitor.begin(revisions.length);
+ // Find all Objy containers to lock as one unit.
+ Set<ooId> containersToLock = new HashSet<ooId>();
+ for (InternalCDORevision revision : revisions)
+ {
+ ooId containerID = OBJYCDOIDUtil.getContainerId(revision.getID());
+ containersToLock.add(containerID);
+ }
+ // containersToLock.add(objySession.getBranchManager(getRepositoryName()).getContainer().getOid());
+ // lockContainers(containersToLock);
+ // long tStart = System.currentTimeMillis();
+ for (InternalCDORevision revision : revisions)
+ {
+ writeRevision(revision, monitor.fork());
+ }
+ // long tDiff = System.currentTimeMillis() - tStart;
+ // System.out.println(">>> IS: writing revisions: " + revisions.length + " - time: " + tDiff);
+ }
+ finally
+ {
+ newObjyObjectsMap.clear();
+ monitor.done();
+ }
+ // objySession.addToLog("IS:>>>", "writeRevisions - end");
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG
+ .trace(" writeRevisions: " + revisions.length + " - time: " + (System.nanoTime() - start) / 1000000.0);
+ // TRACER_DEBUG.trace(" getObjectTime: " + ObjyObjectManager.getObjectTime / 1000000.0);
+ // TRACER_DEBUG.trace(" updateObjectTime: " + ObjyObjectManager.updateObjectTime / 1000000.0);
+ // TRACER_DEBUG.trace(" resourceCheckAndUpdateTime: " + ObjyObjectManager.resourceCheckAndUpdateTime /
+ // 1000000.0);
+ // ObjyObjectManager.getObjectTime = 0;
+ // ObjyObjectManager.updateObjectTime = 0;
+ // ObjyObjectManager.resourceCheckAndUpdateTime = 0;
+ }
+
+ }
+
+ /**
+ * return an ObjyObject that represent the CDOID base.
+ */
+ public ObjyObject getObject(CDOID id)
+ {
+ ObjyObject objyObject = objySession.getObjectManager().getObject(id);
+ // make sure we get the base one and not any cached version.
+ return objyObject.getBaseObject();
+ }
+
+ /*****
+ * Use this code for heart beat. Async async = null; try { monitor.begin(getListMappings().size() + 1); async =
+ * monitor.forkAsync(); reviseObject(accessor, id, timeStamp); } finally { async.stop(); monitor.done(); } [10:07:02
+ * AM] Eike Stepper: that one takes care that the heartbeat goes on [10:07:13 AM] Eike Stepper: for indefinite time
+ */
+
+ private void writeRevision(InternalCDORevision revision, OMMonitor monitor)
+ {
+ Async async = null;
+
+ try
+ {
+ monitor.begin(1000); // IS: experimental.
+ async = monitor.forkAsync();
+
+ // EClass eClass = revision.getEClass();
+ long __start = System.nanoTime();
+ // ObjyObject objyObject = getObject(revision.getID());
+ ObjyObject objyObject = newObjyObjectsMap.get(revision.getID());
+ if (objyObject == null)
+ {
+ objyObject = getObject(revision.getID()); // we shouldn't need to come here.
+ }
+ ObjyObjectManager.getObjectTime += System.nanoTime() - __start;
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("Writing revision: {0} - OID: {1}", revision, objyObject.ooId().getStoreString()); //$NON-NLS-1$
+ }
+
+ // System.out.println(">>>IS: Writing: " + revision.getID() + " - oid: " + objyObject.ooId().getStoreString());
+ // System.out.println("\t - version : " + revision.getVersion());
+ // System.out.println("\t - timestamp : " + revision.getTimeStamp());
+ // System.out.println("\t - revised : " + revision.getRevised());
+ // System.out.println("\t - resourceId : " + revision.getResourceID());
+ // System.out.println("\t - containerId: " + revision.getContainerID());
+ // System.out.println("\t - branch : " + revision.getBranch().toString());
+ // System.out.println("\t - revision : " + revision.toString());
+
+ ObjyObject newObjyRevision = objyObject;
+
+ if (revision.getVersion() > CDOBranchVersion.FIRST_VERSION) // we're updating other versions...
+ {
+ // TRACER_DEBUG.format("...Updating other revisions using writeRevision()...");
+ ObjyObject oldObjyRevision = objyObject.getRevisionByVersion(revision.getVersion() - 1, revision.getBranch()
+ .getID(), objySession.getObjectManager());
+
+ if (oldObjyRevision == null)
+ {
+ new IllegalStateException("Revision with version: " + (revision.getVersion() - 1) + " is not in the store."); //$NON-NLS-1$
+ }
+ if (getStore().isRequiredToSupportAudits())
+ {
+ // if we allow versioning, then create a new one here.
+ // IS: I'm not sure if we'll be called here we always go to the writeRevisionDelta call.
+ newObjyRevision = objySession.getObjectManager().newObject(revision.getEClass(), oldObjyRevision.ooId());
+ objyObject.addToRevisions(newObjyRevision);
+
+ }
+ else
+ {
+ newObjyRevision = oldObjyRevision;
+ }
+ }
+
+ if (getStore().isRequiredToSupportBranches())
+ {
+ // add the newObjyRevision to the proper branch.
+ ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(
+ revision.getBranch().getID());
+ ooObj anObj = ooObj.create_ooObj(newObjyRevision.ooId());
+ try
+ {
+ objyBranch.addRevision(anObj);
+ }
+ catch (LockNotGrantedException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ __start = System.nanoTime();
+ newObjyRevision.update(this, revision);
+ ObjyObjectManager.updateObjectTime += System.nanoTime() - __start;
+
+ // if it's a resource, collect it.
+ if (revision.isResourceNode())
+ {
+ __start = System.nanoTime();
+ // TODO - this is temp solution to lock the common resource list
+ // Add resource to the list
+ ObjyResourceList resourceList = objySession.getResourceList(getRepositoryName());
+ ooObj anObj = (ooObj)objySession.getFD().objectFrom(resourceList.ooId());
+ SmartLock.lock(anObj.getContainer());
+
+ // before we update the data into the object we need to check
+ // if it's a resource and we're trying to add a duplicate.
+ // TODO - do we need to check for Folder and resouce, or is the isResourceNode()
+ // check is enough?!!!
+ if (revision.isResourceFolder() || revision.isResource())
+ {
+ // this call will throw exception if we have a duplicate resource we trying to add.
+ resourceList.checkDuplicateResources(this, revision);
+ }
+ SmartLock.lock(newObjyRevision);
+ try
+ {
+ resourceList.add(newObjyRevision);
+ }
+ catch (LockNotGrantedException ex)
+ {
+ ex.printStackTrace();
+ }
+ ObjyObjectManager.resourceCheckAndUpdateTime += System.nanoTime() - __start;
+ }
+ }
+ finally
+ {
+ async.stop();
+ monitor.done();
+ }
+ }
+
+ @Override
+ protected void doCommit(OMMonitor monitor)
+ {
+ // System.out.println(">>>>IS:<<< doCommit() " + this + " - objy session: " + objySession.toString());
+
+ long start = System.currentTimeMillis();
+ Async async = null;
+ monitor.begin();
+
+ try
+ {
+ try
+ {
+ async = monitor.forkAsync();
+ // The commit request might come from a different thread.
+ ensureSessionJoin();
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Committing ..." + objySession + " nc:" + objySession.nestCount());
+ }
+ if (objySession.isOpen() == true)
+ {
+ objySession.commit();
+ }
+ else
+ {
+ TRACER_DEBUG.trace("Error: calling objySession.commit() without having an open trx.");
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Committed");
+ }
+ }
+ finally
+ {
+ if (async != null)
+ {
+ async.stop();
+ }
+ }
+ }
+ catch (RuntimeException exception)
+ {
+ TRACER_INFO.trace(exception.getMessage(), exception);
+ exception.printStackTrace();
+ throw exception;
+ }
+ finally
+ {
+ monitor.done();
+ }
+
+ // 100920 - IS: for debugging
+ if (TRACER_DEBUG.isEnabled())
+ {
+ // TRACER_DEBUG.trace("doCommit() - new objects created: " + ObjyObjectManager.newObjCount + " - Internal: "
+ // + ObjyObjectManager.newInternalObjCount);
+ // ObjyObjectManager.newObjCount = 0;
+ // ObjyObjectManager.newInternalObjCount = 0;
+ TRACER_DEBUG.trace(" readRvisions: " + readRevisionCount + " - time: " + readRevisionTime / 1000000.0);
+ TRACER_DEBUG.trace(" fetchCount: " + ObjyObject.fetchCount + " - updateCount: " + ObjyObject.updateCount);
+ TRACER_DEBUG.trace("\t commit time: " + (System.currentTimeMillis() - start));
+ readRevisionTime = 0;
+ readRevisionCount = 0;
+ ObjyObject.fetchCount = 0;
+ ObjyObject.updateCount = 0;
+ }
+ // System.out.println("IS:>>> ObjyObject.ctor(): count " + ObjyObject.count + " - totalTime: " + ObjyObject.tDiff);
+ // for (ooId oid : ObjyObject.oids)
+ // {
+ // System.out.println("<" + oid.getStoreString() + "> ");
+ // }
+ // System.out.println();
+ // ObjyObject.count = 0;
+ // ObjyObject.tDiff = 0;
+ // ObjyObject.oids.clear();
+ }
+
+ public IObjectivityStoreChunkReader createChunkReader(InternalCDORevision revision, EStructuralFeature feature)
+ {
+ return new ObjectivityStoreChunkReader(this, revision, feature);
+ }
+
+ public EPackage[] loadPackageUnit(InternalCDOPackageUnit packageUnit)
+ {
+ // using the packageUnit.getID() we'll read the object from the FD and get the bytes.
+ byte[] bytes = null;
+
+ ensureSessionBegin();
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("loadPackageUnit for: {0}", packageUnit.getID()); //$NON-NLS-1$
+ }
+
+ ObjyPackageHandler objyPackageHandler = getStore().getPackageHandler();
+
+ bytes = objyPackageHandler.readPackageBytes(packageUnit);
+
+ EPackage ePackage = createEPackage(packageUnit, bytes);
+
+ return EMFUtil.getAllPackages(ePackage);
+ }
+
+ private EPackage createEPackage(InternalCDOPackageUnit packageUnit, byte[] bytes)
+ {
+ ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(getPackageRegistry());
+ return EMFUtil.createEPackage(packageUnit.getID(), bytes, zipped, resourceSet, false);
+ }
+
+ private CDOPackageRegistry getPackageRegistry()
+ {
+ return getStore().getRepository().getPackageRegistry();
+ }
+
+ /**
+ * TODO - 1) make sure that we return the root resource when we asked for "null" pathPrefix. 2) Create the "null"
+ * resource folder if it doesn't exist, perhaps when we initialize the store.
+ */
+ public void queryResources(QueryResourcesContext context)
+ {
+ ensureSessionBegin();
+
+ String pathPrefix = context.getName();
+ boolean exactMatch = context.exactMatch();
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("queryResources() for : " + (pathPrefix == null ? "NULL" : pathPrefix) + " - exactMatch: "
+ + exactMatch);
+ }
+ ObjyResourceList resourceList = objySession.getResourceList(getRepositoryName());
+ int size = resourceList.size();
+ if (size == 0) // nothing yet.
+ {
+ CDOID resourceID = OBJYCDOIDUtil.getCDOID(null);
+ context.addResource(resourceID);
+ }
+
+ // TBD: We need to verify the folderID as well!!
+ // CDOID folderID = org.eclipse.emf.cdo.common.id.CDOIDUtil.isNull(context.getFolderID()) ? null : context
+ // .getFolderID();
+ for (int i = 0; i < size; i++)
+ {
+ ObjyObject resource = resourceList.getResource(i);
+ if (resource != null)
+ {
+ ObjyObject resourceRevision = resource;
+ // get the proper revision of the resource (might need to refactor this code, see readRevision())
+ if (getStore().isRequiredToSupportBranches())
+ {
+ try
+ {
+ resourceRevision = resource.getRevision(context.getTimeStamp(), context.getBranch().getID(),
+ objySession.getObjectManager());
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+ else if (getStore().isRequiredToSupportAudits())
+ {
+ try
+ {
+ resourceRevision = resource.getRevision(context.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID,
+ objySession.getObjectManager());
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ if (resourceRevision == null || resourceRevision.getVersion() < 0)
+ {
+ continue;
+ }
+
+ String resourceName = ObjyResourceList.getResourceName(resourceRevision);
+ CDOID resourceID = OBJYCDOIDUtil.getCDOID(resource.ooId());
+ if (exactMatch && pathPrefix != null && pathPrefix.equals(resourceName) || pathPrefix == null
+ && resourceName == null)
+ {
+ if (!context.addResource(resourceID))
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format(" queryResources(1.1) got: " + resource.ooId().getStoreString() + " - version: "
+ + resource.getVersion());
+ }
+ // No more results allowed
+ break; // don't continue
+ }
+ }
+ else if (!exactMatch && resourceName != null)
+ {
+ if (resourceName.startsWith(pathPrefix))
+ {
+ context.addResource(resourceID);
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format(" queryResources(1.2) got: " + resource.ooId().getStoreString() + " - version: "
+ + resource.getVersion());
+ }
+ }
+ }
+ /***
+ * TODO - verify if we need this code, originally from the old impl. CDOID lookupFolderID = (CDOID)
+ * objectManager.getEContainer(resource); if (ObjectUtil.equals(lookupFolderID, folderID)) { boolean match =
+ * exactMatch || pathPrefix == null; if (match) { CDOID resourceID = CDOIDUtil.getCDOID(resource.ooId()); if
+ * (!context.addResource(resourceID)) { break; } } }
+ ***/
+ }
+ }
+
+ }
+
+ public void queryXRefs(QueryXRefsContext context)
+ {
+ ensureSessionBegin();
+
+ Set<CDOID> targetIDs = context.getTargetObjects().keySet();
+ Map<EClass, List<EReference>> sourceCandidates = context.getSourceCandidates();
+
+ // get the context branch.
+ CDOBranch branch = context.getBranch();
+ ObjyBranchManager branchManager = objySession.getBranchManager(getRepositoryName());
+ ObjyBranch objyBranch = branchManager.getBranch(branch.getID());
+
+ // iterate over all revision in a branch.
+ ObjyObject objyObject = null;
+ SortedSet<?> revisions = objyBranch.getRevisions();
+ for (Object anObj : revisions)
+ {
+ // the ooObj we get from revisions is the correct one for that branch.
+ objyObject = objySession.getObjectManager().getObject(((ooObj)anObj).getOid());
+
+ // InternalCDORevision revision = getRevision(list, context);
+ // if (revision == null || revision instanceof SyntheticCDORevision)
+ // {
+ // continue;
+ // }
+ //
+ EClass eClass = ObjySchema.getEClass(getStore(), objyObject.objyClass());
+ CDOID sourceID = objyObject.getRevisionId();
+
+ List<EReference> eReferences = sourceCandidates.get(eClass);
+ if (eReferences != null)
+ {
+ for (EReference eReference : eReferences)
+ {
+ if (eReference.isMany())
+ {
+ List<Object> results = objyObject.fetchList(this, eReference, 0, CDORevision.UNCHUNKED);
+ if (results != null)
+ {
+ try
+ {
+ int index = 0;
+ for (Object id : results)
+ {
+ if (!queryXRefs(context, targetIDs, (CDOID)id, sourceID, eReference, index++))
+ {
+ return;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+ else
+ {
+ Object value = objyObject.get(eReference);
+ CDOID id = (CDOID)value;
+ if (!queryXRefs(context, targetIDs, id, sourceID, eReference, 0))
+ {
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private boolean queryXRefs(QueryXRefsContext context, Set<CDOID> targetIDs, CDOID targetID, CDOID sourceID,
+ EReference sourceReference, int index)
+ {
+ for (CDOID id : targetIDs)
+ {
+ if (id.equals(targetID))
+ {
+ if (!context.addXRef(targetID, sourceID, sourceReference, index))
+ {
+ // No more results allowed
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Read all package units from the store. It's the opposite of writePackageUnits
+ */
+ public Collection<InternalCDOPackageUnit> readPackageUnits()
+ {
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("readPackageUnits()"); //$NON-NLS-1$
+ }
+
+ ensureSessionBegin();
+
+ ObjyPackageHandler objyPackageHandler = getStore().getPackageHandler();
+
+ Collection<InternalCDOPackageUnit> packageUnits = objyPackageHandler.readPackageUnits();
+
+ return packageUnits;
+ }
+
+ /**
+ *
+ */
+ public InternalCDORevision readRevision(CDOID id, CDOBranchPoint branchPoint, int listChunk,
+ CDORevisionCacheAdder cache)
+ {
+ long __start = System.nanoTime();
+ ensureSessionBegin();
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("RR - Read rev for: {0}, TS:{1}", id, branchPoint.getTimeStamp()); //$NON-NLS-1$
+ }
+
+ // we shouldn't be doing this!!!
+ if (id instanceof CDOIDExternal)
+ {
+ // 100917 - IS: This must be a bug in CDO, it's throwing a CDOIDExternal at us
+ // we'll return null.
+ // TRACER_DEBUG.format("objy can't read revision for CDOID: {0}, it's external.", id.toString());
+ TRACER_DEBUG.trace("objy can't read revision for external CDOID: " + id.toString());
+ return null;
+ }
+
+ // we might have a proxy object!!!!
+
+ ObjyObject objyObject = getObject(id);
+
+ if (objyObject == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("RR - objyObject is NULL 4 ID:" + id); //$NON-NLS-1$
+ }
+ return null;
+ }
+ // else
+ // {
+ // TRACER_DEBUG.format("RR - objyObject is ID:" + id + ", :" + objyObject.ooId().getStoreString()); //$NON-NLS-1$
+ // }
+
+ InternalCDORevision revision = createRevision(objyObject, id);
+ revision.setBranchPoint(branchPoint);
+
+ ObjyObject objyRevision = objyObject;
+
+ if (getStore().isRequiredToSupportBranches())
+ {
+ try
+ {
+ objyRevision = objyObject.getRevision(branchPoint.getTimeStamp(), branchPoint.getBranch().getID(),
+ objySession.getObjectManager());
+ if (objyRevision == null)
+ {
+ TRACER_DEBUG
+ .format(
+ "RR - branches ID:{0}, OB:{1}, BPB:{2}, BPTS:{3}", id, objyObject.getBranchId(), branchPoint.getBranch().getID(), branchPoint.getTimeStamp()); //$NON-NLS-1$
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ else if (getStore().isRequiredToSupportAudits())
+ {
+ try
+ {
+ objyRevision = objyObject.getRevision(branchPoint.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID,
+ objySession.getObjectManager());
+ if (objyRevision == null)
+ {
+ TRACER_DEBUG
+ .format(
+ "RR - audit ID:{0}, OB:{1}, BPB:{2}, BPTS:{3}", id, objyObject.getBranchId(), branchPoint.getBranch().getID(), branchPoint.getTimeStamp()); //$NON-NLS-1$
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+
+ if (objyRevision == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("RR - objyRevision is NULL 4 ID:" + id); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ // check the version
+ if (objyRevision.getVersion() < 0)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG
+ .format("RR - ...revision for: {0} - OID: {1} is detached.", id, objyObject.ooId().getStoreString()); //$NON-NLS-1$
+ }
+ EClass eClass = ObjySchema.getEClass(getStore(), objyObject.objyClass());
+ return new DetachedCDORevision(eClass, id, branchPoint.getBranch(), -objyRevision.getVersion(),
+ objyRevision.getCreationTime());
+ }
+
+ CDOBranchPoint branchPoint2 = revision.getBranch().getPoint(objyRevision.getCreationTime());
+ revision.setBranchPoint(branchPoint2);
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG
+ .format("RR - Fetching revision details for: {0} - OID:{1}", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$
+ }
+
+ boolean ok = objyRevision.fetch(this, revision, listChunk);
+
+ if (!ok)
+ {
+ TRACER_DEBUG.format("RR - Fetch rev failed 4: {0}, :{1}", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$
+ }
+
+ readRevisionTime += System.nanoTime() - __start;
+ readRevisionCount++;
+
+ return ok ? revision : null;
+ }
+
+ /**
+ *
+ */
+ public InternalCDORevision readRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int listChunk,
+ CDORevisionCacheAdder cache)
+ {
+ long __start = System.nanoTime();
+ ensureSessionBegin();
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("RRBV - Read rev 4: {0}, ver: {1}", id, branchVersion.getVersion()); //$NON-NLS-1$
+ }
+
+ // we might have a proxy object!!!!
+
+ ObjyObject objyObject = getObject(id);
+ if (objyObject == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("RRBV - objyObject is NULL for ID: " + id); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ // {
+ // TRACER_DEBUG.format("RRBV - objyObject 4 ID: " + id + ", :" + objyObject.ooId().getStoreString()); //$NON-NLS-1$
+ // }
+
+ ObjyObject objyRevision = null;
+ objyRevision = objyObject.getRevisionByVersion(branchVersion.getVersion(), branchVersion.getBranch().getID(),
+ objySession.getObjectManager());
+ // if (getStore().isRequiredToSupportAudits())
+ // {
+ // objyRevision = objyObject.getRevisionByVersion(branchVersion.getVersion());
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG
+ .format(
+ "Reading revision by version {0} for: {1} - OID: {2}", branchVersion.getVersion(), id, objyObject.ooId().getStoreString()); //$NON-NLS-1$
+ }
+
+ // }
+ // else
+ // {
+ // objyRevision = objyObject.getLastRevision();
+ //
+ // if (TRACER_DEBUG.isEnabled())
+ // {
+ // TRACER_DEBUG.format(
+ // "(None-Audit) Reading revision by version for: {0} - OID: {1}", id, objyObject.ooId().getStoreString()); //$NON-NLS-1$
+ // }
+ // }
+
+ if (objyRevision == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("RRBV - objyRevision is NULL for ID: ", id); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ InternalCDORevision revision = createRevision(objyRevision, id);
+
+ revision.setVersion(branchVersion.getVersion());
+ revision.setBranchPoint(branchVersion.getBranch().getHead());
+
+ // TODO - clean up the following 3 lines...
+ // InternalCDOBranchManager branchManager = getStore().getRepository().getBranchManager();
+ // CDOBranch mainBranch = branchManager.getBranch(CDOBranch.MAIN_BRANCH_ID);
+ // //revision.setBranchPoint(CDOBranchUtil.createBranchPoint(mainBranch, 0));
+ // revision.setBranchPoint(mainBranch.getHead());
+
+ boolean ok = objyRevision.fetch(this, revision, listChunk);
+
+ if (ok && objyRevision.getVersion() != branchVersion.getVersion())
+ {
+ throw new IllegalStateException("Can only retrieve current version " + revision.getVersion() + " for " + //$NON-NLS-1$ //$NON-NLS-2$
+ id + " - version requested was " + branchVersion + "."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // if (!ok)
+ // {
+ // TRACER_DEBUG.format("RRBV - Fetch rev failed 4: {0}, :", id, objyRevision.ooId().getStoreString()); //$NON-NLS-1$
+ // }
+
+ readRevisionTime += System.nanoTime() - __start;
+ readRevisionCount++;
+
+ return ok ? revision : null;
+ }
+
+ public void writePackageUnits(InternalCDOPackageUnit[] packageUnits, OMMonitor monitor)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("writePackageUnits()"); //$NON-NLS-1$
+ }
+
+ ensureSessionBegin();
+
+ ObjyPackageHandler objyPackageHandler = getStore().getPackageHandler();
+ CDOPackageRegistry packageRegistry = getStore().getRepository().getPackageRegistry();
+
+ for (InternalCDOPackageUnit packageUnit : packageUnits)
+ {
+ objyPackageHandler.writePackages(packageRegistry, packageUnit, monitor/* .fork() */);
+ }
+ }
+
+ private InternalCDORevision createRevision(ObjyObject objyObject, CDOID id)
+ {
+ EClass eClass = ObjySchema.getEClass(getStore(), objyObject.objyClass());
+
+ if (eClass == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("OBJY: Can't find eClass for id:" + id);
+ }
+ return null;
+ }
+
+ return getStore().createRevision(eClass, id);
+ }
+
+ private String getRepositoryName()
+ {
+ return getStore().getRepository().getName();
+ }
+
+ /***
+ * For us, this function creates the skeleton objects in Objectivity, to be able to get the new ooId and pass it to
+ * the commitContext. The objects data will be updated in the call to writeRevision().
+ */
+ @Override
+ public void addIDMappings(InternalCommitContext commitContext, OMMonitor monitor)
+ {
+ long __start = System.nanoTime();
+ ensureSessionBegin();
+ if (commitContext.getNewObjects().length > 0)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("creating " + commitContext.getNewObjects().length + " new objects and assigning new IDs");
+ }
+ InternalCDORevision[] newObjects = commitContext.getNewObjects();
+ try
+ {
+ monitor.begin(newObjects.length);
+
+ ObjyPlacementManagerLocal placementManager = new ObjyPlacementManagerLocal(getStore(), objySession,
+ commitContext, newObjyObjectsMap);
+
+ // iterate over the list and skip the ones we already have created.
+ for (InternalCDORevision revision : newObjects)
+ {
+ try
+ {
+ placementManager.processRevision(revision);
+ }
+ catch (com.objy.db.ObjyRuntimeException ex)
+ {
+ System.out.println(">>>>IS: Exception<<<< Session: " + objySession + " open status: "
+ + objySession.isOpen());
+ ex.printStackTrace();
+ }
+ monitor.worked();
+ }
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(" addIDMappings for " + commitContext.getNewObjects().length + " - time: "
+ + (System.nanoTime() - __start) / 1000000.0);
+ TRACER_DEBUG.trace(" createObjects : " + ObjyObject.createObjectCount + " - time: "
+ + ObjyObject.createObjectTime / 1000000.0);
+ ObjyObject.createObjectTime = 0;
+ ObjyObject.createObjectCount = 0;
+ }
+ }
+
+ @Override
+ protected CDOID getNextCDOID(CDORevision revision)
+ {
+ // Never called
+ throw new UnsupportedOperationException();
+ }
+
+ /***************************
+ * Local Utility functions.
+ ***************************/
+ public void ensureActiveSession()
+ {
+ ensureSessionBegin();
+ }
+
+ protected void ensureSessionBegin()
+ {
+ getObjySession();
+ if (!objySession.isJoined())
+ {
+ objySession.join();
+ }
+ if (!objySession.isOpen())
+ {
+ if (isRead)
+ {
+ objySession.setOpenMode(oo.openReadOnly);
+ }
+ else
+ {
+ objySession.setOpenMode(oo.openReadWrite);
+ }
+ objySession.begin();
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(" ensureBeginSession() called begin() on session: " + objySession + " [name: "
+ + objySession.getName() + " - open: " + objySession.isOpen() + "]");
+ }
+ }
+ }
+
+ private void ensureSessionJoin()
+ {
+ // we better have a session for this store.
+ assert objySession != null;
+ // testSwitchViewTarget() is crashing because objySession is null.
+ // TBD: verify this case!!!
+ if (objySession != null && !objySession.isJoined())
+ {
+ objySession.join();
+ }
+ }
+
+ // *********************************************
+ // New APIs for CDO 3.0
+ // *********************************************
+
+ public void loadCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler)
+ {
+ ensureSessionBegin();
+
+ ObjyCommitInfoHandler commitInfoHandler = getStore().getCommitInfoHandler();
+ List<ObjyCommitInfo> commitInfoList = commitInfoHandler.getCommitInfo(branch, startTime, endTime);
+
+ InternalSessionManager manager = getSession().getManager();
+ InternalRepository repository = manager.getRepository();
+ InternalCDOBranchManager branchManager = repository.getBranchManager();
+ InternalCDOCommitInfoManager commitInfoManager = repository.getCommitInfoManager();
+
+ for (ObjyCommitInfo ooCommitInfo : commitInfoList)
+ {
+ long timeStamp = ooCommitInfo.getTimeStamp();
+ long previousTimeStamp = ooCommitInfo.getPreviousTimeStamp();
+ String userID = ooCommitInfo.getUserId();
+ String comment = ooCommitInfo.getComment();
+ CDOBranch infoBranch = branch;
+ if (infoBranch == null)
+ {
+ int id = ooCommitInfo.getBranchId();
+ infoBranch = branchManager.getBranch(id);
+ }
+
+ CDOCommitInfo commitInfo = commitInfoManager.createCommitInfo(infoBranch, timeStamp, previousTimeStamp, userID,
+ comment, null);
+ handler.handleCommitInfo(commitInfo);
+ }
+
+ }
+
+ @Override
+ protected void writeCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID,
+ String comment, OMMonitor monitor)
+ {
+ ensureSessionBegin();
+ // we need to write the following...
+ // ...branch.getID(), timeStamp, userID, comment.
+ try
+ {
+ ObjyCommitInfoHandler commitInfoHandler = getStore().getCommitInfoHandler();
+ commitInfoHandler.writeCommitInfo(branch.getID(), timeStamp, previousTimeStamp, userID, comment);
+ }
+ catch (com.objy.db.ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public IQueryHandler getQueryHandler(org.eclipse.emf.cdo.common.util.CDOQueryInfo info)
+ {
+ if (ObjectivityQueryHandler.QUERY_LANGUAGE.equals(info.getQueryLanguage()))
+ {
+ return new ObjectivityQueryHandler(this);
+ }
+
+ return null;
+ }
+
+ public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo)
+ {
+ ensureSessionBegin();
+ boolean convertToUpdate = false;
+ // IS: this is a hack to overcome the issue in cdo core where the Accessor is requested for
+ // read but it's trying to create stuff.
+ if (isRead)
+ {
+ TRACER_DEBUG.trace("-->> createBranch() - Hack... Hack... changing read to update.");
+ // upgrade the session to update.
+ objySession.commit();
+ objySession.setOpenMode(oo.openReadWrite);
+ convertToUpdate = true;
+ objySession.begin();
+ }
+ Pair<Integer, Long> retValue = objySession.getBranchManager(getRepositoryName()).createBranch(branchID, branchInfo);
+ if (convertToUpdate)
+ {
+ // return the session to read.
+ objySession.commit();
+ objySession.setOpenMode(oo.openReadOnly);
+ objySession.begin();
+ }
+ return retValue;
+ }
+
+ public BranchInfo loadBranch(int branchID)
+ {
+ ensureSessionBegin();
+ ObjyBranch objyBranch = objySession.getBranchManager(getRepositoryName()).getBranch(branchID);
+ return objyBranch != null ? objyBranch.getBranchInfo() : null;
+ }
+
+ public int loadBranches(int startID, int endID, CDOBranchHandler branchHandler)
+ {
+ int count = 0;
+ List<ObjyBranch> branches = objySession.getBranchManager(getRepositoryName()).getBranches(startID, endID);
+ InternalCDOBranchManager branchManager = getStore().getRepository().getBranchManager();
+
+ for (ObjyBranch objyBranch : branches)
+ {
+ InternalCDOBranch branch = branchManager
+ .getBranch(objyBranch.getBranchId(), new BranchInfo(objyBranch.getBranchName(), objyBranch.getBaseBranchId(),
+ objyBranch.getBaseBranchTimeStamp()));
+ branchHandler.handleBranch(branch);
+ count++;
+ }
+
+ return count;
+
+ }
+
+ public SubBranchInfo[] loadSubBranches(int branchID)
+ {
+ ensureSessionBegin();
+ List<SubBranchInfo> result = new ArrayList<SubBranchInfo>();
+ List<ObjyBranch> objyBranchList = objySession.getBranchManager(getRepositoryName()).getSubBranches(branchID);
+ for (ObjyBranch objyBranch : objyBranchList)
+ {
+ SubBranchInfo subBranchInfo = new SubBranchInfo(objyBranch.getBranchId(), objyBranch.getBranchName(),
+ objyBranch.getBaseBranchTimeStamp());
+ result.add(subBranchInfo);
+ }
+ return result.toArray(new SubBranchInfo[result.size()]);
+ }
+
+ public void handleRevisions(EClass eClass, CDOBranch branch, long timeStamp, boolean exactTime,
+ CDORevisionHandler handler)
+ {
+ ensureSessionBegin();
+ IRepository repository = getStore().getRepository();
+ CDORevisionManager revisionManager = repository.getRevisionManager();
+ CDOBranchManager branchManager = repository.getBranchManager();
+
+ // scan FD for ObjyBase which is the base class for all revisions
+ Iterator<?> itr = objySession.getFD().scan(ObjyBase.CLASS_NAME);
+ ObjyObject objyObject = null;
+ while (itr.hasNext())
+ {
+ objyObject = objySession.getObjectManager().getObject(((ooObj)itr).getOid());
+ if (!handleRevision(objyObject, eClass, branch, timeStamp, exactTime, handler, revisionManager, branchManager))
+ {
+ return;
+ }
+ }
+ // TODO: implement ObjectivityStoreAccessor.handleRevisions(eClass, branch, timeStamp, exactTime, handler)
+ throw new UnsupportedOperationException();
+ }
+
+ private boolean handleRevision(ObjyObject objyObject, EClass eClass, CDOBranch branch, long timeStamp,
+ boolean exactTime, CDORevisionHandler handler, CDORevisionManager revisionManager, CDOBranchManager branchManager)
+ {
+ if (objyObject.getVersion() < 0) // DetachedCDORevision
+ {
+ return true;
+ }
+
+ if (eClass != null && ObjySchema.getEClass(getStore(), objyObject.objyClass()) != eClass)
+ {
+ return true;
+ }
+
+ if (branch != null && objyObject.getBranchId() != branch.getID())
+ {
+ return true;
+ }
+
+ if (timeStamp != CDOBranchPoint.INVALID_DATE)
+ {
+ if (exactTime)
+ {
+ if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE && objyObject.getCreationTime() != timeStamp)
+ {
+ return true;
+ }
+ }
+ else
+ {
+ long startTime = objyObject.getCreationTime();
+ long endTime = objyObject.getRevisedTime();
+ if (!CDOCommonUtil.isValidTimeStamp(timeStamp, startTime, endTime))
+ {
+ return true;
+ }
+ }
+ }
+
+ CDOBranchVersion branchVersion = branchManager.getBranch((int)objyObject.getBranchId()).getVersion(
+ Math.abs(objyObject.getVersion()));
+ InternalCDORevision revision = (InternalCDORevision)revisionManager.getRevisionByVersion(
+ OBJYCDOIDUtil.getCDOID(objyObject.ooId()), branchVersion, CDORevision.UNCHUNKED, true);
+
+ return handler.handleRevision(revision);
+ }
+
+ public Set<CDOID> readChangeSet(OMMonitor monitor, CDOChangeSetSegment... segments)
+ {
+ monitor.begin(segments.length);
+
+ try
+ {
+ ensureSessionBegin();
+
+ ObjyBranchManager objyBranchManager = objySession.getBranchManager(getRepositoryName());
+ ObjyObjectManager objyObjectManager = objySession.getObjectManager();
+ Set<CDOID> results = new HashSet<CDOID>();
+
+ // get all revisions that has branchId, and creation timestamp, and perhaps revised before
+ // end timestamp or haven't been revised.
+ for (CDOChangeSetSegment segment : segments)
+ {
+ ObjyBranch objyBranch = objyBranchManager.getBranch(segment.getBranch().getID());
+ // query the branch revisions for the time range.
+ SortedSet<?> revisions = objyBranch.getRevisions();
+ readChangeSet(monitor.fork(), segment, objyObjectManager, revisions, results);
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ChangeSet " + results.toString());
+ }
+
+ return results;
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+
+ protected void readChangeSet(OMMonitor monitor, CDOChangeSetSegment segment, ObjyObjectManager objyObjectManager,
+ SortedSet<?> revisions, Set<CDOID> results)
+ {
+ int size = revisions.size();
+ monitor.begin(size);
+ Async async = null;
+ try
+ {
+ async = monitor.forkAsync();
+
+ Iterator<?> objItr = revisions.iterator();
+ while (objItr.hasNext())
+ {
+ ooObj anObj = (ooObj)objItr.next();
+ ObjyObject objyObject = objyObjectManager.getObject(anObj.getOid());
+ long creationTime = objyObject.getCreationTime();
+ long revisedTime = objyObject.getRevisedTime();
+ if (creationTime >= segment.getTimeStamp() && (revisedTime <= segment.getEndTime() || revisedTime == 0))
+ {
+ results.add(objyObject.getRevisionId());
+ }
+
+ monitor.worked();
+ }
+ }
+ finally
+ {
+ async.stop();
+ monitor.done();
+
+ }
+ }
+
+ public void queryLobs(List<byte[]> ids)
+ {
+ // TODO: implement ObjectivityStoreAccessor.queryLobs(ids)
+ throw new UnsupportedOperationException();
+ }
+
+ public void handleLobs(long fromTime, long toTime, CDOLobHandler handler) throws IOException
+ {
+ // TODO: implement ObjectivityStoreAccessor.handleLobs(fromTime, toTime, handler)
+ throw new UnsupportedOperationException();
+ }
+
+ public void loadLob(byte[] id, OutputStream out) throws IOException
+ {
+ // TODO: implement ObjectivityStoreAccessor.loadLob(id, out)
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void writeBlob(byte[] id, long size, InputStream inputStream) throws IOException
+ {
+ // TODO: implement ObjectivityStoreAccessor.writeBlob(id, size, inputStream)
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected void writeClob(byte[] id, long size, Reader reader) throws IOException
+ {
+ // TODO: implement ObjectivityStoreAccessor.writeClob(id, size, reader)
+ throw new UnsupportedOperationException();
+ }
+
+ public void rawExport(CDODataOutput out, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime)
+ throws IOException
+ {
+ // TODO: implement ObjectivityStoreAccessor.rawExport();
+ throw new UnsupportedOperationException();
+ }
+
+ public void rawImport(CDODataInput in, int fromBranchID, int toBranchID, long fromCommitTime, long toCommitTime,
+ OMMonitor monitor) throws IOException
+ {
+ // TODO: implement ObjectivityStoreAccessor.rawImport
+ throw new UnsupportedOperationException();
+ }
+
+ public void rawStore(InternalCDOPackageUnit[] packageUnits, OMMonitor monitor)
+ {
+ // TODO: implement ObjectivityStoreAccessor.rawStore
+ throw new UnsupportedOperationException();
+ }
+
+ public void rawStore(InternalCDORevision revision, OMMonitor monitor)
+ {
+ // TODO: implement ObjectivityStoreAccessor.rawStore
+ throw new UnsupportedOperationException();
+ }
+
+ public void rawStore(byte[] id, long size, InputStream inputStream) throws IOException
+ {
+ // TODO: implement ObjectivityStoreAccessor.rawStore
+ throw new UnsupportedOperationException();
+ }
+
+ public void rawStore(byte[] id, long size, Reader reader) throws IOException
+ {
+ // TODO: implement ObjectivityStoreAccessor.rawStore
+ throw new UnsupportedOperationException();
+ }
+
+ public void rawStore(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID, String comment,
+ OMMonitor monitor)
+ {
+ // TODO: implement ObjectivityStoreAccessor.rawStore
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ public void rawDelete(CDOID id, int version, CDOBranch branch, EClass eClass, OMMonitor monitor)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void rawCommit(double commitWork, OMMonitor monitor)
+ {
+ // TODO: implement ObjectivityStoreAccessor.rawCommit
+ throw new UnsupportedOperationException();
+ }
+
+ public LockArea createLockArea(String userID, CDOBranchPoint branchPoint, boolean readOnly,
+ Map<CDOID, LockGrade> locks)
+ {
+ // TODO: implement ObjectivityStoreAccessor.createLockArea
+ throw new UnsupportedOperationException();
+ }
+
+ public LockArea getLockArea(String durableLockingID) throws LockAreaNotFoundException
+ {
+ // TODO: implement ObjectivityStoreAccessor.getLockArea
+ throw new UnsupportedOperationException();
+ }
+
+ public void getLockAreas(String userIDPrefix, Handler handler)
+ {
+ ensureSessionBegin();
+
+ InternalCDOBranchManager branchManager = getStore().getRepository().getBranchManager();
+ ObjyLockAreaManager objyLockAreaManager = objySession.getLockAreaManager(getRepositoryName());
+ objyLockAreaManager.getLockAreas(branchManager, userIDPrefix, handler);
+ }
+
+ public void deleteLockArea(String durableLockingID)
+ {
+ // TODO: implement ObjectivityStoreAccessor.deleteLockArea
+ throw new UnsupportedOperationException();
+ }
+
+ public void lock(String durableLockingID, LockType type, Collection<? extends Object> objectsToLock)
+ {
+ // TODO: implement ObjectivityStoreAccessor.lock
+ throw new UnsupportedOperationException();
+ }
+
+ public void unlock(String durableLockingID, LockType type, Collection<? extends Object> objectsToUnlock)
+ {
+ // TODO: implement ObjectivityStoreAccessor.unlock
+ throw new UnsupportedOperationException();
+ }
+
+ public void unlock(String durableLockingID)
+ {
+ // TODO: implement ObjectivityStoreAccessor.unlock
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java
index 948dbe4f21..720d6bd149 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreChunkReader.java
@@ -1,65 +1,65 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.IStoreAccessor;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreChunkReader;
-import org.eclipse.emf.cdo.spi.server.StoreChunkReader;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.util.List;
-
-public class ObjectivityStoreChunkReader extends StoreChunkReader implements IObjectivityStoreChunkReader
-{
- public ObjectivityStoreChunkReader(IStoreAccessor accessor, CDORevision revision, EStructuralFeature feature)
- {
- super(accessor, revision, feature);
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public ObjectivityStoreAccessor getAccessor()
- {
- return (ObjectivityStoreAccessor)super.getAccessor();
- }
-
- public List<Chunk> executeRead()
- {
- CDOID id = getRevision().getID();
- getAccessor().ensureActiveSession();
- ObjyObject objyObject = getAccessor().getObject(id);
- ObjyObject objyRevision = objyObject.getRevisionByVersion(getRevision().getVersion(), getRevision().getBranch()
- .getID(), getAccessor().getObjySession().getObjectManager());
-
- List<Chunk> chunks = getChunks();
-
- for (Chunk chunk : chunks)
- {
- int chunkStartIndex = chunk.getStartIndex();
- int chunkSize = chunk.size();
-
- // get the data from the feature.
- List<Object> objects = objyRevision.fetchList(getAccessor(), getFeature(), chunkStartIndex, chunkSize);
- // although we asked for a chunkSize we might get less.
- int i = 0;
- for (Object obj : objects)
- {
- chunk.add(i++, obj);
- }
- }
- return chunks;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.IStoreAccessor;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreChunkReader;
+import org.eclipse.emf.cdo.spi.server.StoreChunkReader;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.util.List;
+
+public class ObjectivityStoreChunkReader extends StoreChunkReader implements IObjectivityStoreChunkReader
+{
+ public ObjectivityStoreChunkReader(IStoreAccessor accessor, CDORevision revision, EStructuralFeature feature)
+ {
+ super(accessor, revision, feature);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public ObjectivityStoreAccessor getAccessor()
+ {
+ return (ObjectivityStoreAccessor)super.getAccessor();
+ }
+
+ public List<Chunk> executeRead()
+ {
+ CDOID id = getRevision().getID();
+ getAccessor().ensureActiveSession();
+ ObjyObject objyObject = getAccessor().getObject(id);
+ ObjyObject objyRevision = objyObject.getRevisionByVersion(getRevision().getVersion(), getRevision().getBranch()
+ .getID(), getAccessor().getObjySession().getObjectManager());
+
+ List<Chunk> chunks = getChunks();
+
+ for (Chunk chunk : chunks)
+ {
+ int chunkStartIndex = chunk.getStartIndex();
+ int chunkSize = chunk.size();
+
+ // get the data from the feature.
+ List<Object> objects = objyRevision.fetchList(getAccessor(), getFeature(), chunkStartIndex, chunkSize);
+ // although we asked for a chunkSize we might get less.
+ int i = 0;
+ for (Object obj : objects)
+ {
+ chunk.add(i++, obj);
+ }
+ }
+ return chunks;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreConfig.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreConfig.java
index d0b85b46be..ed3d489c43 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreConfig.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreConfig.java
@@ -1,158 +1,158 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-
-package org.eclipse.emf.cdo.server.internal.objectivity;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.FdManager;
-import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreConfig;
-
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-
-import com.objy.db.app.Connection;
-import com.objy.db.app.oo;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-public class ObjectivityStoreConfig extends Lifecycle implements IObjectivityStoreConfig
-{
- private static final long serialVersionUID = 1L;
-
- FdManager fdManager = new FdManager();
-
- private int sessionMinCacheSize = 0;
-
- private int sessionMaxCacheSize = 0;
-
- private int logOption = oo.LogNone;
-
- public ObjectivityStoreConfig()
- {
- // fdManager.deleteFD();
- fdManager.configure();
- }
-
- public ObjectivityStoreConfig(Element storeConfig)
- {
- // for now we'll just call the default configuration...
- getFdProperties(storeConfig);
- fdManager.configure();
- }
-
- public ObjectivityStoreConfig(String name)
- {
- // create an FD with that name.
- fdManager.configure(name);
- }
-
- @Override
- public void doActivate()
- {
- // System.out.println("ObjectivityStoreConfig.doActivate()");
- fdManager.deleteFD();
- fdManager.configure();
- }
-
- @Override
- public void doDeactivate()
- {
- fdManager.deleteFD();
- }
-
- public String getFdName()
- {
- return fdManager.getFd();
- }
-
- public void resetFD()
- {
- if (Connection.current() == null)
- {
- return;
- }
-
- fdManager.removeData();
- }
-
- private void getFdProperties(Element storeConfig)
- {
- NodeList fdConfigs = storeConfig.getElementsByTagName("fdConfig"); //$NON-NLS-1$
- if (fdConfigs.getLength() != 1)
- {
- throw new IllegalStateException("FD configuration is missing"); //$NON-NLS-1$
- }
-
- Element fdConfig = (Element)fdConfigs.item(0);
- String fdName = fdConfig.getAttribute("name"); //$NON-NLS-1$
- String lockServerHost = fdConfig.getAttribute("lockServerHost"); //$NON-NLS-1$
- String fdDirPath = fdConfig.getAttribute("fdDirPath"); //$NON-NLS-1$
- // for future use once we allow databases to be created somewhere else.
- // String dbDirPath = fdConfig.getAttribute("dbDirPath"); //$NON-NLS-1$
- String logDirPath = fdConfig.getAttribute("logDirPath");//$NON-NLS-1$
- String fdFileHost = fdConfig.getAttribute("fdFileHost"); //$NON-NLS-1$
- String fdNumber = fdConfig.getAttribute("fdNumber"); //$NON-NLS-1$
- String pageSize = fdConfig.getAttribute("pageSize"); //$NON-NLS-1$
-
- // Session Cache data.
- sessionMinCacheSize = getIntegerValue(fdConfig.getAttribute("SessionMinCacheSize"), 0); //$NON-NLS-1$
- sessionMaxCacheSize = getIntegerValue(fdConfig.getAttribute("SessionMaxCacheSize"), 0); //$NON-NLS-1$
-
- // Log options.
- String logOptionString = fdConfig.getAttribute("logOption");
- if (logOptionString.equalsIgnoreCase("LogAll"))
- {
- logOption = oo.LogAll;
- }
- else if (logOptionString.equalsIgnoreCase("LogSession"))
- {
- logOption = oo.LogSession;
- }
-
- fdManager.setFdName(fdName);
- fdManager.setFdDirPath(fdDirPath);
- fdManager.setlogDirPath(logDirPath);
- fdManager.setFdNumber(fdNumber);
- fdManager.setFdFileHost(fdFileHost);
- fdManager.setLockServerHost(lockServerHost);
- fdManager.setPageSize(pageSize);
-
- }
-
- private int getIntegerValue(String str, int defaultValue)
- {
- if (str.length() == 0) // once we move to JDK 6 we can use isEmpty().
- {
- return defaultValue;
- }
-
- return new Integer(str).intValue();
- }
-
- public int getSessionMinCacheSize()
- {
- return sessionMinCacheSize;
- }
-
- public int getSessionMaxCacheSize()
- {
- return sessionMaxCacheSize;
- }
-
- public String getLogPath()
- {
- return fdManager.getLogPath();
- }
-
- public int getLogOption()
- {
- return logOption;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+
+package org.eclipse.emf.cdo.server.internal.objectivity;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.FdManager;
+import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreConfig;
+
+import org.eclipse.net4j.util.lifecycle.Lifecycle;
+
+import com.objy.db.app.Connection;
+import com.objy.db.app.oo;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class ObjectivityStoreConfig extends Lifecycle implements IObjectivityStoreConfig
+{
+ private static final long serialVersionUID = 1L;
+
+ FdManager fdManager = new FdManager();
+
+ private int sessionMinCacheSize = 0;
+
+ private int sessionMaxCacheSize = 0;
+
+ private int logOption = oo.LogNone;
+
+ public ObjectivityStoreConfig()
+ {
+ // fdManager.deleteFD();
+ fdManager.configure();
+ }
+
+ public ObjectivityStoreConfig(Element storeConfig)
+ {
+ // for now we'll just call the default configuration...
+ getFdProperties(storeConfig);
+ fdManager.configure();
+ }
+
+ public ObjectivityStoreConfig(String name)
+ {
+ // create an FD with that name.
+ fdManager.configure(name);
+ }
+
+ @Override
+ public void doActivate()
+ {
+ // System.out.println("ObjectivityStoreConfig.doActivate()");
+ fdManager.deleteFD();
+ fdManager.configure();
+ }
+
+ @Override
+ public void doDeactivate()
+ {
+ fdManager.deleteFD();
+ }
+
+ public String getFdName()
+ {
+ return fdManager.getFd();
+ }
+
+ public void resetFD()
+ {
+ if (Connection.current() == null)
+ {
+ return;
+ }
+
+ fdManager.removeData();
+ }
+
+ private void getFdProperties(Element storeConfig)
+ {
+ NodeList fdConfigs = storeConfig.getElementsByTagName("fdConfig"); //$NON-NLS-1$
+ if (fdConfigs.getLength() != 1)
+ {
+ throw new IllegalStateException("FD configuration is missing"); //$NON-NLS-1$
+ }
+
+ Element fdConfig = (Element)fdConfigs.item(0);
+ String fdName = fdConfig.getAttribute("name"); //$NON-NLS-1$
+ String lockServerHost = fdConfig.getAttribute("lockServerHost"); //$NON-NLS-1$
+ String fdDirPath = fdConfig.getAttribute("fdDirPath"); //$NON-NLS-1$
+ // for future use once we allow databases to be created somewhere else.
+ // String dbDirPath = fdConfig.getAttribute("dbDirPath"); //$NON-NLS-1$
+ String logDirPath = fdConfig.getAttribute("logDirPath");//$NON-NLS-1$
+ String fdFileHost = fdConfig.getAttribute("fdFileHost"); //$NON-NLS-1$
+ String fdNumber = fdConfig.getAttribute("fdNumber"); //$NON-NLS-1$
+ String pageSize = fdConfig.getAttribute("pageSize"); //$NON-NLS-1$
+
+ // Session Cache data.
+ sessionMinCacheSize = getIntegerValue(fdConfig.getAttribute("SessionMinCacheSize"), 0); //$NON-NLS-1$
+ sessionMaxCacheSize = getIntegerValue(fdConfig.getAttribute("SessionMaxCacheSize"), 0); //$NON-NLS-1$
+
+ // Log options.
+ String logOptionString = fdConfig.getAttribute("logOption");
+ if (logOptionString.equalsIgnoreCase("LogAll"))
+ {
+ logOption = oo.LogAll;
+ }
+ else if (logOptionString.equalsIgnoreCase("LogSession"))
+ {
+ logOption = oo.LogSession;
+ }
+
+ fdManager.setFdName(fdName);
+ fdManager.setFdDirPath(fdDirPath);
+ fdManager.setlogDirPath(logDirPath);
+ fdManager.setFdNumber(fdNumber);
+ fdManager.setFdFileHost(fdFileHost);
+ fdManager.setLockServerHost(lockServerHost);
+ fdManager.setPageSize(pageSize);
+
+ }
+
+ private int getIntegerValue(String str, int defaultValue)
+ {
+ if (str.length() == 0) // once we move to JDK 6 we can use isEmpty().
+ {
+ return defaultValue;
+ }
+
+ return new Integer(str).intValue();
+ }
+
+ public int getSessionMinCacheSize()
+ {
+ return sessionMinCacheSize;
+ }
+
+ public int getSessionMaxCacheSize()
+ {
+ return sessionMaxCacheSize;
+ }
+
+ public String getLogPath()
+ {
+ return fdManager.getLogPath();
+ }
+
+ public int getLogOption()
+ {
+ return logOption;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreFactory.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreFactory.java
index 5b340509e7..cfcbf3f99f 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreFactory.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/ObjectivityStoreFactory.java
@@ -1,62 +1,62 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity;
-
-import org.eclipse.emf.cdo.server.IStore;
-import org.eclipse.emf.cdo.server.IStoreFactory;
-
-import org.w3c.dom.Element;
-
-import java.util.Map;
-
-public class ObjectivityStoreFactory implements IStoreFactory
-{
-
- public ObjectivityStoreFactory()
- {
- }
-
- public IStore createStore(String repositoryName, Map<String, String> repositoryProperties, Element storeConfig)
- {
- // System.out.println(">>> OSF.createStore()");
- // TODO - we might want to initialize Objy with the
- // FD name here!!!
- ObjectivityStoreConfig objyStoreConfig = new ObjectivityStoreConfig(storeConfig);
-
- // open the connection to Objy...
- // if (Connection.current() == null)
- // {
- // try
- // {
- // // Connection.setUserClassLoader(ObjectivityStoreFactory.class.getClassLoader());
- // Connection.open(objyStoreConfig.getFdName(), oo.openReadWrite);
- // }
- // catch (DatabaseOpenException e)
- // {
- // e.printStackTrace();
- // }
- // catch (DatabaseNotFoundException e)
- // {
- // e.printStackTrace();
- // }
- // }
-
- ObjectivityStore store = new ObjectivityStore(objyStoreConfig);
- return store;
- }
-
- public String getStoreType()
- {
- return ObjectivityStore.TYPE;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity;
+
+import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.IStoreFactory;
+
+import org.w3c.dom.Element;
+
+import java.util.Map;
+
+public class ObjectivityStoreFactory implements IStoreFactory
+{
+
+ public ObjectivityStoreFactory()
+ {
+ }
+
+ public IStore createStore(String repositoryName, Map<String, String> repositoryProperties, Element storeConfig)
+ {
+ // System.out.println(">>> OSF.createStore()");
+ // TODO - we might want to initialize Objy with the
+ // FD name here!!!
+ ObjectivityStoreConfig objyStoreConfig = new ObjectivityStoreConfig(storeConfig);
+
+ // open the connection to Objy...
+ // if (Connection.current() == null)
+ // {
+ // try
+ // {
+ // // Connection.setUserClassLoader(ObjectivityStoreFactory.class.getClassLoader());
+ // Connection.open(objyStoreConfig.getFdName(), oo.openReadWrite);
+ // }
+ // catch (DatabaseOpenException e)
+ // {
+ // e.printStackTrace();
+ // }
+ // catch (DatabaseNotFoundException e)
+ // {
+ // e.printStackTrace();
+ // }
+ // }
+
+ ObjectivityStore store = new ObjectivityStore(objyStoreConfig);
+ return store;
+ }
+
+ public String getStoreType()
+ {
+ return ObjectivityStore.TYPE;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/bundle/OM.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/bundle/OM.java
index 6d0ea853e1..854ddde10a 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/bundle/OM.java
@@ -1,51 +1,51 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Ibrahim Sallam
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.server.objectivity"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- // TODO Consider using LOG for important things
- public static final OMTracer INFO = BUNDLE.tracer("info"); //$NON-NLS-1$
-
- // TODO Consider using LOG for important things
- public static final OMTracer ERROR = BUNDLE.tracer("error"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.bundle;
+
+import org.eclipse.net4j.util.om.OMBundle;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.OSGiActivator;
+import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.trace.OMTracer;
+
+/**
+ * The <em>Operations & Maintenance</em> class of this bundle.
+ *
+ * @author Ibrahim Sallam
+ */
+public abstract class OM
+{
+ public static final String BUNDLE_ID = "org.eclipse.emf.cdo.server.objectivity"; //$NON-NLS-1$
+
+ public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
+
+ public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
+
+ // TODO Consider using LOG for important things
+ public static final OMTracer INFO = BUNDLE.tracer("info"); //$NON-NLS-1$
+
+ // TODO Consider using LOG for important things
+ public static final OMTracer ERROR = BUNDLE.tracer("error"); //$NON-NLS-1$
+
+ public static final OMLogger LOG = BUNDLE.logger();
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Activator extends OSGiActivator
+ {
+ public Activator()
+ {
+ super(BUNDLE);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManager.java
index 5465946c36..636d81163b 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManager.java
@@ -1,24 +1,24 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.clustering;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.db.app.ooId;
-
-public interface ObjyPlacementManager
-{
- ooId getNearObject(ObjyObject parent, EStructuralFeature feature, EClass newClassObject);
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.clustering;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.db.app.ooId;
+
+public interface ObjyPlacementManager
+{
+ ooId getNearObject(ObjyObject parent, EStructuralFeature feature, EClass newClassObject);
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerImpl.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerImpl.java
index 01d8794807..2cad3dca36 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerImpl.java
@@ -1,54 +1,54 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.clustering;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.db.app.ooId;
-
-public class ObjyPlacementManagerImpl implements ObjyPlacementManager
-{
-
- private String resourceContName = "resCont";
-
- private String dbName = "DB";
-
- private String defContName = "DefaultCont";
-
- private String genContName = "Cont";
-
- /**
- * Only used when we can't figure out a near object, so we'll end up putting the object in a default location.
- */
- public ooId getNearObject(ObjyObject parent, EStructuralFeature feature, EClass newClassObject)
- {
- ObjyScope objyScope = null;
-
- if (parent == null)
- {
- objyScope = new ObjyScope(dbName, resourceContName);
- }
- else if (feature == null)
- {
- objyScope = new ObjyScope(dbName, defContName);
- }
- else
- {
- objyScope = new ObjyScope(dbName, genContName);
- }
- return objyScope.getScopeContOid();
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.clustering;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.db.app.ooId;
+
+public class ObjyPlacementManagerImpl implements ObjyPlacementManager
+{
+
+ private String resourceContName = "resCont";
+
+ private String dbName = "DB";
+
+ private String defContName = "DefaultCont";
+
+ private String genContName = "Cont";
+
+ /**
+ * Only used when we can't figure out a near object, so we'll end up putting the object in a default location.
+ */
+ public ooId getNearObject(ObjyObject parent, EStructuralFeature feature, EClass newClassObject)
+ {
+ ObjyScope objyScope = null;
+
+ if (parent == null)
+ {
+ objyScope = new ObjyScope(dbName, resourceContName);
+ }
+ else if (feature == null)
+ {
+ objyScope = new ObjyScope(dbName, defContName);
+ }
+ else
+ {
+ objyScope = new ObjyScope(dbName, genContName);
+ }
+ return objyScope.getScopeContOid();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java
index e4526420fe..69b604c6bb 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/clustering/ObjyPlacementManagerLocal.java
@@ -1,247 +1,247 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.clustering;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStore;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-
-import com.objy.db.app.ooId;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/***
- * This class will attempt to cluster objects with their container, or with a resource. It should be able to use the
- * global clustering which will use model elements to locate where an object will end up.
- *
- * @author Ibrahim Sallam
- */
-public class ObjyPlacementManagerLocal
-{
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyPlacementManagerLocal.class);
-
- // private static final ContextTracer TRACER_ERROR = new ContextTracer(OM.ERROR, ObjyPlacementManagerLocal.class);
-
- // private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyPlacementManagerLocal.class);
-
- private String repositoryName = null;
-
- ObjySession objySession = null;
-
- InternalCommitContext commitContext = null;
-
- Map<CDOID, InternalCDORevision> newObjectsMap;
-
- Map<CDOID, CDOID> idMapper;
-
- Map<CDOID, ObjyObject> newObjyObjectsMap;
-
- public ObjyPlacementManagerLocal(ObjectivityStore objyStore, ObjySession objySession,
- InternalCommitContext commitContext, Map<CDOID, ObjyObject> newObjyObjectsMap)
- {
- repositoryName = objyStore.getRepository().getName();
- this.objySession = objySession;
- this.commitContext = commitContext;
- // first put them in a map for easy lookup and processing....
- newObjectsMap = new HashMap<CDOID, InternalCDORevision>();
- for (InternalCDORevision revision : commitContext.getNewObjects())
- {
- newObjectsMap.put(revision.getID(), revision);
- }
-
- idMapper = new HashMap<CDOID, CDOID>();
-
- this.newObjyObjectsMap = newObjyObjectsMap;
- }
-
- public void processRevision(InternalCDORevision revision)
- {
- // the revision could've been processed in case if it's a container
- // object and we reached it while processing another revision.
- if (isIdProcessed(revision.getID()))
- {
- return;
- }
-
- // create the object and add it to mapping, this will recursively call
- // other object creation as needed, based on the default clustering of
- // having each object is stored with its container.
- try
- {
- createObjectAndAddToMapping(revision);
- }
- catch (com.objy.db.ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- private ObjyObject createObjectAndAddToMapping(InternalCDORevision revision)
- {
- ObjyObject objyObject = createObject(revision);
-
- CDOID newID = OBJYCDOIDUtil.getCDOID(objyObject.ooId());
-
- // nearObject = objyObject.ooId();
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Adding object to mapping from " + revision.getID() + " to " + newID);
- }
- commitContext.addIDMapping(revision.getID(), newID);
- // keep a track of this mapping.
- idMapper.put(revision.getID(), newID);
- newObjyObjectsMap.put(newID, objyObject);
-
- return objyObject;
- }
-
- protected boolean isIdProcessed(CDOID id)
- {
- // if the ID in the idMapper, then we did process the revision alreay
- return idMapper.get(id) != null;
- }
-
- protected ObjyObject createObject(InternalCDORevision revision)
- {
- long startTime = System.nanoTime();
- ooId nearObject = null;
- EClass eClass = revision.getEClass();
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Creating new object for revision: " + revision + " - eClass: " + eClass);
- }
- if (revision.isResourceNode())
- {
- String resourceName = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0);
- // The resourcelist is in the ConfigDB, but each resource is in a resource
- // container in the repo database, except the first root (ID == resourceID).
- // if (revision.getID() == revision.getResourceID()) // Check with Eike!
- if (resourceName == null) // root.
- {
- nearObject = objySession.getResourceList(repositoryName).ooId();
- }
- else
- {
- ObjyScope objyScope = new ObjyScope(repositoryName, resourceName /* ObjyDb.RESOURCELIST_CONT_NAME */);
- nearObject = objyScope.getScopeContOid();
- }
- }
- else
- {
- nearObject = getNearObject(revision);
- }
-
- if (nearObject == null)
- {
- // we have to put it somewhere.
- // call the global placement manager.
- nearObject = objySession.getObjectManager().getGlobalPlacementManager()
- .getNearObject(null, null, revision.getEClass());
- }
-
- ObjyObject objyObject = objySession.getObjectManager().newObject(eClass, nearObject);
-
- // // if it's a resource, collect it.
- // if (revision.isResourceNode())
- // {
- // // Add resource to the list
- // ObjyResourceList resourceList = objySession.getResourceList();
- //
- // // before we update the data into the object we need to check
- // // if it's a resource and we're trying to add a duplicate.
- // // TODO - do we need to check for Folder and resouce, or is the isResourceNode()
- // // check is enough?!!!
- // if (revision.isResourceFolder() || revision.isResource())
- // {
- // // this call will throw exception if we have a duplicate resource we trying to add.
- // resourceList.checkDuplicateResources(revision);
- // }
- // SmartLock.lock(objyObject);
- // resourceList.add(objyObject);
- // }
- ObjyObject.createObjectTime += System.nanoTime() - startTime;
- ObjyObject.createObjectCount++;
-
- return objyObject;
- }
-
- /***
- * This function might be called recursively throw the call to createAndAddToMapping() to create all the container
- * objects and or resources needed to cluster the rest of the new objects...
- */
- protected ooId getNearObject(InternalCDORevision revision)
- {
- ooId nearObject = null;
- // find the new object which is either a container or a resource.
- Object id = revision.getContainerID();
-
- if (id instanceof CDOID && (CDOID)id != CDOID.NULL)
- {
- nearObject = getOidFromCDOID((CDOID)id);
- }
- else
- {
- // use the resource...
- CDOID resourceId = revision.getResourceID();
- nearObject = getOidFromCDOID(resourceId);
- }
- return nearObject;
- }
-
- protected ooId getOidFromCDOID(CDOID id)
- {
- ooId oid = null;
-
- // if (OBJYCDOIDUtil.isValidObjyId(id))
- // oid = OBJYCDOIDUtil.getooId(id);
-
- if (id instanceof AbstractCDOIDLong)
- {
- oid = OBJYCDOIDUtil.getooId(id);
- }
- else if (id instanceof CDOIDTemp)
- {
- // see if we've seen it before
- CDOID nearId = idMapper.get(id);
- if (nearId != null)
- {
- oid = OBJYCDOIDUtil.getooId(nearId);
- }
- else
- {
- // create that object since it wasn't created and mapped yet.
- InternalCDORevision containerRevision = newObjectsMap.get(id);
- if (containerRevision != null)
- {
- oid = createObjectAndAddToMapping(containerRevision).ooId();
- }
- }
- }
-
- return oid;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.clustering;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDTemp;
+import org.eclipse.emf.cdo.eresource.EresourcePackage;
+import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStore;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.server.InternalCommitContext;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EClass;
+
+import com.objy.db.app.ooId;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/***
+ * This class will attempt to cluster objects with their container, or with a resource. It should be able to use the
+ * global clustering which will use model elements to locate where an object will end up.
+ *
+ * @author Ibrahim Sallam
+ */
+public class ObjyPlacementManagerLocal
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyPlacementManagerLocal.class);
+
+ // private static final ContextTracer TRACER_ERROR = new ContextTracer(OM.ERROR, ObjyPlacementManagerLocal.class);
+
+ // private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyPlacementManagerLocal.class);
+
+ private String repositoryName = null;
+
+ ObjySession objySession = null;
+
+ InternalCommitContext commitContext = null;
+
+ Map<CDOID, InternalCDORevision> newObjectsMap;
+
+ Map<CDOID, CDOID> idMapper;
+
+ Map<CDOID, ObjyObject> newObjyObjectsMap;
+
+ public ObjyPlacementManagerLocal(ObjectivityStore objyStore, ObjySession objySession,
+ InternalCommitContext commitContext, Map<CDOID, ObjyObject> newObjyObjectsMap)
+ {
+ repositoryName = objyStore.getRepository().getName();
+ this.objySession = objySession;
+ this.commitContext = commitContext;
+ // first put them in a map for easy lookup and processing....
+ newObjectsMap = new HashMap<CDOID, InternalCDORevision>();
+ for (InternalCDORevision revision : commitContext.getNewObjects())
+ {
+ newObjectsMap.put(revision.getID(), revision);
+ }
+
+ idMapper = new HashMap<CDOID, CDOID>();
+
+ this.newObjyObjectsMap = newObjyObjectsMap;
+ }
+
+ public void processRevision(InternalCDORevision revision)
+ {
+ // the revision could've been processed in case if it's a container
+ // object and we reached it while processing another revision.
+ if (isIdProcessed(revision.getID()))
+ {
+ return;
+ }
+
+ // create the object and add it to mapping, this will recursively call
+ // other object creation as needed, based on the default clustering of
+ // having each object is stored with its container.
+ try
+ {
+ createObjectAndAddToMapping(revision);
+ }
+ catch (com.objy.db.ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ private ObjyObject createObjectAndAddToMapping(InternalCDORevision revision)
+ {
+ ObjyObject objyObject = createObject(revision);
+
+ CDOID newID = OBJYCDOIDUtil.getCDOID(objyObject.ooId());
+
+ // nearObject = objyObject.ooId();
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Adding object to mapping from " + revision.getID() + " to " + newID);
+ }
+ commitContext.addIDMapping(revision.getID(), newID);
+ // keep a track of this mapping.
+ idMapper.put(revision.getID(), newID);
+ newObjyObjectsMap.put(newID, objyObject);
+
+ return objyObject;
+ }
+
+ protected boolean isIdProcessed(CDOID id)
+ {
+ // if the ID in the idMapper, then we did process the revision alreay
+ return idMapper.get(id) != null;
+ }
+
+ protected ObjyObject createObject(InternalCDORevision revision)
+ {
+ long startTime = System.nanoTime();
+ ooId nearObject = null;
+ EClass eClass = revision.getEClass();
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Creating new object for revision: " + revision + " - eClass: " + eClass);
+ }
+ if (revision.isResourceNode())
+ {
+ String resourceName = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0);
+ // The resourcelist is in the ConfigDB, but each resource is in a resource
+ // container in the repo database, except the first root (ID == resourceID).
+ // if (revision.getID() == revision.getResourceID()) // Check with Eike!
+ if (resourceName == null) // root.
+ {
+ nearObject = objySession.getResourceList(repositoryName).ooId();
+ }
+ else
+ {
+ ObjyScope objyScope = new ObjyScope(repositoryName, resourceName /* ObjyDb.RESOURCELIST_CONT_NAME */);
+ nearObject = objyScope.getScopeContOid();
+ }
+ }
+ else
+ {
+ nearObject = getNearObject(revision);
+ }
+
+ if (nearObject == null)
+ {
+ // we have to put it somewhere.
+ // call the global placement manager.
+ nearObject = objySession.getObjectManager().getGlobalPlacementManager()
+ .getNearObject(null, null, revision.getEClass());
+ }
+
+ ObjyObject objyObject = objySession.getObjectManager().newObject(eClass, nearObject);
+
+ // // if it's a resource, collect it.
+ // if (revision.isResourceNode())
+ // {
+ // // Add resource to the list
+ // ObjyResourceList resourceList = objySession.getResourceList();
+ //
+ // // before we update the data into the object we need to check
+ // // if it's a resource and we're trying to add a duplicate.
+ // // TODO - do we need to check for Folder and resouce, or is the isResourceNode()
+ // // check is enough?!!!
+ // if (revision.isResourceFolder() || revision.isResource())
+ // {
+ // // this call will throw exception if we have a duplicate resource we trying to add.
+ // resourceList.checkDuplicateResources(revision);
+ // }
+ // SmartLock.lock(objyObject);
+ // resourceList.add(objyObject);
+ // }
+ ObjyObject.createObjectTime += System.nanoTime() - startTime;
+ ObjyObject.createObjectCount++;
+
+ return objyObject;
+ }
+
+ /***
+ * This function might be called recursively throw the call to createAndAddToMapping() to create all the container
+ * objects and or resources needed to cluster the rest of the new objects...
+ */
+ protected ooId getNearObject(InternalCDORevision revision)
+ {
+ ooId nearObject = null;
+ // find the new object which is either a container or a resource.
+ Object id = revision.getContainerID();
+
+ if (id instanceof CDOID && (CDOID)id != CDOID.NULL)
+ {
+ nearObject = getOidFromCDOID((CDOID)id);
+ }
+ else
+ {
+ // use the resource...
+ CDOID resourceId = revision.getResourceID();
+ nearObject = getOidFromCDOID(resourceId);
+ }
+ return nearObject;
+ }
+
+ protected ooId getOidFromCDOID(CDOID id)
+ {
+ ooId oid = null;
+
+ // if (OBJYCDOIDUtil.isValidObjyId(id))
+ // oid = OBJYCDOIDUtil.getooId(id);
+
+ if (id instanceof AbstractCDOIDLong)
+ {
+ oid = OBJYCDOIDUtil.getooId(id);
+ }
+ else if (id instanceof CDOIDTemp)
+ {
+ // see if we've seen it before
+ CDOID nearId = idMapper.get(id);
+ if (nearId != null)
+ {
+ oid = OBJYCDOIDUtil.getooId(nearId);
+ }
+ else
+ {
+ // create that object since it wasn't created and mapped yet.
+ InternalCDORevision containerRevision = newObjectsMap.get(id);
+ if (containerRevision != null)
+ {
+ oid = createObjectAndAddToMapping(containerRevision).ooId();
+ }
+ }
+ }
+
+ return oid;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/FdManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/FdManager.java
index a908554689..ca08494923 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/FdManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/FdManager.java
@@ -1,569 +1,569 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-
-import org.eclipse.net4j.util.io.TMPUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.db.app.Session;
-import com.objy.db.app.oo;
-import com.objy.db.app.ooContObj;
-import com.objy.db.app.ooDBObj;
-
-import org.w3c.dom.Element;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Random;
-
-public class FdManager
-{
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, FdManager.class);
-
- private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, FdManager.class);
-
- private static final String DEFAULT_VALUE = "_DEFAULT_";
-
- private String fdName = "test";
-
- private String fdFileHost = DEFAULT_VALUE;
-
- private String fdDirPath = null;
-
- private String lockServerHost = DEFAULT_VALUE;
-
- private String fdNumber = "12345";
-
- private String pageSize = DEFAULT_VALUE;
-
- private String fdFilePath = null;
-
- private String bootFilePath = null;
-
- private boolean initialized = false;
-
- private String logDirPath = null;
-
- protected void initialize(boolean reset)
- {
- if (fdDirPath == null)
- {
- File dataFolder = TMPUtil.createTempFolder("Objy", "data");
- fdDirPath = dataFolder.getAbsolutePath();
- }
- if (noDefaultValueSet(logDirPath))
- {
- logDirPath = fdDirPath;
- }
- if (fdFilePath == null)
- {
- fdFilePath = fdDirPath + File.separator + fdName + ".fdb";
- }
- if (bootFilePath == null)
- {
- bootFilePath = fdDirPath + File.separator + fdName + ".boot";
- }
-
- if (!initialized)
- {
- if (reset)
- {
- initialized = resetFD();
- }
- else if (!fdExists())
- {
- initialized = createFD();
- }
- else
- {
- // FD is ready, just use it.
- initialized = true;
- }
- }
- }
-
- public String getFd()
- {
- return bootFilePath;
- }
-
- public boolean resetFD()
- {
- return deleteDBs();
- }
-
- public boolean resetFD_OLD()
- {
- boolean bRet = true;
- // TBD: we need to add code to delete all DBs.
- // also we need to delete the schema.
- // It might be easier to just delete the FD, then create another one.
- if (fdExists())
- {
- bRet = deleteFD();
- }
-
- if (bRet)
- {
- bRet = createFD();
- }
-
- return bRet;
- }
-
- private boolean createFD()
- {
- boolean bRet = false;
- Process proc = null;
-
- StringBuilder command = new StringBuilder(256);
- command.append("oonewfd");
- // command.append(" -fdfilehost ").append(getFdFileHost());
- command.append(" -fdfilepath ").append(fdFilePath);
- command.append(" -lockserver ").append(getLockServerHost());
- command.append(" -fdnumber ").append(fdNumber);
- command.append(" -pagesize ").append(getPageSize());
- // command.append(" -jnldirpath ").append(jrnlDirPath);
- // command.append(" -licensefile ").append(licenseFilePath);
- // if (standAlone) command.append(" -standalone ");
- command.append(' ').append(bootFilePath);
-
- TRACER_INFO.trace("Createing FD: '" + bootFilePath + "'.");
-
- try
- {
- proc = Runtime.getRuntime().exec(command.toString());
- if (proc.waitFor() != 0)
- {
- dumpStream(proc.getErrorStream());
- throw new RuntimeException("Error creating FD...");
- }
-
- dumpStream(proc.getInputStream());
- bRet = true;
- // loadSchema();
-
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return bRet;
- }
-
- // TODO - we made it public to allow wiping out the whole FD, there is close
- // package names and classes in the test suite.
- public boolean deleteFD()
- {
- boolean bRet = false;
- Process proc = null;
- File file = new File(bootFilePath);
- if (!file.exists())
- {
- return true;
- }
-
- String command = "oodeletefd" + " -force " + bootFilePath;
- TRACER_INFO.trace("Deleting FD: '" + bootFilePath + "'.");
-
- try
- {
- proc = Runtime.getRuntime().exec(command);
- if (proc.waitFor() != 0)
- {
- dumpStream(proc.getErrorStream());
- throw new RuntimeException("Error deleting FD...");
- }
-
- dumpStream(proc.getInputStream());
- bRet = true;
-
- }
- catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return bRet;
-
- }
-
- private boolean deleteDBs()
- {
- boolean bRet = false;
- Process proc = null;
-
- String command = "oodeletedb" + " -all " + " -force " + bootFilePath;
- // command += " ; del *.DB";
- TRACER_INFO.trace("Deleting all DBs from : '" + bootFilePath + "'.");
-
- try
- {
- proc = Runtime.getRuntime().exec(command);
- if (proc.waitFor() != 0)
- {
- dumpStream(proc.getErrorStream());
- throw new RuntimeException("Error deleting DBs...");
- }
-
- dumpStream(proc.getInputStream());
- bRet = true;
-
- }
- catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return bRet;
-
- }
-
- @SuppressWarnings("unused")
- private boolean deleteDBs_cl()
- {
- boolean bRet = false;
- Process proc = null;
-
- String command = "oodeletedb" + " -all " + " -force " + bootFilePath;
- // command += " ; del *.DB";
- TRACER_INFO.trace("Deleting all DBs from : '" + bootFilePath + "'.");
-
- try
- {
- proc = Runtime.getRuntime().exec(command);
- if (proc.waitFor() != 0)
- {
- dumpStream(proc.getErrorStream());
- throw new RuntimeException("Error deleting DBs...");
- }
-
- dumpStream(proc.getInputStream());
- bRet = true;
-
- }
- catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch (IOException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return bRet;
- }
-
- private boolean fdExists()
- {
- boolean bRet = false;
-
- File file = new File(bootFilePath);
- bRet = file.exists();
- // Process proc = null;
- //
- // String command = "oochange" + " -notitle " + bootFilePath;
- // TRACER_DEBUG.trace("Checking if FD: '" + bootFilePath + "' exists.");
- //
- // try
- // {
- // proc = Runtime.getRuntime().exec(command);
- // if (proc.waitFor() != 0)
- // {
- // dumpStream(proc.getErrorStream());
- // }
- // else
- // {
- // dumpStream(proc.getInputStream());
- // bRet = true;
- // }
- // }
- // catch (IOException e)
- // {
- // e.printStackTrace();
- // }
- // catch (InterruptedException e)
- // {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
-
- return bRet;
- }
-
- // This is a temp solution to avoid unloaded schema.
- // We'll explicitly load the schema after creating the FD
- @SuppressWarnings("unused")
- private boolean loadSchema()
- {
- boolean bRet = false;
- Process proc = null;
-
- String command = "ooschemaupgrade" + " -infile config" + File.separator + "schema.txt " + bootFilePath;
- TRACER_DEBUG.trace("Loading schema to FD: '" + bootFilePath + "'.");
-
- try
- {
- proc = Runtime.getRuntime().exec(command);
- if (proc.waitFor() != 0)
- {
- dumpStream(proc.getErrorStream());
- }
- else
- {
- dumpStream(proc.getInputStream());
- bRet = true;
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return bRet;
- }
-
- public String getFdFileHost()
- {
- if (noDefaultValueSet(fdFileHost))
- {
- // get local host
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- fdFileHost = address.getHostName();
- }
- catch (UnknownHostException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
- return fdFileHost;
- }
-
- public void setFdFileHost(String fdFileHost)
- {
- this.fdFileHost = fdFileHost;
- }
-
- public String getFdDirPath()
- {
- return fdDirPath;
- }
-
- public void setFdDirPath(String fdDirPath)
- {
- this.fdDirPath = fdDirPath;
- }
-
- public String getLockServerHost()
- {
- if (noDefaultValueSet(lockServerHost))
- {
- // get local host
- try
- {
- InetAddress address = InetAddress.getLocalHost();
- lockServerHost = address.getHostName();
- }
- catch (UnknownHostException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
- return lockServerHost;
- }
-
- public void setLockServerHost(String lockServerHost)
- {
- this.lockServerHost = lockServerHost;
- }
-
- public String getFdNumber()
- {
- return fdNumber;
- }
-
- public void setFdNumber(String fdNumber)
- {
- this.fdNumber = fdNumber;
- }
-
- public String getPageSize()
- {
- if (noDefaultValueSet(pageSize))
- {
- pageSize = "8192";
- }
- return pageSize;
- }
-
- public void setPageSize(String pageSize)
- {
- this.pageSize = pageSize;
- }
-
- public String getFdName()
- {
- return fdName;
- }
-
- public void setFdName(String fdName)
- {
- this.fdName = fdName;
- }
-
- private void dumpStream(InputStream inStream)
- {
- BufferedInputStream inBuffStream = new BufferedInputStream(inStream);
- try
- {
- byte[] buffer = new byte[1024];
- int bytesRead = 0;
- while ((bytesRead = inBuffStream.read(buffer)) != -1)
- {
- String chunk = new String(buffer, 0, bytesRead);
- TRACER_DEBUG.trace(chunk);
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
-
- public void configure()
- {
- initialize(false);
- }
-
- /**
- * TODO
- *
- * @param storeConfig
- */
- public void configure(Element storeConfig)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void configure(String name)
- {
- fdDirPath = fdDirPath + File.separator + name;
- // insure that path exist.
- File dir = new File(fdDirPath);
- if (!dir.exists())
- {
- // create the directory.
- dir.mkdirs();
- }
- Integer number = Math.abs(new Random().nextInt() % 65000);
- fdNumber = number.toString();
- initialize(false);
- }
-
- /**
- * Data cleanup code, that's mostly used by the test applications. This code will not remove schema.
- */
- public void removeData()
- {
- // ObjyConnection.INSTANCE.disconnect();
- // fdManager.resetFD();
- Session session = new Session();
- session.setIndexMode(oo.EXPLICIT_UPDATE);
- session.begin();
- Iterator<?> itr = session.getFD().containedDBs();
- ooDBObj dbObj = null;
- List<ooDBObj> dbList = new ArrayList<ooDBObj>();
- List<ooContObj> contList = new ArrayList<ooContObj>();
- while (itr.hasNext())
- {
- dbObj = (ooDBObj)itr.next();
- dbList.add(dbObj);
- {
- Iterator<?> contItr = dbObj.contains();
- while (contItr.hasNext())
- {
- contList.add((ooContObj)contItr.next());
- }
- }
- }
-
- for (ooContObj cont : contList)
- {
- cont.delete();
- }
-
- // for (ooDBObj db : dbList)
- // {
- // System.out.println("restFD() - deleting DB(" + db.getOid().getStoreString() + "):" + db.getName());
- // db.delete();
- // }
-
- session.commit();
- session.terminate();
- }
-
- boolean noDefaultValueSet(String value)
- {
- return value == null || value.length() == 0 || value.equals(DEFAULT_VALUE);
- }
-
- public void setlogDirPath(String logDirPath)
- {
- this.logDirPath = logDirPath;
- }
-
- public String getLogPath()
- {
- return logDirPath;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+
+import org.eclipse.net4j.util.io.TMPUtil;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.db.app.Session;
+import com.objy.db.app.oo;
+import com.objy.db.app.ooContObj;
+import com.objy.db.app.ooDBObj;
+
+import org.w3c.dom.Element;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+
+public class FdManager
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, FdManager.class);
+
+ private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, FdManager.class);
+
+ private static final String DEFAULT_VALUE = "_DEFAULT_";
+
+ private String fdName = "test";
+
+ private String fdFileHost = DEFAULT_VALUE;
+
+ private String fdDirPath = null;
+
+ private String lockServerHost = DEFAULT_VALUE;
+
+ private String fdNumber = "12345";
+
+ private String pageSize = DEFAULT_VALUE;
+
+ private String fdFilePath = null;
+
+ private String bootFilePath = null;
+
+ private boolean initialized = false;
+
+ private String logDirPath = null;
+
+ protected void initialize(boolean reset)
+ {
+ if (fdDirPath == null)
+ {
+ File dataFolder = TMPUtil.createTempFolder("Objy", "data");
+ fdDirPath = dataFolder.getAbsolutePath();
+ }
+ if (noDefaultValueSet(logDirPath))
+ {
+ logDirPath = fdDirPath;
+ }
+ if (fdFilePath == null)
+ {
+ fdFilePath = fdDirPath + File.separator + fdName + ".fdb";
+ }
+ if (bootFilePath == null)
+ {
+ bootFilePath = fdDirPath + File.separator + fdName + ".boot";
+ }
+
+ if (!initialized)
+ {
+ if (reset)
+ {
+ initialized = resetFD();
+ }
+ else if (!fdExists())
+ {
+ initialized = createFD();
+ }
+ else
+ {
+ // FD is ready, just use it.
+ initialized = true;
+ }
+ }
+ }
+
+ public String getFd()
+ {
+ return bootFilePath;
+ }
+
+ public boolean resetFD()
+ {
+ return deleteDBs();
+ }
+
+ public boolean resetFD_OLD()
+ {
+ boolean bRet = true;
+ // TBD: we need to add code to delete all DBs.
+ // also we need to delete the schema.
+ // It might be easier to just delete the FD, then create another one.
+ if (fdExists())
+ {
+ bRet = deleteFD();
+ }
+
+ if (bRet)
+ {
+ bRet = createFD();
+ }
+
+ return bRet;
+ }
+
+ private boolean createFD()
+ {
+ boolean bRet = false;
+ Process proc = null;
+
+ StringBuilder command = new StringBuilder(256);
+ command.append("oonewfd");
+ // command.append(" -fdfilehost ").append(getFdFileHost());
+ command.append(" -fdfilepath ").append(fdFilePath);
+ command.append(" -lockserver ").append(getLockServerHost());
+ command.append(" -fdnumber ").append(fdNumber);
+ command.append(" -pagesize ").append(getPageSize());
+ // command.append(" -jnldirpath ").append(jrnlDirPath);
+ // command.append(" -licensefile ").append(licenseFilePath);
+ // if (standAlone) command.append(" -standalone ");
+ command.append(' ').append(bootFilePath);
+
+ TRACER_INFO.trace("Createing FD: '" + bootFilePath + "'.");
+
+ try
+ {
+ proc = Runtime.getRuntime().exec(command.toString());
+ if (proc.waitFor() != 0)
+ {
+ dumpStream(proc.getErrorStream());
+ throw new RuntimeException("Error creating FD...");
+ }
+
+ dumpStream(proc.getInputStream());
+ bRet = true;
+ // loadSchema();
+
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return bRet;
+ }
+
+ // TODO - we made it public to allow wiping out the whole FD, there is close
+ // package names and classes in the test suite.
+ public boolean deleteFD()
+ {
+ boolean bRet = false;
+ Process proc = null;
+ File file = new File(bootFilePath);
+ if (!file.exists())
+ {
+ return true;
+ }
+
+ String command = "oodeletefd" + " -force " + bootFilePath;
+ TRACER_INFO.trace("Deleting FD: '" + bootFilePath + "'.");
+
+ try
+ {
+ proc = Runtime.getRuntime().exec(command);
+ if (proc.waitFor() != 0)
+ {
+ dumpStream(proc.getErrorStream());
+ throw new RuntimeException("Error deleting FD...");
+ }
+
+ dumpStream(proc.getInputStream());
+ bRet = true;
+
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return bRet;
+
+ }
+
+ private boolean deleteDBs()
+ {
+ boolean bRet = false;
+ Process proc = null;
+
+ String command = "oodeletedb" + " -all " + " -force " + bootFilePath;
+ // command += " ; del *.DB";
+ TRACER_INFO.trace("Deleting all DBs from : '" + bootFilePath + "'.");
+
+ try
+ {
+ proc = Runtime.getRuntime().exec(command);
+ if (proc.waitFor() != 0)
+ {
+ dumpStream(proc.getErrorStream());
+ throw new RuntimeException("Error deleting DBs...");
+ }
+
+ dumpStream(proc.getInputStream());
+ bRet = true;
+
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return bRet;
+
+ }
+
+ @SuppressWarnings("unused")
+ private boolean deleteDBs_cl()
+ {
+ boolean bRet = false;
+ Process proc = null;
+
+ String command = "oodeletedb" + " -all " + " -force " + bootFilePath;
+ // command += " ; del *.DB";
+ TRACER_INFO.trace("Deleting all DBs from : '" + bootFilePath + "'.");
+
+ try
+ {
+ proc = Runtime.getRuntime().exec(command);
+ if (proc.waitFor() != 0)
+ {
+ dumpStream(proc.getErrorStream());
+ throw new RuntimeException("Error deleting DBs...");
+ }
+
+ dumpStream(proc.getInputStream());
+ bRet = true;
+
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return bRet;
+ }
+
+ private boolean fdExists()
+ {
+ boolean bRet = false;
+
+ File file = new File(bootFilePath);
+ bRet = file.exists();
+ // Process proc = null;
+ //
+ // String command = "oochange" + " -notitle " + bootFilePath;
+ // TRACER_DEBUG.trace("Checking if FD: '" + bootFilePath + "' exists.");
+ //
+ // try
+ // {
+ // proc = Runtime.getRuntime().exec(command);
+ // if (proc.waitFor() != 0)
+ // {
+ // dumpStream(proc.getErrorStream());
+ // }
+ // else
+ // {
+ // dumpStream(proc.getInputStream());
+ // bRet = true;
+ // }
+ // }
+ // catch (IOException e)
+ // {
+ // e.printStackTrace();
+ // }
+ // catch (InterruptedException e)
+ // {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+
+ return bRet;
+ }
+
+ // This is a temp solution to avoid unloaded schema.
+ // We'll explicitly load the schema after creating the FD
+ @SuppressWarnings("unused")
+ private boolean loadSchema()
+ {
+ boolean bRet = false;
+ Process proc = null;
+
+ String command = "ooschemaupgrade" + " -infile config" + File.separator + "schema.txt " + bootFilePath;
+ TRACER_DEBUG.trace("Loading schema to FD: '" + bootFilePath + "'.");
+
+ try
+ {
+ proc = Runtime.getRuntime().exec(command);
+ if (proc.waitFor() != 0)
+ {
+ dumpStream(proc.getErrorStream());
+ }
+ else
+ {
+ dumpStream(proc.getInputStream());
+ bRet = true;
+ }
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InterruptedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return bRet;
+ }
+
+ public String getFdFileHost()
+ {
+ if (noDefaultValueSet(fdFileHost))
+ {
+ // get local host
+ try
+ {
+ InetAddress address = InetAddress.getLocalHost();
+ fdFileHost = address.getHostName();
+ }
+ catch (UnknownHostException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ return fdFileHost;
+ }
+
+ public void setFdFileHost(String fdFileHost)
+ {
+ this.fdFileHost = fdFileHost;
+ }
+
+ public String getFdDirPath()
+ {
+ return fdDirPath;
+ }
+
+ public void setFdDirPath(String fdDirPath)
+ {
+ this.fdDirPath = fdDirPath;
+ }
+
+ public String getLockServerHost()
+ {
+ if (noDefaultValueSet(lockServerHost))
+ {
+ // get local host
+ try
+ {
+ InetAddress address = InetAddress.getLocalHost();
+ lockServerHost = address.getHostName();
+ }
+ catch (UnknownHostException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ return lockServerHost;
+ }
+
+ public void setLockServerHost(String lockServerHost)
+ {
+ this.lockServerHost = lockServerHost;
+ }
+
+ public String getFdNumber()
+ {
+ return fdNumber;
+ }
+
+ public void setFdNumber(String fdNumber)
+ {
+ this.fdNumber = fdNumber;
+ }
+
+ public String getPageSize()
+ {
+ if (noDefaultValueSet(pageSize))
+ {
+ pageSize = "8192";
+ }
+ return pageSize;
+ }
+
+ public void setPageSize(String pageSize)
+ {
+ this.pageSize = pageSize;
+ }
+
+ public String getFdName()
+ {
+ return fdName;
+ }
+
+ public void setFdName(String fdName)
+ {
+ this.fdName = fdName;
+ }
+
+ private void dumpStream(InputStream inStream)
+ {
+ BufferedInputStream inBuffStream = new BufferedInputStream(inStream);
+ try
+ {
+ byte[] buffer = new byte[1024];
+ int bytesRead = 0;
+ while ((bytesRead = inBuffStream.read(buffer)) != -1)
+ {
+ String chunk = new String(buffer, 0, bytesRead);
+ TRACER_DEBUG.trace(chunk);
+ }
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void configure()
+ {
+ initialize(false);
+ }
+
+ /**
+ * TODO
+ *
+ * @param storeConfig
+ */
+ public void configure(Element storeConfig)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void configure(String name)
+ {
+ fdDirPath = fdDirPath + File.separator + name;
+ // insure that path exist.
+ File dir = new File(fdDirPath);
+ if (!dir.exists())
+ {
+ // create the directory.
+ dir.mkdirs();
+ }
+ Integer number = Math.abs(new Random().nextInt() % 65000);
+ fdNumber = number.toString();
+ initialize(false);
+ }
+
+ /**
+ * Data cleanup code, that's mostly used by the test applications. This code will not remove schema.
+ */
+ public void removeData()
+ {
+ // ObjyConnection.INSTANCE.disconnect();
+ // fdManager.resetFD();
+ Session session = new Session();
+ session.setIndexMode(oo.EXPLICIT_UPDATE);
+ session.begin();
+ Iterator<?> itr = session.getFD().containedDBs();
+ ooDBObj dbObj = null;
+ List<ooDBObj> dbList = new ArrayList<ooDBObj>();
+ List<ooContObj> contList = new ArrayList<ooContObj>();
+ while (itr.hasNext())
+ {
+ dbObj = (ooDBObj)itr.next();
+ dbList.add(dbObj);
+ {
+ Iterator<?> contItr = dbObj.contains();
+ while (contItr.hasNext())
+ {
+ contList.add((ooContObj)contItr.next());
+ }
+ }
+ }
+
+ for (ooContObj cont : contList)
+ {
+ cont.delete();
+ }
+
+ // for (ooDBObj db : dbList)
+ // {
+ // System.out.println("restFD() - deleting DB(" + db.getOid().getStoreString() + "):" + db.getName());
+ // db.delete();
+ // }
+
+ session.commit();
+ session.terminate();
+ }
+
+ boolean noDefaultValueSet(String value)
+ {
+ return value == null || value.length() == 0 || value.equals(DEFAULT_VALUE);
+ }
+
+ public void setlogDirPath(String logDirPath)
+ {
+ this.logDirPath = logDirPath;
+ }
+
+ public String getLogPath()
+ {
+ return logDirPath;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClass.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClass.java
index 9a7b001bb2..5046e7f243 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClass.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClass.java
@@ -1,135 +1,135 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import com.objy.as.app.Class_Position;
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.d_Class;
-
-import java.util.HashMap;
-
-/**
- * Wrapper around the AS class to be able to cache attributes.
- *
- * @author ibrahim
- */
-public class ObjyClass
-{
-
- protected d_Class asClass;
-
- protected String asClassName;
-
- protected HashMap<String, d_Attribute> attributeMap = new HashMap<String, d_Attribute>();
-
- protected HashMap<String, Class_Position> classPositionMap = new HashMap<String, Class_Position>();
-
- public ObjyClass(d_Class asClass/* , EClass eClass */)
- {
- this.asClass = asClass;
- if (asClass.namespace_name() != null)
- {
- asClassName = asClass.namespace_name() + ":" + asClass.name();
- }
- else
- {
- asClassName = asClass.name();
- }
- }
-
- public d_Attribute resolve_attribute(String attribute_name)
- {
- d_Attribute attr = attributeMap.get(attribute_name);
- if (attr == null)
- {
- attr = asClass.resolve_attribute(attribute_name);
- // we might get (attr == null) if the attribute is from a base class.
- // so we'll try to get the attribute through the position.
- if (attr == null)
- {
- Class_Position position = resolve_position(attribute_name);
- if (position != null)
- {
- attr = asClass.attribute_at_position(position);
- }
- }
- attributeMap.put(attribute_name, attr);
- }
- return attr;
- }
-
- public Class_Position resolve_position(String attribute_name)
- {
- Class_Position attr = classPositionMap.get(attribute_name);
- if (attr == null)
- {
- attr = asClass.position_in_class(attribute_name);
- classPositionMap.put(attribute_name, attr);
- }
- return attr;
- }
-
- public d_Class getASClass()
- {
- return asClass;
- }
-
- public String getASClassName()
- {
- return asClassName;
- }
-
- // public List<Class_Position> getListOfRefAttributes()
- // {
- // List<Class_Position> positions = new ArrayList<Class_Position>();
- //
- // System.out.println(">>> Class: " + asClassName);
- //
- // //
- // @SuppressWarnings("rawtypes")
- // Iterator itr = asClass.attributes_plus_inherited();
- // while (itr.hasNext())
- // {
- // d_Attribute attribute = (d_Attribute)itr.next();
- // if (attribute.is_type() && attribute.type_of() instanceof d_Ref_Type)
- // {
- // d_Class dClass = attribute.class_type_of();
- // if (dClass.name().equals(ObjyFeatureMapArrayList.ClassName))
- // {
- // // we'll need to copy this one.
- // positions.add(resolve_position(attribute.name()));
- // System.out.println("\t attr: " + attribute.name());
- // }
- // else if (dClass.name().equals(ObjyArrayListString.ClassName))
- // {
- // // we'll need to copy this one.
- // positions.add(resolve_position(attribute.name()));
- // System.out.println("\t attr: " + attribute.name());
- // }
- // else if (dClass.name().equals(ObjyArrayListId.className))
- // {
- // // we'll need to copy this one.
- // positions.add(resolve_position(attribute.name()));
- // System.out.println("\t attr: " + attribute.name());
- // }
- // else if (dClass.name().equals(ObjyProxy.className))
- // {
- // // we'll need to copy this one.
- // positions.add(resolve_position(attribute.name()));
- // System.out.println("\t attr: " + attribute.name());
- // }
- // }
- // }
- //
- // return positions;
- // }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import com.objy.as.app.Class_Position;
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.d_Class;
+
+import java.util.HashMap;
+
+/**
+ * Wrapper around the AS class to be able to cache attributes.
+ *
+ * @author ibrahim
+ */
+public class ObjyClass
+{
+
+ protected d_Class asClass;
+
+ protected String asClassName;
+
+ protected HashMap<String, d_Attribute> attributeMap = new HashMap<String, d_Attribute>();
+
+ protected HashMap<String, Class_Position> classPositionMap = new HashMap<String, Class_Position>();
+
+ public ObjyClass(d_Class asClass/* , EClass eClass */)
+ {
+ this.asClass = asClass;
+ if (asClass.namespace_name() != null)
+ {
+ asClassName = asClass.namespace_name() + ":" + asClass.name();
+ }
+ else
+ {
+ asClassName = asClass.name();
+ }
+ }
+
+ public d_Attribute resolve_attribute(String attribute_name)
+ {
+ d_Attribute attr = attributeMap.get(attribute_name);
+ if (attr == null)
+ {
+ attr = asClass.resolve_attribute(attribute_name);
+ // we might get (attr == null) if the attribute is from a base class.
+ // so we'll try to get the attribute through the position.
+ if (attr == null)
+ {
+ Class_Position position = resolve_position(attribute_name);
+ if (position != null)
+ {
+ attr = asClass.attribute_at_position(position);
+ }
+ }
+ attributeMap.put(attribute_name, attr);
+ }
+ return attr;
+ }
+
+ public Class_Position resolve_position(String attribute_name)
+ {
+ Class_Position attr = classPositionMap.get(attribute_name);
+ if (attr == null)
+ {
+ attr = asClass.position_in_class(attribute_name);
+ classPositionMap.put(attribute_name, attr);
+ }
+ return attr;
+ }
+
+ public d_Class getASClass()
+ {
+ return asClass;
+ }
+
+ public String getASClassName()
+ {
+ return asClassName;
+ }
+
+ // public List<Class_Position> getListOfRefAttributes()
+ // {
+ // List<Class_Position> positions = new ArrayList<Class_Position>();
+ //
+ // System.out.println(">>> Class: " + asClassName);
+ //
+ // //
+ // @SuppressWarnings("rawtypes")
+ // Iterator itr = asClass.attributes_plus_inherited();
+ // while (itr.hasNext())
+ // {
+ // d_Attribute attribute = (d_Attribute)itr.next();
+ // if (attribute.is_type() && attribute.type_of() instanceof d_Ref_Type)
+ // {
+ // d_Class dClass = attribute.class_type_of();
+ // if (dClass.name().equals(ObjyFeatureMapArrayList.ClassName))
+ // {
+ // // we'll need to copy this one.
+ // positions.add(resolve_position(attribute.name()));
+ // System.out.println("\t attr: " + attribute.name());
+ // }
+ // else if (dClass.name().equals(ObjyArrayListString.ClassName))
+ // {
+ // // we'll need to copy this one.
+ // positions.add(resolve_position(attribute.name()));
+ // System.out.println("\t attr: " + attribute.name());
+ // }
+ // else if (dClass.name().equals(ObjyArrayListId.className))
+ // {
+ // // we'll need to copy this one.
+ // positions.add(resolve_position(attribute.name()));
+ // System.out.println("\t attr: " + attribute.name());
+ // }
+ // else if (dClass.name().equals(ObjyProxy.className))
+ // {
+ // // we'll need to copy this one.
+ // positions.add(resolve_position(attribute.name()));
+ // System.out.println("\t attr: " + attribute.name());
+ // }
+ // }
+ // }
+ //
+ // return positions;
+ // }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java
index ce25566008..896e0495e6 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyClassProposed.java
@@ -1,243 +1,243 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBase;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.d_Class;
-import com.objy.as.app.d_Inheritance;
-import com.objy.as.app.d_Module;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-public class ObjyClassProposed
-{
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyClassProposed.class);
-
- private EClass eClass;
-
- private d_Module module;
-
- private boolean onlyStructure = false; // TODO - I'm not sure why we need this TBV.
-
- public ObjyClassProposed(d_Module module, EClass eClass, boolean onlyStructure)
- {
- this.eClass = eClass;
- this.module = module;
- this.onlyStructure = onlyStructure;
-
- }
-
- public void propose()
- {
- String className = ObjySchema.formObjectivityClassName(eClass, onlyStructure);
-
- Proposed_Class proposedooClass = null;
-
- {
- proposedooClass = ObjySchema.getTopModule().propose_new_class(className);
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ECLASS " + eClass.getName() + " -> " + className + " = ADD - START");
- }
-
- int countIndex = 0;
-
- for (EClass eSuperObject : eClass.getESuperTypes())
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ECLASS " + className + " ADDING SUPER CLASS " + eSuperObject.getName());
- }
- // This is used to only allow one base class with persistence inheritance.
- boolean itrOnlyStructure = countIndex == 0 ? false || onlyStructure : true;
-
- ObjySchema.createObjyClassSchema(eSuperObject, itrOnlyStructure);
-
- String superClassName = ObjySchema.formObjectivityClassName(eSuperObject, itrOnlyStructure);
- proposedooClass.add_base_class(com.objy.as.app.d_Module.LAST, // Position
- d_Access_Kind.d_PUBLIC, // Access kind
- superClassName); // Base class name*/
- countIndex++;
- }
-
- if (eClass.getESuperTypes().size() == 0 && !onlyStructure)
- {
- // this is done in ObjySchema.buildSchema()...
- // ooBaseClass.buildSchema();
- proposedooClass.add_base_class(com.objy.as.app.d_Module.LAST, // Position
- d_Access_Kind.d_PUBLIC, // Access kind
- ObjyBase.CLASS_NAME); // Base class name
-
- }
- }
- EList<EStructuralFeature> listFeatures = eClass.getEStructuralFeatures();
- ArrayList<EClass> toBeProcessed = new ArrayList<EClass>();
- for (EStructuralFeature feature : listFeatures)
- {
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
- {
- continue;
- }
-
- EClassifier destination = feature.getEType();
-
- ITypeMapper bridge = ObjyMapper.INSTANCE.getTypeMapper(feature);
-
- if (bridge == null)
- {
- continue;
- }
-
- // new field
- bridge.createSchema(proposedooClass, feature);
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("New Attribut for " + eClass.getName() + " name : " + feature.getName());
- }
-
- if (feature instanceof EReference)
- {
- // ObjySchema.createObjyClassSchema((EClass)destination, false);
- toBeProcessed.add((EClass)destination);
- }
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ECLASS " + eClass.getName() + " -> " + className + " -- DONE");
- }
-
- for (EClass classifier : toBeProcessed)
- {
- // ObjySchema.getOrCreate(classifier);
- ObjySchema.createObjyClassSchema(classifier, false);
- }
-
- }
-
- public void evolve(d_Class dClass)
- {
- String className = ObjySchema.formObjectivityClassName(eClass, onlyStructure);
-
- Proposed_Class proposedooClass = null;
-
- // boolean evolution = false;
-
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ECLASS " + eClass.getName() + " -> " + className + " EVOLVE - START");
- }
-
- Iterator<?> subClasses = dClass.sub_class_list();
- while (subClasses.hasNext())
- {
- d_Inheritance subClass = (d_Inheritance)subClasses.next();
- module.propose_evolved_class(subClass.inherits_to().name());
- }
- proposedooClass = module.propose_evolved_class(className);
- }
-
- EList<EStructuralFeature> listFeatures = eClass.getEStructuralFeatures();
- ArrayList<EClass> toBeEvolve = new ArrayList<EClass>();
- for (EStructuralFeature feature : listFeatures)
- {
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
- {
- continue;
- }
-
- EClassifier destination = feature.getEType();
-
- ITypeMapper bridge = ObjyMapper.INSTANCE.getTypeMapper(feature);
-
- if (bridge == null)
- {
- continue;
- }
-
- d_Attribute attr = null;
- attr = dClass.resolve_attribute(feature.getName());
-
- if (attr == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("New Attribut for " + eClass.getName() + " name : " + feature.getName());
- }
-
- // new field
- bridge.createSchema(proposedooClass, feature);
- }
- // TODO - enable the rest of attribute type evolution...
- // else if (bridge.validate(attr, feature))
- // {
- // continue;
- // }
- else
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Attribut Changed for " + eClass.getName() + " name : " + feature.getName());
- TRACER_DEBUG.trace("... attribute change is not supported in this release... for " + eClass.getName()
- + " name : " + feature.getName());
- }
-
- // TODO - enable the rest of attribute type evolution...
- // bridge.modifySchema(proposedooClass, feature);
- }
-
- if (feature instanceof EReference)
- {
- // String destinationClassName = getObjectivityClass(destination);
- // d_Class dClass = module.resolve_class(destinationClassName);
- toBeEvolve.add((EClass)destination);
- }
- }
-
- TRACER_DEBUG.trace("evolve ECLASS " + eClass.getName() + " -> " + className + " -- DONE");
-
- for (EClass classifier : toBeEvolve)
- {
- String localName = ObjySchema.formObjectivityClassName(classifier, false);
- d_Class localDClass = ObjySchema.getTopModule().resolve_class(localName);
- if (localDClass == null)
- {
- ObjySchema.createObjyClassSchema(classifier, false);
- }
- else
- {
- ObjySchema.evolveObjyClassSchema(classifier, false);
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBase;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.d_Class;
+import com.objy.as.app.d_Inheritance;
+import com.objy.as.app.d_Module;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class ObjyClassProposed
+{
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyClassProposed.class);
+
+ private EClass eClass;
+
+ private d_Module module;
+
+ private boolean onlyStructure = false; // TODO - I'm not sure why we need this TBV.
+
+ public ObjyClassProposed(d_Module module, EClass eClass, boolean onlyStructure)
+ {
+ this.eClass = eClass;
+ this.module = module;
+ this.onlyStructure = onlyStructure;
+
+ }
+
+ public void propose()
+ {
+ String className = ObjySchema.formObjectivityClassName(eClass, onlyStructure);
+
+ Proposed_Class proposedooClass = null;
+
+ {
+ proposedooClass = ObjySchema.getTopModule().propose_new_class(className);
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ECLASS " + eClass.getName() + " -> " + className + " = ADD - START");
+ }
+
+ int countIndex = 0;
+
+ for (EClass eSuperObject : eClass.getESuperTypes())
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ECLASS " + className + " ADDING SUPER CLASS " + eSuperObject.getName());
+ }
+ // This is used to only allow one base class with persistence inheritance.
+ boolean itrOnlyStructure = countIndex == 0 ? false || onlyStructure : true;
+
+ ObjySchema.createObjyClassSchema(eSuperObject, itrOnlyStructure);
+
+ String superClassName = ObjySchema.formObjectivityClassName(eSuperObject, itrOnlyStructure);
+ proposedooClass.add_base_class(com.objy.as.app.d_Module.LAST, // Position
+ d_Access_Kind.d_PUBLIC, // Access kind
+ superClassName); // Base class name*/
+ countIndex++;
+ }
+
+ if (eClass.getESuperTypes().size() == 0 && !onlyStructure)
+ {
+ // this is done in ObjySchema.buildSchema()...
+ // ooBaseClass.buildSchema();
+ proposedooClass.add_base_class(com.objy.as.app.d_Module.LAST, // Position
+ d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyBase.CLASS_NAME); // Base class name
+
+ }
+ }
+ EList<EStructuralFeature> listFeatures = eClass.getEStructuralFeatures();
+ ArrayList<EClass> toBeProcessed = new ArrayList<EClass>();
+ for (EStructuralFeature feature : listFeatures)
+ {
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ {
+ continue;
+ }
+
+ EClassifier destination = feature.getEType();
+
+ ITypeMapper bridge = ObjyMapper.INSTANCE.getTypeMapper(feature);
+
+ if (bridge == null)
+ {
+ continue;
+ }
+
+ // new field
+ bridge.createSchema(proposedooClass, feature);
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("New Attribut for " + eClass.getName() + " name : " + feature.getName());
+ }
+
+ if (feature instanceof EReference)
+ {
+ // ObjySchema.createObjyClassSchema((EClass)destination, false);
+ toBeProcessed.add((EClass)destination);
+ }
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ECLASS " + eClass.getName() + " -> " + className + " -- DONE");
+ }
+
+ for (EClass classifier : toBeProcessed)
+ {
+ // ObjySchema.getOrCreate(classifier);
+ ObjySchema.createObjyClassSchema(classifier, false);
+ }
+
+ }
+
+ public void evolve(d_Class dClass)
+ {
+ String className = ObjySchema.formObjectivityClassName(eClass, onlyStructure);
+
+ Proposed_Class proposedooClass = null;
+
+ // boolean evolution = false;
+
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ECLASS " + eClass.getName() + " -> " + className + " EVOLVE - START");
+ }
+
+ Iterator<?> subClasses = dClass.sub_class_list();
+ while (subClasses.hasNext())
+ {
+ d_Inheritance subClass = (d_Inheritance)subClasses.next();
+ module.propose_evolved_class(subClass.inherits_to().name());
+ }
+ proposedooClass = module.propose_evolved_class(className);
+ }
+
+ EList<EStructuralFeature> listFeatures = eClass.getEStructuralFeatures();
+ ArrayList<EClass> toBeEvolve = new ArrayList<EClass>();
+ for (EStructuralFeature feature : listFeatures)
+ {
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ {
+ continue;
+ }
+
+ EClassifier destination = feature.getEType();
+
+ ITypeMapper bridge = ObjyMapper.INSTANCE.getTypeMapper(feature);
+
+ if (bridge == null)
+ {
+ continue;
+ }
+
+ d_Attribute attr = null;
+ attr = dClass.resolve_attribute(feature.getName());
+
+ if (attr == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("New Attribut for " + eClass.getName() + " name : " + feature.getName());
+ }
+
+ // new field
+ bridge.createSchema(proposedooClass, feature);
+ }
+ // TODO - enable the rest of attribute type evolution...
+ // else if (bridge.validate(attr, feature))
+ // {
+ // continue;
+ // }
+ else
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Attribut Changed for " + eClass.getName() + " name : " + feature.getName());
+ TRACER_DEBUG.trace("... attribute change is not supported in this release... for " + eClass.getName()
+ + " name : " + feature.getName());
+ }
+
+ // TODO - enable the rest of attribute type evolution...
+ // bridge.modifySchema(proposedooClass, feature);
+ }
+
+ if (feature instanceof EReference)
+ {
+ // String destinationClassName = getObjectivityClass(destination);
+ // d_Class dClass = module.resolve_class(destinationClassName);
+ toBeEvolve.add((EClass)destination);
+ }
+ }
+
+ TRACER_DEBUG.trace("evolve ECLASS " + eClass.getName() + " -> " + className + " -- DONE");
+
+ for (EClass classifier : toBeEvolve)
+ {
+ String localName = ObjySchema.formObjectivityClassName(classifier, false);
+ d_Class localDClass = ObjySchema.getTopModule().resolve_class(localName);
+ if (localDClass == null)
+ {
+ ObjySchema.createObjyClassSchema(classifier, false);
+ }
+ else
+ {
+ ObjySchema.evolveObjyClassSchema(classifier, false);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyCommitInfoHandler.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyCommitInfoHandler.java
index f1d5c224bf..2a2456d8b4 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyCommitInfoHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyCommitInfoHandler.java
@@ -1,112 +1,112 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyCommitInfo;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
-
-import com.objy.db.app.Session;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooTreeSetX;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class ObjyCommitInfoHandler
-{
- protected ooId commitInfoSetId;
-
- public ObjyCommitInfoHandler(String repositoryName)
- {
- commitInfoSetId = ObjyDb.getOrCreateCommitInfoList(repositoryName);
- }
-
- /***
- * Factory method to create the CommitInfoList, which is a TreeListX
- */
- public static ooId create(ooId scopeContOid)
- {
- ooTreeSetX treeSet = new ooTreeSetX(20, true);
- ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
- clusterObject.cluster(treeSet);
-
- return treeSet.getOid();
- }
-
- /***
- * This function assume we are in an Objy trnasaction.
- */
-
- public void writeCommitInfo(int id, long timeStamp, long previousTimeStamp, String userID, String comment)
- {
- ObjyCommitInfo commitInfo = new ObjyCommitInfo(id, timeStamp, previousTimeStamp, userID, comment);
- getTreeSet().add(commitInfo);
- }
-
- /***
- * Find all objects in the ooTreeListX that's between startTime and endTime inclusive, and have branch.getID() if
- * branch is not null We don't have any optimization for time, but we could make the treeset use custom comparator.
- */
- public List<ObjyCommitInfo> getCommitInfo(CDOBranch branch, long startTime, long endTime)
- {
- ooTreeSetX treeSet = getTreeSet();
- ObjyCommitInfo ooCommitInfo = null;
- List<ObjyCommitInfo> results = new ArrayList<ObjyCommitInfo>();
-
- boolean getIt = false;
-
- @SuppressWarnings("unchecked")
- Iterator<ObjyCommitInfo> itr = treeSet.iterator();
- while (itr.hasNext())
- {
- ooCommitInfo = itr.next();
- getIt = true; // assume it's what we need, then we filter below.
- long timeStamp = ooCommitInfo.getTimeStamp();
- long branchId = ooCommitInfo.getBranchId();
-
- if (branch != null && branch.getID() != branchId)
- {
- getIt = false;
- }
- if (getIt && startTime != CDOBranchPoint.UNSPECIFIED_DATE && timeStamp < startTime)
- {
- getIt = false;
- }
- if (getIt && endTime != CDOBranchPoint.UNSPECIFIED_DATE && timeStamp > endTime)
- {
- getIt = false;
- }
-
- if (getIt)
- {
- results.add(ooCommitInfo);
- }
- }
-
- return results;
- }
-
- /***
- * This function assume we are in an Objy trnasaction.
- */
- protected ooTreeSetX getTreeSet()
- {
- ooTreeSetX treeSet = null;
- treeSet = (ooTreeSetX)Session.getCurrent().getFD().objectFrom(commitInfoSetId.getString());
- return treeSet;
-
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyCommitInfo;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
+
+import com.objy.db.app.Session;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeSetX;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ObjyCommitInfoHandler
+{
+ protected ooId commitInfoSetId;
+
+ public ObjyCommitInfoHandler(String repositoryName)
+ {
+ commitInfoSetId = ObjyDb.getOrCreateCommitInfoList(repositoryName);
+ }
+
+ /***
+ * Factory method to create the CommitInfoList, which is a TreeListX
+ */
+ public static ooId create(ooId scopeContOid)
+ {
+ ooTreeSetX treeSet = new ooTreeSetX(20, true);
+ ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
+ clusterObject.cluster(treeSet);
+
+ return treeSet.getOid();
+ }
+
+ /***
+ * This function assume we are in an Objy trnasaction.
+ */
+
+ public void writeCommitInfo(int id, long timeStamp, long previousTimeStamp, String userID, String comment)
+ {
+ ObjyCommitInfo commitInfo = new ObjyCommitInfo(id, timeStamp, previousTimeStamp, userID, comment);
+ getTreeSet().add(commitInfo);
+ }
+
+ /***
+ * Find all objects in the ooTreeListX that's between startTime and endTime inclusive, and have branch.getID() if
+ * branch is not null We don't have any optimization for time, but we could make the treeset use custom comparator.
+ */
+ public List<ObjyCommitInfo> getCommitInfo(CDOBranch branch, long startTime, long endTime)
+ {
+ ooTreeSetX treeSet = getTreeSet();
+ ObjyCommitInfo ooCommitInfo = null;
+ List<ObjyCommitInfo> results = new ArrayList<ObjyCommitInfo>();
+
+ boolean getIt = false;
+
+ @SuppressWarnings("unchecked")
+ Iterator<ObjyCommitInfo> itr = treeSet.iterator();
+ while (itr.hasNext())
+ {
+ ooCommitInfo = itr.next();
+ getIt = true; // assume it's what we need, then we filter below.
+ long timeStamp = ooCommitInfo.getTimeStamp();
+ long branchId = ooCommitInfo.getBranchId();
+
+ if (branch != null && branch.getID() != branchId)
+ {
+ getIt = false;
+ }
+ if (getIt && startTime != CDOBranchPoint.UNSPECIFIED_DATE && timeStamp < startTime)
+ {
+ getIt = false;
+ }
+ if (getIt && endTime != CDOBranchPoint.UNSPECIFIED_DATE && timeStamp > endTime)
+ {
+ getIt = false;
+ }
+
+ if (getIt)
+ {
+ results.add(ooCommitInfo);
+ }
+ }
+
+ return results;
+ }
+
+ /***
+ * This function assume we are in an Objy trnasaction.
+ */
+ protected ooTreeSetX getTreeSet()
+ {
+ ooTreeSetX treeSet = null;
+ treeSet = (ooTreeSetX)Session.getCurrent().getFD().objectFrom(commitInfoSetId.getString());
+ return treeSet;
+
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyConnection.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyConnection.java
index c41f895531..9257ed64c3 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyConnection.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyConnection.java
@@ -1,439 +1,439 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManagerImpl;
-import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreConfig;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.db.DatabaseNotFoundException;
-import com.objy.db.DatabaseOpenException;
-import com.objy.db.ObjyRuntimeException;
-import com.objy.db.app.Connection;
-import com.objy.db.app.Session;
-import com.objy.db.app.oo;
-
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.ReentrantLock;
-
-public class ObjyConnection
-{
-
- public static final ObjyConnection INSTANCE = new ObjyConnection();
-
- protected Connection connection = null;
-
- protected boolean isConnected = false;
-
- protected String fdName = "";
-
- // protected ObjectivityStore store = null;
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyConnection.class);
-
- // private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyConnection.class);
-
- // TODO - session pools could be a configuration candidate.
- private static final String SESSION_POOL_NAME_READ = "ReadSP";
-
- private static final String SESSION_POOL_NAME_WRITE = "WriteSP";
-
- // private static final String PoolInfo = "PoolInfo";
-
- protected ConcurrentHashMap<String, ObjySession> readPool;
-
- protected ConcurrentHashMap<String, ObjySession> writePool;
-
- private ObjyPlacementManager defaultPlacementManager = null;
-
- private Object syncObject = new Object();
-
- private ReentrantLock lock = new ReentrantLock();
-
- private int sessionMinCacheSize = 600;
-
- private int sessionMaxCacheSize = 1000;
-
- private final int minInactiveSessions = 5;
-
- private int sessionCount = 0;
-
- private String logDirPath = null;
-
- private int logOption = oo.LogNone;
-
- public ObjyConnection()
- {
- readPool = new ConcurrentHashMap<String, ObjySession>(5);
- writePool = new ConcurrentHashMap<String, ObjySession>(5);
- }
-
- /***
- * Connect to a store and an FD. TODO - We might need to allow switching of FD in the future.
- */
- synchronized public void connect(IObjectivityStoreConfig storeConfig)
- {
- /****
- * If
- */
- fdName = storeConfig.getFdName();
- logDirPath = storeConfig.getLogPath();
- logOption = storeConfig.getLogOption();
- connect();
- // this.store = store;
- }
-
- synchronized public void connect(String fdName, int logOption)
- {
- /****
- * If
- */
- this.fdName = fdName;
- this.logOption = logOption;
- connect();
- // this.store = store;
- }
-
- private void connect()
- {
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(" SessionMinCacheSize: " + sessionMinCacheSize);
- TRACER_DEBUG.trace(" SessionMaxCacheSize: " + sessionMaxCacheSize);
- }
-
- if (!isConnected)
- {
- try
- {
- if (Connection.current() == null)
- {
- if (logOption != oo.LogNone)
- {
- Connection.setLoggingOptions(logOption, true, // boolean logToFiles
- true, // boolean appendLogFiles,
- logDirPath, // String logDirPath,
- "MainLog.txt"// String mainLogFileName
- );
- }
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(" creating new Connection");
- }
- connection = Connection.open(fdName, oo.openReadWrite);
- connection.useContextClassLoader(true);
- }
- else
- {
- connection.addToMainLog("ObjyConnection.connect()", "...reopen connection to the FD.");
- connection.setOpenMode(oo.openReadWrite);
- connection.reopen();
- connection.loadSchemaClasses(true);
- }
- isConnected = true;
- }
- catch (DatabaseOpenException e)
- {
- e.printStackTrace();
- }
- catch (DatabaseNotFoundException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- public String getSessionPoolNameRead()
- {
- return SESSION_POOL_NAME_READ;
- }
-
- public String getSessionPoolNameWrite()
- {
- return SESSION_POOL_NAME_WRITE;
- }
-
- public ObjySession getWriteSessionFromPool(String sessionName)
- {
- return getSessionFromPool(sessionName);
- }
-
- public ObjySession getReadSessionFromPool(String sessionName)
- {
- return getSessionFromPool(sessionName);
- }
-
- protected ObjySession getSessionFromPool(String sessionName)
- {
- synchronized (syncObject)
- {
- // return connection.getSessionFromPool(getSessionPoolNameWrite(), sessionName);
- ObjySession session = readPool.get(sessionName);
- if (session == null)
- {
- if (sessionCount >= minInactiveSessions)
- {
- // look for an inactive one, rename it and use it.
- for (ObjySession objySession : readPool.values())
- {
- if (objySession.isAvailable())
- {
- objySession.setName(sessionName);
- session = objySession;
- break;
- }
- }
- }
-
- // we are forced to create one.
- if (session == null)
- {
- session = new ObjySession(sessionName, readPool, this);
- ++sessionCount;
- // System.out.println(">>> IS: creating new session: " + sessionName + " - total: " + sessionCount);
- readPool.put(sessionName, session);
- }
- }
- session.join();
- session.setAvailable(false);
- return session;
- }
- }
-
- public void disconnect()
- {
- if (!isConnected)
- {
- return;
- }
- // synchronized(syncObject)
- {
- // it's important to do the lock() call, otherwise during the test-suite
- // run we can exit the test before cleaning up, and session might be
- // partly terminated.
- // We could change the code in cleanupSessionPool() to remove the session
- // from the pool before terminating it, but this could leave some sessions
- // in the connection (another issue here is the connection.reconnect()
- // doesn't work all the time).
- lock.lock();
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ObjyConnection.disconnect() -- Start. " + toString());
- }
-
- // terminate the session and cleanup the Pool.
- // TRACER_DEBUG.trace("ObjyConnection.disconnect() -- cleanup readPool. ");
- cleanupSessionPool(readPool);
- // TRACER_DEBUG.trace("ObjyConnection.disconnect() -- cleanup writePool. ");
- cleanupSessionPool(writePool);
-
- sessionCount = 0;
-
- // TRACER_DEBUG.trace("ObjyConnection.disconnect() -- cleanup any other sessions. ");
- // for testing we need to find out if there are any open sessions.
-
- @SuppressWarnings("unchecked")
- Vector<Session> sessions = connection.sessions();
- for (Session aSession : sessions)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Session: " + aSession + " - open state: " + aSession.isOpen());
- }
- // we need to make sure that any open session is aborted, otherwise we
- // can't reopen the fd.
- if (aSession.isOpen())
- {
- try
- {
- aSession.join();
- aSession.abort();
- // IS: sometime we get exception about no transaction, although we checked
- // aSession.isOpen() above.
- }
- catch (ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- }
- finally
- {
- aSession.terminate();
- }
- }
- }
-
- // 100211:IS - Avoid closing the connection, we're seeing
- // sort of schema issues doing so with 9.4.1...
- /****
- * try { Session session = new Session(); session.begin(); //connection.dropAllUserClasses(true);
- * connection.dropAllUnregisterableClasses(); session.commit(); connection.close(); isConnected = false; } catch
- * (DatabaseClosedException e) { // TODO Auto-generated catch block e.printStackTrace(); }
- ****/
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ObjyConnection.disconnect() -- END. ");
- }
- lock.unlock();
- }
-
- }
-
- // public void resetFD()
- // {
- // //fdManager.resetFD();
- // if (Connection.current() != null)
- // {
- // if (!isConnected)
- // connect();
- //
- // // for testing we need to find out if there are any open sessions.
- // Vector<Session> sessions = Connection.current().sessions();
- // System.out.println("Sessions still available: " + sessions.size());
- // for (Session aSession : sessions)
- // {
- // System.out.println("Session: " + aSession + " - open state: " + aSession.isOpen());
- // // we need to make sure that any open session is aborted, otherwise we
- // // can't reopen the fd.
- // if (aSession.isOpen())
- // {
- // try {
- // aSession.join();
- // aSession.abort();
- // // IS: sometime we get exception about no transaction, although we checked
- // // aSession.isOpen() above.
- // } catch (ObjyRuntimeException ex) {
- // ex.printStackTrace();
- // } finally {
- // aSession.terminate();
- // }
- // }
- // }
- //
- // // Session session = new Session();
- // // session.begin();
- // // Iterator itr = session.getFD().containedDBs();
- // // ooDBObj dbObj = null;
- // // List<ooDBObj> dbList = new ArrayList<ooDBObj>();
- // // while (itr.hasNext())
- // // {
- // // dbObj = (ooDBObj) itr.next();
- // // dbList.add(dbObj);
- // // }
- // // itr.close();
- // // session.commit();
- //
- // // session.begin();
- // // for (ooDBObj db : dbList)
- // // {
- // // System.out.println("restFD() - deleting DB(" + db.getOid().getStoreString()+"):" + db.getName());
- // // db.delete();
- // // }
- // // session.commit();
- //
- // // we need to wipe the schema, some tests have similar class and package
- // // names which could cause tests to fail.
- // // for now we'll just wipe the wole FD.
- // //fdManager.resetFD_OLD();
- //
- // //
- // // System.out.println("resetFD() - dumping catalog BEGIN.........");
- // // session.begin();
- // // session.getFD().dumpCatalog();
- // // session.commit();
- // // System.out.println("resetFD() - dumping catalog END...........");
- // // session.terminate();
- //
- // disconnect();
- // }
- // }
-
- public void registerClass(String name)
- {
- connection.registerClass(name);
- }
-
- public ObjyPlacementManager getDefaultPlacementManager()
- {
- if (defaultPlacementManager == null)
- {
- defaultPlacementManager = new ObjyPlacementManagerImpl();
- }
- return defaultPlacementManager;
- }
-
- protected void cleanupSessionPool(ConcurrentHashMap<String, ObjySession> pool)
- {
- for (ObjySession objySession : pool.values())
- {
- try
- {
- if (objySession.isOpen())
- {
- objySession.join();
- objySession.abort();
- // IS: sometime we get exception about no transaction, although we checked
- // aSession.isOpen() above.
- }
- }
- catch (ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- }
- finally
- {
- // TRACER_DEBUG.trace("ObjyConnection.cleanupSessionPool() -- start terminating session. " +
- // objySession.toString());
- try
- {
- objySession.terminate();
- // TRACER_DEBUG.trace("ObjyConnection.cleanupSessionPool() -- end terminating session. " +
- // objySession.toString());
- }
- catch (ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
- }
- pool.clear();
- }
-
- public void setSessionMinCacheSize(int sessionMinCacheSize)
- {
- if (sessionMinCacheSize > this.sessionMinCacheSize)
- {
- this.sessionMinCacheSize = sessionMinCacheSize;
- }
- }
-
- public void setSessionMaxCacheSize(int sessionMaxCacheSize)
- {
- if (sessionMaxCacheSize > this.sessionMaxCacheSize)
- {
- this.sessionMaxCacheSize = sessionMaxCacheSize;
- }
- }
-
- public int getMinSessionCacheSize()
- {
- return sessionMinCacheSize;
- }
-
- public int getMaxSessionCacheSize()
- {
- return sessionMaxCacheSize;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManagerImpl;
+import org.eclipse.emf.cdo.server.objectivity.IObjectivityStoreConfig;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.db.DatabaseNotFoundException;
+import com.objy.db.DatabaseOpenException;
+import com.objy.db.ObjyRuntimeException;
+import com.objy.db.app.Connection;
+import com.objy.db.app.Session;
+import com.objy.db.app.oo;
+
+import java.util.Vector;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.locks.ReentrantLock;
+
+public class ObjyConnection
+{
+
+ public static final ObjyConnection INSTANCE = new ObjyConnection();
+
+ protected Connection connection = null;
+
+ protected boolean isConnected = false;
+
+ protected String fdName = "";
+
+ // protected ObjectivityStore store = null;
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyConnection.class);
+
+ // private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyConnection.class);
+
+ // TODO - session pools could be a configuration candidate.
+ private static final String SESSION_POOL_NAME_READ = "ReadSP";
+
+ private static final String SESSION_POOL_NAME_WRITE = "WriteSP";
+
+ // private static final String PoolInfo = "PoolInfo";
+
+ protected ConcurrentHashMap<String, ObjySession> readPool;
+
+ protected ConcurrentHashMap<String, ObjySession> writePool;
+
+ private ObjyPlacementManager defaultPlacementManager = null;
+
+ private Object syncObject = new Object();
+
+ private ReentrantLock lock = new ReentrantLock();
+
+ private int sessionMinCacheSize = 600;
+
+ private int sessionMaxCacheSize = 1000;
+
+ private final int minInactiveSessions = 5;
+
+ private int sessionCount = 0;
+
+ private String logDirPath = null;
+
+ private int logOption = oo.LogNone;
+
+ public ObjyConnection()
+ {
+ readPool = new ConcurrentHashMap<String, ObjySession>(5);
+ writePool = new ConcurrentHashMap<String, ObjySession>(5);
+ }
+
+ /***
+ * Connect to a store and an FD. TODO - We might need to allow switching of FD in the future.
+ */
+ synchronized public void connect(IObjectivityStoreConfig storeConfig)
+ {
+ /****
+ * If
+ */
+ fdName = storeConfig.getFdName();
+ logDirPath = storeConfig.getLogPath();
+ logOption = storeConfig.getLogOption();
+ connect();
+ // this.store = store;
+ }
+
+ synchronized public void connect(String fdName, int logOption)
+ {
+ /****
+ * If
+ */
+ this.fdName = fdName;
+ this.logOption = logOption;
+ connect();
+ // this.store = store;
+ }
+
+ private void connect()
+ {
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(" SessionMinCacheSize: " + sessionMinCacheSize);
+ TRACER_DEBUG.trace(" SessionMaxCacheSize: " + sessionMaxCacheSize);
+ }
+
+ if (!isConnected)
+ {
+ try
+ {
+ if (Connection.current() == null)
+ {
+ if (logOption != oo.LogNone)
+ {
+ Connection.setLoggingOptions(logOption, true, // boolean logToFiles
+ true, // boolean appendLogFiles,
+ logDirPath, // String logDirPath,
+ "MainLog.txt"// String mainLogFileName
+ );
+ }
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(" creating new Connection");
+ }
+ connection = Connection.open(fdName, oo.openReadWrite);
+ connection.useContextClassLoader(true);
+ }
+ else
+ {
+ connection.addToMainLog("ObjyConnection.connect()", "...reopen connection to the FD.");
+ connection.setOpenMode(oo.openReadWrite);
+ connection.reopen();
+ connection.loadSchemaClasses(true);
+ }
+ isConnected = true;
+ }
+ catch (DatabaseOpenException e)
+ {
+ e.printStackTrace();
+ }
+ catch (DatabaseNotFoundException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public String getSessionPoolNameRead()
+ {
+ return SESSION_POOL_NAME_READ;
+ }
+
+ public String getSessionPoolNameWrite()
+ {
+ return SESSION_POOL_NAME_WRITE;
+ }
+
+ public ObjySession getWriteSessionFromPool(String sessionName)
+ {
+ return getSessionFromPool(sessionName);
+ }
+
+ public ObjySession getReadSessionFromPool(String sessionName)
+ {
+ return getSessionFromPool(sessionName);
+ }
+
+ protected ObjySession getSessionFromPool(String sessionName)
+ {
+ synchronized (syncObject)
+ {
+ // return connection.getSessionFromPool(getSessionPoolNameWrite(), sessionName);
+ ObjySession session = readPool.get(sessionName);
+ if (session == null)
+ {
+ if (sessionCount >= minInactiveSessions)
+ {
+ // look for an inactive one, rename it and use it.
+ for (ObjySession objySession : readPool.values())
+ {
+ if (objySession.isAvailable())
+ {
+ objySession.setName(sessionName);
+ session = objySession;
+ break;
+ }
+ }
+ }
+
+ // we are forced to create one.
+ if (session == null)
+ {
+ session = new ObjySession(sessionName, readPool, this);
+ ++sessionCount;
+ // System.out.println(">>> IS: creating new session: " + sessionName + " - total: " + sessionCount);
+ readPool.put(sessionName, session);
+ }
+ }
+ session.join();
+ session.setAvailable(false);
+ return session;
+ }
+ }
+
+ public void disconnect()
+ {
+ if (!isConnected)
+ {
+ return;
+ }
+ // synchronized(syncObject)
+ {
+ // it's important to do the lock() call, otherwise during the test-suite
+ // run we can exit the test before cleaning up, and session might be
+ // partly terminated.
+ // We could change the code in cleanupSessionPool() to remove the session
+ // from the pool before terminating it, but this could leave some sessions
+ // in the connection (another issue here is the connection.reconnect()
+ // doesn't work all the time).
+ lock.lock();
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ObjyConnection.disconnect() -- Start. " + toString());
+ }
+
+ // terminate the session and cleanup the Pool.
+ // TRACER_DEBUG.trace("ObjyConnection.disconnect() -- cleanup readPool. ");
+ cleanupSessionPool(readPool);
+ // TRACER_DEBUG.trace("ObjyConnection.disconnect() -- cleanup writePool. ");
+ cleanupSessionPool(writePool);
+
+ sessionCount = 0;
+
+ // TRACER_DEBUG.trace("ObjyConnection.disconnect() -- cleanup any other sessions. ");
+ // for testing we need to find out if there are any open sessions.
+
+ @SuppressWarnings("unchecked")
+ Vector<Session> sessions = connection.sessions();
+ for (Session aSession : sessions)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Session: " + aSession + " - open state: " + aSession.isOpen());
+ }
+ // we need to make sure that any open session is aborted, otherwise we
+ // can't reopen the fd.
+ if (aSession.isOpen())
+ {
+ try
+ {
+ aSession.join();
+ aSession.abort();
+ // IS: sometime we get exception about no transaction, although we checked
+ // aSession.isOpen() above.
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ aSession.terminate();
+ }
+ }
+ }
+
+ // 100211:IS - Avoid closing the connection, we're seeing
+ // sort of schema issues doing so with 9.4.1...
+ /****
+ * try { Session session = new Session(); session.begin(); //connection.dropAllUserClasses(true);
+ * connection.dropAllUnregisterableClasses(); session.commit(); connection.close(); isConnected = false; } catch
+ * (DatabaseClosedException e) { // TODO Auto-generated catch block e.printStackTrace(); }
+ ****/
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ObjyConnection.disconnect() -- END. ");
+ }
+ lock.unlock();
+ }
+
+ }
+
+ // public void resetFD()
+ // {
+ // //fdManager.resetFD();
+ // if (Connection.current() != null)
+ // {
+ // if (!isConnected)
+ // connect();
+ //
+ // // for testing we need to find out if there are any open sessions.
+ // Vector<Session> sessions = Connection.current().sessions();
+ // System.out.println("Sessions still available: " + sessions.size());
+ // for (Session aSession : sessions)
+ // {
+ // System.out.println("Session: " + aSession + " - open state: " + aSession.isOpen());
+ // // we need to make sure that any open session is aborted, otherwise we
+ // // can't reopen the fd.
+ // if (aSession.isOpen())
+ // {
+ // try {
+ // aSession.join();
+ // aSession.abort();
+ // // IS: sometime we get exception about no transaction, although we checked
+ // // aSession.isOpen() above.
+ // } catch (ObjyRuntimeException ex) {
+ // ex.printStackTrace();
+ // } finally {
+ // aSession.terminate();
+ // }
+ // }
+ // }
+ //
+ // // Session session = new Session();
+ // // session.begin();
+ // // Iterator itr = session.getFD().containedDBs();
+ // // ooDBObj dbObj = null;
+ // // List<ooDBObj> dbList = new ArrayList<ooDBObj>();
+ // // while (itr.hasNext())
+ // // {
+ // // dbObj = (ooDBObj) itr.next();
+ // // dbList.add(dbObj);
+ // // }
+ // // itr.close();
+ // // session.commit();
+ //
+ // // session.begin();
+ // // for (ooDBObj db : dbList)
+ // // {
+ // // System.out.println("restFD() - deleting DB(" + db.getOid().getStoreString()+"):" + db.getName());
+ // // db.delete();
+ // // }
+ // // session.commit();
+ //
+ // // we need to wipe the schema, some tests have similar class and package
+ // // names which could cause tests to fail.
+ // // for now we'll just wipe the wole FD.
+ // //fdManager.resetFD_OLD();
+ //
+ // //
+ // // System.out.println("resetFD() - dumping catalog BEGIN.........");
+ // // session.begin();
+ // // session.getFD().dumpCatalog();
+ // // session.commit();
+ // // System.out.println("resetFD() - dumping catalog END...........");
+ // // session.terminate();
+ //
+ // disconnect();
+ // }
+ // }
+
+ public void registerClass(String name)
+ {
+ connection.registerClass(name);
+ }
+
+ public ObjyPlacementManager getDefaultPlacementManager()
+ {
+ if (defaultPlacementManager == null)
+ {
+ defaultPlacementManager = new ObjyPlacementManagerImpl();
+ }
+ return defaultPlacementManager;
+ }
+
+ protected void cleanupSessionPool(ConcurrentHashMap<String, ObjySession> pool)
+ {
+ for (ObjySession objySession : pool.values())
+ {
+ try
+ {
+ if (objySession.isOpen())
+ {
+ objySession.join();
+ objySession.abort();
+ // IS: sometime we get exception about no transaction, although we checked
+ // aSession.isOpen() above.
+ }
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ // TRACER_DEBUG.trace("ObjyConnection.cleanupSessionPool() -- start terminating session. " +
+ // objySession.toString());
+ try
+ {
+ objySession.terminate();
+ // TRACER_DEBUG.trace("ObjyConnection.cleanupSessionPool() -- end terminating session. " +
+ // objySession.toString());
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+ pool.clear();
+ }
+
+ public void setSessionMinCacheSize(int sessionMinCacheSize)
+ {
+ if (sessionMinCacheSize > this.sessionMinCacheSize)
+ {
+ this.sessionMinCacheSize = sessionMinCacheSize;
+ }
+ }
+
+ public void setSessionMaxCacheSize(int sessionMaxCacheSize)
+ {
+ if (sessionMaxCacheSize > this.sessionMaxCacheSize)
+ {
+ this.sessionMaxCacheSize = sessionMaxCacheSize;
+ }
+ }
+
+ public int getMinSessionCacheSize()
+ {
+ return sessionMinCacheSize;
+ }
+
+ public int getMaxSessionCacheSize()
+ {
+ return sessionMaxCacheSize;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java
index f28e0af414..59d073ed72 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObject.java
@@ -1,1692 +1,1692 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDExternal;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreAccessor;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.IManyTypeMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ISingleTypeMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.SingleReferenceMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListId;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListString;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBase;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapArrayList;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapEntry;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.collection.MoveableList;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.FeatureMap;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Relationship_Object;
-import com.objy.as.app.String_Value;
-import com.objy.as.app.VArray_Object;
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.d_Class;
-import com.objy.as.app.d_Ref_Type;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Ibrahim Sallam
- */
-public class ObjyObject
-{
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyObject.class);
-
- protected Class_Object classObject;
-
- protected ObjyClass objyClass;
-
- protected Class_Object baseClassObject = null;
-
- protected Relationship_Object baseRel = null;
-
- protected boolean hasBaseRelationshipChecked = false;
-
- protected Relationship_Object revisionsRel = null;
-
- protected Relationship_Object lastRevisionRel = null;
-
- protected ooId objectId;
-
- protected ooId revisionId = null;
-
- protected int version = Integer.MAX_VALUE;
-
- public static int fetchCount = 0;
-
- public static int updateCount = 0;
-
- public static long createObjectTime = 0;
-
- public static int createObjectCount = 0;
-
- // protected boolean isRoot = false;
-
- // IS: for stats.
- // public static int count = 0;
- // public static long tDiff = 0;
-
- // good for fast access.
- // private Map<Class_Position, Object> featureMap = new HashMap<Class_Position, Object>();
- private Map<String, Object> featureMap = new HashMap<String, Object>();
-
- public ObjyObject(Class_Object classObject)
- {
- // long tStart = System.currentTimeMillis();
-
- this.classObject = classObject;
- d_Class dClass = classObject.type_of();
- String fullyQualifiedClassName = null;
-
- try
- {
-
- if (dClass.namespace_name() != null)
- {
- fullyQualifiedClassName = dClass.namespace_name() + ":" + dClass.name();
- }
- else
- {
- fullyQualifiedClassName = dClass.name();
- }
-
- objyClass = ObjySchema.getObjyClass(fullyQualifiedClassName);
-
- // if (dClass.has_base_class(ObjyBase.CLASS_NAME))
- // {
- // if (TRACER_DEBUG.isEnabled())
- // {
- // TRACER_DEBUG.format("...classObject type: {0} - oid: {1}", classObject.type_of().name(), classObject
- // .objectID().getStoreString());
- // }
- // getBaseRelationship(classObject);
- // if (!baseRel.exists())
- // {
- // // we are the base...
- // getRevisionsRelationship(classObject);
- // getLastRevisionRelationship(classObject);
- // }
- // else
- // {
- // baseClassObject = baseRel.get_class_obj();
- // // TODO - we might want to delay getting the list of versions unless we need them.
- // // revisionsRel = baseClassObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_REVISIONS));
- // // lastRevisionRel = baseClassObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_LAST_REVISION));
- // }
- // }
- setObjectId(classObject.objectID());
- // version = classObject.get_numeric(objyClass.resolve_position(ObjyBase.ATT_VERSION)).intValue();
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
-
- // count++;
- // tDiff += System.currentTimeMillis() - tStart;
- }
-
- private Relationship_Object getLastRevisionRelationship()
- {
- if (lastRevisionRel == null)
- {
- lastRevisionRel = classObject.nget_relationship(ObjyBase.ATT_LAST_REVISION);
- }
- return lastRevisionRel;
- }
-
- private Relationship_Object getRevisionsRelationship()
- {
- if (revisionsRel == null)
- {
- // revisionsRel = classObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_REVISIONS));
- revisionsRel = classObject.nget_relationship(ObjyBase.ATT_REVISIONS);
- }
- return revisionsRel;
- }
-
- private Relationship_Object getBaseRelationship()
- {
- if (baseRel == null)
- {
- // baseRel = classObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_BASE));
- baseRel = classObject.nget_relationship(ObjyBase.ATT_BASE);
- }
- return baseRel;
- }
-
- public ObjyClass objyClass()
- {
- return objyClass;
- }
-
- public Class_Object ooClassObject()
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- return classObject;
- }
-
- public void setObjectId(ooId objectId)
- {
- this.objectId = objectId;
- }
-
- /**
- *
- */
- public ooId ooId()
- {
- return objectId;
- }
-
- public void setEContainer(Object containerID)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
-
- // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID);
-
- SingleReferenceMapper.INSTANCE.setValue(this, ObjyBase.ATT_CONTAINERID/* position */, containerID);
- }
-
- public Object getEContainer()
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
-
- // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID);
- Object value = SingleReferenceMapper.INSTANCE.getValue(this, ObjyBase.ATT_CONTAINERID/* position */);
-
- return value;
- }
-
- public ooId getEContainerAsOid()
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
-
- // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID);
- ooId childOid = get_ooId(ObjyBase.ATT_CONTAINERID/* position */);
- return childOid;
- }
-
- public void setEResource(Object resourceID)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
-
- // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID);
- SingleReferenceMapper.INSTANCE.setValue(this, ObjyBase.ATT_RESOURCEID/* position */, resourceID);
-
- }
-
- public Object getEResource()
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
-
- // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID);
- Object value = SingleReferenceMapper.INSTANCE.getValue(this, ObjyBase.ATT_RESOURCEID/* position */);
-
- return value;
- }
-
- public ooId getEResourceAsOid()
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID);
- ooId childOid = get_ooId(ObjyBase.ATT_RESOURCEID/* position */);
- return childOid;
- }
-
- public void setEContainingFeature(int contFeature)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINER_FEATUERID);
- set_numeric(ObjyBase.ATT_CONTAINER_FEATUERID/* position */, new Numeric_Value(contFeature));
- }
-
- public int getEContainingFeature()
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINER_FEATUERID);
- return get_numeric(ObjyBase.ATT_CONTAINER_FEATUERID/* position */).intValue();
- }
-
- /**
- * This is used to cache the composite features, (manyAttributes, manyReference, and featureMap. TBD - verify the need
- * of this.
- */
- // public Object getFeatureList(Class_Position position)
- // {
- // return featureMap.get(position);
- // }
- public Object getFeatureList(String featureName)
- {
- return featureMap.get(featureName);
- }
-
- // public void setFeatureList(Class_Position position, Object object)
- // {
- // featureMap.put(position, object);
- // }
- public void setFeatureList(String featureName, Object object)
- {
- featureMap.put(featureName, object);
- }
-
- public int getVersion()
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- // if (version == Integer.MAX_VALUE)
- {
- version = classObject.nget_numeric(ObjyBase.ATT_VERSION).intValue();
- }
- return version;
- }
-
- public void setVersion(int version)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- classObject.nset_numeric(ObjyBase.ATT_VERSION, new Numeric_Value(version));
- // getVersion(); // TBD, verify the need for this call!!!!
- this.version = version;
- }
-
- public long getCreationTime()
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- long creationTime = classObject.nget_numeric(ObjyBase.ATT_CREATION_TIME).longValue();
- return creationTime;
- }
-
- public void setCreationTime(long creationTime)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- classObject.nset_numeric(ObjyBase.ATT_CREATION_TIME, new Numeric_Value(creationTime));
- }
-
- public long getRevisedTime()
- {
- long revisedTime = 0;
-
- try
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- revisedTime = classObject.nget_numeric(ObjyBase.ATT_REVISED_TIME).longValue();
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
-
- return revisedTime;
- }
-
- public void setRevisedTime(long revisedTime)
- {
- try
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- classObject.nset_numeric(ObjyBase.ATT_REVISED_TIME, new Numeric_Value(revisedTime));
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- public void setBranchId(int branchId)
- {
- try
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- classObject.nset_numeric(ObjyBase.ATT_BRANCHID, new Numeric_Value(branchId));
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
-
- }
-
- public long getBranchId()
- {
- int branchId = 0;
- try
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- branchId = classObject.nget_numeric(ObjyBase.ATT_BRANCHID).intValue();
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- return branchId;
- }
-
- public ObjyObject copy(EClass eClass, ObjyObjectManager objyObjectManager)
- {
- ObjyObject newObjyObject = null;
- ooObj obj = ooObj.create_ooObj(objectId);
- ooObj newObj = (ooObj)obj.copy(obj); // Objy internal copy.
- // Dependent structures, for example array of refs are not copies, so we
- // have to iterate and copy (deep copy).
- // newObjyObject = new ObjyObject(Class_Object.class_object_from_oid(newObj.getOid()));
- newObjyObject = objyObjectManager.getObject(newObj.getOid());
-
- try
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ObjyObject.copy() - oid:" + ooId().getStoreString() + " version:" + getVersion());
- }
- for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
- {
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
- {
- continue;
- }
-
- if (feature.isMany())
- {
- // copy this feature to the new object.
- // copy this feature to the new object.
- // get the attribute using feature name.
- d_Attribute attribute = objyClass.resolve_attribute(feature.getName());
- // System.out.println("... checking feature: " + feature.getName() + - attributeType: "
- // + attribute.type_of().name());
- if (attribute != null && attribute.type_of() instanceof d_Ref_Type)
- {
- // IS:temptest Class_Position position = objyClass.resolve_position(feature.getName());
- // ooId refOoId = get_ooId(position);
- Class_Object cObj = get_class_obj(feature.getName());
- if (cObj != null)
- {
- // System.out.println("\t\t referenced Class_Object with OID: " +cObj.objectID().getStoreString());
- d_Class refClass = cObj.type_of();
- String refClassName = refClass.name();
- if (refClassName.equals(ObjyFeatureMapArrayList.ClassName))
- {
- // we'll need to copy this one.
- TRACER_DEBUG.trace("\t TBD - copying ObjyFeatureMapArrayList attr: " + attribute.name());
- }
- else if (refClassName.equals(ObjyArrayListString.ClassName))
- {
- // we'll need to copy this one.
- TRACER_DEBUG.trace("\t TBD - copying ObjyArrayListString attr: " + attribute.name());
- }
- else if (refClassName.equals(ObjyArrayListId.className))
- {
- // we'll need to copy this one.
- // System.out.println("\t copying ObjyArrayListId attr: " + attibute.name());
- ObjyArrayListId arrayListId = new ObjyArrayListId(cObj);
- ooObj newArrayListId = arrayListId.copy(newObj);
- newObjyObject.set_ooId(feature.getName(), newArrayListId.getOid());
- }
- else if (refClassName.equals(ObjyProxy.className))
- {
- // we'll need to copy this one.
- TRACER_DEBUG.trace("\t TBD - copying ObjyProxy attr: " + attribute.name());
- }
- }
- }
-
- }
- }
- }
- catch (com.objy.as.asException ex)
- {
- ex.printStackTrace();
- }
-
- return newObjyObject;
- }
-
- /**
- * Use the revision info to update the object in the store.
- *
- * @param storeAccessor
- * @param revision
- */
- public void update(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision)
- {
- updateCount++;
-
- try
- {
-
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- TRACER_DEBUG.trace("ObjyObject.update() - oid:" + ooId().getStoreString() + " - version:"
- + revision.getVersion());
- }
-
- // this is done in the updateDate()
- // setEContainer(revision.getContainerID());
- // setEResource(revision.getResourceID());
- // setEContainingFeature(revision.getContainingFeatureID());
-
- updateData(storeAccessor, revision);
- }
- catch (com.objy.as.asException ex)
- {
- ex.printStackTrace();
- }
- }
-
- /**
- * Use the revision info to update the object in the store.
- *
- * @param storeAccessor
- * @param revision
- */
- private void updateData(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision)
- {
- EClass eClass = revision.getEClass();
-
- try
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("=> ObjyObject.updateData() - oid:" + ooId().getStoreString() + //$NON-NLS-1$
- " - version:" + revision.getVersion()); //$NON-NLS-1$
- }
-
- setVersion(revision.getVersion());
-
- setEContainer(revision.getContainerID());
- setEResource(revision.getResourceID());
- setEContainingFeature(revision.getContainingFeatureID());
- setCreationTime(revision.getTimeStamp());
- setRevisedTime(revision.getRevised());
- setBranchId(revision.getBranch().getID());
-
- for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
- {
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
- {
- continue;
- }
-
- ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
- if (mapper == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("In " + ooId().getStoreString() + " - Can't find mapper for feature "
- + feature.getName());
- }
- continue;
- }
- // -----------------------------------------------
- // TODO - this code definitely need refactoring!!!
- // -----------------------------------------------
-
- // Class_Position attr = objyClass.resolve_position(feature.getName());
- if (feature.isMany())
- {
- // Object newValue = revision.getValue(feature);
- // --- TEMP solution to fix one of the tests...
- CDOList list = revision.getList(feature);
- Object[] values = new Object[list.size()];
- // we need to pass a list of ooId objects.
- // TODO - This need some work!!!!
- for (int i = 0; i < values.length; i++)
- {
- // TODO - this code need refactoring...
- Object value = list.get(i);
- if (null == value)
- {
- values[i] = value;
- continue;
- }
- else if (value instanceof CDOIDExternal)
- {
- TRACER_DEBUG
- .trace("... CDOIDExternal inserted, at:" + i + ", content:" + ((CDOIDExternal)value).getURI());
- // System.out.println("value is a proxy object - it should be handled by the mapper.");
- // create an ObjyProxy object to hold the the value.
- ObjyProxy proxyObject = ObjyProxy.createObject(ooId());
- proxyObject.setUri(((CDOIDExternal)value).getURI());
- values[i] = proxyObject.ooId();
-
- }
- else if (value instanceof CDOID)
- {
- values[i] = OBJYCDOIDUtil.getooId((CDOID)value);
- }
- else if (value instanceof FeatureMap.Entry)
- {
- FeatureMap.Entry entry = (FeatureMap.Entry)value;
- EStructuralFeature entryFeature = entry.getEStructuralFeature();
- Object entryValue = entry.getValue();
-
- ooId oid = null;
- if (entryValue instanceof CDOIDExternal)
- {
- TRACER_DEBUG.trace("... CDOIDExternal inserted, at:" + i + ", content:"
- + ((CDOIDExternal)entryValue).getURI());
- // System.out.println("value is a proxy object - it should be handled by the mapper.");
- // create an ObjyProxy object to hold the the value.
- ObjyProxy proxyObject = ObjyProxy.createObject(ooId());
- proxyObject.setUri(((CDOIDExternal)entryValue).getURI());
- oid = proxyObject.ooId();
- }
- else if (entryValue instanceof CDOID)
- {
- oid = OBJYCDOIDUtil.getooId((CDOID)entryValue);
- }
- else
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("OBJY: don't know what kind of entryValue is this!!! - " + entryValue);
- }
- }
- // FeatureMapEntry is a presistent class.
- ObjyFeatureMapEntry featureMapEntry = new ObjyFeatureMapEntry(entryFeature.getFeatureID(), oid, objectId);
-
- // this.cluster(featureMapEntry);
- values[i] = featureMapEntry;
- }
- else if (value.equals(InternalCDOList.UNINITIALIZED))
- {
- TRACER_DEBUG.format("...GOT UNINITIALIZED at {0}, listSize:{1}, feature:{2}, oid:{3}", i, values.length,
- feature.getName(), objectId.getStoreString());
- continue;
- }
- else
- {
- // different feature then.
- values[i] = value;
- }
- }
-
- ((IManyTypeMapper)mapper).setAll(this, feature, 0, values);
- }
- else
- {
- Object newValue = revision.get(feature, feature.getFeatureID());
- // if (newValue instanceof CDOIDExternal)
- // {
- // System.out.println("value is a proxy object");
- // }
- ((ISingleTypeMapper)mapper).setValue(this, feature, newValue);
- }
- }
- }
- catch (com.objy.as.asException ex)
- {
- ex.printStackTrace();
- }
- }
-
- public ObjyObject getLastRevision(ObjyObjectManager objyObjectManager)
- {
- if (!getLastRevisionRelationship().exists())
- {
- return this;
- }
-
- // Class_Object lastRevision = lastRevisionRel.get_class_obj();
- ooId lastRevisionOid = getLastRevisionRelationship().get_ooId();
- // return new ObjyObject(lastRevision);
- return objyObjectManager.getObject(lastRevisionOid);
- }
-
- public ObjyObject getRevisionByVersion(int version, long branchId, ObjyObjectManager objyObjectManager)
- {
- ObjyObject objyRevision = null;
- int objectVersion = getVersion();
- long objectBranchId = getBranchId();
-
- if (branchId == objectBranchId && Math.abs(objectVersion) == version)
- {
- // there is a first time for everything...
- return this;
- }
-
- // check last revision first.
- objyRevision = getLastRevision(objyObjectManager);
- objectVersion = objyRevision.getVersion();
- objectBranchId = objyRevision.getBranchId();
- if (branchId == objectBranchId && Math.abs(objectVersion) == version)
- {
- return objyRevision;
- }
-
- // Session.getCurrent().setReturn_Class_Object(true);
- // int numRevisions = (int) revisions.size();
-
- @SuppressWarnings("unchecked")
- Iterator<ooObj> itr = getRevisionsRelationship().get_iterator();
- while (itr.hasNext())
- {
- // objyRevision = new ObjyObject(itr.next());
- objyRevision = objyObjectManager.getObject(itr.next().getOid());
- objectVersion = objyRevision.getVersion();
- objectBranchId = objyRevision.getBranchId();
- if (branchId == objectBranchId && Math.abs(objectVersion) == version)
- {
- return objyRevision;
- }
- objyRevision = null;
- }
-
- return null;
- }
-
- public void addToRevisions(ObjyObject objyRevision)
- {
- try
- {
- getRevisionsRelationship().add(objyRevision.objectId);
- // set it as last rev.
- getLastRevisionRelationship().clear(); // Ouch!! performance issue...
- getLastRevisionRelationship().form(objyRevision.objectId);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- // /**
- // * Wrapper around ObjyObject to allow clustering of other objects near this one.
- // */
- // private void cluster(ooObj otherObj)
- // {
- // try
- // {
- // ooObj thisObj = ooObj.create_ooObj(objectId);
- // thisObj.cluster(otherObj);
- // }
- // catch (ObjyRuntimeException ex)
- // {
- // ex.printStackTrace();
- // }
- // }
-
- /**
- * Fetch data from the store and return a revision.
- */
- public boolean fetch(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision, int listChunk)
- {
- boolean bRet = true;
- fetchCount++;
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- EClass eClass = revision.getEClass();
-
- try
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ObjyObject.fetch() - oid:" + ooId().getStoreString() + " version:" + getVersion());
- }
- // Put the version of the objects;
- revision.setVersion(getVersion());
- revision.setContainerID(getEContainer());
- revision.setResourceID((CDOID)getEResource());
- revision.setContainingFeatureID(getEContainingFeature());
- long creationTime = getCreationTime();
- long revisedTime = getRevisedTime();
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("... ObjyObject.creationTime: " + creationTime);
- TRACER_DEBUG.trace("... ObjyObject.revisedTime : " + revisedTime);
- }
-
- revision.setRevised(revisedTime);
-
- for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
- {
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
- {
- continue;
- }
-
- if (feature.isMany())
- {
- int featureSize = size(feature);
- int chunkSize = featureSize;
- if (listChunk != CDORevision.UNCHUNKED && listChunk > 0)
- {
- chunkSize = Math.min(chunkSize, listChunk);
- }
-
- Object[] objects = getAll(feature, 0, chunkSize);
- // if (size > 0)
- {
- // TODO - we could use getList() then fill the array with values, we
- // also
- // need to consider the chunking...
- // InternalCDOList cdoList =
- // (InternalCDOList)CDOListFactory.DEFAULT.createList(objects.length,
- // objects.length, 0);
- // TODO - use the following line instead of creating the cdoList
- // above.
- MoveableList<Object> list = revision.getList(feature);
-
- // size = Math.min(size, 0);
- for (int i = 0; i < chunkSize; i++)
- {
- if (objects[i] instanceof ooId)
- {
- // TODO - this code need refactoring....
- CDOID cdoId = null;
- ooId objyOid = (ooId)objects[i];
- if (objyOid.isNull())
- {
- cdoId = OBJYCDOIDUtil.getCDOID(objyOid);
- }
- else
- {
- Class_Object refClassObject = Class_Object.class_object_from_oid((ooId)objects[i]);
-
- if (refClassObject.type_of().name().equals(ObjyProxy.className))
- {
- // System.out.println("OBJY: Got proxy: " + refClassObject.objectID().getStoreString());
- ObjyProxy proxyObject = new ObjyProxy(refClassObject);
- // cdoList.set(i,
- // OBJYCDOIDUtil.createCDIDExternal(proxyObject));
- cdoId = OBJYCDOIDUtil.createCDIDExternal(proxyObject);
- }
- else
- {
- cdoId = OBJYCDOIDUtil.getCDOID(objyOid);
- }
- refClassObject = null;
- }
- list.add(cdoId);
-
- continue;
- }
- else if (objects[i] instanceof ObjyFeatureMapEntry)
- {
- FeatureMap.Entry entry = getFeatureMapEntry(eClass, (ObjyFeatureMapEntry)objects[i]);
- list.add(entry);
- }
- else
- {
- // different feature then.
- // System.out.println("-->> Hmmm fetch() feature (" + i + ") -> feature:" + feature.getName()
- // + " - value:" + objects[i]);
- // cdoList.set(i, objects[i]);
- list.add(objects[i]);
- }
- }
- // fill the rest if needed.
- if (featureSize - chunkSize > 0)
- {
- for (int i = 0; i < featureSize - chunkSize; i++)
- {
- list.add(InternalCDOList.UNINITIALIZED);
- }
- }
- }
- }
- else
- {
- Object object = get(feature, 0);
-
- /**
- * TODO - verify if this is needed for 2.x if (cdoFeature.getType() == CDOType.CUSTOM) { object =
- * EcoreUtil.convertToString((EDataType)eFeature.getEType(), object); }
- */
- revision.set(feature, 0, object);
- }
- }
- }
- catch (com.objy.as.asException ex)
- {
- ex.printStackTrace();
- }
-
- return bRet;
- }
-
- /**
- * Fetch data for a specific feature from the store, and return a list of objects. Used by
- * ObjectivityStoreChunkAccessor
- */
- public List<Object> fetchList(ObjectivityStoreAccessor storeAccessor, EStructuralFeature feature, int startIndex,
- int chunkSize)
- {
- fetchCount++;
-
- List<Object> results = new ArrayList<Object>();
- EClass eClass = feature.getEContainingClass();
-
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
-
- try
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ObjyObject.fetch() - feature:" + feature.getName() + "from Object: "
- + ooId().getStoreString() + " version:" + getVersion());
- }
- int featureSize = size(feature);
- chunkSize = Math.min(featureSize - startIndex, chunkSize);
-
- Object[] objects = getAll(feature, startIndex, chunkSize);
- convertToCdoList(objects, results, eClass, chunkSize);
- }
- catch (com.objy.as.asException ex)
- {
- ex.printStackTrace();
- }
-
- return results;
- }
-
- /**
- * Function thats takes a list of Objy objects and convert them to CDO IDs This function is used by queryXRefs() as
- * well.
- */
- protected void convertToCdoList(Object[] objects, List<Object> results, EClass eClass, int chunkSize)
- {
- {
- for (int i = 0; i < chunkSize; i++)
- {
- if (objects[i] instanceof ooId)
- {
- // TODO - this code need refactoring....
-
- // System.out.println("-->> IS: getting Class_Object from OID: "
- // + childObject.getStoreString());
- CDOID cdoId = null;
- ooId objyOid = (ooId)objects[i];
- if (objyOid.isNull())
- {
- cdoId = OBJYCDOIDUtil.getCDOID(objyOid);
- }
- else
- {
- Class_Object refClassObject = Class_Object.class_object_from_oid(objyOid);
-
- if (refClassObject.type_of().name().equals(ObjyProxy.className))
- {
- ObjyProxy proxyObject = new ObjyProxy(refClassObject);
- cdoId = OBJYCDOIDUtil.createCDIDExternal(proxyObject);
- }
- else
- {
- cdoId = OBJYCDOIDUtil.getCDOID(objyOid);
- }
- refClassObject = null;
- }
-
- results.add(cdoId);
- continue;
-
- }
- else if (objects[i] instanceof ObjyFeatureMapEntry)
- {
- FeatureMap.Entry entry = getFeatureMapEntry(eClass, (ObjyFeatureMapEntry)objects[i]);
- results.add(entry);
- }
- }
- }
- }
-
- private FeatureMap.Entry getFeatureMapEntry(EClass eClass, ObjyFeatureMapEntry mapEntry)
- {
- ooId oid = mapEntry.getObject();
- CDOID id = null;
- Class_Object refClassObject = Class_Object.class_object_from_oid(oid);
- if (refClassObject.type_of().name().equals(ObjyProxy.className))
- {
- ObjyProxy proxyObject = new ObjyProxy(refClassObject);
- id = OBJYCDOIDUtil.createCDIDExternal(proxyObject);
- }
- else
- {
- id = OBJYCDOIDUtil.getCDOID(oid);
- }
-
- EStructuralFeature entryFeature = eClass.getEStructuralFeature(mapEntry.getTagId());
- FeatureMap.Entry entry = CDORevisionUtil.createFeatureMapEntry(entryFeature, id);
- return entry;
- }
-
- /**
- * Get the size of the composite object using the store info.
- *
- * @param feature
- * @return
- */
- private int size(EStructuralFeature feature)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
- int size = 0;
-
- // Class_Position position = objyClass().resolve_position(feature.getName());
- try
- {
- IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature);
-
- size = mapper.size(this, feature);
-
- if (TRACER_DEBUG.isEnabled())
- {
- // TODO - verify the message.
- TRACER_DEBUG.trace("Size of object " + ooId().getStoreString() + " - is: " + size + " - feature: "
- + feature.getName());
- }
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- return size;
- }
-
- /**
- * Get the value of an attribute from the persistent object.
- */
- public Object get(EStructuralFeature feature)
- {
- if (feature.isMany())
- {
- return getAll(feature, 0, CDORevision.UNCHUNKED);
- }
- return get(feature, 0);
- }
-
- /**
- * Get the value of an attribute at index (if many) from the persistent object.
- *
- * @param feature
- * @param index
- * @return
- */
- private Object get(EStructuralFeature feature, int index)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- // TODO - verify the message.
- TRACER_DEBUG.trace("Getting object " + objectId.getStoreString() + " <feature ' " + feature.getName() + "':"
- + feature.getEType() + "> from " + this);
- }
-
- // Class_Position position =
- // this.objyClass().resolve_position(feature.getName());
-
- ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
- Object value = null;
- try
- {
- if (feature.isMany())
- {
- value = ((IManyTypeMapper)mapper).getValue(this, feature, index);
- }
- else
- {
- value = ((ISingleTypeMapper)mapper).getValue(this, feature);
- }
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- return value;
- }
-
- /**
- * Get all the values of an attribute, used for feature.isMany(). This function is also used by the
- * ObjectivityStoreChunkReader to read chunks of data from a feature.
- *
- * @param feature
- * @param size
- * @return
- */
- protected Object[] getAll(EStructuralFeature feature, int startIndex, int chunkSize)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- // TODO - verify the message.
- TRACER_DEBUG.trace("Get All objects for ID: " + ooId().getStoreString() + " <feature ' " + feature/*
- * .getName( )
- */
- + "':" + feature.getEType() + "> from " + this);
- }
-
- assert feature.isMany();
- Object[] values = null;
-
- try
- {
- IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature);
- values = mapper.getAll(this, feature, startIndex, chunkSize);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
-
- return values;
- }
-
- public void add(EStructuralFeature feature, int index, Object value)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- TRACER_DEBUG.trace("Adding object " + value + " to " + ooId().getStoreString());
- }
-
- assert feature.isMany();
-
- try
- {
- IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature);
-
- // -- TODO -- verify the need to this one.
- // ensureObjectAttached(feature, value);
-
- // I believe we do the conversion in the add()
- // value = provider.convertToStore(ooObject, value);
-
- mapper.add(this, feature, index, value);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- /***
- * @param feature
- */
- public void clear(EStructuralFeature feature)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- TRACER_DEBUG.trace("Clear List for " + ooId().getStoreString());
- }
-
- // Class_Position position = objyClass.resolve_position(feature.getName());
- try
- {
- ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
-
- ((IManyTypeMapper)mapper).clear(this, feature);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- public void move(EStructuralFeature feature, int targetIndex, int sourceIndex)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- TRACER_DEBUG.trace("Move element from " + sourceIndex + " to " + targetIndex);
- }
- try
- {
- ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
-
- ((IManyTypeMapper)mapper).move(this, feature, targetIndex, sourceIndex);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- public Object remove(EStructuralFeature feature, int index)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- TRACER_DEBUG.trace("Remove object from '" + ooId().getStoreString() + "' at index " + index);
- }
-
- // Class_Position position = objyClass.resolve_position(feature.getName());
- Object retObject = null;
-
- try
- {
- IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature);
-
- Object value = mapper.remove(this, feature, index);
-
- if (feature instanceof EAttribute)
- {
- return value;
- }
-
- retObject = OBJYCDOIDUtil.getCDOID((ooId)value);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
-
- return retObject;
-
- }
-
- public Object set(EStructuralFeature feature, int index, Object value)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- checkSession();
- TRACER_DEBUG.trace("Set object '" + ooId().getStoreString() + "' feature : " + feature.getName());
- }
-
- /*
- * int i =0; for (EClass superEClass : object.eClass().getESuperTypes()) { if
- * (feature.getEContainingClass().isSuperTypeOf(superEClass)) { break; } i++; break; } String className = null; if
- * (i == 0) { className = EProposedManager.getObjectivityClass(feature.getEContainingClass()); } else { className =
- * EProposedManager.getObjectivityClass(feature.getEContainingClass(), true); } Class_Position position =
- * ooObject.ooClass().resolve_position(className + "::" + feature.getName());
- */
- // Class_Position position = objyClass.resolve_position(feature.getName());
- try
- {
- ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
-
- // --- TODO --- verify the need...
- // ensureObjectAttached(this, feature, value);
-
- /***
- * I believe we do the conversion in the setValue if (feature instanceof EReference) { value =
- * CDOIDUtil.getooId((CDOID)value); }
- ***/
-
- if (feature.isMany())
- {
- ((IManyTypeMapper)mapper).setValue(this, feature, index, value);
- }
- else
- {
- ((ISingleTypeMapper)mapper).setValue(this, feature, value);
- }
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
-
- return value;
- }
-
- /***
- * @param feature
- */
- public void unset(EStructuralFeature feature)
- {
- set(feature, 0, null);
- }
-
- protected void checkSession()
- {
- // 100610 - IS: disabled for now, since we have an issue with oojava_epl.jar "getSession()"
- // is not available.
- // if (TRACER_DEBUG.isEnabled())
- // {
- // try
- // {
- // if (!classObject.getPersistor().getSession().isOpen())
- // {
- // throw new Exception("Attempt to work on an object " + objectId.toString() + " without a trx. [Session: "
- // + classObject.getPersistor().getSession() + "]");
- // }
- // }
- // catch (Exception ex)
- // {
- // ex.printStackTrace();
- // } // for debugging.
- // }
- }
-
- /***
- * Iterate over the attributes and references and mark them deleted. This will only be called in non-audit mode.
- */
- public void delete(ObjectivityStoreAccessor storeAccessor, ObjyObjectManager objectManager)
- {
- EClass eClass = ObjySchema.getEClass(storeAccessor.getStore(), objyClass());
- try
- {
- for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
- {
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
- {
- continue;
- }
-
- if (feature.isMany())
- {
- deleteFeatureObjects(objectManager, feature);
- }
- else
- {
- ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
-
- if (mapper == null)
- {
- continue;
- }
- mapper.delete(this, feature);
- }
- }
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- private void deleteFeatureObjects(ObjyObjectManager objectManager, EStructuralFeature feature)
- {
- // TODO - verify that we can do this to all referenced list.
- // I'm not sure if it's valid when you have many-many relationship.
- Object[] objects = getAll(feature, 0, CDORevision.UNCHUNKED);
-
- if (objects == null)
- {
- return;
- }
-
- for (int i = 0; i < objects.length; i++)
- {
- if (objects[i] instanceof ooId)
- {
- ooId oid = (ooId)objects[i];
- // TODO - this code need refactoring....
- ooObj obj = ooObj.create_ooObj(oid);
- if (obj.isDead())
- {
- continue;
- }
-
- Class_Object refClassObject = Class_Object.class_object_from_oid(oid);
-
- if (refClassObject.type_of().name().equals(ObjyProxy.className))
- {
- obj.delete();
- }
- else
- {
- // if this object is a parent (resourceId or
- // containerId) for obj, then we
- // need to mark obj version as (-1).
- ObjyObject childObjyObject = objectManager.getObject(oid);
- ooId containerId = childObjyObject.getEContainerAsOid();
- ooId resourceId = childObjyObject.getEResourceAsOid();
- int childVersion = childObjyObject.getVersion();
- if (containerId.equals(objectId) || resourceId.equals(objectId))
- {
- childObjyObject.setVersion(-childVersion);
- }
-
- }
- }
- else if (objects[i] instanceof ObjyFeatureMapEntry)
- {
- ObjyFeatureMapEntry mapEntry = (ObjyFeatureMapEntry)objects[i];
- ooId oid = mapEntry.getObject();
- ooObj obj = ooObj.create_ooObj(oid);
- obj.delete();
- }
- else
- {
- // different feature then.
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("-->> No process to delete() feature (" + i + ") -> feature:" + feature.getName()
- + " - value:" + objects[i] + " ... nothing to do here.");
- }
- }
- }
- }
-
- // Wrapper functions over class object.
- // public Numeric_Value get_numeric(Class_Position position)
- // {
- // return classObject.get_numeric(position);
- // }
- public Numeric_Value get_numeric(String attributeName)
- {
- return classObject.nget_numeric(attributeName);
- }
-
- // public String_Value get_string(Class_Position position)
- // {
- // return classObject.get_string(position);
- // }
- public String_Value get_string(String attributeName)
- {
- return classObject.nget_string(attributeName);
- }
-
- // public void set_numeric(Class_Position position, Numeric_Value value)
- // {
- // classObject.set_numeric(position, value);
- // }
- public void set_numeric(String attributeName, Numeric_Value value)
- {
- classObject.nset_numeric(attributeName, value);
- }
-
- // public VArray_Object get_varray(Class_Position position)
- // {
- // return classObject.get_varray(position);
- // }
- public VArray_Object get_varray(String attributeName)
- {
- return classObject.nget_varray(attributeName);
- }
-
- // public ooId get_ooId(Class_Position position)
- // {
- // return classObject.get_ooId(position);
- // }
- public ooId get_ooId(String attributeName)
- {
- return classObject.nget_ooId(attributeName);
- }
-
- // public Class_Object get_class_obj(Class_Position position)
- // {
- // return classObject.get_class_obj(position);
- // }
-
- public Class_Object get_class_obj(String attributeName)
- {
- return classObject.nget_class_obj(attributeName);
- }
-
- // public void set_ooId(Class_Position position, ooId object)
- // {
- // classObject.set_ooId(position, object);
- // }
-
- public void set_ooId(String attributeName, ooId object)
- {
- classObject.nset_ooId(attributeName, object);
- }
-
- /**
- * Return the CDOID for the ObjyObject, it will go up to the base revision, and return it's ID.
- */
- public CDOID getRevisionId()
- {
- if (revisionId == null)
- {
- if (hasBaseRelationship())
- {
- baseClassObject = getBaseRelationship().get_class_obj();
- revisionId = baseClassObject.objectID();
- }
- else
- {
- revisionId = objectId;
- }
- }
-
- return OBJYCDOIDUtil.getCDOID(revisionId);
- }
-
- public ObjyObject getBaseObject()
- {
- ObjyObject objyObject = null;
- if (hasBaseRelationship())
- {
- baseClassObject = getBaseRelationship().get_class_obj();
- objyObject = new ObjyObject(baseClassObject);
- }
- else
- {
- objyObject = this;
- }
- return objyObject;
- }
-
- private boolean hasBaseRelationship()
- {
- if (!hasBaseRelationshipChecked)
- {
- hasBaseRelationshipChecked = getBaseRelationship().exists();
- }
- return hasBaseRelationshipChecked;
- }
-
- // private boolean hasRevisionsRelationship()
- // {
- // if (!hasRevisionsRelChecked)
- // {
- // hasRevisionsRelChecked = getRevisionsRelationship().exists();
- // }
- // return hasRevisionsRelChecked;
- // }
- //
- // private boolean hasLastRevisionRelationship()
- // {
- // if (!hasLastRevisionRelChecked)
- // {
- // hasLastRevisionRelChecked = getLastRevisionRelationship().exists();
- // }
- // return hasLastRevisionRelChecked;
- // }
-
- /**
- * Return the revision that satisfies the timeStamp and branchId constrains.
- *
- * @param objyObjectManager
- */
- public ObjyObject getRevision(long timeStamp, int branchId, ObjyObjectManager objyObjectManager)
- {
- ObjyObject objyRevision = null;
-
- // // evaluate current first.
- // if (evaluateRevision(timeStamp, branchId, this))
- // {
- // return this;
- // }
- //
- // // if we don't have other revisions.
- // if (!getLastRevisionRelationship().exists())
- // {
- // return null;
- // }
-
- // check last revision first.
- objyRevision = getLastRevision(objyObjectManager);
- if (evaluateRevision(timeStamp, branchId, objyRevision))
- {
- return objyRevision;
- }
-
- ObjyObject possibleRevision = null;
-
- // check first revision.
- if (evaluateRevision(timeStamp, branchId, this))
- {
- possibleRevision = this;
- }
-
- @SuppressWarnings("unchecked")
- Iterator<ooObj> itr = getRevisionsRelationship().get_iterator();
- while (itr.hasNext())
- {
- // objyRevision = new ObjyObject(itr.next());
- objyRevision = objyObjectManager.getObject(itr.next().getOid());
- if (evaluateRevision(timeStamp, branchId, objyRevision))
- {
- possibleRevision = objyRevision;
- }
- }
-
- return possibleRevision;
- }
-
- /**
- * return true if the objyRevision satisfies the constrains. This function is only called in case of auditing, and
- * branching.
- */
- protected boolean evaluateRevision(long timeStamp, int branchId, ObjyObject objyRevision)
- {
- // check the branchId first.
- if (objyRevision.getBranchId() == branchId)
- {
- // long revisedTS = objyRevision.getRevisedTime();
- // if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
- // {
- // long creationTS = objyRevision.getCreationTime();
- // if (creationTS <= timeStamp && (revisedTS == CDOBranchPoint.UNSPECIFIED_DATE || revisedTS >= timeStamp))
- // // if (creationTS >= timeStamp && (revisedTS == CDOBranchPoint.UNSPECIFIED_DATE || revisedTS <= timeStamp))
- // {
- // return true;
- // }
- // }
- // else if (revisedTS == CDOBranchPoint.UNSPECIFIED_DATE) // return the latest version in that branch.
- // {
- // return true;
- // }
-
- long creationTS = objyRevision.getCreationTime();
- long revisedTS = objyRevision.getRevisedTime();
- if (CDOCommonUtil.isValidTimeStamp(timeStamp, creationTS, revisedTS))
- {
- return true;
- }
- }
- return false;
- }
-
- public void detach(int version, CDOBranch branch, long timeStamp)
- {
- ObjyClass objyClass = ObjySchema.getObjyClass(ObjyBase.CLASS_NAME);
- Class_Object detachedClassObject = Class_Object.new_persistent_object(objyClass.getASClass(), objectId, false);
- if (TRACER_DEBUG.isEnabled())
- {
- ObjyObjectManager.newInternalObjCount++;
- }
- ObjyObject detachedObjyObject = null;
-
- try
- {
- detachedObjyObject = new ObjyObject(detachedClassObject);
-
- detachedObjyObject.setVersion(-(version + 1));
- detachedObjyObject.setBranchId(branch.getID());
- detachedObjyObject.setCreationTime(timeStamp);
-
- // add it to the revisions.
- addToRevisions(detachedObjyObject);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDExternal;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreAccessor;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.IManyTypeMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ISingleTypeMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.SingleReferenceMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListId;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListString;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBase;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapArrayList;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapEntry;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.net4j.util.collection.MoveableList;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.FeatureMap;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Relationship_Object;
+import com.objy.as.app.String_Value;
+import com.objy.as.app.VArray_Object;
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.d_Class;
+import com.objy.as.app.d_Ref_Type;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public class ObjyObject
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyObject.class);
+
+ protected Class_Object classObject;
+
+ protected ObjyClass objyClass;
+
+ protected Class_Object baseClassObject = null;
+
+ protected Relationship_Object baseRel = null;
+
+ protected boolean hasBaseRelationshipChecked = false;
+
+ protected Relationship_Object revisionsRel = null;
+
+ protected Relationship_Object lastRevisionRel = null;
+
+ protected ooId objectId;
+
+ protected ooId revisionId = null;
+
+ protected int version = Integer.MAX_VALUE;
+
+ public static int fetchCount = 0;
+
+ public static int updateCount = 0;
+
+ public static long createObjectTime = 0;
+
+ public static int createObjectCount = 0;
+
+ // protected boolean isRoot = false;
+
+ // IS: for stats.
+ // public static int count = 0;
+ // public static long tDiff = 0;
+
+ // good for fast access.
+ // private Map<Class_Position, Object> featureMap = new HashMap<Class_Position, Object>();
+ private Map<String, Object> featureMap = new HashMap<String, Object>();
+
+ public ObjyObject(Class_Object classObject)
+ {
+ // long tStart = System.currentTimeMillis();
+
+ this.classObject = classObject;
+ d_Class dClass = classObject.type_of();
+ String fullyQualifiedClassName = null;
+
+ try
+ {
+
+ if (dClass.namespace_name() != null)
+ {
+ fullyQualifiedClassName = dClass.namespace_name() + ":" + dClass.name();
+ }
+ else
+ {
+ fullyQualifiedClassName = dClass.name();
+ }
+
+ objyClass = ObjySchema.getObjyClass(fullyQualifiedClassName);
+
+ // if (dClass.has_base_class(ObjyBase.CLASS_NAME))
+ // {
+ // if (TRACER_DEBUG.isEnabled())
+ // {
+ // TRACER_DEBUG.format("...classObject type: {0} - oid: {1}", classObject.type_of().name(), classObject
+ // .objectID().getStoreString());
+ // }
+ // getBaseRelationship(classObject);
+ // if (!baseRel.exists())
+ // {
+ // // we are the base...
+ // getRevisionsRelationship(classObject);
+ // getLastRevisionRelationship(classObject);
+ // }
+ // else
+ // {
+ // baseClassObject = baseRel.get_class_obj();
+ // // TODO - we might want to delay getting the list of versions unless we need them.
+ // // revisionsRel = baseClassObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_REVISIONS));
+ // // lastRevisionRel = baseClassObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_LAST_REVISION));
+ // }
+ // }
+ setObjectId(classObject.objectID());
+ // version = classObject.get_numeric(objyClass.resolve_position(ObjyBase.ATT_VERSION)).intValue();
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ // count++;
+ // tDiff += System.currentTimeMillis() - tStart;
+ }
+
+ private Relationship_Object getLastRevisionRelationship()
+ {
+ if (lastRevisionRel == null)
+ {
+ lastRevisionRel = classObject.nget_relationship(ObjyBase.ATT_LAST_REVISION);
+ }
+ return lastRevisionRel;
+ }
+
+ private Relationship_Object getRevisionsRelationship()
+ {
+ if (revisionsRel == null)
+ {
+ // revisionsRel = classObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_REVISIONS));
+ revisionsRel = classObject.nget_relationship(ObjyBase.ATT_REVISIONS);
+ }
+ return revisionsRel;
+ }
+
+ private Relationship_Object getBaseRelationship()
+ {
+ if (baseRel == null)
+ {
+ // baseRel = classObject.get_relationship(objyClass.resolve_position(ObjyBase.ATT_BASE));
+ baseRel = classObject.nget_relationship(ObjyBase.ATT_BASE);
+ }
+ return baseRel;
+ }
+
+ public ObjyClass objyClass()
+ {
+ return objyClass;
+ }
+
+ public Class_Object ooClassObject()
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ return classObject;
+ }
+
+ public void setObjectId(ooId objectId)
+ {
+ this.objectId = objectId;
+ }
+
+ /**
+ *
+ */
+ public ooId ooId()
+ {
+ return objectId;
+ }
+
+ public void setEContainer(Object containerID)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+
+ // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID);
+
+ SingleReferenceMapper.INSTANCE.setValue(this, ObjyBase.ATT_CONTAINERID/* position */, containerID);
+ }
+
+ public Object getEContainer()
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+
+ // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID);
+ Object value = SingleReferenceMapper.INSTANCE.getValue(this, ObjyBase.ATT_CONTAINERID/* position */);
+
+ return value;
+ }
+
+ public ooId getEContainerAsOid()
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+
+ // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINERID);
+ ooId childOid = get_ooId(ObjyBase.ATT_CONTAINERID/* position */);
+ return childOid;
+ }
+
+ public void setEResource(Object resourceID)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+
+ // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID);
+ SingleReferenceMapper.INSTANCE.setValue(this, ObjyBase.ATT_RESOURCEID/* position */, resourceID);
+
+ }
+
+ public Object getEResource()
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+
+ // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID);
+ Object value = SingleReferenceMapper.INSTANCE.getValue(this, ObjyBase.ATT_RESOURCEID/* position */);
+
+ return value;
+ }
+
+ public ooId getEResourceAsOid()
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_RESOURCEID);
+ ooId childOid = get_ooId(ObjyBase.ATT_RESOURCEID/* position */);
+ return childOid;
+ }
+
+ public void setEContainingFeature(int contFeature)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINER_FEATUERID);
+ set_numeric(ObjyBase.ATT_CONTAINER_FEATUERID/* position */, new Numeric_Value(contFeature));
+ }
+
+ public int getEContainingFeature()
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ // Class_Position position = objyClass.resolve_position(ObjyBase.ATT_CONTAINER_FEATUERID);
+ return get_numeric(ObjyBase.ATT_CONTAINER_FEATUERID/* position */).intValue();
+ }
+
+ /**
+ * This is used to cache the composite features, (manyAttributes, manyReference, and featureMap. TBD - verify the need
+ * of this.
+ */
+ // public Object getFeatureList(Class_Position position)
+ // {
+ // return featureMap.get(position);
+ // }
+ public Object getFeatureList(String featureName)
+ {
+ return featureMap.get(featureName);
+ }
+
+ // public void setFeatureList(Class_Position position, Object object)
+ // {
+ // featureMap.put(position, object);
+ // }
+ public void setFeatureList(String featureName, Object object)
+ {
+ featureMap.put(featureName, object);
+ }
+
+ public int getVersion()
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ // if (version == Integer.MAX_VALUE)
+ {
+ version = classObject.nget_numeric(ObjyBase.ATT_VERSION).intValue();
+ }
+ return version;
+ }
+
+ public void setVersion(int version)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ classObject.nset_numeric(ObjyBase.ATT_VERSION, new Numeric_Value(version));
+ // getVersion(); // TBD, verify the need for this call!!!!
+ this.version = version;
+ }
+
+ public long getCreationTime()
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ long creationTime = classObject.nget_numeric(ObjyBase.ATT_CREATION_TIME).longValue();
+ return creationTime;
+ }
+
+ public void setCreationTime(long creationTime)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ classObject.nset_numeric(ObjyBase.ATT_CREATION_TIME, new Numeric_Value(creationTime));
+ }
+
+ public long getRevisedTime()
+ {
+ long revisedTime = 0;
+
+ try
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ revisedTime = classObject.nget_numeric(ObjyBase.ATT_REVISED_TIME).longValue();
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return revisedTime;
+ }
+
+ public void setRevisedTime(long revisedTime)
+ {
+ try
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ classObject.nset_numeric(ObjyBase.ATT_REVISED_TIME, new Numeric_Value(revisedTime));
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void setBranchId(int branchId)
+ {
+ try
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ classObject.nset_numeric(ObjyBase.ATT_BRANCHID, new Numeric_Value(branchId));
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+
+ public long getBranchId()
+ {
+ int branchId = 0;
+ try
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ branchId = classObject.nget_numeric(ObjyBase.ATT_BRANCHID).intValue();
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ return branchId;
+ }
+
+ public ObjyObject copy(EClass eClass, ObjyObjectManager objyObjectManager)
+ {
+ ObjyObject newObjyObject = null;
+ ooObj obj = ooObj.create_ooObj(objectId);
+ ooObj newObj = (ooObj)obj.copy(obj); // Objy internal copy.
+ // Dependent structures, for example array of refs are not copies, so we
+ // have to iterate and copy (deep copy).
+ // newObjyObject = new ObjyObject(Class_Object.class_object_from_oid(newObj.getOid()));
+ newObjyObject = objyObjectManager.getObject(newObj.getOid());
+
+ try
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ObjyObject.copy() - oid:" + ooId().getStoreString() + " version:" + getVersion());
+ }
+ for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
+ {
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ {
+ continue;
+ }
+
+ if (feature.isMany())
+ {
+ // copy this feature to the new object.
+ // copy this feature to the new object.
+ // get the attribute using feature name.
+ d_Attribute attribute = objyClass.resolve_attribute(feature.getName());
+ // System.out.println("... checking feature: " + feature.getName() + - attributeType: "
+ // + attribute.type_of().name());
+ if (attribute != null && attribute.type_of() instanceof d_Ref_Type)
+ {
+ // IS:temptest Class_Position position = objyClass.resolve_position(feature.getName());
+ // ooId refOoId = get_ooId(position);
+ Class_Object cObj = get_class_obj(feature.getName());
+ if (cObj != null)
+ {
+ // System.out.println("\t\t referenced Class_Object with OID: " +cObj.objectID().getStoreString());
+ d_Class refClass = cObj.type_of();
+ String refClassName = refClass.name();
+ if (refClassName.equals(ObjyFeatureMapArrayList.ClassName))
+ {
+ // we'll need to copy this one.
+ TRACER_DEBUG.trace("\t TBD - copying ObjyFeatureMapArrayList attr: " + attribute.name());
+ }
+ else if (refClassName.equals(ObjyArrayListString.ClassName))
+ {
+ // we'll need to copy this one.
+ TRACER_DEBUG.trace("\t TBD - copying ObjyArrayListString attr: " + attribute.name());
+ }
+ else if (refClassName.equals(ObjyArrayListId.className))
+ {
+ // we'll need to copy this one.
+ // System.out.println("\t copying ObjyArrayListId attr: " + attibute.name());
+ ObjyArrayListId arrayListId = new ObjyArrayListId(cObj);
+ ooObj newArrayListId = arrayListId.copy(newObj);
+ newObjyObject.set_ooId(feature.getName(), newArrayListId.getOid());
+ }
+ else if (refClassName.equals(ObjyProxy.className))
+ {
+ // we'll need to copy this one.
+ TRACER_DEBUG.trace("\t TBD - copying ObjyProxy attr: " + attribute.name());
+ }
+ }
+ }
+
+ }
+ }
+ }
+ catch (com.objy.as.asException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return newObjyObject;
+ }
+
+ /**
+ * Use the revision info to update the object in the store.
+ *
+ * @param storeAccessor
+ * @param revision
+ */
+ public void update(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision)
+ {
+ updateCount++;
+
+ try
+ {
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ TRACER_DEBUG.trace("ObjyObject.update() - oid:" + ooId().getStoreString() + " - version:"
+ + revision.getVersion());
+ }
+
+ // this is done in the updateDate()
+ // setEContainer(revision.getContainerID());
+ // setEResource(revision.getResourceID());
+ // setEContainingFeature(revision.getContainingFeatureID());
+
+ updateData(storeAccessor, revision);
+ }
+ catch (com.objy.as.asException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Use the revision info to update the object in the store.
+ *
+ * @param storeAccessor
+ * @param revision
+ */
+ private void updateData(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision)
+ {
+ EClass eClass = revision.getEClass();
+
+ try
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("=> ObjyObject.updateData() - oid:" + ooId().getStoreString() + //$NON-NLS-1$
+ " - version:" + revision.getVersion()); //$NON-NLS-1$
+ }
+
+ setVersion(revision.getVersion());
+
+ setEContainer(revision.getContainerID());
+ setEResource(revision.getResourceID());
+ setEContainingFeature(revision.getContainingFeatureID());
+ setCreationTime(revision.getTimeStamp());
+ setRevisedTime(revision.getRevised());
+ setBranchId(revision.getBranch().getID());
+
+ for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
+ {
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ {
+ continue;
+ }
+
+ ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
+ if (mapper == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("In " + ooId().getStoreString() + " - Can't find mapper for feature "
+ + feature.getName());
+ }
+ continue;
+ }
+ // -----------------------------------------------
+ // TODO - this code definitely need refactoring!!!
+ // -----------------------------------------------
+
+ // Class_Position attr = objyClass.resolve_position(feature.getName());
+ if (feature.isMany())
+ {
+ // Object newValue = revision.getValue(feature);
+ // --- TEMP solution to fix one of the tests...
+ CDOList list = revision.getList(feature);
+ Object[] values = new Object[list.size()];
+ // we need to pass a list of ooId objects.
+ // TODO - This need some work!!!!
+ for (int i = 0; i < values.length; i++)
+ {
+ // TODO - this code need refactoring...
+ Object value = list.get(i);
+ if (null == value)
+ {
+ values[i] = value;
+ continue;
+ }
+ else if (value instanceof CDOIDExternal)
+ {
+ TRACER_DEBUG
+ .trace("... CDOIDExternal inserted, at:" + i + ", content:" + ((CDOIDExternal)value).getURI());
+ // System.out.println("value is a proxy object - it should be handled by the mapper.");
+ // create an ObjyProxy object to hold the the value.
+ ObjyProxy proxyObject = ObjyProxy.createObject(ooId());
+ proxyObject.setUri(((CDOIDExternal)value).getURI());
+ values[i] = proxyObject.ooId();
+
+ }
+ else if (value instanceof CDOID)
+ {
+ values[i] = OBJYCDOIDUtil.getooId((CDOID)value);
+ }
+ else if (value instanceof FeatureMap.Entry)
+ {
+ FeatureMap.Entry entry = (FeatureMap.Entry)value;
+ EStructuralFeature entryFeature = entry.getEStructuralFeature();
+ Object entryValue = entry.getValue();
+
+ ooId oid = null;
+ if (entryValue instanceof CDOIDExternal)
+ {
+ TRACER_DEBUG.trace("... CDOIDExternal inserted, at:" + i + ", content:"
+ + ((CDOIDExternal)entryValue).getURI());
+ // System.out.println("value is a proxy object - it should be handled by the mapper.");
+ // create an ObjyProxy object to hold the the value.
+ ObjyProxy proxyObject = ObjyProxy.createObject(ooId());
+ proxyObject.setUri(((CDOIDExternal)entryValue).getURI());
+ oid = proxyObject.ooId();
+ }
+ else if (entryValue instanceof CDOID)
+ {
+ oid = OBJYCDOIDUtil.getooId((CDOID)entryValue);
+ }
+ else
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("OBJY: don't know what kind of entryValue is this!!! - " + entryValue);
+ }
+ }
+ // FeatureMapEntry is a presistent class.
+ ObjyFeatureMapEntry featureMapEntry = new ObjyFeatureMapEntry(entryFeature.getFeatureID(), oid, objectId);
+
+ // this.cluster(featureMapEntry);
+ values[i] = featureMapEntry;
+ }
+ else if (value.equals(InternalCDOList.UNINITIALIZED))
+ {
+ TRACER_DEBUG.format("...GOT UNINITIALIZED at {0}, listSize:{1}, feature:{2}, oid:{3}", i, values.length,
+ feature.getName(), objectId.getStoreString());
+ continue;
+ }
+ else
+ {
+ // different feature then.
+ values[i] = value;
+ }
+ }
+
+ ((IManyTypeMapper)mapper).setAll(this, feature, 0, values);
+ }
+ else
+ {
+ Object newValue = revision.get(feature, feature.getFeatureID());
+ // if (newValue instanceof CDOIDExternal)
+ // {
+ // System.out.println("value is a proxy object");
+ // }
+ ((ISingleTypeMapper)mapper).setValue(this, feature, newValue);
+ }
+ }
+ }
+ catch (com.objy.as.asException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public ObjyObject getLastRevision(ObjyObjectManager objyObjectManager)
+ {
+ if (!getLastRevisionRelationship().exists())
+ {
+ return this;
+ }
+
+ // Class_Object lastRevision = lastRevisionRel.get_class_obj();
+ ooId lastRevisionOid = getLastRevisionRelationship().get_ooId();
+ // return new ObjyObject(lastRevision);
+ return objyObjectManager.getObject(lastRevisionOid);
+ }
+
+ public ObjyObject getRevisionByVersion(int version, long branchId, ObjyObjectManager objyObjectManager)
+ {
+ ObjyObject objyRevision = null;
+ int objectVersion = getVersion();
+ long objectBranchId = getBranchId();
+
+ if (branchId == objectBranchId && Math.abs(objectVersion) == version)
+ {
+ // there is a first time for everything...
+ return this;
+ }
+
+ // check last revision first.
+ objyRevision = getLastRevision(objyObjectManager);
+ objectVersion = objyRevision.getVersion();
+ objectBranchId = objyRevision.getBranchId();
+ if (branchId == objectBranchId && Math.abs(objectVersion) == version)
+ {
+ return objyRevision;
+ }
+
+ // Session.getCurrent().setReturn_Class_Object(true);
+ // int numRevisions = (int) revisions.size();
+
+ @SuppressWarnings("unchecked")
+ Iterator<ooObj> itr = getRevisionsRelationship().get_iterator();
+ while (itr.hasNext())
+ {
+ // objyRevision = new ObjyObject(itr.next());
+ objyRevision = objyObjectManager.getObject(itr.next().getOid());
+ objectVersion = objyRevision.getVersion();
+ objectBranchId = objyRevision.getBranchId();
+ if (branchId == objectBranchId && Math.abs(objectVersion) == version)
+ {
+ return objyRevision;
+ }
+ objyRevision = null;
+ }
+
+ return null;
+ }
+
+ public void addToRevisions(ObjyObject objyRevision)
+ {
+ try
+ {
+ getRevisionsRelationship().add(objyRevision.objectId);
+ // set it as last rev.
+ getLastRevisionRelationship().clear(); // Ouch!! performance issue...
+ getLastRevisionRelationship().form(objyRevision.objectId);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ // /**
+ // * Wrapper around ObjyObject to allow clustering of other objects near this one.
+ // */
+ // private void cluster(ooObj otherObj)
+ // {
+ // try
+ // {
+ // ooObj thisObj = ooObj.create_ooObj(objectId);
+ // thisObj.cluster(otherObj);
+ // }
+ // catch (ObjyRuntimeException ex)
+ // {
+ // ex.printStackTrace();
+ // }
+ // }
+
+ /**
+ * Fetch data from the store and return a revision.
+ */
+ public boolean fetch(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision, int listChunk)
+ {
+ boolean bRet = true;
+ fetchCount++;
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ EClass eClass = revision.getEClass();
+
+ try
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ObjyObject.fetch() - oid:" + ooId().getStoreString() + " version:" + getVersion());
+ }
+ // Put the version of the objects;
+ revision.setVersion(getVersion());
+ revision.setContainerID(getEContainer());
+ revision.setResourceID((CDOID)getEResource());
+ revision.setContainingFeatureID(getEContainingFeature());
+ long creationTime = getCreationTime();
+ long revisedTime = getRevisedTime();
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("... ObjyObject.creationTime: " + creationTime);
+ TRACER_DEBUG.trace("... ObjyObject.revisedTime : " + revisedTime);
+ }
+
+ revision.setRevised(revisedTime);
+
+ for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
+ {
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ {
+ continue;
+ }
+
+ if (feature.isMany())
+ {
+ int featureSize = size(feature);
+ int chunkSize = featureSize;
+ if (listChunk != CDORevision.UNCHUNKED && listChunk > 0)
+ {
+ chunkSize = Math.min(chunkSize, listChunk);
+ }
+
+ Object[] objects = getAll(feature, 0, chunkSize);
+ // if (size > 0)
+ {
+ // TODO - we could use getList() then fill the array with values, we
+ // also
+ // need to consider the chunking...
+ // InternalCDOList cdoList =
+ // (InternalCDOList)CDOListFactory.DEFAULT.createList(objects.length,
+ // objects.length, 0);
+ // TODO - use the following line instead of creating the cdoList
+ // above.
+ MoveableList<Object> list = revision.getList(feature);
+
+ // size = Math.min(size, 0);
+ for (int i = 0; i < chunkSize; i++)
+ {
+ if (objects[i] instanceof ooId)
+ {
+ // TODO - this code need refactoring....
+ CDOID cdoId = null;
+ ooId objyOid = (ooId)objects[i];
+ if (objyOid.isNull())
+ {
+ cdoId = OBJYCDOIDUtil.getCDOID(objyOid);
+ }
+ else
+ {
+ Class_Object refClassObject = Class_Object.class_object_from_oid((ooId)objects[i]);
+
+ if (refClassObject.type_of().name().equals(ObjyProxy.className))
+ {
+ // System.out.println("OBJY: Got proxy: " + refClassObject.objectID().getStoreString());
+ ObjyProxy proxyObject = new ObjyProxy(refClassObject);
+ // cdoList.set(i,
+ // OBJYCDOIDUtil.createCDIDExternal(proxyObject));
+ cdoId = OBJYCDOIDUtil.createCDIDExternal(proxyObject);
+ }
+ else
+ {
+ cdoId = OBJYCDOIDUtil.getCDOID(objyOid);
+ }
+ refClassObject = null;
+ }
+ list.add(cdoId);
+
+ continue;
+ }
+ else if (objects[i] instanceof ObjyFeatureMapEntry)
+ {
+ FeatureMap.Entry entry = getFeatureMapEntry(eClass, (ObjyFeatureMapEntry)objects[i]);
+ list.add(entry);
+ }
+ else
+ {
+ // different feature then.
+ // System.out.println("-->> Hmmm fetch() feature (" + i + ") -> feature:" + feature.getName()
+ // + " - value:" + objects[i]);
+ // cdoList.set(i, objects[i]);
+ list.add(objects[i]);
+ }
+ }
+ // fill the rest if needed.
+ if (featureSize - chunkSize > 0)
+ {
+ for (int i = 0; i < featureSize - chunkSize; i++)
+ {
+ list.add(InternalCDOList.UNINITIALIZED);
+ }
+ }
+ }
+ }
+ else
+ {
+ Object object = get(feature, 0);
+
+ /**
+ * TODO - verify if this is needed for 2.x if (cdoFeature.getType() == CDOType.CUSTOM) { object =
+ * EcoreUtil.convertToString((EDataType)eFeature.getEType(), object); }
+ */
+ revision.set(feature, 0, object);
+ }
+ }
+ }
+ catch (com.objy.as.asException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return bRet;
+ }
+
+ /**
+ * Fetch data for a specific feature from the store, and return a list of objects. Used by
+ * ObjectivityStoreChunkAccessor
+ */
+ public List<Object> fetchList(ObjectivityStoreAccessor storeAccessor, EStructuralFeature feature, int startIndex,
+ int chunkSize)
+ {
+ fetchCount++;
+
+ List<Object> results = new ArrayList<Object>();
+ EClass eClass = feature.getEContainingClass();
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+
+ try
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ObjyObject.fetch() - feature:" + feature.getName() + "from Object: "
+ + ooId().getStoreString() + " version:" + getVersion());
+ }
+ int featureSize = size(feature);
+ chunkSize = Math.min(featureSize - startIndex, chunkSize);
+
+ Object[] objects = getAll(feature, startIndex, chunkSize);
+ convertToCdoList(objects, results, eClass, chunkSize);
+ }
+ catch (com.objy.as.asException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return results;
+ }
+
+ /**
+ * Function thats takes a list of Objy objects and convert them to CDO IDs This function is used by queryXRefs() as
+ * well.
+ */
+ protected void convertToCdoList(Object[] objects, List<Object> results, EClass eClass, int chunkSize)
+ {
+ {
+ for (int i = 0; i < chunkSize; i++)
+ {
+ if (objects[i] instanceof ooId)
+ {
+ // TODO - this code need refactoring....
+
+ // System.out.println("-->> IS: getting Class_Object from OID: "
+ // + childObject.getStoreString());
+ CDOID cdoId = null;
+ ooId objyOid = (ooId)objects[i];
+ if (objyOid.isNull())
+ {
+ cdoId = OBJYCDOIDUtil.getCDOID(objyOid);
+ }
+ else
+ {
+ Class_Object refClassObject = Class_Object.class_object_from_oid(objyOid);
+
+ if (refClassObject.type_of().name().equals(ObjyProxy.className))
+ {
+ ObjyProxy proxyObject = new ObjyProxy(refClassObject);
+ cdoId = OBJYCDOIDUtil.createCDIDExternal(proxyObject);
+ }
+ else
+ {
+ cdoId = OBJYCDOIDUtil.getCDOID(objyOid);
+ }
+ refClassObject = null;
+ }
+
+ results.add(cdoId);
+ continue;
+
+ }
+ else if (objects[i] instanceof ObjyFeatureMapEntry)
+ {
+ FeatureMap.Entry entry = getFeatureMapEntry(eClass, (ObjyFeatureMapEntry)objects[i]);
+ results.add(entry);
+ }
+ }
+ }
+ }
+
+ private FeatureMap.Entry getFeatureMapEntry(EClass eClass, ObjyFeatureMapEntry mapEntry)
+ {
+ ooId oid = mapEntry.getObject();
+ CDOID id = null;
+ Class_Object refClassObject = Class_Object.class_object_from_oid(oid);
+ if (refClassObject.type_of().name().equals(ObjyProxy.className))
+ {
+ ObjyProxy proxyObject = new ObjyProxy(refClassObject);
+ id = OBJYCDOIDUtil.createCDIDExternal(proxyObject);
+ }
+ else
+ {
+ id = OBJYCDOIDUtil.getCDOID(oid);
+ }
+
+ EStructuralFeature entryFeature = eClass.getEStructuralFeature(mapEntry.getTagId());
+ FeatureMap.Entry entry = CDORevisionUtil.createFeatureMapEntry(entryFeature, id);
+ return entry;
+ }
+
+ /**
+ * Get the size of the composite object using the store info.
+ *
+ * @param feature
+ * @return
+ */
+ private int size(EStructuralFeature feature)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+ int size = 0;
+
+ // Class_Position position = objyClass().resolve_position(feature.getName());
+ try
+ {
+ IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature);
+
+ size = mapper.size(this, feature);
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ // TODO - verify the message.
+ TRACER_DEBUG.trace("Size of object " + ooId().getStoreString() + " - is: " + size + " - feature: "
+ + feature.getName());
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ return size;
+ }
+
+ /**
+ * Get the value of an attribute from the persistent object.
+ */
+ public Object get(EStructuralFeature feature)
+ {
+ if (feature.isMany())
+ {
+ return getAll(feature, 0, CDORevision.UNCHUNKED);
+ }
+ return get(feature, 0);
+ }
+
+ /**
+ * Get the value of an attribute at index (if many) from the persistent object.
+ *
+ * @param feature
+ * @param index
+ * @return
+ */
+ private Object get(EStructuralFeature feature, int index)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ // TODO - verify the message.
+ TRACER_DEBUG.trace("Getting object " + objectId.getStoreString() + " <feature ' " + feature.getName() + "':"
+ + feature.getEType() + "> from " + this);
+ }
+
+ // Class_Position position =
+ // this.objyClass().resolve_position(feature.getName());
+
+ ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
+ Object value = null;
+ try
+ {
+ if (feature.isMany())
+ {
+ value = ((IManyTypeMapper)mapper).getValue(this, feature, index);
+ }
+ else
+ {
+ value = ((ISingleTypeMapper)mapper).getValue(this, feature);
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ return value;
+ }
+
+ /**
+ * Get all the values of an attribute, used for feature.isMany(). This function is also used by the
+ * ObjectivityStoreChunkReader to read chunks of data from a feature.
+ *
+ * @param feature
+ * @param size
+ * @return
+ */
+ protected Object[] getAll(EStructuralFeature feature, int startIndex, int chunkSize)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ // TODO - verify the message.
+ TRACER_DEBUG.trace("Get All objects for ID: " + ooId().getStoreString() + " <feature ' " + feature/*
+ * .getName( )
+ */
+ + "':" + feature.getEType() + "> from " + this);
+ }
+
+ assert feature.isMany();
+ Object[] values = null;
+
+ try
+ {
+ IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature);
+ values = mapper.getAll(this, feature, startIndex, chunkSize);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return values;
+ }
+
+ public void add(EStructuralFeature feature, int index, Object value)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ TRACER_DEBUG.trace("Adding object " + value + " to " + ooId().getStoreString());
+ }
+
+ assert feature.isMany();
+
+ try
+ {
+ IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature);
+
+ // -- TODO -- verify the need to this one.
+ // ensureObjectAttached(feature, value);
+
+ // I believe we do the conversion in the add()
+ // value = provider.convertToStore(ooObject, value);
+
+ mapper.add(this, feature, index, value);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /***
+ * @param feature
+ */
+ public void clear(EStructuralFeature feature)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ TRACER_DEBUG.trace("Clear List for " + ooId().getStoreString());
+ }
+
+ // Class_Position position = objyClass.resolve_position(feature.getName());
+ try
+ {
+ ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
+
+ ((IManyTypeMapper)mapper).clear(this, feature);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void move(EStructuralFeature feature, int targetIndex, int sourceIndex)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ TRACER_DEBUG.trace("Move element from " + sourceIndex + " to " + targetIndex);
+ }
+ try
+ {
+ ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
+
+ ((IManyTypeMapper)mapper).move(this, feature, targetIndex, sourceIndex);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public Object remove(EStructuralFeature feature, int index)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ TRACER_DEBUG.trace("Remove object from '" + ooId().getStoreString() + "' at index " + index);
+ }
+
+ // Class_Position position = objyClass.resolve_position(feature.getName());
+ Object retObject = null;
+
+ try
+ {
+ IManyTypeMapper mapper = (IManyTypeMapper)ObjyMapper.INSTANCE.getTypeMapper(feature);
+
+ Object value = mapper.remove(this, feature, index);
+
+ if (feature instanceof EAttribute)
+ {
+ return value;
+ }
+
+ retObject = OBJYCDOIDUtil.getCDOID((ooId)value);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return retObject;
+
+ }
+
+ public Object set(EStructuralFeature feature, int index, Object value)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ checkSession();
+ TRACER_DEBUG.trace("Set object '" + ooId().getStoreString() + "' feature : " + feature.getName());
+ }
+
+ /*
+ * int i =0; for (EClass superEClass : object.eClass().getESuperTypes()) { if
+ * (feature.getEContainingClass().isSuperTypeOf(superEClass)) { break; } i++; break; } String className = null; if
+ * (i == 0) { className = EProposedManager.getObjectivityClass(feature.getEContainingClass()); } else { className =
+ * EProposedManager.getObjectivityClass(feature.getEContainingClass(), true); } Class_Position position =
+ * ooObject.ooClass().resolve_position(className + "::" + feature.getName());
+ */
+ // Class_Position position = objyClass.resolve_position(feature.getName());
+ try
+ {
+ ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
+
+ // --- TODO --- verify the need...
+ // ensureObjectAttached(this, feature, value);
+
+ /***
+ * I believe we do the conversion in the setValue if (feature instanceof EReference) { value =
+ * CDOIDUtil.getooId((CDOID)value); }
+ ***/
+
+ if (feature.isMany())
+ {
+ ((IManyTypeMapper)mapper).setValue(this, feature, index, value);
+ }
+ else
+ {
+ ((ISingleTypeMapper)mapper).setValue(this, feature, value);
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return value;
+ }
+
+ /***
+ * @param feature
+ */
+ public void unset(EStructuralFeature feature)
+ {
+ set(feature, 0, null);
+ }
+
+ protected void checkSession()
+ {
+ // 100610 - IS: disabled for now, since we have an issue with oojava_epl.jar "getSession()"
+ // is not available.
+ // if (TRACER_DEBUG.isEnabled())
+ // {
+ // try
+ // {
+ // if (!classObject.getPersistor().getSession().isOpen())
+ // {
+ // throw new Exception("Attempt to work on an object " + objectId.toString() + " without a trx. [Session: "
+ // + classObject.getPersistor().getSession() + "]");
+ // }
+ // }
+ // catch (Exception ex)
+ // {
+ // ex.printStackTrace();
+ // } // for debugging.
+ // }
+ }
+
+ /***
+ * Iterate over the attributes and references and mark them deleted. This will only be called in non-audit mode.
+ */
+ public void delete(ObjectivityStoreAccessor storeAccessor, ObjyObjectManager objectManager)
+ {
+ EClass eClass = ObjySchema.getEClass(storeAccessor.getStore(), objyClass());
+ try
+ {
+ for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
+ {
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ {
+ continue;
+ }
+
+ if (feature.isMany())
+ {
+ deleteFeatureObjects(objectManager, feature);
+ }
+ else
+ {
+ ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
+
+ if (mapper == null)
+ {
+ continue;
+ }
+ mapper.delete(this, feature);
+ }
+ }
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ private void deleteFeatureObjects(ObjyObjectManager objectManager, EStructuralFeature feature)
+ {
+ // TODO - verify that we can do this to all referenced list.
+ // I'm not sure if it's valid when you have many-many relationship.
+ Object[] objects = getAll(feature, 0, CDORevision.UNCHUNKED);
+
+ if (objects == null)
+ {
+ return;
+ }
+
+ for (int i = 0; i < objects.length; i++)
+ {
+ if (objects[i] instanceof ooId)
+ {
+ ooId oid = (ooId)objects[i];
+ // TODO - this code need refactoring....
+ ooObj obj = ooObj.create_ooObj(oid);
+ if (obj.isDead())
+ {
+ continue;
+ }
+
+ Class_Object refClassObject = Class_Object.class_object_from_oid(oid);
+
+ if (refClassObject.type_of().name().equals(ObjyProxy.className))
+ {
+ obj.delete();
+ }
+ else
+ {
+ // if this object is a parent (resourceId or
+ // containerId) for obj, then we
+ // need to mark obj version as (-1).
+ ObjyObject childObjyObject = objectManager.getObject(oid);
+ ooId containerId = childObjyObject.getEContainerAsOid();
+ ooId resourceId = childObjyObject.getEResourceAsOid();
+ int childVersion = childObjyObject.getVersion();
+ if (containerId.equals(objectId) || resourceId.equals(objectId))
+ {
+ childObjyObject.setVersion(-childVersion);
+ }
+
+ }
+ }
+ else if (objects[i] instanceof ObjyFeatureMapEntry)
+ {
+ ObjyFeatureMapEntry mapEntry = (ObjyFeatureMapEntry)objects[i];
+ ooId oid = mapEntry.getObject();
+ ooObj obj = ooObj.create_ooObj(oid);
+ obj.delete();
+ }
+ else
+ {
+ // different feature then.
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("-->> No process to delete() feature (" + i + ") -> feature:" + feature.getName()
+ + " - value:" + objects[i] + " ... nothing to do here.");
+ }
+ }
+ }
+ }
+
+ // Wrapper functions over class object.
+ // public Numeric_Value get_numeric(Class_Position position)
+ // {
+ // return classObject.get_numeric(position);
+ // }
+ public Numeric_Value get_numeric(String attributeName)
+ {
+ return classObject.nget_numeric(attributeName);
+ }
+
+ // public String_Value get_string(Class_Position position)
+ // {
+ // return classObject.get_string(position);
+ // }
+ public String_Value get_string(String attributeName)
+ {
+ return classObject.nget_string(attributeName);
+ }
+
+ // public void set_numeric(Class_Position position, Numeric_Value value)
+ // {
+ // classObject.set_numeric(position, value);
+ // }
+ public void set_numeric(String attributeName, Numeric_Value value)
+ {
+ classObject.nset_numeric(attributeName, value);
+ }
+
+ // public VArray_Object get_varray(Class_Position position)
+ // {
+ // return classObject.get_varray(position);
+ // }
+ public VArray_Object get_varray(String attributeName)
+ {
+ return classObject.nget_varray(attributeName);
+ }
+
+ // public ooId get_ooId(Class_Position position)
+ // {
+ // return classObject.get_ooId(position);
+ // }
+ public ooId get_ooId(String attributeName)
+ {
+ return classObject.nget_ooId(attributeName);
+ }
+
+ // public Class_Object get_class_obj(Class_Position position)
+ // {
+ // return classObject.get_class_obj(position);
+ // }
+
+ public Class_Object get_class_obj(String attributeName)
+ {
+ return classObject.nget_class_obj(attributeName);
+ }
+
+ // public void set_ooId(Class_Position position, ooId object)
+ // {
+ // classObject.set_ooId(position, object);
+ // }
+
+ public void set_ooId(String attributeName, ooId object)
+ {
+ classObject.nset_ooId(attributeName, object);
+ }
+
+ /**
+ * Return the CDOID for the ObjyObject, it will go up to the base revision, and return it's ID.
+ */
+ public CDOID getRevisionId()
+ {
+ if (revisionId == null)
+ {
+ if (hasBaseRelationship())
+ {
+ baseClassObject = getBaseRelationship().get_class_obj();
+ revisionId = baseClassObject.objectID();
+ }
+ else
+ {
+ revisionId = objectId;
+ }
+ }
+
+ return OBJYCDOIDUtil.getCDOID(revisionId);
+ }
+
+ public ObjyObject getBaseObject()
+ {
+ ObjyObject objyObject = null;
+ if (hasBaseRelationship())
+ {
+ baseClassObject = getBaseRelationship().get_class_obj();
+ objyObject = new ObjyObject(baseClassObject);
+ }
+ else
+ {
+ objyObject = this;
+ }
+ return objyObject;
+ }
+
+ private boolean hasBaseRelationship()
+ {
+ if (!hasBaseRelationshipChecked)
+ {
+ hasBaseRelationshipChecked = getBaseRelationship().exists();
+ }
+ return hasBaseRelationshipChecked;
+ }
+
+ // private boolean hasRevisionsRelationship()
+ // {
+ // if (!hasRevisionsRelChecked)
+ // {
+ // hasRevisionsRelChecked = getRevisionsRelationship().exists();
+ // }
+ // return hasRevisionsRelChecked;
+ // }
+ //
+ // private boolean hasLastRevisionRelationship()
+ // {
+ // if (!hasLastRevisionRelChecked)
+ // {
+ // hasLastRevisionRelChecked = getLastRevisionRelationship().exists();
+ // }
+ // return hasLastRevisionRelChecked;
+ // }
+
+ /**
+ * Return the revision that satisfies the timeStamp and branchId constrains.
+ *
+ * @param objyObjectManager
+ */
+ public ObjyObject getRevision(long timeStamp, int branchId, ObjyObjectManager objyObjectManager)
+ {
+ ObjyObject objyRevision = null;
+
+ // // evaluate current first.
+ // if (evaluateRevision(timeStamp, branchId, this))
+ // {
+ // return this;
+ // }
+ //
+ // // if we don't have other revisions.
+ // if (!getLastRevisionRelationship().exists())
+ // {
+ // return null;
+ // }
+
+ // check last revision first.
+ objyRevision = getLastRevision(objyObjectManager);
+ if (evaluateRevision(timeStamp, branchId, objyRevision))
+ {
+ return objyRevision;
+ }
+
+ ObjyObject possibleRevision = null;
+
+ // check first revision.
+ if (evaluateRevision(timeStamp, branchId, this))
+ {
+ possibleRevision = this;
+ }
+
+ @SuppressWarnings("unchecked")
+ Iterator<ooObj> itr = getRevisionsRelationship().get_iterator();
+ while (itr.hasNext())
+ {
+ // objyRevision = new ObjyObject(itr.next());
+ objyRevision = objyObjectManager.getObject(itr.next().getOid());
+ if (evaluateRevision(timeStamp, branchId, objyRevision))
+ {
+ possibleRevision = objyRevision;
+ }
+ }
+
+ return possibleRevision;
+ }
+
+ /**
+ * return true if the objyRevision satisfies the constrains. This function is only called in case of auditing, and
+ * branching.
+ */
+ protected boolean evaluateRevision(long timeStamp, int branchId, ObjyObject objyRevision)
+ {
+ // check the branchId first.
+ if (objyRevision.getBranchId() == branchId)
+ {
+ // long revisedTS = objyRevision.getRevisedTime();
+ // if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
+ // {
+ // long creationTS = objyRevision.getCreationTime();
+ // if (creationTS <= timeStamp && (revisedTS == CDOBranchPoint.UNSPECIFIED_DATE || revisedTS >= timeStamp))
+ // // if (creationTS >= timeStamp && (revisedTS == CDOBranchPoint.UNSPECIFIED_DATE || revisedTS <= timeStamp))
+ // {
+ // return true;
+ // }
+ // }
+ // else if (revisedTS == CDOBranchPoint.UNSPECIFIED_DATE) // return the latest version in that branch.
+ // {
+ // return true;
+ // }
+
+ long creationTS = objyRevision.getCreationTime();
+ long revisedTS = objyRevision.getRevisedTime();
+ if (CDOCommonUtil.isValidTimeStamp(timeStamp, creationTS, revisedTS))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void detach(int version, CDOBranch branch, long timeStamp)
+ {
+ ObjyClass objyClass = ObjySchema.getObjyClass(ObjyBase.CLASS_NAME);
+ Class_Object detachedClassObject = Class_Object.new_persistent_object(objyClass.getASClass(), objectId, false);
+ if (TRACER_DEBUG.isEnabled())
+ {
+ ObjyObjectManager.newInternalObjCount++;
+ }
+ ObjyObject detachedObjyObject = null;
+
+ try
+ {
+ detachedObjyObject = new ObjyObject(detachedClassObject);
+
+ detachedObjyObject.setVersion(-(version + 1));
+ detachedObjyObject.setBranchId(branch.getID());
+ detachedObjyObject.setCreationTime(timeStamp);
+
+ // add it to the revisions.
+ addToRevisions(detachedObjyObject);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java
index 78e6676bcd..704d0d4d0d 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyObjectManager.java
@@ -1,281 +1,281 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreAccessor;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.db.ObjyRuntimeException;
-import com.objy.db.app.ooId;
-
-import java.util.WeakHashMap;
-
-public class ObjyObjectManager
-{
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyObjectManager.class);
-
- // private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyObjectManager.class);
-
- // private Map<Long, ObjyObject> idToObjyObjectMap = new ReferenceValueMap.Weak<Long, ObjyObject>();
- private WeakHashMap<Long, ObjyObject> idToObjyObjectMap = new WeakHashMap<Long, ObjyObject>();
-
- private ObjyPlacementManager globalPlacementManager = null;
-
- public static int newObjCount = 0;
-
- public static int newInternalObjCount = 0;
-
- public static long getObjectTime = 0;
-
- public static long updateObjectTime = 0;
-
- public static long resourceCheckAndUpdateTime = 0;
-
- public ObjyObjectManager(ObjyPlacementManager placementManager)
- {
- globalPlacementManager = placementManager;
- }
-
- public int sizeOfObjectMap()
- {
- return idToObjyObjectMap.size();
- }
-
- /**
- *
- */
- public ObjyObject newObject(EClass eClass, ooId nearObject)
- {
- if (nearObject == null)
- {
- // TODO - we might need to use annotation for placement.
- nearObject = globalPlacementManager.getNearObject(null, null, eClass);
- }
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Create new object of type " + eClass.getName() + " near object "
- + (nearObject != null ? nearObject.getStoreString() : null));
- }
-
- Class_Object newClassObject = newClassObject(eClass, nearObject);
- ObjyObject objyObject = new ObjyObject(newClassObject);
- // idToObjyObjectMap.put(OBJYCDOIDUtil.getLong(objyObject.ooId()), objyObject);
- if (TRACER_DEBUG.isEnabled())
- {
- newObjCount++;
- }
- return objyObject;
- }
-
- /**
- * @param eClass
- * @return
- */
- // public Class_Object newClassObject(EClass eClass, ooId nearObject)
- // {
- // return newClassObject(eClass, nearObject/*, null*/);
- // }
-
- /**
- * Creates an Objy 'Class_Object' from an eClass. This will construct a shell Class_Object in the store using the
- * schema.
- */
- private Class_Object newClassObject(EClass eClass, ooId nearObject/* , InitializeValue init */)
- {
-
- // we don create classes on the fly...
- // TODO - can we pre-create using the model?
- ObjyClass objyClass = ObjySchema.getOrCreate(eClass);
-
- // System.out.println(">> Create new object of type " + eClass.getName() + " near object " + (nearObject != null ?
- // nearObject
- // .getStoreString() : null));
-
- Class_Object newClassObject = Class_Object.new_persistent_object(objyClass.getASClass(), nearObject, false);
- if (TRACER_DEBUG.isEnabled())
- {
- ObjyObjectManager.newInternalObjCount++;
- }
-
- // if (init != null)
- // {
- // init.init(newClassObject);
- // }
-
- // Initialize the object
- for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
- {
- if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
- {
- continue;
- }
-
- ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
- if (mapper == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Can't find mapper for feature " + feature.getName());
- }
- continue;
- }
-
- // Class_Position attr = objyClass.resolve_position(feature.getName());
-
- mapper.initialize(newClassObject, feature);
-
- // TODO - verify the need for this (see ESessionImpl in the old code)
- // if (init != null)
- // {
- // init.init(feature);
- // }
- }
- return newClassObject;
- }
-
- /**
- * return an ObjyObject based on the id passed. usually this is used for existing object when trying to modify them.
- */
- public ObjyObject getObject(CDOID id)
- {
- if (id == null)
- {
- return null;
- }
-
- ooId oid = OBJYCDOIDUtil.getooId(id);
- return getObject(oid);
- }
-
- /**
- * return an ObjyObject based on the ooId passed.
- */
- public ObjyObject getObject(ooId oid)
- {
- ObjyObject objyObject = null;
- if (oid == null)
- {
- return objyObject;
- }
-
- // System.out.println("ObjyObjectManager.getObject_ooId("+oid.getStoreString()+")");
- objyObject = idToObjyObjectMap.get(OBJYCDOIDUtil.getLong(oid));
- if (objyObject == null)
- {
- try
- {
- objyObject = getObjectFromClassObject(Class_Object.class_object_from_oid(oid));
- }
- catch (ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- return objyObject;
- }
-
- /***
- * The following are utility function that get the base attributes from the object.
- *
- * @param objyObject
- * @return replaced by the ones in ObjyObject. public Object getEContainer(ObjyObject objyObject) { Class_Position
- * position = objyObject.objyClass().resolve_position(ooBaseClass.ClassName_containerid); ooId oid = (ooId)
- * SingleReferenceMapper.INSTANCE.getValue(objyObject, null, position, 0); return getObject(oid); } public
- * Object getEResource(ObjyObject objyObject) { Class_Position position =
- * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_resourceid); ooId oid = (ooId)
- * SingleReferenceMapper.INSTANCE.getValue(objyObject, null, position, 0); return getObject(oid); } public int
- * getEContainingFeature(ObjyObject objyObject) { Class_Position position =
- * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_containerfeatureid); Integer value =
- * (Integer)IntegerTypeMapper.INSTANCE.getValue(objyObject, null, position, 0); return value == null ? 0 :
- * value; } public void setEContainer(ObjyObject objyObject, Object containerID) { //containerID =
- * provider.convertToStore(ooObject, containerID); Class_Position position =
- * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_containerid);
- * SingleReferenceMapper.INSTANCE.setValue(objyObject, null, position, 0, containerID); } public void
- * setEResource(ObjyObject objyObject, Object resourceID) { //resourceID = provider.convertToStore(ooObject,
- * resourceID); Class_Position position =
- * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_resourceid);
- * SingleReferenceMapper.INSTANCE.setValue(objyObject, null, position, 0, resourceID); } public void
- * setEContainingFeature(ObjyObject objyObject, int containerID) { Class_Position position =
- * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_containerfeatureid);
- * IntegerTypeMapper.INSTANCE.setValue(objyObject, null, position, 0, containerID); }
- */
-
- /**
- * Construct an ObjyObject from an existing Class_Object and add it to the idToObjyObjectMap.
- *
- * @param classObject
- * @return
- */
- private ObjyObject getObjectFromClassObject(Class_Object classObject)
- {
- ObjyObject objyObject = new ObjyObject(classObject);
- idToObjyObjectMap.put(OBJYCDOIDUtil.getLong(objyObject.ooId()), objyObject);
- return objyObject;
- }
-
- /***
- * TODO - Remove the eClass and just use the objyObject attributes to do the clean up.
- *
- * @param objyObject
- */
- public void remove(ObjyObject objyObject)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ObjyObjectManager.delete(" + objyObject.ooId().getStoreString() + ")");
- }
-
- // //remove it from it's resource.
- // Object resource = objyObject.getEResource();
- // // locate the ObjyObject.
- // ObjyObject resourceObject = this.getObject((ooId)resource);
-
- synchronized (idToObjyObjectMap)
- {
- idToObjyObjectMap.remove(OBJYCDOIDUtil.getLong(objyObject.ooId()));
- }
- }
-
- // we could've used the CDO copy revision technique, but it will be expensive
- // to create the new copy over the Java/JNI boundaries, doing a low level
- // copy is faster.
- public ObjyObject copyRevision(ObjectivityStoreAccessor storeAccessor, ObjyObject objyObject)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ObjyObjectManager.copyRevision(" + objyObject.ooId().getStoreString() + ")");
- }
- EClass eClass = ObjySchema.getEClass(storeAccessor.getStore(), objyObject.objyClass());
- ObjyObject newObjyRevision = objyObject.copy(eClass, this);
- return newObjyRevision;
- }
-
- public ObjyPlacementManager getGlobalPlacementManager()
- {
- return globalPlacementManager;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreAccessor;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.clustering.ObjyPlacementManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.db.ObjyRuntimeException;
+import com.objy.db.app.ooId;
+
+import java.util.WeakHashMap;
+
+public class ObjyObjectManager
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyObjectManager.class);
+
+ // private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyObjectManager.class);
+
+ // private Map<Long, ObjyObject> idToObjyObjectMap = new ReferenceValueMap.Weak<Long, ObjyObject>();
+ private WeakHashMap<Long, ObjyObject> idToObjyObjectMap = new WeakHashMap<Long, ObjyObject>();
+
+ private ObjyPlacementManager globalPlacementManager = null;
+
+ public static int newObjCount = 0;
+
+ public static int newInternalObjCount = 0;
+
+ public static long getObjectTime = 0;
+
+ public static long updateObjectTime = 0;
+
+ public static long resourceCheckAndUpdateTime = 0;
+
+ public ObjyObjectManager(ObjyPlacementManager placementManager)
+ {
+ globalPlacementManager = placementManager;
+ }
+
+ public int sizeOfObjectMap()
+ {
+ return idToObjyObjectMap.size();
+ }
+
+ /**
+ *
+ */
+ public ObjyObject newObject(EClass eClass, ooId nearObject)
+ {
+ if (nearObject == null)
+ {
+ // TODO - we might need to use annotation for placement.
+ nearObject = globalPlacementManager.getNearObject(null, null, eClass);
+ }
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Create new object of type " + eClass.getName() + " near object "
+ + (nearObject != null ? nearObject.getStoreString() : null));
+ }
+
+ Class_Object newClassObject = newClassObject(eClass, nearObject);
+ ObjyObject objyObject = new ObjyObject(newClassObject);
+ // idToObjyObjectMap.put(OBJYCDOIDUtil.getLong(objyObject.ooId()), objyObject);
+ if (TRACER_DEBUG.isEnabled())
+ {
+ newObjCount++;
+ }
+ return objyObject;
+ }
+
+ /**
+ * @param eClass
+ * @return
+ */
+ // public Class_Object newClassObject(EClass eClass, ooId nearObject)
+ // {
+ // return newClassObject(eClass, nearObject/*, null*/);
+ // }
+
+ /**
+ * Creates an Objy 'Class_Object' from an eClass. This will construct a shell Class_Object in the store using the
+ * schema.
+ */
+ private Class_Object newClassObject(EClass eClass, ooId nearObject/* , InitializeValue init */)
+ {
+
+ // we don create classes on the fly...
+ // TODO - can we pre-create using the model?
+ ObjyClass objyClass = ObjySchema.getOrCreate(eClass);
+
+ // System.out.println(">> Create new object of type " + eClass.getName() + " near object " + (nearObject != null ?
+ // nearObject
+ // .getStoreString() : null));
+
+ Class_Object newClassObject = Class_Object.new_persistent_object(objyClass.getASClass(), nearObject, false);
+ if (TRACER_DEBUG.isEnabled())
+ {
+ ObjyObjectManager.newInternalObjCount++;
+ }
+
+ // if (init != null)
+ // {
+ // init.init(newClassObject);
+ // }
+
+ // Initialize the object
+ for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
+ {
+ if (!(feature instanceof EAttribute || feature instanceof EReference) || !EMFUtil.isPersistent(feature))
+ {
+ continue;
+ }
+
+ ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
+ if (mapper == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Can't find mapper for feature " + feature.getName());
+ }
+ continue;
+ }
+
+ // Class_Position attr = objyClass.resolve_position(feature.getName());
+
+ mapper.initialize(newClassObject, feature);
+
+ // TODO - verify the need for this (see ESessionImpl in the old code)
+ // if (init != null)
+ // {
+ // init.init(feature);
+ // }
+ }
+ return newClassObject;
+ }
+
+ /**
+ * return an ObjyObject based on the id passed. usually this is used for existing object when trying to modify them.
+ */
+ public ObjyObject getObject(CDOID id)
+ {
+ if (id == null)
+ {
+ return null;
+ }
+
+ ooId oid = OBJYCDOIDUtil.getooId(id);
+ return getObject(oid);
+ }
+
+ /**
+ * return an ObjyObject based on the ooId passed.
+ */
+ public ObjyObject getObject(ooId oid)
+ {
+ ObjyObject objyObject = null;
+ if (oid == null)
+ {
+ return objyObject;
+ }
+
+ // System.out.println("ObjyObjectManager.getObject_ooId("+oid.getStoreString()+")");
+ objyObject = idToObjyObjectMap.get(OBJYCDOIDUtil.getLong(oid));
+ if (objyObject == null)
+ {
+ try
+ {
+ objyObject = getObjectFromClassObject(Class_Object.class_object_from_oid(oid));
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ return objyObject;
+ }
+
+ /***
+ * The following are utility function that get the base attributes from the object.
+ *
+ * @param objyObject
+ * @return replaced by the ones in ObjyObject. public Object getEContainer(ObjyObject objyObject) { Class_Position
+ * position = objyObject.objyClass().resolve_position(ooBaseClass.ClassName_containerid); ooId oid = (ooId)
+ * SingleReferenceMapper.INSTANCE.getValue(objyObject, null, position, 0); return getObject(oid); } public
+ * Object getEResource(ObjyObject objyObject) { Class_Position position =
+ * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_resourceid); ooId oid = (ooId)
+ * SingleReferenceMapper.INSTANCE.getValue(objyObject, null, position, 0); return getObject(oid); } public int
+ * getEContainingFeature(ObjyObject objyObject) { Class_Position position =
+ * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_containerfeatureid); Integer value =
+ * (Integer)IntegerTypeMapper.INSTANCE.getValue(objyObject, null, position, 0); return value == null ? 0 :
+ * value; } public void setEContainer(ObjyObject objyObject, Object containerID) { //containerID =
+ * provider.convertToStore(ooObject, containerID); Class_Position position =
+ * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_containerid);
+ * SingleReferenceMapper.INSTANCE.setValue(objyObject, null, position, 0, containerID); } public void
+ * setEResource(ObjyObject objyObject, Object resourceID) { //resourceID = provider.convertToStore(ooObject,
+ * resourceID); Class_Position position =
+ * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_resourceid);
+ * SingleReferenceMapper.INSTANCE.setValue(objyObject, null, position, 0, resourceID); } public void
+ * setEContainingFeature(ObjyObject objyObject, int containerID) { Class_Position position =
+ * objyObject.objyClass().resolve_position(ooBaseClass.ClassName_containerfeatureid);
+ * IntegerTypeMapper.INSTANCE.setValue(objyObject, null, position, 0, containerID); }
+ */
+
+ /**
+ * Construct an ObjyObject from an existing Class_Object and add it to the idToObjyObjectMap.
+ *
+ * @param classObject
+ * @return
+ */
+ private ObjyObject getObjectFromClassObject(Class_Object classObject)
+ {
+ ObjyObject objyObject = new ObjyObject(classObject);
+ idToObjyObjectMap.put(OBJYCDOIDUtil.getLong(objyObject.ooId()), objyObject);
+ return objyObject;
+ }
+
+ /***
+ * TODO - Remove the eClass and just use the objyObject attributes to do the clean up.
+ *
+ * @param objyObject
+ */
+ public void remove(ObjyObject objyObject)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ObjyObjectManager.delete(" + objyObject.ooId().getStoreString() + ")");
+ }
+
+ // //remove it from it's resource.
+ // Object resource = objyObject.getEResource();
+ // // locate the ObjyObject.
+ // ObjyObject resourceObject = this.getObject((ooId)resource);
+
+ synchronized (idToObjyObjectMap)
+ {
+ idToObjyObjectMap.remove(OBJYCDOIDUtil.getLong(objyObject.ooId()));
+ }
+ }
+
+ // we could've used the CDO copy revision technique, but it will be expensive
+ // to create the new copy over the Java/JNI boundaries, doing a low level
+ // copy is faster.
+ public ObjyObject copyRevision(ObjectivityStoreAccessor storeAccessor, ObjyObject objyObject)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ObjyObjectManager.copyRevision(" + objyObject.ooId().getStoreString() + ")");
+ }
+ EClass eClass = ObjySchema.getEClass(storeAccessor.getStore(), objyObject.objyClass());
+ ObjyObject newObjyRevision = objyObject.copy(eClass, this);
+ return newObjyRevision;
+ }
+
+ public ObjyPlacementManager getGlobalPlacementManager()
+ {
+ return globalPlacementManager;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPackageHandler.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPackageHandler.java
index f7448f9dfb..f57bb244c2 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPackageHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPackageHandler.java
@@ -1,255 +1,255 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageInfo;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageUnit;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.SmartLock;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EPackage;
-
-import com.objy.db.app.Session;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooMap;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-public class ObjyPackageHandler
-{
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyPackageHandler.class);
-
- private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyPackageHandler.class);
-
- protected ooId packageMapId;
-
- private boolean zipped = true;
-
- public ObjyPackageHandler(String repositoryName)
- {
- // this.store = store;
- packageMapId = ObjyDb.getOrCreatePackageMap(repositoryName);
- }
-
- /***
- * Factory method to create the PackageMap, which is an ooMap
- */
- public static ooId create(ooId scopeContOid)
- {
- ooMap map = new ooMap();
- ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
- clusterObject.cluster(map);
- return map.getOid();
- }
-
- public void writePackages(CDOPackageRegistry packageRegistry, InternalCDOPackageUnit packageUnit, OMMonitor monitor)
- {
- try
- {
- ooMap packageMap = getMap();
-
- SmartLock.lock(packageMap.getContainer());
- InternalCDOPackageInfo[] packageInfos = packageUnit.getPackageInfos();
- monitor.begin(1 + packageInfos.length);
-
- if (TRACER_INFO.isEnabled())
- {
- TRACER_INFO.format("Writing package unit: {0}", packageUnit); //$NON-NLS-1$
- }
-
- byte[] ePackageAsBytes = getEPackageBytes(packageRegistry, packageUnit);
-
- ObjyPackageUnit objyPackageUnit = new ObjyPackageUnit(ePackageAsBytes.length);
- packageMap.cluster(objyPackageUnit);
-
- objyPackageUnit.setId(packageUnit.getID());
- objyPackageUnit.setOrdinal(packageUnit.getOriginalType().ordinal());
- objyPackageUnit.setTimeStamp(packageUnit.getTimeStamp());
- objyPackageUnit.setPackageAsBytes(ePackageAsBytes);
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("... writing ObjyPackageUnit.getId(): " + objyPackageUnit.getId());
- }
-
- ObjyPackageInfo objyPackageInfo;
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- objyPackageInfo = createPackageInfo(packageInfo, monitor); // Don't fork monitor
- objyPackageUnit.addPackageInfo(objyPackageInfo);
- // make sure we have the mapping between the Package name an the nsURI
- // set mapping between package name and the nsURI
- // getStore().addPackageMapping(packageInfo.getPackageURI(), ooPackageInfo.getPackageName());
- // getStore().addPackageMapping(ooPackageInfo.getPackageName(), packageInfo.getPackageURI());
- String objyPackageName = ObjySchema.getObjyPackageName(packageInfo.getPackageURI());
- ObjySchema.setPackageNameMapping(packageInfo.getPackageURI(), objyPackageName);
- ObjySchema.setPackageNameMapping(objyPackageName, packageInfo.getPackageURI());
-
- // we might as well create the schema in Objy, although I`m not sure if we needed for the ecore pacakge.
- EPackage ePackage = packageInfo.getEPackage();
- ObjySchema.registerEPackage(ePackage);
- }
-
- // add the package unit to the map.
- packageMap.add(objyPackageUnit, objyPackageUnit.getId());
- }
- finally
- {
- monitor.done();
- }
- }
-
- private ObjyPackageInfo createPackageInfo(InternalCDOPackageInfo packageInfo, OMMonitor monitor)
- {
- if (TRACER_INFO.isEnabled())
- {
- TRACER_INFO.format("Writing package info: {0}", packageInfo); //$NON-NLS-1$
- }
-
- ObjyPackageInfo ooPackageInfo = new ObjyPackageInfo();
- ooPackageInfo.setPackageURI(packageInfo.getPackageURI());
- ooPackageInfo.setParentURI(packageInfo.getParentURI());
- ooPackageInfo.setUnitID(packageInfo.getPackageUnit().getID());
- ooPackageInfo.setPackageName(packageInfo.getEPackage().getName());
-
- return ooPackageInfo;
- }
-
- private byte[] getEPackageBytes(CDOPackageRegistry packageRegistry, InternalCDOPackageUnit packageUnit)
- {
- EPackage ePackage = packageUnit.getTopLevelPackageInfo().getEPackage();
- return EMFUtil.getEPackageBytes(ePackage, zipped, packageRegistry);
- }
-
- public Collection<InternalCDOPackageUnit> readPackageUnits()
- {
- final Map<ObjyPackageUnit, InternalCDOPackageUnit> packageUnitsMap = new HashMap<ObjyPackageUnit, InternalCDOPackageUnit>();
-
- ooMap packageMap = getMap();
-
- Iterator<?> itr = packageMap.elements();
- while (itr.hasNext())
- {
- ObjyPackageUnit objyPackageUnit = (ObjyPackageUnit)itr.next();
- InternalCDOPackageUnit packageUnit = createPackageUnit();
- packageUnit.setOriginalType(CDOPackageUnit.Type.values()[objyPackageUnit.getOrdinal()]);
- packageUnit.setTimeStamp(objyPackageUnit.getTimeStamp());
- packageUnitsMap.put(objyPackageUnit, packageUnit);
- if (TRACER_INFO.isEnabled())
- {
- TRACER_INFO.format("Read package unit: {0}", packageUnit); //$NON-NLS-1$
- }
- }
-
- // create the package infos from the units.
- for (Entry<ObjyPackageUnit, InternalCDOPackageUnit> entry : packageUnitsMap.entrySet())
- {
- // scan the relationship.
- List<ObjyPackageInfo> objyPackageInfoList = entry.getKey().getPackageInfos();
- List<InternalCDOPackageInfo> packageInfoList = new ArrayList<InternalCDOPackageInfo>();
- // create the package infos.
- for (ObjyPackageInfo objyPackageInfo : objyPackageInfoList)
- {
- InternalCDOPackageInfo packageInfo = createPackageInfo(objyPackageInfo);
- packageInfoList.add(packageInfo);
- // set mapping between package URI and the package name used in Objy Schema.
- // getStore().addPackageMapping(packageInfo.getPackageURI(), ooPackageInfo.getPackageName());
- // getStore().addPackageMapping(ooPackageInfo.getPackageName(), packageInfo.getPackageURI());
- String objyPackageName = ObjySchema.getObjyPackageName(packageInfo.getPackageURI());
- ObjySchema.setPackageNameMapping(packageInfo.getPackageURI(), objyPackageName);
- ObjySchema.setPackageNameMapping(objyPackageName, packageInfo.getPackageURI());
- }
- // add the package infos to the unit.
- InternalCDOPackageInfo[] array = packageInfoList.toArray(new InternalCDOPackageInfo[packageInfoList.size()]);
- entry.getValue().setPackageInfos(array);
- }
-
- return packageUnitsMap.values();
- }
-
- protected InternalCDOPackageUnit createPackageUnit()
- {
- return (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit();
- }
-
- protected InternalCDOPackageInfo createPackageInfo()
- {
- return (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo();
- }
-
- private InternalCDOPackageInfo createPackageInfo(ObjyPackageInfo ooPackageInfo)
- {
- if (TRACER_INFO.isEnabled())
- {
- TRACER_INFO.format("create package info: {0}", ooPackageInfo); //$NON-NLS-1$
- }
-
- InternalCDOPackageInfo packageInfo = createPackageInfo();
-
- packageInfo.setPackageURI(ooPackageInfo.getPackageURI());
- packageInfo.setParentURI(ooPackageInfo.getParentURI());
- // TODO - do we need this!!!! setUnitID(packageInfo.getPackageUnit().getID());
-
- return packageInfo;
- }
-
- public byte[] readPackageBytes(InternalCDOPackageUnit packageUnit)
- {
- byte[] bytes = null;
-
- ooMap map = getMap();
- String packageUnitId = packageUnit.getID();
- if (TRACER_INFO.isEnabled())
- {
- TRACER_INFO.format("Looking for package unit with ID: {0}", packageUnitId); //$NON-NLS-1$
- }
- if (map.isMember(packageUnitId))
- {
- if (TRACER_INFO.isEnabled())
- {
- TRACER_INFO.format("Reading package unit with ID: {0}", packageUnitId); //$NON-NLS-1$
- }
- ObjyPackageUnit objyPackageUnit = (ObjyPackageUnit)map.lookup(packageUnitId);
- // this is our package...
- bytes = objyPackageUnit.getPackageAsBytes();
- }
- return bytes;
- }
-
- /***
- * This function assume we are in an Objy transaction.
- */
- private ooMap getMap()
- {
- ooMap map = null;
- map = (ooMap)Session.getCurrent().getFD().objectFrom(packageMapId);
- return map;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.common.model.CDOModelUtil;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageInfo;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageUnit;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.SmartLock;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
+
+import org.eclipse.net4j.util.om.monitor.OMMonitor;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EPackage;
+
+import com.objy.db.app.Session;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooMap;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+public class ObjyPackageHandler
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyPackageHandler.class);
+
+ private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyPackageHandler.class);
+
+ protected ooId packageMapId;
+
+ private boolean zipped = true;
+
+ public ObjyPackageHandler(String repositoryName)
+ {
+ // this.store = store;
+ packageMapId = ObjyDb.getOrCreatePackageMap(repositoryName);
+ }
+
+ /***
+ * Factory method to create the PackageMap, which is an ooMap
+ */
+ public static ooId create(ooId scopeContOid)
+ {
+ ooMap map = new ooMap();
+ ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
+ clusterObject.cluster(map);
+ return map.getOid();
+ }
+
+ public void writePackages(CDOPackageRegistry packageRegistry, InternalCDOPackageUnit packageUnit, OMMonitor monitor)
+ {
+ try
+ {
+ ooMap packageMap = getMap();
+
+ SmartLock.lock(packageMap.getContainer());
+ InternalCDOPackageInfo[] packageInfos = packageUnit.getPackageInfos();
+ monitor.begin(1 + packageInfos.length);
+
+ if (TRACER_INFO.isEnabled())
+ {
+ TRACER_INFO.format("Writing package unit: {0}", packageUnit); //$NON-NLS-1$
+ }
+
+ byte[] ePackageAsBytes = getEPackageBytes(packageRegistry, packageUnit);
+
+ ObjyPackageUnit objyPackageUnit = new ObjyPackageUnit(ePackageAsBytes.length);
+ packageMap.cluster(objyPackageUnit);
+
+ objyPackageUnit.setId(packageUnit.getID());
+ objyPackageUnit.setOrdinal(packageUnit.getOriginalType().ordinal());
+ objyPackageUnit.setTimeStamp(packageUnit.getTimeStamp());
+ objyPackageUnit.setPackageAsBytes(ePackageAsBytes);
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("... writing ObjyPackageUnit.getId(): " + objyPackageUnit.getId());
+ }
+
+ ObjyPackageInfo objyPackageInfo;
+ for (InternalCDOPackageInfo packageInfo : packageInfos)
+ {
+ objyPackageInfo = createPackageInfo(packageInfo, monitor); // Don't fork monitor
+ objyPackageUnit.addPackageInfo(objyPackageInfo);
+ // make sure we have the mapping between the Package name an the nsURI
+ // set mapping between package name and the nsURI
+ // getStore().addPackageMapping(packageInfo.getPackageURI(), ooPackageInfo.getPackageName());
+ // getStore().addPackageMapping(ooPackageInfo.getPackageName(), packageInfo.getPackageURI());
+ String objyPackageName = ObjySchema.getObjyPackageName(packageInfo.getPackageURI());
+ ObjySchema.setPackageNameMapping(packageInfo.getPackageURI(), objyPackageName);
+ ObjySchema.setPackageNameMapping(objyPackageName, packageInfo.getPackageURI());
+
+ // we might as well create the schema in Objy, although I`m not sure if we needed for the ecore pacakge.
+ EPackage ePackage = packageInfo.getEPackage();
+ ObjySchema.registerEPackage(ePackage);
+ }
+
+ // add the package unit to the map.
+ packageMap.add(objyPackageUnit, objyPackageUnit.getId());
+ }
+ finally
+ {
+ monitor.done();
+ }
+ }
+
+ private ObjyPackageInfo createPackageInfo(InternalCDOPackageInfo packageInfo, OMMonitor monitor)
+ {
+ if (TRACER_INFO.isEnabled())
+ {
+ TRACER_INFO.format("Writing package info: {0}", packageInfo); //$NON-NLS-1$
+ }
+
+ ObjyPackageInfo ooPackageInfo = new ObjyPackageInfo();
+ ooPackageInfo.setPackageURI(packageInfo.getPackageURI());
+ ooPackageInfo.setParentURI(packageInfo.getParentURI());
+ ooPackageInfo.setUnitID(packageInfo.getPackageUnit().getID());
+ ooPackageInfo.setPackageName(packageInfo.getEPackage().getName());
+
+ return ooPackageInfo;
+ }
+
+ private byte[] getEPackageBytes(CDOPackageRegistry packageRegistry, InternalCDOPackageUnit packageUnit)
+ {
+ EPackage ePackage = packageUnit.getTopLevelPackageInfo().getEPackage();
+ return EMFUtil.getEPackageBytes(ePackage, zipped, packageRegistry);
+ }
+
+ public Collection<InternalCDOPackageUnit> readPackageUnits()
+ {
+ final Map<ObjyPackageUnit, InternalCDOPackageUnit> packageUnitsMap = new HashMap<ObjyPackageUnit, InternalCDOPackageUnit>();
+
+ ooMap packageMap = getMap();
+
+ Iterator<?> itr = packageMap.elements();
+ while (itr.hasNext())
+ {
+ ObjyPackageUnit objyPackageUnit = (ObjyPackageUnit)itr.next();
+ InternalCDOPackageUnit packageUnit = createPackageUnit();
+ packageUnit.setOriginalType(CDOPackageUnit.Type.values()[objyPackageUnit.getOrdinal()]);
+ packageUnit.setTimeStamp(objyPackageUnit.getTimeStamp());
+ packageUnitsMap.put(objyPackageUnit, packageUnit);
+ if (TRACER_INFO.isEnabled())
+ {
+ TRACER_INFO.format("Read package unit: {0}", packageUnit); //$NON-NLS-1$
+ }
+ }
+
+ // create the package infos from the units.
+ for (Entry<ObjyPackageUnit, InternalCDOPackageUnit> entry : packageUnitsMap.entrySet())
+ {
+ // scan the relationship.
+ List<ObjyPackageInfo> objyPackageInfoList = entry.getKey().getPackageInfos();
+ List<InternalCDOPackageInfo> packageInfoList = new ArrayList<InternalCDOPackageInfo>();
+ // create the package infos.
+ for (ObjyPackageInfo objyPackageInfo : objyPackageInfoList)
+ {
+ InternalCDOPackageInfo packageInfo = createPackageInfo(objyPackageInfo);
+ packageInfoList.add(packageInfo);
+ // set mapping between package URI and the package name used in Objy Schema.
+ // getStore().addPackageMapping(packageInfo.getPackageURI(), ooPackageInfo.getPackageName());
+ // getStore().addPackageMapping(ooPackageInfo.getPackageName(), packageInfo.getPackageURI());
+ String objyPackageName = ObjySchema.getObjyPackageName(packageInfo.getPackageURI());
+ ObjySchema.setPackageNameMapping(packageInfo.getPackageURI(), objyPackageName);
+ ObjySchema.setPackageNameMapping(objyPackageName, packageInfo.getPackageURI());
+ }
+ // add the package infos to the unit.
+ InternalCDOPackageInfo[] array = packageInfoList.toArray(new InternalCDOPackageInfo[packageInfoList.size()]);
+ entry.getValue().setPackageInfos(array);
+ }
+
+ return packageUnitsMap.values();
+ }
+
+ protected InternalCDOPackageUnit createPackageUnit()
+ {
+ return (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit();
+ }
+
+ protected InternalCDOPackageInfo createPackageInfo()
+ {
+ return (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo();
+ }
+
+ private InternalCDOPackageInfo createPackageInfo(ObjyPackageInfo ooPackageInfo)
+ {
+ if (TRACER_INFO.isEnabled())
+ {
+ TRACER_INFO.format("create package info: {0}", ooPackageInfo); //$NON-NLS-1$
+ }
+
+ InternalCDOPackageInfo packageInfo = createPackageInfo();
+
+ packageInfo.setPackageURI(ooPackageInfo.getPackageURI());
+ packageInfo.setParentURI(ooPackageInfo.getParentURI());
+ // TODO - do we need this!!!! setUnitID(packageInfo.getPackageUnit().getID());
+
+ return packageInfo;
+ }
+
+ public byte[] readPackageBytes(InternalCDOPackageUnit packageUnit)
+ {
+ byte[] bytes = null;
+
+ ooMap map = getMap();
+ String packageUnitId = packageUnit.getID();
+ if (TRACER_INFO.isEnabled())
+ {
+ TRACER_INFO.format("Looking for package unit with ID: {0}", packageUnitId); //$NON-NLS-1$
+ }
+ if (map.isMember(packageUnitId))
+ {
+ if (TRACER_INFO.isEnabled())
+ {
+ TRACER_INFO.format("Reading package unit with ID: {0}", packageUnitId); //$NON-NLS-1$
+ }
+ ObjyPackageUnit objyPackageUnit = (ObjyPackageUnit)map.lookup(packageUnitId);
+ // this is our package...
+ bytes = objyPackageUnit.getPackageAsBytes();
+ }
+ return bytes;
+ }
+
+ /***
+ * This function assume we are in an Objy transaction.
+ */
+ private ooMap getMap()
+ {
+ ooMap map = null;
+ map = (ooMap)Session.getCurrent().getFD().objectFrom(packageMapId);
+ return map;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPropertyMapHandler.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPropertyMapHandler.java
index 66374f64e5..33bbedf361 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPropertyMapHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyPropertyMapHandler.java
@@ -1,126 +1,126 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProperty;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
-
-import com.objy.db.app.Session;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooMap;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-public class ObjyPropertyMapHandler
-{
- protected ooId propertyMapId;
-
- public ObjyPropertyMapHandler(String repositoryName)
- {
- propertyMapId = ObjyDb.getOrCreatePropertyMap(repositoryName);
- }
-
- /***
- * Factory method to create the PropertyMap, which is an ooMap
- */
- public static ooId create(ooId scopeContOid)
- {
- ooMap map = new ooMap();
- ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
- clusterObject.cluster(map);
- return map.getOid();
- }
-
- /***
- * This function assume we are in an Objy trnasaction.
- */
- public void setPropertyValues(Map<String, String> properties)
- {
- // get the map.
- ooMap propertyMap = getMap();
- String key = null;
- String value = null;
- ObjyProperty property = null;
- for (Entry<String, String> entry : properties.entrySet())
- {
- key = entry.getKey();
- value = entry.getValue();
-
- // check if we have the property
- if (propertyMap.isMember(key))
- {
- property = (ObjyProperty)propertyMap.lookup(key);
- property.setValue(value);
- }
- else
- {
- property = new ObjyProperty(key, value);
- propertyMap.add(property, key);
- }
- }
- }
-
- /***
- * This function assume we are in an Objy trnasaction.
- */
- public void removePropertyValues(Set<String> names)
- {
- // get the map.
- ooMap propertyMap = getMap();
- ObjyProperty property = null;
- for (String key : names)
- {
- if (propertyMap.isMember(key))
- {
- property = (ObjyProperty)propertyMap.lookup(key);
- // although removing the object will remove it from the map
- // it's cleaner to do it explicitly.
- propertyMap.remove(key);
- property.delete();
- }
- }
- }
-
- /***
- * This function assume we are in an Objy trnasaction.
- */
- public Map<String, String> getPropertyValues(Set<String> names)
- {
- Map<String, String> properties = new HashMap<String, String>();
- // get the map.
- ooMap propertyMap = getMap();
- ObjyProperty property = null;
-
- for (String key : names)
- {
- if (propertyMap.isMember(key))
- {
- property = (ObjyProperty)propertyMap.lookup(key);
- properties.put(property.getKey(), property.getValue());
- }
- }
- return properties;
- }
-
- /***
- * This function assume we are in an Objy transaction.
- */
- private ooMap getMap()
- {
- ooMap map = null;
- map = (ooMap)Session.getCurrent().getFD().objectFrom(propertyMapId);
- return map;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProperty;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
+
+import com.objy.db.app.Session;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooMap;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+public class ObjyPropertyMapHandler
+{
+ protected ooId propertyMapId;
+
+ public ObjyPropertyMapHandler(String repositoryName)
+ {
+ propertyMapId = ObjyDb.getOrCreatePropertyMap(repositoryName);
+ }
+
+ /***
+ * Factory method to create the PropertyMap, which is an ooMap
+ */
+ public static ooId create(ooId scopeContOid)
+ {
+ ooMap map = new ooMap();
+ ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
+ clusterObject.cluster(map);
+ return map.getOid();
+ }
+
+ /***
+ * This function assume we are in an Objy trnasaction.
+ */
+ public void setPropertyValues(Map<String, String> properties)
+ {
+ // get the map.
+ ooMap propertyMap = getMap();
+ String key = null;
+ String value = null;
+ ObjyProperty property = null;
+ for (Entry<String, String> entry : properties.entrySet())
+ {
+ key = entry.getKey();
+ value = entry.getValue();
+
+ // check if we have the property
+ if (propertyMap.isMember(key))
+ {
+ property = (ObjyProperty)propertyMap.lookup(key);
+ property.setValue(value);
+ }
+ else
+ {
+ property = new ObjyProperty(key, value);
+ propertyMap.add(property, key);
+ }
+ }
+ }
+
+ /***
+ * This function assume we are in an Objy trnasaction.
+ */
+ public void removePropertyValues(Set<String> names)
+ {
+ // get the map.
+ ooMap propertyMap = getMap();
+ ObjyProperty property = null;
+ for (String key : names)
+ {
+ if (propertyMap.isMember(key))
+ {
+ property = (ObjyProperty)propertyMap.lookup(key);
+ // although removing the object will remove it from the map
+ // it's cleaner to do it explicitly.
+ propertyMap.remove(key);
+ property.delete();
+ }
+ }
+ }
+
+ /***
+ * This function assume we are in an Objy trnasaction.
+ */
+ public Map<String, String> getPropertyValues(Set<String> names)
+ {
+ Map<String, String> properties = new HashMap<String, String>();
+ // get the map.
+ ooMap propertyMap = getMap();
+ ObjyProperty property = null;
+
+ for (String key : names)
+ {
+ if (propertyMap.isMember(key))
+ {
+ property = (ObjyProperty)propertyMap.lookup(key);
+ properties.put(property.getKey(), property.getValue());
+ }
+ }
+ return properties;
+ }
+
+ /***
+ * This function assume we are in an Objy transaction.
+ */
+ private ooMap getMap()
+ {
+ ooMap map = null;
+ map = (ooMap)Session.getCurrent().getFD().objectFrom(propertyMapId);
+ return map;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySchema.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySchema.java
index 6623143fc9..5f6b9edee6 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySchema.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySchema.java
@@ -1,507 +1,507 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStore;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListId;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListString;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBase;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapArrayList;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EAttribute;
-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.EStructuralFeature;
-import org.eclipse.emf.ecore.EcorePackage;
-
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.d_Class;
-import com.objy.as.app.d_Module;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Wrapper for the AS schema code with caching of the wrapped classes. This class need to be reseted by the
- * ObjectivityStore doDeactivate().
- *
- * @author ibrahim
- */
-public class ObjySchema
-{
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjySchema.class);
-
- // static HashMap<String, d_Class> mapOfCacheClasses = new HashMap<String, d_Class>();
-
- private static HashMap<String, ObjyClass> mapOfObjyClasses = new HashMap<String, ObjyClass>();
-
- private static HashMap<String, EClass> mapOfEClasses = new HashMap<String, EClass>();
-
- private static HashMap<EClass, EClass> visitedClasses = new HashMap<EClass, EClass>();
-
- private static HashMap<EClass, EClass> visitedStructureOnlyClasses = new HashMap<EClass, EClass>();
-
- private static Map<String, String> packageNameMapping = new HashMap<String, String>();
-
- private static d_Module topModule = null;
-
- public static void resetCache()
- {
- topModule = null;
- mapOfObjyClasses.clear();
- mapOfEClasses.clear();
- visitedClasses.clear();
- visitedStructureOnlyClasses.clear();
- }
-
- public static ObjyClass getObjyClass(String name)
- {
- ObjyClass classObject = mapOfObjyClasses.get(name);
- if (classObject == null)
- {
- d_Class newClass = getTopModule().resolve_class(name);
- // EClass eClass = getEClass(store, name);
- // IS:TEMP
- if (newClass == null)
- {
- TRACER_DEBUG.trace("NULL..... dClass for " + name);
- }
- classObject = new ObjyClass(newClass);
- mapOfObjyClasses.put(name, classObject);
- }
- return classObject;
- }
-
- public static d_Module getTopModule()
- {
- if (topModule == null)
- {
- topModule = d_Module.top_level();
- }
- return topModule;
- }
-
- /**
- * Originally in EProposedManager.
- */
- static public String getObjectivityClassName(EClassifier eClassifier)
- {
- return formObjectivityClassName(eClassifier, false);
- }
-
- /**
- * Originally in EProposedManager
- */
- static String formObjectivityClassName(EClassifier eClassifier, boolean onlyStructure)
- {
- if (eClassifier == EcorePackage.eINSTANCE.getEObject())
- {
- return "ooObj";
- }
-
- // same class names might exist in different nsUri.
- String nsURI = eClassifier.getEPackage().getNsURI();
- // // get the hash string for uniqueness.
- // String nsURIHash = new Integer(Math.abs(nsURI.hashCode())).toString();
- String objyPackageName = getObjyPackageName(nsURI);
-
- if (onlyStructure)
- {
- // return "oo_" + eClassifier.getEPackage().getName() + "_" + eClassifier.getName() + "ST";
- // return "oo_" + nsURIHash + "_" + eClassifier.getEPackage().getNsPrefix() + "_" + eClassifier.getName() + "_ST";
- return objyPackageName + ":" + eClassifier.getName() + "_ST";
- }
-
- // return "oo_" + eClassifier.getEPackage().getName() + "_" + eClassifier.getName();
- // return "oo_" + nsURIHash + "_" + eClassifier.getEPackage().getNsPrefix() + "_" + eClassifier.getName();
- return objyPackageName + ":" + eClassifier.getName();
- }
-
- static public void setPackageNameMapping(String name1, String name2)
- {
- if (packageNameMapping.get(name1) == null)
- {
- packageNameMapping.put(name1, name2);
- }
- }
-
- static public String getPackageNameMapping(String key)
- {
- return packageNameMapping.get(key);
- }
-
- /**
- * Originally in EProposedManager
- *
- * @param ePackage
- */
- static public void registerEPackage(EPackage ePackage)
- {
- for (EClassifier eClass : ePackage.getEClassifiers())
- {
- if (eClass instanceof EClass)
- {
- getOrCreate(eClass.eClass());
- }
- }
- }
-
- /**
- * @param eClass
- * @return ObjyClass
- */
- static public ObjyClass getOrCreate(EClass eClass)
- {
- String className = getObjectivityClassName(eClass);
-
- ObjyClass objyClass = mapOfObjyClasses.get(className);
-
- if (objyClass != null)
- {
- return objyClass;
- }
-
- // create the ObjyClass and hash it.
- synchronized (getTopModule())
- {
- // System.out.println("OBJY: finding class '" + className + "' in objy schema.");
- d_Class dClass = getTopModule().resolve_class(className);
- // System.out.println("OBJY:... got d_Class:" + dClass);
-
- // TODO - evolving classes is partially implemented, only adding attributes is
- // supported.
- if (dClass == null)
- {
- objyClass = createObjyClass(eClass);
- }
- else if (!isSameClass(dClass, eClass))
- {
- objyClass = evolveObjyClass(eClass);
- }
- else
- {
- objyClass = new ObjyClass(dClass/* , eClass */);
- }
-
- if (objyClass == null)
- {
- throw new RuntimeException("Cannot retrieved " + eClass.getName() + " class from Objy schema as:" + className);
- }
- String asClassName = objyClass.getASClassName();
- mapOfObjyClasses.put(asClassName, objyClass);
- mapOfEClasses.put(asClassName, eClass);
- }
-
- return objyClass;
- }
-
- /**
- * @param eClass
- * @return
- */
- private static ObjyClass createObjyClass(EClass eClass)
- {
- try
- {
-
- String className = getObjectivityClassName(eClass);
-
- // System.out.println("OBJY: calling createObjyClassSchema for class: " + className);
- createObjyClassSchema(eClass, false);
-
- getTopModule().activate_proposals(true, true);
- // getTopModule().activate_proposals(true);
-
- // System.out.println("OBJY: resolving class '" + className + "' in objy schema.");
- d_Class dClass = getTopModule().resolve_class(className);
- // IS:TEMP
- if (dClass == null)
- {
- TRACER_DEBUG.trace("NULL..... dClass for " + className);
- }
-
- ObjyClass objyClass = new ObjyClass(dClass/* , eClass */);
- return objyClass;
- }
- catch (Throwable throwable)
- {
- throwable.printStackTrace();
- }
- return null;
- }
-
- public static ObjyClass evolveObjyClass(EClass eClass)
- {
- try
- {
-
- String className = getObjectivityClassName(eClass);
-
- evolveObjyClassSchema(eClass, false);
-
- getTopModule().activate_proposals(true, true);
- // getTopModule().activate_proposals(true);
-
- // System.out.println("OBJY: resolving class '" + className + "' in objy schema.");
- d_Class dClass = getTopModule().resolve_class(className);
- // IS:TEMP.
- if (dClass == null)
- {
- TRACER_DEBUG.trace("NULL..... dClass for " + className);
- }
- ObjyClass objyClass = new ObjyClass(dClass/* , eClass */);
- return objyClass;
- }
- catch (Throwable throwable)
- {
- throwable.printStackTrace();
- }
- return null;
- }
-
- /**
- * This function creates the schema in Objectivity, if the class is being proposed or already exist no action is
- * happening.
- */
- static void createObjyClassSchema(EClass eClass, boolean onlyStructure)
- {
- HashMap<EClass, EClass> hashMap = onlyStructure ? visitedStructureOnlyClasses : visitedClasses;
- if (hashMap.containsKey(eClass))
- {
- return;
- }
-
- hashMap.put(eClass, eClass);
- String className = formObjectivityClassName(eClass, onlyStructure);
- d_Class dClass = getTopModule().resolve_class(className);
-
- if (dClass != null)
- {
- return;
- }
-
- // check if the class has been proposed before
- if (getTopModule().resolve_proposed_class(className) == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Creating new class: " + className);
- }
-
- // start schema creation.
- // System.out.println("OBJY: starting schema creation for class: " + className);
- ObjyClassProposed proposedClass = new ObjyClassProposed(getTopModule(), eClass, onlyStructure);
- proposedClass.propose();
- }
- }
-
- /**
- * @param eClass
- * @param itrOnlyStructure
- */
- static void evolveObjyClassSchema(EClass eClass, boolean onlyStructure)
- {
- String className = formObjectivityClassName(eClass, onlyStructure);
-
- // check if the class has been proposed before
- if (getTopModule().resolve_proposed_class(className) == null)
- {
- d_Class dClass = getTopModule().resolve_class(className);
-
- TRACER_DEBUG.trace("Evolving class: " + className);
-
- // start schema evolution.
- // System.out.println("OBJY: starting schema creation for class: " + className);
- ObjyClassProposed proposedClass = new ObjyClassProposed(getTopModule(), eClass, onlyStructure);
- proposedClass.evolve(dClass);
- }
- }
-
- // From EProposedManager...
- // For now check only the name of the attribute
- // It only check from EMF to Objectivity... not the reverse
- // TODO - see if we can do full cycle schema changes.
- static boolean isSameClass(d_Class dClass, EClass eClass)
- {
- // Look at the hierarchy
- for (EClass superType : eClass.getESuperTypes())
- {
- getOrCreate(superType);
- }
-
- for (EStructuralFeature feature : eClass.getEStructuralFeatures())
- {
- if (!(feature instanceof EAttribute || feature instanceof EReference))
- {
- continue;
- }
- ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
- if (mapper == null)
- {
- continue;
- }
-
- // identify any missing attribute.
- d_Attribute dAttr = dClass.resolve_attribute(feature.getName());
- if (dAttr == null)
- {
- return false;
- }
- /****
- * TODO - actiavte this code, once ITypeMapper.validate() is implemented. ITypeMapper attributeMapper =
- * ObjyMapper.INSTANCE.getTypeMapper(feature); if (attributeMapper.validate(dAttr, feature) == false) { if
- * (TRACER_DEBUG.isEnabled()) { TRACER_DEBUG.trace("Feature " + feature.getName() + " for object " +
- * eClass.getName() + " changed "); } attributeMapper.validate(dAttr, feature); return false; }
- ****/
- }
- return true;
- }
-
- // /**
- // * From EProposedManager.
- // */
- // void ensureEClassExist(EClass eClass, boolean onlyStructure)
- // {
- // HashMap<EClass, EClass> hashMap = onlyStructure ? visitedStructureOnlyClass : visitedClass;
- // if (hashMap.containsKey(eClass))
- // {
- // return;
- // }
- //
- // hashMap.put(eClass, eClass);
- // String nameClass = getObjectivityClassName(eClass, onlyStructure);
- // d_Class ooClass = getTopModule().resolve_class(nameClass);
- //
- // if (ooClass != null && isSameClass(ooClass, eClass))
- // {
- // return;
- // }
- //
- // if (module.resolve_proposed_class(nameClass) == null)
- // {
- // EProposedClass proposedClass = new EProposedClass(module, eClass, onlyStructure);
- // proposedClass.propose(this, ooClass);
- // }
- // }
-
- // /**
- // * From EProposedManager.
- // */
- // void ensureEClassExist(EClass eClass)
- // {
- // ensureEClassExist(eClass, false);
- // }
-
- public static EClass getEClass(ObjectivityStore store, ObjyClass objyClass)
- {
- String className = objyClass.getASClassName();
- return getEClass(store, className);
- }
-
- public static EClass getEClass(ObjectivityStore store, String className)
- {
- // String className = objyObject.getASClass().name();
- // System.out.println("OBJY: getEClass(store, " + className +")");
- EClass eClass = mapOfEClasses.get(className);
- if (eClass == null)
- {
- // the format is "<some_URI_name_used_as_package_name>:className"
- String[] splits = className.split(":");
- // get the mapping to the nsURI.
- CDOPackageRegistry registry = store.getRepository().getPackageRegistry();
- String nsURI = getPackageNameMapping(splits[0]);
- EPackage packageObject = registry.getEPackage(nsURI);
-
- if (packageObject == null)
- {
- throw new RuntimeException("Package not found " + splits[1] + " for class name " + className);
- }
- eClass = (EClass)packageObject.getEClassifier(splits[splits.length - 1]);
- mapOfEClasses.put(className, eClass);
- }
- // else
- // {
- // System.out.println("***OBJY: getEClass(cached): " + eClass);
- // }
- return eClass;
- }
-
- /***
- * identify if the class is of type Resource. TODO - why we need to pass the store, can't we keep the info we need for
- * the package mapping here?!!!
- */
- public static boolean isResource(ObjectivityStore store, ObjyClass objyClass)
- {
- EClass eClass = getEClass(store, objyClass);
-
- if (eClass == EresourcePackage.Literals.CDO_RESOURCE || eClass == EresourcePackage.Literals.CDO_RESOURCE_NODE
- || eClass == EresourcePackage.Literals.CDO_RESOURCE_FOLDER)
- {
- return true;
- }
-
- return false;
- }
-
- /***
- * Build initial schema for some collection classes.
- */
- public static void createBaseSchema()
- {
- ObjyArrayListId.buildSchema();
- ObjyFeatureMapArrayList.buildSchema();
- ObjyProxy.buildSchema();
- ObjyArrayListString.buildSchema();
- ObjyBase.buildSchema();
- ObjyResourceList.buildSchema();
- }
-
- public static String getObjyPackageName(String packageURI)
- {
- String name = "";
- boolean first = true;
- // parse the URI, remove "http://" and replace each "." with "_"
- String[] splits = packageURI.split("://");
- for (String strValue : splits)
- {
- if (strValue.equals("http"))
- {
- continue;
- }
- if (!first)
- {
- name = name.concat("_");
- }
- else
- {
- first = false;
- }
-
- name = name.concat(strValue);
- }
- name = name.replace("/", ".");
- name = name.replace(".", "_");
- return name;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.eresource.EresourcePackage;
+import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStore;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ObjyMapper;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListId;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListString;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBase;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapArrayList;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EAttribute;
+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.EStructuralFeature;
+import org.eclipse.emf.ecore.EcorePackage;
+
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.d_Class;
+import com.objy.as.app.d_Module;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Wrapper for the AS schema code with caching of the wrapped classes. This class need to be reseted by the
+ * ObjectivityStore doDeactivate().
+ *
+ * @author ibrahim
+ */
+public class ObjySchema
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjySchema.class);
+
+ // static HashMap<String, d_Class> mapOfCacheClasses = new HashMap<String, d_Class>();
+
+ private static HashMap<String, ObjyClass> mapOfObjyClasses = new HashMap<String, ObjyClass>();
+
+ private static HashMap<String, EClass> mapOfEClasses = new HashMap<String, EClass>();
+
+ private static HashMap<EClass, EClass> visitedClasses = new HashMap<EClass, EClass>();
+
+ private static HashMap<EClass, EClass> visitedStructureOnlyClasses = new HashMap<EClass, EClass>();
+
+ private static Map<String, String> packageNameMapping = new HashMap<String, String>();
+
+ private static d_Module topModule = null;
+
+ public static void resetCache()
+ {
+ topModule = null;
+ mapOfObjyClasses.clear();
+ mapOfEClasses.clear();
+ visitedClasses.clear();
+ visitedStructureOnlyClasses.clear();
+ }
+
+ public static ObjyClass getObjyClass(String name)
+ {
+ ObjyClass classObject = mapOfObjyClasses.get(name);
+ if (classObject == null)
+ {
+ d_Class newClass = getTopModule().resolve_class(name);
+ // EClass eClass = getEClass(store, name);
+ // IS:TEMP
+ if (newClass == null)
+ {
+ TRACER_DEBUG.trace("NULL..... dClass for " + name);
+ }
+ classObject = new ObjyClass(newClass);
+ mapOfObjyClasses.put(name, classObject);
+ }
+ return classObject;
+ }
+
+ public static d_Module getTopModule()
+ {
+ if (topModule == null)
+ {
+ topModule = d_Module.top_level();
+ }
+ return topModule;
+ }
+
+ /**
+ * Originally in EProposedManager.
+ */
+ static public String getObjectivityClassName(EClassifier eClassifier)
+ {
+ return formObjectivityClassName(eClassifier, false);
+ }
+
+ /**
+ * Originally in EProposedManager
+ */
+ static String formObjectivityClassName(EClassifier eClassifier, boolean onlyStructure)
+ {
+ if (eClassifier == EcorePackage.eINSTANCE.getEObject())
+ {
+ return "ooObj";
+ }
+
+ // same class names might exist in different nsUri.
+ String nsURI = eClassifier.getEPackage().getNsURI();
+ // // get the hash string for uniqueness.
+ // String nsURIHash = new Integer(Math.abs(nsURI.hashCode())).toString();
+ String objyPackageName = getObjyPackageName(nsURI);
+
+ if (onlyStructure)
+ {
+ // return "oo_" + eClassifier.getEPackage().getName() + "_" + eClassifier.getName() + "ST";
+ // return "oo_" + nsURIHash + "_" + eClassifier.getEPackage().getNsPrefix() + "_" + eClassifier.getName() + "_ST";
+ return objyPackageName + ":" + eClassifier.getName() + "_ST";
+ }
+
+ // return "oo_" + eClassifier.getEPackage().getName() + "_" + eClassifier.getName();
+ // return "oo_" + nsURIHash + "_" + eClassifier.getEPackage().getNsPrefix() + "_" + eClassifier.getName();
+ return objyPackageName + ":" + eClassifier.getName();
+ }
+
+ static public void setPackageNameMapping(String name1, String name2)
+ {
+ if (packageNameMapping.get(name1) == null)
+ {
+ packageNameMapping.put(name1, name2);
+ }
+ }
+
+ static public String getPackageNameMapping(String key)
+ {
+ return packageNameMapping.get(key);
+ }
+
+ /**
+ * Originally in EProposedManager
+ *
+ * @param ePackage
+ */
+ static public void registerEPackage(EPackage ePackage)
+ {
+ for (EClassifier eClass : ePackage.getEClassifiers())
+ {
+ if (eClass instanceof EClass)
+ {
+ getOrCreate(eClass.eClass());
+ }
+ }
+ }
+
+ /**
+ * @param eClass
+ * @return ObjyClass
+ */
+ static public ObjyClass getOrCreate(EClass eClass)
+ {
+ String className = getObjectivityClassName(eClass);
+
+ ObjyClass objyClass = mapOfObjyClasses.get(className);
+
+ if (objyClass != null)
+ {
+ return objyClass;
+ }
+
+ // create the ObjyClass and hash it.
+ synchronized (getTopModule())
+ {
+ // System.out.println("OBJY: finding class '" + className + "' in objy schema.");
+ d_Class dClass = getTopModule().resolve_class(className);
+ // System.out.println("OBJY:... got d_Class:" + dClass);
+
+ // TODO - evolving classes is partially implemented, only adding attributes is
+ // supported.
+ if (dClass == null)
+ {
+ objyClass = createObjyClass(eClass);
+ }
+ else if (!isSameClass(dClass, eClass))
+ {
+ objyClass = evolveObjyClass(eClass);
+ }
+ else
+ {
+ objyClass = new ObjyClass(dClass/* , eClass */);
+ }
+
+ if (objyClass == null)
+ {
+ throw new RuntimeException("Cannot retrieved " + eClass.getName() + " class from Objy schema as:" + className);
+ }
+ String asClassName = objyClass.getASClassName();
+ mapOfObjyClasses.put(asClassName, objyClass);
+ mapOfEClasses.put(asClassName, eClass);
+ }
+
+ return objyClass;
+ }
+
+ /**
+ * @param eClass
+ * @return
+ */
+ private static ObjyClass createObjyClass(EClass eClass)
+ {
+ try
+ {
+
+ String className = getObjectivityClassName(eClass);
+
+ // System.out.println("OBJY: calling createObjyClassSchema for class: " + className);
+ createObjyClassSchema(eClass, false);
+
+ getTopModule().activate_proposals(true, true);
+ // getTopModule().activate_proposals(true);
+
+ // System.out.println("OBJY: resolving class '" + className + "' in objy schema.");
+ d_Class dClass = getTopModule().resolve_class(className);
+ // IS:TEMP
+ if (dClass == null)
+ {
+ TRACER_DEBUG.trace("NULL..... dClass for " + className);
+ }
+
+ ObjyClass objyClass = new ObjyClass(dClass/* , eClass */);
+ return objyClass;
+ }
+ catch (Throwable throwable)
+ {
+ throwable.printStackTrace();
+ }
+ return null;
+ }
+
+ public static ObjyClass evolveObjyClass(EClass eClass)
+ {
+ try
+ {
+
+ String className = getObjectivityClassName(eClass);
+
+ evolveObjyClassSchema(eClass, false);
+
+ getTopModule().activate_proposals(true, true);
+ // getTopModule().activate_proposals(true);
+
+ // System.out.println("OBJY: resolving class '" + className + "' in objy schema.");
+ d_Class dClass = getTopModule().resolve_class(className);
+ // IS:TEMP.
+ if (dClass == null)
+ {
+ TRACER_DEBUG.trace("NULL..... dClass for " + className);
+ }
+ ObjyClass objyClass = new ObjyClass(dClass/* , eClass */);
+ return objyClass;
+ }
+ catch (Throwable throwable)
+ {
+ throwable.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * This function creates the schema in Objectivity, if the class is being proposed or already exist no action is
+ * happening.
+ */
+ static void createObjyClassSchema(EClass eClass, boolean onlyStructure)
+ {
+ HashMap<EClass, EClass> hashMap = onlyStructure ? visitedStructureOnlyClasses : visitedClasses;
+ if (hashMap.containsKey(eClass))
+ {
+ return;
+ }
+
+ hashMap.put(eClass, eClass);
+ String className = formObjectivityClassName(eClass, onlyStructure);
+ d_Class dClass = getTopModule().resolve_class(className);
+
+ if (dClass != null)
+ {
+ return;
+ }
+
+ // check if the class has been proposed before
+ if (getTopModule().resolve_proposed_class(className) == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Creating new class: " + className);
+ }
+
+ // start schema creation.
+ // System.out.println("OBJY: starting schema creation for class: " + className);
+ ObjyClassProposed proposedClass = new ObjyClassProposed(getTopModule(), eClass, onlyStructure);
+ proposedClass.propose();
+ }
+ }
+
+ /**
+ * @param eClass
+ * @param itrOnlyStructure
+ */
+ static void evolveObjyClassSchema(EClass eClass, boolean onlyStructure)
+ {
+ String className = formObjectivityClassName(eClass, onlyStructure);
+
+ // check if the class has been proposed before
+ if (getTopModule().resolve_proposed_class(className) == null)
+ {
+ d_Class dClass = getTopModule().resolve_class(className);
+
+ TRACER_DEBUG.trace("Evolving class: " + className);
+
+ // start schema evolution.
+ // System.out.println("OBJY: starting schema creation for class: " + className);
+ ObjyClassProposed proposedClass = new ObjyClassProposed(getTopModule(), eClass, onlyStructure);
+ proposedClass.evolve(dClass);
+ }
+ }
+
+ // From EProposedManager...
+ // For now check only the name of the attribute
+ // It only check from EMF to Objectivity... not the reverse
+ // TODO - see if we can do full cycle schema changes.
+ static boolean isSameClass(d_Class dClass, EClass eClass)
+ {
+ // Look at the hierarchy
+ for (EClass superType : eClass.getESuperTypes())
+ {
+ getOrCreate(superType);
+ }
+
+ for (EStructuralFeature feature : eClass.getEStructuralFeatures())
+ {
+ if (!(feature instanceof EAttribute || feature instanceof EReference))
+ {
+ continue;
+ }
+ ITypeMapper mapper = ObjyMapper.INSTANCE.getTypeMapper(feature);
+ if (mapper == null)
+ {
+ continue;
+ }
+
+ // identify any missing attribute.
+ d_Attribute dAttr = dClass.resolve_attribute(feature.getName());
+ if (dAttr == null)
+ {
+ return false;
+ }
+ /****
+ * TODO - actiavte this code, once ITypeMapper.validate() is implemented. ITypeMapper attributeMapper =
+ * ObjyMapper.INSTANCE.getTypeMapper(feature); if (attributeMapper.validate(dAttr, feature) == false) { if
+ * (TRACER_DEBUG.isEnabled()) { TRACER_DEBUG.trace("Feature " + feature.getName() + " for object " +
+ * eClass.getName() + " changed "); } attributeMapper.validate(dAttr, feature); return false; }
+ ****/
+ }
+ return true;
+ }
+
+ // /**
+ // * From EProposedManager.
+ // */
+ // void ensureEClassExist(EClass eClass, boolean onlyStructure)
+ // {
+ // HashMap<EClass, EClass> hashMap = onlyStructure ? visitedStructureOnlyClass : visitedClass;
+ // if (hashMap.containsKey(eClass))
+ // {
+ // return;
+ // }
+ //
+ // hashMap.put(eClass, eClass);
+ // String nameClass = getObjectivityClassName(eClass, onlyStructure);
+ // d_Class ooClass = getTopModule().resolve_class(nameClass);
+ //
+ // if (ooClass != null && isSameClass(ooClass, eClass))
+ // {
+ // return;
+ // }
+ //
+ // if (module.resolve_proposed_class(nameClass) == null)
+ // {
+ // EProposedClass proposedClass = new EProposedClass(module, eClass, onlyStructure);
+ // proposedClass.propose(this, ooClass);
+ // }
+ // }
+
+ // /**
+ // * From EProposedManager.
+ // */
+ // void ensureEClassExist(EClass eClass)
+ // {
+ // ensureEClassExist(eClass, false);
+ // }
+
+ public static EClass getEClass(ObjectivityStore store, ObjyClass objyClass)
+ {
+ String className = objyClass.getASClassName();
+ return getEClass(store, className);
+ }
+
+ public static EClass getEClass(ObjectivityStore store, String className)
+ {
+ // String className = objyObject.getASClass().name();
+ // System.out.println("OBJY: getEClass(store, " + className +")");
+ EClass eClass = mapOfEClasses.get(className);
+ if (eClass == null)
+ {
+ // the format is "<some_URI_name_used_as_package_name>:className"
+ String[] splits = className.split(":");
+ // get the mapping to the nsURI.
+ CDOPackageRegistry registry = store.getRepository().getPackageRegistry();
+ String nsURI = getPackageNameMapping(splits[0]);
+ EPackage packageObject = registry.getEPackage(nsURI);
+
+ if (packageObject == null)
+ {
+ throw new RuntimeException("Package not found " + splits[1] + " for class name " + className);
+ }
+ eClass = (EClass)packageObject.getEClassifier(splits[splits.length - 1]);
+ mapOfEClasses.put(className, eClass);
+ }
+ // else
+ // {
+ // System.out.println("***OBJY: getEClass(cached): " + eClass);
+ // }
+ return eClass;
+ }
+
+ /***
+ * identify if the class is of type Resource. TODO - why we need to pass the store, can't we keep the info we need for
+ * the package mapping here?!!!
+ */
+ public static boolean isResource(ObjectivityStore store, ObjyClass objyClass)
+ {
+ EClass eClass = getEClass(store, objyClass);
+
+ if (eClass == EresourcePackage.Literals.CDO_RESOURCE || eClass == EresourcePackage.Literals.CDO_RESOURCE_NODE
+ || eClass == EresourcePackage.Literals.CDO_RESOURCE_FOLDER)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ /***
+ * Build initial schema for some collection classes.
+ */
+ public static void createBaseSchema()
+ {
+ ObjyArrayListId.buildSchema();
+ ObjyFeatureMapArrayList.buildSchema();
+ ObjyProxy.buildSchema();
+ ObjyArrayListString.buildSchema();
+ ObjyBase.buildSchema();
+ ObjyResourceList.buildSchema();
+ }
+
+ public static String getObjyPackageName(String packageURI)
+ {
+ String name = "";
+ boolean first = true;
+ // parse the URI, remove "http://" and replace each "." with "_"
+ String[] splits = packageURI.split("://");
+ for (String strValue : splits)
+ {
+ if (strValue.equals("http"))
+ {
+ continue;
+ }
+ if (!first)
+ {
+ name = name.concat("_");
+ }
+ else
+ {
+ first = false;
+ }
+
+ name = name.concat(strValue);
+ }
+ name = name.replace("/", ".");
+ name = name.replace(".", "_");
+ return name;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyScope.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyScope.java
index 09d1e448b6..f16d4f5e0e 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyScope.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjyScope.java
@@ -1,242 +1,242 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.as.app.Class_Object;
-import com.objy.db.ObjyRuntimeException;
-import com.objy.db.app.Session;
-import com.objy.db.app.ooContObj;
-import com.objy.db.app.ooDBObj;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-
-/**
- * @author Ibrahim Sallam
- */
-public class ObjyScope
-{
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyScope.class);
-
- private ooContObj contObj = null;
-
- private ooDBObj dbObj = null;
-
- private String dbName;
-
- private String contName;
-
- /**
- * Static function used for initialisation of the store.
- */
- public static void insureScopeExist(ObjySession objySession, String dbName, String contName)
- {
- ooDBObj db;
- ooContObj cont;
- try
- {
- if (!objySession.getFD().hasDB(dbName))
- {
- db = Session.getCurrent().getFD().newDB(dbName);
- }
- else
- {
- db = Session.getCurrent().getFD().lookupDB(dbName);
- }
-
- if (db.hasContainer(contName))
- {
- cont = db.lookupContainer(contName);
- }
- else
- {
- cont = new ooContObj();
- db.addContainer(cont, 0, contName, 0, 0);
- }
-
- }
- catch (ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- public ObjyScope(String dbName, String contName)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ObjyScope - DB: " + dbName + " - CT: " + contName);
- }
- this.dbName = dbName;
- this.contName = contName;
- init();
- }
-
- // optimized version that takes an ooDBObj.
- public ObjyScope(ooDBObj dbObj, String contName)
- {
- dbName = dbObj.getName();
- this.contName = contName;
- this.dbObj = dbObj;
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("ObjyScope - DB: " + dbObj.getName() + " - CT: " + contName);
- }
- init();
- }
-
- public ooId getScopeContOid()
- {
- return getContainerObj().getOid();
- }
-
- public ooId getScopeDbOid()
- {
- return getDatabaseObj().getOid();
- }
-
- private void init()
- {
- getContainerObj();
- }
-
- // /**
- // * TODO - verify need.
- // */
- // private ooContObj getContainer(ooId id)
- // {
- // String contID = "#" + id.getDB() + "-" + id.getOC() + "-1-1";
- //
- // return (ooContObj)Session.getCurrent().getFD().objectFrom(contID);
- // }
-
- public ooContObj getContainerObj()
- {
-
- if (contObj == null)
- {
- ooDBObj db = getDatabaseObj();
-
- if (db.hasContainer(contName))
- {
-
- contObj = db.lookupContainer(contName);
-
- }
- else
- {
- contObj = createNewContainer(contName);
- }
- }
- return contObj;
- }
-
- /**
- * Need this when scanning a scope.
- */
- public ooDBObj getDatabaseObj()
- {
- if (dbObj == null)
- {
- if (!Session.getCurrent().getFD().hasDB(dbName))
- {
- dbObj = Session.getCurrent().getFD().newDB(dbName);
- // System.out.println("OBJY: Creating new DB ID: " + dbObj.getOid().getStoreString() +
- // " - name:" + dbObj.getName());
- }
- else
- {
- dbObj = Session.getCurrent().getFD().lookupDB(dbName);
- }
- // System.out.println("OBJY: Working with DB ID: " + dbObj.getOid().getStoreString() +
- // " - name:" + dbObj.getName());
- }
-
- return dbObj;
- }
-
- // /**
- // * TODO - verify need.
- // */
- // private ooContObj createNewContainer()
- // {
- // return createNewContainer(null);
- // }
-
- /**
- * TODO - verify need.
- *
- * @return
- */
- private ooContObj createNewContainer(String name)
- {
- ooDBObj db = getDatabaseObj();
- ooContObj cont = new ooContObj();
- db.addContainer(cont, 0, name, 0, 0);
- return cont;
- }
-
- public String getDbName()
- {
- return dbName;
- }
-
- /**
- * This function will throw an exception if the lookupObj() fails to find the named object.
- */
- public ObjyObject lookupObjyObject(String nameObject)
- {
- ObjyObject objyObject = null;
- ooId oid = lookupObjectOid(nameObject);
- objyObject = new ObjyObject(Class_Object.class_object_from_oid(oid));
- return objyObject;
- }
-
- public ooId lookupObjectOid(String nameObject)
- {
- ooObj anObj = null;
- anObj = (ooObj)getContainerObj().lookupObj(nameObject);
- return anObj.getOid();
- }
-
- public ooObj lookupObject(String nameObject)
- {
- ooObj anObj = null;
- anObj = (ooObj)getContainerObj().lookupObj(nameObject);
- return anObj;
- }
-
- public void nameObj(String objName, ObjyObject objyObject)
- {
- ooId oid = objyObject.ooId();
- nameObj(objName, oid);
- }
-
- public void nameObj(String objName, ooId oid)
- {
- ooObj object = ooObj.create_ooObj(oid);
- nameObj(objName, object);
- }
-
- public void nameObj(String objName, ooObj obj)
- {
- // if (!obj.isPersistent())
- // {
- // getContainerObj().cluster(obj);
- // }
- getContainerObj().nameObj(obj, objName);
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.as.app.Class_Object;
+import com.objy.db.ObjyRuntimeException;
+import com.objy.db.app.Session;
+import com.objy.db.app.ooContObj;
+import com.objy.db.app.ooDBObj;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public class ObjyScope
+{
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyScope.class);
+
+ private ooContObj contObj = null;
+
+ private ooDBObj dbObj = null;
+
+ private String dbName;
+
+ private String contName;
+
+ /**
+ * Static function used for initialisation of the store.
+ */
+ public static void insureScopeExist(ObjySession objySession, String dbName, String contName)
+ {
+ ooDBObj db;
+ ooContObj cont;
+ try
+ {
+ if (!objySession.getFD().hasDB(dbName))
+ {
+ db = Session.getCurrent().getFD().newDB(dbName);
+ }
+ else
+ {
+ db = Session.getCurrent().getFD().lookupDB(dbName);
+ }
+
+ if (db.hasContainer(contName))
+ {
+ cont = db.lookupContainer(contName);
+ }
+ else
+ {
+ cont = new ooContObj();
+ db.addContainer(cont, 0, contName, 0, 0);
+ }
+
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public ObjyScope(String dbName, String contName)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ObjyScope - DB: " + dbName + " - CT: " + contName);
+ }
+ this.dbName = dbName;
+ this.contName = contName;
+ init();
+ }
+
+ // optimized version that takes an ooDBObj.
+ public ObjyScope(ooDBObj dbObj, String contName)
+ {
+ dbName = dbObj.getName();
+ this.contName = contName;
+ this.dbObj = dbObj;
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("ObjyScope - DB: " + dbObj.getName() + " - CT: " + contName);
+ }
+ init();
+ }
+
+ public ooId getScopeContOid()
+ {
+ return getContainerObj().getOid();
+ }
+
+ public ooId getScopeDbOid()
+ {
+ return getDatabaseObj().getOid();
+ }
+
+ private void init()
+ {
+ getContainerObj();
+ }
+
+ // /**
+ // * TODO - verify need.
+ // */
+ // private ooContObj getContainer(ooId id)
+ // {
+ // String contID = "#" + id.getDB() + "-" + id.getOC() + "-1-1";
+ //
+ // return (ooContObj)Session.getCurrent().getFD().objectFrom(contID);
+ // }
+
+ public ooContObj getContainerObj()
+ {
+
+ if (contObj == null)
+ {
+ ooDBObj db = getDatabaseObj();
+
+ if (db.hasContainer(contName))
+ {
+
+ contObj = db.lookupContainer(contName);
+
+ }
+ else
+ {
+ contObj = createNewContainer(contName);
+ }
+ }
+ return contObj;
+ }
+
+ /**
+ * Need this when scanning a scope.
+ */
+ public ooDBObj getDatabaseObj()
+ {
+ if (dbObj == null)
+ {
+ if (!Session.getCurrent().getFD().hasDB(dbName))
+ {
+ dbObj = Session.getCurrent().getFD().newDB(dbName);
+ // System.out.println("OBJY: Creating new DB ID: " + dbObj.getOid().getStoreString() +
+ // " - name:" + dbObj.getName());
+ }
+ else
+ {
+ dbObj = Session.getCurrent().getFD().lookupDB(dbName);
+ }
+ // System.out.println("OBJY: Working with DB ID: " + dbObj.getOid().getStoreString() +
+ // " - name:" + dbObj.getName());
+ }
+
+ return dbObj;
+ }
+
+ // /**
+ // * TODO - verify need.
+ // */
+ // private ooContObj createNewContainer()
+ // {
+ // return createNewContainer(null);
+ // }
+
+ /**
+ * TODO - verify need.
+ *
+ * @return
+ */
+ private ooContObj createNewContainer(String name)
+ {
+ ooDBObj db = getDatabaseObj();
+ ooContObj cont = new ooContObj();
+ db.addContainer(cont, 0, name, 0, 0);
+ return cont;
+ }
+
+ public String getDbName()
+ {
+ return dbName;
+ }
+
+ /**
+ * This function will throw an exception if the lookupObj() fails to find the named object.
+ */
+ public ObjyObject lookupObjyObject(String nameObject)
+ {
+ ObjyObject objyObject = null;
+ ooId oid = lookupObjectOid(nameObject);
+ objyObject = new ObjyObject(Class_Object.class_object_from_oid(oid));
+ return objyObject;
+ }
+
+ public ooId lookupObjectOid(String nameObject)
+ {
+ ooObj anObj = null;
+ anObj = (ooObj)getContainerObj().lookupObj(nameObject);
+ return anObj.getOid();
+ }
+
+ public ooObj lookupObject(String nameObject)
+ {
+ ooObj anObj = null;
+ anObj = (ooObj)getContainerObj().lookupObj(nameObject);
+ return anObj;
+ }
+
+ public void nameObj(String objName, ObjyObject objyObject)
+ {
+ ooId oid = objyObject.ooId();
+ nameObj(objName, oid);
+ }
+
+ public void nameObj(String objName, ooId oid)
+ {
+ ooObj object = ooObj.create_ooObj(oid);
+ nameObj(objName, object);
+ }
+
+ public void nameObj(String objName, ooObj obj)
+ {
+ // if (!obj.isPersistent())
+ // {
+ // getContainerObj().cluster(obj);
+ // }
+ getContainerObj().nameObj(obj, objName);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySession.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySession.java
index 35cc0d29bc..8975e911b6 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySession.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/db/ObjySession.java
@@ -1,184 +1,184 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.db;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.db.CannotUpgradeLockException;
-import com.objy.db.app.Session;
-import com.objy.db.app.oo;
-import com.objy.db.app.ooContObj;
-import com.objy.db.app.ooId;
-
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-/*
- * @author ibrahim
- */
-public class ObjySession extends Session
-{
- private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjySession.class);
-
- private ObjyObjectManager objectManger = null;
-
- private ObjyResourceList resourceList = null;
-
- private ObjyBranchManager branchManager = null;
-
- private ObjyLockAreaManager lockAreaManager = null;
-
- protected String sessionName;
-
- protected ConcurrentHashMap<String, ObjySession> sessionPool;
-
- protected boolean available;
-
- public ObjySession(String name, ConcurrentHashMap<String, ObjySession> pool, ObjyConnection objyConnection)
- {
- super(objyConnection.getMinSessionCacheSize(), objyConnection.getMaxSessionCacheSize());
- setThreadPolicy(oo.THREAD_POLICY_UNRESTRICTED);
- // setHotMode(false);
- setIndexMode(oo.EXPLICIT_UPDATE);
- sessionName = name;
- sessionPool = pool;
- objectManger = new ObjyObjectManager(objyConnection.getDefaultPlacementManager());
- }
-
- public ObjyObjectManager getObjectManager()
- {
- return objectManger;
- }
-
- public ObjyBranchManager getBranchManager(String repositoryName)
- {
- if (branchManager == null)
- {
- branchManager = ObjyDb.getOrCreateBranchManager(repositoryName);
- }
- return branchManager;
- }
-
- public ObjyLockAreaManager getLockAreaManager(String repositoryName)
- {
- if (lockAreaManager == null)
- {
- lockAreaManager = ObjyDb.getOrCreateLockAreaManager(repositoryName);
- }
- return lockAreaManager;
- }
-
- public void setAvailable(boolean value)
- {
- available = value;
- }
-
- public boolean isAvailable()
- {
- return available;
- }
-
- public String getName()
- {
- return sessionName;
- }
-
- public void setName(String name)
- {
- sessionName = name;
- }
-
- public ConcurrentHashMap<String, ObjySession> getPool()
- {
- return sessionPool;
- }
-
- public ObjyResourceList getResourceList(String repositoryName)
- {
- if (resourceList == null)
- {
- resourceList = new ObjyResourceList(this, ObjyDb.getOrCreateResourceList(repositoryName));
- }
- return resourceList;
- }
-
- @Override
- public synchronized void returnSessionToPool()
- {
- // System.out.println(">>> IS: returning session: " + session.getName());
- leave();
- setAvailable(true);
- }
-
- @Override
- public synchronized void terminate()
- {
- // System.out.println("OBJY>>> Terminating session... " + sessionName + " - " + toString());
- resourceList = null;
- super.terminate();
- }
-
- public void lockContainers(Set<ooId> containerToLocks)
- {
- // Locks all containers for modified objects
- if (!containerToLocks.isEmpty())
- {
- ooId idsToLock[] = containerToLocks.toArray(new ooId[containerToLocks.size()]);
- // 100920 - IS: for debugging... TBR.
- // for (ooId id : idsToLock)
- // {
- // TRACER_INFO.trace("Locking container: " + id.getStoreString());
- // }
-
- int count = 10;
- while (0 != count--)
- {
- try
- {
- openContainers(idsToLock, oo.openReadWrite);
- break;
- }
- catch (CannotUpgradeLockException cule)
- {
- // refresh containers.
- for (ooId contId : idsToLock)
- {
- ooContObj contObj = (ooContObj)getFD().objectFrom(contId);
- contObj.refresh(oo.WRITE);
- }
- }
- catch (Exception e)
- {
- TRACER_INFO.trace("Locking problem try again : " + e.getMessage());
- // this.ensureNewBeginSession();
- if (!isOpen())
- {
- TRACER_INFO.trace("Objy session is not open");
- }
- try
- {
- wait(500);
- }
- catch (InterruptedException ex)
- {
- }
- }
- }
- }
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.db;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.ObjyDb;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.db.CannotUpgradeLockException;
+import com.objy.db.app.Session;
+import com.objy.db.app.oo;
+import com.objy.db.app.ooContObj;
+import com.objy.db.app.ooId;
+
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+/*
+ * @author ibrahim
+ */
+public class ObjySession extends Session
+{
+ private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjySession.class);
+
+ private ObjyObjectManager objectManger = null;
+
+ private ObjyResourceList resourceList = null;
+
+ private ObjyBranchManager branchManager = null;
+
+ private ObjyLockAreaManager lockAreaManager = null;
+
+ protected String sessionName;
+
+ protected ConcurrentHashMap<String, ObjySession> sessionPool;
+
+ protected boolean available;
+
+ public ObjySession(String name, ConcurrentHashMap<String, ObjySession> pool, ObjyConnection objyConnection)
+ {
+ super(objyConnection.getMinSessionCacheSize(), objyConnection.getMaxSessionCacheSize());
+ setThreadPolicy(oo.THREAD_POLICY_UNRESTRICTED);
+ // setHotMode(false);
+ setIndexMode(oo.EXPLICIT_UPDATE);
+ sessionName = name;
+ sessionPool = pool;
+ objectManger = new ObjyObjectManager(objyConnection.getDefaultPlacementManager());
+ }
+
+ public ObjyObjectManager getObjectManager()
+ {
+ return objectManger;
+ }
+
+ public ObjyBranchManager getBranchManager(String repositoryName)
+ {
+ if (branchManager == null)
+ {
+ branchManager = ObjyDb.getOrCreateBranchManager(repositoryName);
+ }
+ return branchManager;
+ }
+
+ public ObjyLockAreaManager getLockAreaManager(String repositoryName)
+ {
+ if (lockAreaManager == null)
+ {
+ lockAreaManager = ObjyDb.getOrCreateLockAreaManager(repositoryName);
+ }
+ return lockAreaManager;
+ }
+
+ public void setAvailable(boolean value)
+ {
+ available = value;
+ }
+
+ public boolean isAvailable()
+ {
+ return available;
+ }
+
+ public String getName()
+ {
+ return sessionName;
+ }
+
+ public void setName(String name)
+ {
+ sessionName = name;
+ }
+
+ public ConcurrentHashMap<String, ObjySession> getPool()
+ {
+ return sessionPool;
+ }
+
+ public ObjyResourceList getResourceList(String repositoryName)
+ {
+ if (resourceList == null)
+ {
+ resourceList = new ObjyResourceList(this, ObjyDb.getOrCreateResourceList(repositoryName));
+ }
+ return resourceList;
+ }
+
+ @Override
+ public synchronized void returnSessionToPool()
+ {
+ // System.out.println(">>> IS: returning session: " + session.getName());
+ leave();
+ setAvailable(true);
+ }
+
+ @Override
+ public synchronized void terminate()
+ {
+ // System.out.println("OBJY>>> Terminating session... " + sessionName + " - " + toString());
+ resourceList = null;
+ super.terminate();
+ }
+
+ public void lockContainers(Set<ooId> containerToLocks)
+ {
+ // Locks all containers for modified objects
+ if (!containerToLocks.isEmpty())
+ {
+ ooId idsToLock[] = containerToLocks.toArray(new ooId[containerToLocks.size()]);
+ // 100920 - IS: for debugging... TBR.
+ // for (ooId id : idsToLock)
+ // {
+ // TRACER_INFO.trace("Locking container: " + id.getStoreString());
+ // }
+
+ int count = 10;
+ while (0 != count--)
+ {
+ try
+ {
+ openContainers(idsToLock, oo.openReadWrite);
+ break;
+ }
+ catch (CannotUpgradeLockException cule)
+ {
+ // refresh containers.
+ for (ooId contId : idsToLock)
+ {
+ ooContObj contObj = (ooContObj)getFD().objectFrom(contId);
+ contObj.refresh(oo.WRITE);
+ }
+ }
+ catch (Exception e)
+ {
+ TRACER_INFO.trace("Locking problem try again : " + e.getMessage());
+ // this.ensureNewBeginSession();
+ if (!isOpen())
+ {
+ TRACER_INFO.trace("Objy session is not open");
+ }
+ try
+ {
+ wait(500);
+ }
+ catch (InterruptedException ex)
+ {
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BasicTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BasicTypeMapper.java
index 87830d2c99..5578d991ab 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BasicTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BasicTypeMapper.java
@@ -1,62 +1,62 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-//import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-//import org.eclipse.net4j.util.om.trace.ContextTracer;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * mapping between Objy AS class/type and EMF types.
- *
- * @author ibrahim
- */
-public abstract class BasicTypeMapper
-{
-
- // private static final ContextTracer TRACER_DEBUG = new ContextTracer(
- // OM.DEBUG, BasicTypeMapper.class);
-
- protected String getAttributeName(EStructuralFeature feature)
- {
- return feature.getName();
- }
-
- protected String getNullAttributeName(EStructuralFeature feature)
- {
- return feature.getName() + "_isNull";
- }
-
- // protected Class_Position getAttributePosition(ObjyObject objyObject, EStructuralFeature feature)
- // {
- // return objyObject.objyClass().resolve_position(getAttributeName(feature));
- // }
-
- // protected Class_Position getNullAttributePosition(ObjyObject objyObject, EStructuralFeature feature)
- // {
- // return objyObject.objyClass().resolve_position(getNullAttributeName(feature));
- // }
-
- // ---------------------------------
- // Object
- // ---------------------------------
- // public void initialize(Class_Object class_Object,
- // EStructuralFeature feature, Class_Position attr)
- // {
- //
- // }
- //
- // public void delete(ObjyObject objyObject,
- // EStructuralFeature feature, Class_Position position)
- // {
- // }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+//import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+//import org.eclipse.net4j.util.om.trace.ContextTracer;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * mapping between Objy AS class/type and EMF types.
+ *
+ * @author ibrahim
+ */
+public abstract class BasicTypeMapper
+{
+
+ // private static final ContextTracer TRACER_DEBUG = new ContextTracer(
+ // OM.DEBUG, BasicTypeMapper.class);
+
+ protected String getAttributeName(EStructuralFeature feature)
+ {
+ return feature.getName();
+ }
+
+ protected String getNullAttributeName(EStructuralFeature feature)
+ {
+ return feature.getName() + "_isNull";
+ }
+
+ // protected Class_Position getAttributePosition(ObjyObject objyObject, EStructuralFeature feature)
+ // {
+ // return objyObject.objyClass().resolve_position(getAttributeName(feature));
+ // }
+
+ // protected Class_Position getNullAttributePosition(ObjyObject objyObject, EStructuralFeature feature)
+ // {
+ // return objyObject.objyClass().resolve_position(getNullAttributeName(feature));
+ // }
+
+ // ---------------------------------
+ // Object
+ // ---------------------------------
+ // public void initialize(Class_Object class_Object,
+ // EStructuralFeature feature, Class_Position attr)
+ // {
+ //
+ // }
+ //
+ // public void delete(ObjyObject objyObject,
+ // EStructuralFeature feature, Class_Position position)
+ // {
+ // }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigDecimalTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigDecimalTypeMapper.java
index f72cd59281..413f8e0741 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigDecimalTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigDecimalTypeMapper.java
@@ -1,98 +1,98 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.String_Value;
-import com.objy.as.app.d_Attribute;
-
-import java.math.BigDecimal;
-
-/**
- * @author Simon McDuff
- */
-public class BigDecimalTypeMapper extends StringTypeMapper
-{
- public static BigDecimalTypeMapper INSTANCE = new BigDecimalTypeMapper();
-
- @Override
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
-
- boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
- Object value = null;
-
- if (!isNull)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- String_Value stringValue = objyObject.get_string(attributeName/* position */);
- value = new BigDecimal(stringValue.toString());
- }
- // else if (feature.isUnsettable())
- // {
- // value = CDORevisionData.NIL;
- // }
-
- return value;
- }
-
- @Override
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
- {
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
-
- boolean isNull = newValue == null || newValue == CDORevisionData.NIL;
- Numeric_Value isNullValue = isNull ? numericTrue : numericFalse;
-
- if (!isNull)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- String_Value stringValue = objyObject.get_string(attributeName/* position */);
- stringValue.update();
- String strValue = ((BigDecimal)newValue).toString();
- stringValue.set(strValue == null ? "" : strValue);
- }
- objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
- }
-
- @Override
- public Object remove(ObjyObject objyObject, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- @Override
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- return false;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.String_Value;
+import com.objy.as.app.d_Attribute;
+
+import java.math.BigDecimal;
+
+/**
+ * @author Simon McDuff
+ */
+public class BigDecimalTypeMapper extends StringTypeMapper
+{
+ public static BigDecimalTypeMapper INSTANCE = new BigDecimalTypeMapper();
+
+ @Override
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+
+ boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
+ Object value = null;
+
+ if (!isNull)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ String_Value stringValue = objyObject.get_string(attributeName/* position */);
+ value = new BigDecimal(stringValue.toString());
+ }
+ // else if (feature.isUnsettable())
+ // {
+ // value = CDORevisionData.NIL;
+ // }
+
+ return value;
+ }
+
+ @Override
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
+ {
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+
+ boolean isNull = newValue == null || newValue == CDORevisionData.NIL;
+ Numeric_Value isNullValue = isNull ? numericTrue : numericFalse;
+
+ if (!isNull)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ String_Value stringValue = objyObject.get_string(attributeName/* position */);
+ stringValue.update();
+ String strValue = ((BigDecimal)newValue).toString();
+ stringValue.set(strValue == null ? "" : strValue);
+ }
+ objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
+ }
+
+ @Override
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ @Override
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigIntegerTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigIntegerTypeMapper.java
index ec811bf4e0..79555aebf5 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigIntegerTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/BigIntegerTypeMapper.java
@@ -1,91 +1,91 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.String_Value;
-import com.objy.as.app.d_Attribute;
-
-import java.math.BigInteger;
-
-/**
- * @author Ibrahim Sallam
- */
-public class BigIntegerTypeMapper extends StringTypeMapper
-{
- public static BigIntegerTypeMapper INSTANCE = new BigIntegerTypeMapper();
-
- @Override
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
-
- boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
- Object value = null;
-
- if (!isNull)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- String_Value stringValue = objyObject.get_string(attributeName/* position */);
- value = new BigInteger(stringValue.toString());
- }
- // else if (feature.isUnsettable())
- // {
- // value = CDORevisionData.NIL;
- // }
-
- return value;
- }
-
- @Override
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
- {
- String nullAttributeName = getNullAttributeName(feature);
-
- boolean isNull = newValue == null || newValue == CDORevisionData.NIL;
- Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse;
-
- if (!isNull)
- {
- String attributeName = getAttributeName(feature);
-
- String_Value stringValue = objyObject.get_string(attributeName/* position */);
- stringValue.update();
- String strValue = newValue.toString();
- stringValue.set(strValue);
- }
- objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
- }
-
- @Override
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- return false;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.String_Value;
+import com.objy.as.app.d_Attribute;
+
+import java.math.BigInteger;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public class BigIntegerTypeMapper extends StringTypeMapper
+{
+ public static BigIntegerTypeMapper INSTANCE = new BigIntegerTypeMapper();
+
+ @Override
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+
+ boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
+ Object value = null;
+
+ if (!isNull)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ String_Value stringValue = objyObject.get_string(attributeName/* position */);
+ value = new BigInteger(stringValue.toString());
+ }
+ // else if (feature.isUnsettable())
+ // {
+ // value = CDORevisionData.NIL;
+ // }
+
+ return value;
+ }
+
+ @Override
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
+ {
+ String nullAttributeName = getNullAttributeName(feature);
+
+ boolean isNull = newValue == null || newValue == CDORevisionData.NIL;
+ Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse;
+
+ if (!isNull)
+ {
+ String attributeName = getAttributeName(feature);
+
+ String_Value stringValue = objyObject.get_string(attributeName/* position */);
+ stringValue.update();
+ String strValue = newValue.toString();
+ stringValue.set(strValue);
+ }
+ objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
+ }
+
+ @Override
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ByteArrayTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ByteArrayTypeMapper.java
index a112c9c525..f92f6ff3f7 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ByteArrayTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ByteArrayTypeMapper.java
@@ -1,182 +1,182 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.VArray_Object;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.d_Type;
-import com.objy.as.app.ooBaseType;
-
-/**
- * @author Simon McDuff
- */
-// This is a special class compared to the other array of simple types.
-public class ByteArrayTypeMapper extends BasicTypeMapper implements ISingleTypeMapper
-{
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ByteArrayTypeMapper.class);
-
- static ByteArrayTypeMapper INSTANCE = new ByteArrayTypeMapper();
-
- protected ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT8;
- }
-
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- VArray_Object vArray = objyObject.get_varray(attributeName/* position */);
-
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
- boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
-
- if (isNull)
- {
- return null;
- }
-
- int size = (int)vArray.size();
- byte byteArray[] = new byte[size];
- for (int i = 0; i < size; i++)
- {
- Numeric_Value value = vArray.get_numeric(i);
- byteArray[i] = value.byteValue();
- }
- return byteArray;
- }
-
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- VArray_Object vArray = objyObject.get_varray(attributeName/* position */);
-
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
-
- Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse;
-
- objyObject.set_numeric(nullAttributeName /* nullPosition */, isNullValue);
-
- // System.out.println("OID: " + objyObject.ooId().getStoreString() + " - START work");
- if (newValue == null)
- {
- vArray.resize(0);
- return;
- }
-
- byte byteArray[] = (byte[])newValue;
-
- if (vArray.size() != byteArray.length)
- {
- vArray.resize(byteArray.length);
- }
-
- for (int i = 0; i < byteArray.length; i++)
- {
- Byte byteValue = byteArray[i];
- Numeric_Value numericValue = new Numeric_Value(byteValue);
- vArray.set_numeric(i, numericValue);
- }
- // System.out.println("OID: " + objyObject.ooId().getStoreString() + " - DONE.");
- }
-
- /**
- *
- */
- public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Adding attribute " + feature.getName() + " " + this.getClass().getName());
- }
-
- proposedClass.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- getAttributeName(feature), // Attribute name
- 1, // # elements in fixed-size array
- getObjyBaseType()); // Default value
-
- proposedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- getNullAttributeName(feature), // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooBOOLEAN // Default value
- );
-
- return false;
- }
-
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- d_Type type = ooAttribute.type_of();
-
- return type.is_varray_basic_type();
- }
-
- // TODO - this is not the most optimized version fo the code.
- // we are trying to finish functionality for now 100202:IS
- // public void add(ObjyObject objyObject, EStructuralFeature feature,
- // Class_Position position, int index, Object value)
- // {
- // if (index < size(objyObject, feature, position))
- // {
- // throw new UnsupportedOperationException("adding object inside VArray... Implement Me!!!");
- // }
- //
- // VArray_Object vArray = objyObject.ooClassObject().get_varray(position);
- // Numeric_Value numericValue = new Numeric_Value((Byte)value);
- // vArray.extend(numericValue);
- // }
-
- public Object remove(ObjyObject objyObject, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void delete(ObjyObject objyObject, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void initialize(Class_Object classObject, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- // throw new UnsupportedOperationException("Implement me!!");
- // at least rest the varray...
- // Class_Position position = classObject.type_of().position_in_class(feature.getName());
- VArray_Object vArray = classObject.nget_varray(feature.getName());
- vArray.resize(0);
- }
-
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.VArray_Object;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.d_Type;
+import com.objy.as.app.ooBaseType;
+
+/**
+ * @author Simon McDuff
+ */
+// This is a special class compared to the other array of simple types.
+public class ByteArrayTypeMapper extends BasicTypeMapper implements ISingleTypeMapper
+{
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ByteArrayTypeMapper.class);
+
+ static ByteArrayTypeMapper INSTANCE = new ByteArrayTypeMapper();
+
+ protected ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT8;
+ }
+
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ VArray_Object vArray = objyObject.get_varray(attributeName/* position */);
+
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+ boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
+
+ if (isNull)
+ {
+ return null;
+ }
+
+ int size = (int)vArray.size();
+ byte byteArray[] = new byte[size];
+ for (int i = 0; i < size; i++)
+ {
+ Numeric_Value value = vArray.get_numeric(i);
+ byteArray[i] = value.byteValue();
+ }
+ return byteArray;
+ }
+
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ VArray_Object vArray = objyObject.get_varray(attributeName/* position */);
+
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+
+ Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse;
+
+ objyObject.set_numeric(nullAttributeName /* nullPosition */, isNullValue);
+
+ // System.out.println("OID: " + objyObject.ooId().getStoreString() + " - START work");
+ if (newValue == null)
+ {
+ vArray.resize(0);
+ return;
+ }
+
+ byte byteArray[] = (byte[])newValue;
+
+ if (vArray.size() != byteArray.length)
+ {
+ vArray.resize(byteArray.length);
+ }
+
+ for (int i = 0; i < byteArray.length; i++)
+ {
+ Byte byteValue = byteArray[i];
+ Numeric_Value numericValue = new Numeric_Value(byteValue);
+ vArray.set_numeric(i, numericValue);
+ }
+ // System.out.println("OID: " + objyObject.ooId().getStoreString() + " - DONE.");
+ }
+
+ /**
+ *
+ */
+ public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Adding attribute " + feature.getName() + " " + this.getClass().getName());
+ }
+
+ proposedClass.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ getAttributeName(feature), // Attribute name
+ 1, // # elements in fixed-size array
+ getObjyBaseType()); // Default value
+
+ proposedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ getNullAttributeName(feature), // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooBOOLEAN // Default value
+ );
+
+ return false;
+ }
+
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ d_Type type = ooAttribute.type_of();
+
+ return type.is_varray_basic_type();
+ }
+
+ // TODO - this is not the most optimized version fo the code.
+ // we are trying to finish functionality for now 100202:IS
+ // public void add(ObjyObject objyObject, EStructuralFeature feature,
+ // Class_Position position, int index, Object value)
+ // {
+ // if (index < size(objyObject, feature, position))
+ // {
+ // throw new UnsupportedOperationException("adding object inside VArray... Implement Me!!!");
+ // }
+ //
+ // VArray_Object vArray = objyObject.ooClassObject().get_varray(position);
+ // Numeric_Value numericValue = new Numeric_Value((Byte)value);
+ // vArray.extend(numericValue);
+ // }
+
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void delete(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void initialize(Class_Object classObject, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ // throw new UnsupportedOperationException("Implement me!!");
+ // at least rest the varray...
+ // Class_Position position = classObject.type_of().position_in_class(feature.getName());
+ VArray_Object vArray = classObject.nget_varray(feature.getName());
+ vArray.resize(0);
+ }
+
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataManyTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataManyTypeMapper.java
index fbeff64cc4..72cea6f420 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataManyTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataManyTypeMapper.java
@@ -1,46 +1,46 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/***
- * Overrides StringManyTypeMapper, and implement the two functions to convert a string to an object and vice versa.
- *
- * @author Ibrahim Sallam
- */
-public class CustomDataManyTypeMapper extends StringManyTypeMapper
-{
-
- public static CustomDataManyTypeMapper INSTANCE = new CustomDataManyTypeMapper();
-
- @Override
- protected String stringFromObject(EStructuralFeature feature, Object objectValue)
- {
- EDataType dataType = (EDataType)feature.getEType();
- EFactory factory = dataType.getEPackage().getEFactoryInstance();
- String stringValue = factory.convertToString(dataType, objectValue);
- return stringValue;
- }
-
- @Override
- protected Object objectFromString(EStructuralFeature feature, String stringValue)
- {
- EDataType dataType = (EDataType)feature.getEType();
- EFactory factory = dataType.getEPackage().getEFactoryInstance();
- Object value = null;
- value = factory.createFromString(dataType, stringValue);
- return value;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/***
+ * Overrides StringManyTypeMapper, and implement the two functions to convert a string to an object and vice versa.
+ *
+ * @author Ibrahim Sallam
+ */
+public class CustomDataManyTypeMapper extends StringManyTypeMapper
+{
+
+ public static CustomDataManyTypeMapper INSTANCE = new CustomDataManyTypeMapper();
+
+ @Override
+ protected String stringFromObject(EStructuralFeature feature, Object objectValue)
+ {
+ EDataType dataType = (EDataType)feature.getEType();
+ EFactory factory = dataType.getEPackage().getEFactoryInstance();
+ String stringValue = factory.convertToString(dataType, objectValue);
+ return stringValue;
+ }
+
+ @Override
+ protected Object objectFromString(EStructuralFeature feature, String stringValue)
+ {
+ EDataType dataType = (EDataType)feature.getEType();
+ EFactory factory = dataType.getEPackage().getEFactoryInstance();
+ Object value = null;
+ value = factory.createFromString(dataType, stringValue);
+ return value;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataTypeMapper.java
index 063e4e9a91..9e7ebb98bd 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/CustomDataTypeMapper.java
@@ -1,97 +1,97 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.String_Value;
-import com.objy.as.app.d_Attribute;
-
-/**
- * @author Ibrahim Sallam
- */
-public class CustomDataTypeMapper extends StringTypeMapper
-{
- public static CustomDataTypeMapper INSTANCE = new CustomDataTypeMapper();
-
- @Override
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
-
- String_Value stringValue = objyObject.get_string(attributeName/* position */);
- boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
-
- // EDataType dataType = (EDataType)feature.getEType();
- // EFactory factory = dataType.getEPackage().getEFactoryInstance();
- // Object value = null;
- // if (!isNull)
- // {
- // value = factory.createFromString(dataType, stringValue.toString());
- // }
- //
- // return value;
- if (isNull)
- {
- return null;
- }
-
- return stringValue.toString();
- }
-
- @Override
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
-
- String_Value stringValue = objyObject.get_string(attributeName/* position */);
- stringValue.update();
-
- // EDataType dataType = (EDataType)feature.getEType();
- // EFactory factory = dataType.getEPackage().getEFactoryInstance();
- // String valueAsString = factory.convertToString(dataType, newValue);
- //
- Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse;
- // String strValue = newValue == null ? null : valueAsString;
- stringValue.set(newValue == null ? "" : newValue.toString());
- objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
- }
-
- @Override
- public Object remove(ObjyObject objyObject, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- @Override
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- return false;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.String_Value;
+import com.objy.as.app.d_Attribute;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public class CustomDataTypeMapper extends StringTypeMapper
+{
+ public static CustomDataTypeMapper INSTANCE = new CustomDataTypeMapper();
+
+ @Override
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+
+ String_Value stringValue = objyObject.get_string(attributeName/* position */);
+ boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
+
+ // EDataType dataType = (EDataType)feature.getEType();
+ // EFactory factory = dataType.getEPackage().getEFactoryInstance();
+ // Object value = null;
+ // if (!isNull)
+ // {
+ // value = factory.createFromString(dataType, stringValue.toString());
+ // }
+ //
+ // return value;
+ if (isNull)
+ {
+ return null;
+ }
+
+ return stringValue.toString();
+ }
+
+ @Override
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+
+ String_Value stringValue = objyObject.get_string(attributeName/* position */);
+ stringValue.update();
+
+ // EDataType dataType = (EDataType)feature.getEType();
+ // EFactory factory = dataType.getEPackage().getEFactoryInstance();
+ // String valueAsString = factory.convertToString(dataType, newValue);
+ //
+ Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse;
+ // String strValue = newValue == null ? null : valueAsString;
+ stringValue.set(newValue == null ? "" : newValue.toString());
+ objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
+ }
+
+ @Override
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ @Override
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/EnumTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/EnumTypeMapper.java
index 7a99cc91fa..1ec0642861 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/EnumTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/EnumTypeMapper.java
@@ -1,53 +1,53 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author Simon McDuff
- */
-public class EnumTypeMapper extends NumericTypeMapper.TMInteger
-{
- static EnumTypeMapper INSTANCE = new EnumTypeMapper();
-
- @Override
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Integer intValue = (Integer) super.getValue(objyObject, feature);
- // /*
- // EEnum enumType = (EEnum)feature.getEType();
- // EEnumLiteral literal = enumType.getEEnumLiteral(intValue);
- // if (literal == null)
- // {
- // throw new IllegalStateException();
- // }
- // return literal.getInstance();
- // */
- // return intValue;
- return super.getValue(objyObject, feature);
- }
-
- @Override
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
- {
- Integer enumLiteral = (Integer)newValue;
- if (enumLiteral == null)
- {
- return;
- }
- super.setValue(objyObject, feature, enumLiteral);
- // Numeric_Value numericValue = new Numeric_Value(enumLiteral.intValue());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * @author Simon McDuff
+ */
+public class EnumTypeMapper extends NumericTypeMapper.TMInteger
+{
+ static EnumTypeMapper INSTANCE = new EnumTypeMapper();
+
+ @Override
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Integer intValue = (Integer) super.getValue(objyObject, feature);
+ // /*
+ // EEnum enumType = (EEnum)feature.getEType();
+ // EEnumLiteral literal = enumType.getEEnumLiteral(intValue);
+ // if (literal == null)
+ // {
+ // throw new IllegalStateException();
+ // }
+ // return literal.getInstance();
+ // */
+ // return intValue;
+ return super.getValue(objyObject, feature);
+ }
+
+ @Override
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
+ {
+ Integer enumLiteral = (Integer)newValue;
+ if (enumLiteral == null)
+ {
+ return;
+ }
+ super.setValue(objyObject, feature, enumLiteral);
+ // Numeric_Value numericValue = new Numeric_Value(enumLiteral.intValue());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/FeatureMapTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/FeatureMapTypeMapper.java
index 3fcd6969ce..dac45cf0d3 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/FeatureMapTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/FeatureMapTypeMapper.java
@@ -1,172 +1,172 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapArrayList;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapEntry;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.d_Class;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-
-/**
- * @author Simon McDuff
- */
-public class FeatureMapTypeMapper extends BasicTypeMapper implements IManyTypeMapper
-{
- static FeatureMapTypeMapper INSTANCE = new FeatureMapTypeMapper();
-
- static d_Class dClassObject = null;
-
- private static d_Class getArrayListClass()
- {
- if (dClassObject == null)
- {
- dClassObject = ObjySchema.getTopModule().resolve_class(ObjyFeatureMapArrayList.ClassName);
- }
- return dClassObject;
- }
-
- public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
- {
- proposedClasses.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
- d_Access_Kind.d_PUBLIC, // Access kind
- feature.getName(), // Attribute name
- 1, // # elements in fixed-size array
- ObjyFeatureMapArrayList.ClassName, false); // Default value // Default value
-
- return true;
- }
-
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature, int index)
- {
- return getList(objyObject, feature).get(index);
- }
-
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, int index, Object newValue)
- {
- getList(objyObject, feature).set(index, (ObjyFeatureMapEntry)newValue);
- }
-
- public ObjyFeatureMapArrayList getList(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- ObjyFeatureMapArrayList list = (ObjyFeatureMapArrayList)objyObject.getFeatureList(attributeName/* position */);
- if (list == null)
- {
- list = new ObjyFeatureMapArrayList(objyObject.get_class_obj(attributeName/* position */));
- objyObject.setFeatureList(attributeName/* position */, list);
- }
- return list;
- }
-
- public int size(ObjyObject objyObject, EStructuralFeature feature)
- {
- return (int)getList(objyObject, feature).size();
- }
-
- public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value)
- {
- getList(objyObject, feature).add(index, (ObjyFeatureMapEntry)value);
- }
-
- public void addAll(ObjyObject classObject, EStructuralFeature feature, int index, Object[] values)
- {
- getList(classObject, feature).addAll(index, values);
- }
-
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void initialize(Class_Object classObject, EStructuralFeature feature)
- {
- // create the reference.
- Class_Object newClassObject = Class_Object
- .new_persistent_object(getArrayListClass(), classObject.objectID(), false);
- // {
- // ObjyObjectManager.newInternalObjCount++;
- // }
- // Class_Position position = classObject.type_of().position_in_class(getAttributeName(feature));
- classObject.nset_ooId(getAttributeName(feature), newClassObject.objectID());
- // initialize the list structure.
- ObjyFeatureMapArrayList.initObject(newClassObject);
- }
-
- public void delete(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- ooId tobeDeleted = objyObject.get_ooId(getAttributeName(feature)/* position */);
- ooObj objectToDelete = ooObj.create_ooObj(tobeDeleted);
- objectToDelete.delete();
- }
-
- public void clear(ObjyObject objyObject, EStructuralFeature feature)
- {
- getList(objyObject, feature).clear();
- }
-
- public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
- {
- Object oldValue = getValue(objyObject, feature, index);
-
- getList(objyObject, feature).remove(index);
-
- return oldValue;
- }
-
- public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
- {
- // throw new UnsupportedOperationException("Implement me!!");
- int size = (int)getList(objyObject, feature).size();
- if (chunkSize != CDORevision.UNCHUNKED)
- {
- size = Math.min(size, chunkSize);
- }
- Object[] objects = new Object[size - index];
- for (int i = 0; i < size; i++)
- {
- objects[i] = getValue(objyObject, feature, i + index);
- }
- return objects;
- }
-
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
- {
- for (int i = 0; i < newValues.length; i++)
- {
- add(objyObject, feature, i, newValues[i]);
- }
- }
-
- public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapArrayList;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyFeatureMapEntry;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.d_Class;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+
+/**
+ * @author Simon McDuff
+ */
+public class FeatureMapTypeMapper extends BasicTypeMapper implements IManyTypeMapper
+{
+ static FeatureMapTypeMapper INSTANCE = new FeatureMapTypeMapper();
+
+ static d_Class dClassObject = null;
+
+ private static d_Class getArrayListClass()
+ {
+ if (dClassObject == null)
+ {
+ dClassObject = ObjySchema.getTopModule().resolve_class(ObjyFeatureMapArrayList.ClassName);
+ }
+ return dClassObject;
+ }
+
+ public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
+ {
+ proposedClasses.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ feature.getName(), // Attribute name
+ 1, // # elements in fixed-size array
+ ObjyFeatureMapArrayList.ClassName, false); // Default value // Default value
+
+ return true;
+ }
+
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature, int index)
+ {
+ return getList(objyObject, feature).get(index);
+ }
+
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, int index, Object newValue)
+ {
+ getList(objyObject, feature).set(index, (ObjyFeatureMapEntry)newValue);
+ }
+
+ public ObjyFeatureMapArrayList getList(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ ObjyFeatureMapArrayList list = (ObjyFeatureMapArrayList)objyObject.getFeatureList(attributeName/* position */);
+ if (list == null)
+ {
+ list = new ObjyFeatureMapArrayList(objyObject.get_class_obj(attributeName/* position */));
+ objyObject.setFeatureList(attributeName/* position */, list);
+ }
+ return list;
+ }
+
+ public int size(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ return (int)getList(objyObject, feature).size();
+ }
+
+ public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value)
+ {
+ getList(objyObject, feature).add(index, (ObjyFeatureMapEntry)value);
+ }
+
+ public void addAll(ObjyObject classObject, EStructuralFeature feature, int index, Object[] values)
+ {
+ getList(classObject, feature).addAll(index, values);
+ }
+
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void initialize(Class_Object classObject, EStructuralFeature feature)
+ {
+ // create the reference.
+ Class_Object newClassObject = Class_Object
+ .new_persistent_object(getArrayListClass(), classObject.objectID(), false);
+ // {
+ // ObjyObjectManager.newInternalObjCount++;
+ // }
+ // Class_Position position = classObject.type_of().position_in_class(getAttributeName(feature));
+ classObject.nset_ooId(getAttributeName(feature), newClassObject.objectID());
+ // initialize the list structure.
+ ObjyFeatureMapArrayList.initObject(newClassObject);
+ }
+
+ public void delete(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ ooId tobeDeleted = objyObject.get_ooId(getAttributeName(feature)/* position */);
+ ooObj objectToDelete = ooObj.create_ooObj(tobeDeleted);
+ objectToDelete.delete();
+ }
+
+ public void clear(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ getList(objyObject, feature).clear();
+ }
+
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
+ {
+ Object oldValue = getValue(objyObject, feature, index);
+
+ getList(objyObject, feature).remove(index);
+
+ return oldValue;
+ }
+
+ public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
+ {
+ // throw new UnsupportedOperationException("Implement me!!");
+ int size = (int)getList(objyObject, feature).size();
+ if (chunkSize != CDORevision.UNCHUNKED)
+ {
+ size = Math.min(size, chunkSize);
+ }
+ Object[] objects = new Object[size - index];
+ for (int i = 0; i < size; i++)
+ {
+ objects[i] = getValue(objyObject, feature, i + index);
+ }
+ return objects;
+ }
+
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
+ {
+ for (int i = 0; i < newValues.length; i++)
+ {
+ add(objyObject, feature, i, newValues[i]);
+ }
+ }
+
+ public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IManyTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IManyTypeMapper.java
index c06ff9fe61..19d5a8e8c2 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IManyTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IManyTypeMapper.java
@@ -1,64 +1,64 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * Mapper for composite types (featureMap, manyReference, Multiple...)
- *
- * @author ibrahim
- */
-public interface IManyTypeMapper extends ITypeMapper
-{
-
- final String embeddedAttributeName = "value";
-
- final String embeddedAttributeNull = "isNull";
-
- final int valueAttributePosition = 0; // caution, we assume position index here!!!
-
- final int nullAttributePosition = 1; // caution, we assume position index here!!!
-
- // set a single object/value at index.
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, int index, Object newValue);
-
- // get a single object/value at index.
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature, int index);
-
- // remove a single value at index, it will set the value to default, and mark it
- // as "null", i.e. unset.
- public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index);
-
- // add value at index (extend the collection size).
- public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value);
-
- // add all objects starting from an index. (extend the collection size).
- public void addAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] value);
-
- // clear all collection.
- public void clear(ObjyObject objyObject, EStructuralFeature feature);
-
- // this is similar to addAll, but it replaces the existing ones.
- public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValue);
-
- // get all objects/values starting from an index.
- public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize);
-
- // return the size of the collection.
- public int size(ObjyObject objyObject, EStructuralFeature feature);
-
- // move element in the feature from sourceIndex to targetIndex
- public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex);
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * Mapper for composite types (featureMap, manyReference, Multiple...)
+ *
+ * @author ibrahim
+ */
+public interface IManyTypeMapper extends ITypeMapper
+{
+
+ final String embeddedAttributeName = "value";
+
+ final String embeddedAttributeNull = "isNull";
+
+ final int valueAttributePosition = 0; // caution, we assume position index here!!!
+
+ final int nullAttributePosition = 1; // caution, we assume position index here!!!
+
+ // set a single object/value at index.
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, int index, Object newValue);
+
+ // get a single object/value at index.
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature, int index);
+
+ // remove a single value at index, it will set the value to default, and mark it
+ // as "null", i.e. unset.
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index);
+
+ // add value at index (extend the collection size).
+ public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value);
+
+ // add all objects starting from an index. (extend the collection size).
+ public void addAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] value);
+
+ // clear all collection.
+ public void clear(ObjyObject objyObject, EStructuralFeature feature);
+
+ // this is similar to addAll, but it replaces the existing ones.
+ public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValue);
+
+ // get all objects/values starting from an index.
+ public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize);
+
+ // return the size of the collection.
+ public int size(ObjyObject objyObject, EStructuralFeature feature);
+
+ // move element in the feature from sourceIndex to targetIndex
+ public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex);
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ISingleTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ISingleTypeMapper.java
index b2908da818..0e9c76e185 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ISingleTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ISingleTypeMapper.java
@@ -1,30 +1,30 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-public interface ISingleTypeMapper extends ITypeMapper
-{
-
- // Instance
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue);
-
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature);
-
- // remove the entry.
- // 100204:IS - Hmmm. I'm not sure what the usage...
- public Object remove(ObjyObject objyObject, EStructuralFeature feature);
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+public interface ISingleTypeMapper extends ITypeMapper
+{
+
+ // Instance
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue);
+
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature);
+
+ // remove the entry.
+ // 100204:IS - Hmmm. I'm not sure what the usage...
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature);
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ITypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ITypeMapper.java
index 0b7b429566..ab8a331af1 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ITypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ITypeMapper.java
@@ -1,49 +1,49 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Attribute;
-
-/**
- * Maps between Objy types (classes and objects), and EMF types.
- *
- * @author ibrahim
- */
-public interface ITypeMapper
-{
-
- final Numeric_Value numericTrue = new Numeric_Value(true);
-
- final Numeric_Value numericFalse = new Numeric_Value(false);
-
- // Model
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature);
-
- public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature);
-
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature);
-
- // Instance
- public void initialize(Class_Object class_Object, EStructuralFeature feature);
-
- // delete the entry.
- // 100204:IS - Hmmm. I'm not sure what the usage...
- public void delete(ObjyObject objyObject, EStructuralFeature feature);
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Attribute;
+
+/**
+ * Maps between Objy types (classes and objects), and EMF types.
+ *
+ * @author ibrahim
+ */
+public interface ITypeMapper
+{
+
+ final Numeric_Value numericTrue = new Numeric_Value(true);
+
+ final Numeric_Value numericFalse = new Numeric_Value(false);
+
+ // Model
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature);
+
+ public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature);
+
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature);
+
+ // Instance
+ public void initialize(Class_Object class_Object, EStructuralFeature feature);
+
+ // delete the entry.
+ // 100204:IS - Hmmm. I'm not sure what the usage...
+ public void delete(ObjyObject objyObject, EStructuralFeature feature);
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IndexesReferenceMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IndexesReferenceMapper.java
index 87d2a1f636..0caa11c45f 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IndexesReferenceMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/IndexesReferenceMapper.java
@@ -1,115 +1,115 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Attribute;
-
-/**
- * @author Simon McDuff
- */
-
-// TODO - need implementation.
-public class IndexesReferenceMapper implements IManyTypeMapper
-{
-
- public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
- {
- EAnnotation annotation = feature.getEAnnotation("ooindex");
- if (annotation != null)
- {
- // String oclString = annotation.getDetails().get("key");
-
- }
- return true;
- }
-
- public Object getValue(ObjyObject internal, EStructuralFeature feature, int index)
- {
- throw new UnsupportedOperationException();
- }
-
- public void setValue(ObjyObject internal, EStructuralFeature feature, int index, Object newValue)
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- return true;
- }
-
- public void add(ObjyObject classObject, EStructuralFeature feature, int index, Object value)
- {
- // Index element!!!
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void addAll(ObjyObject classObject, EStructuralFeature feature, int index, Object[] value)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public int size(ObjyObject classObject, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public void initialize(Class_Object class_Object, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void clear(ObjyObject classObject, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public Object remove(ObjyObject classObject, EStructuralFeature feature, int index)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void delete(ObjyObject class_Object, EStructuralFeature feature)
- {
- }
-
- public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValue)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EAnnotation;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Attribute;
+
+/**
+ * @author Simon McDuff
+ */
+
+// TODO - need implementation.
+public class IndexesReferenceMapper implements IManyTypeMapper
+{
+
+ public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
+ {
+ EAnnotation annotation = feature.getEAnnotation("ooindex");
+ if (annotation != null)
+ {
+ // String oclString = annotation.getDetails().get("key");
+
+ }
+ return true;
+ }
+
+ public Object getValue(ObjyObject internal, EStructuralFeature feature, int index)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setValue(ObjyObject internal, EStructuralFeature feature, int index, Object newValue)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ public void add(ObjyObject classObject, EStructuralFeature feature, int index, Object value)
+ {
+ // Index element!!!
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void addAll(ObjyObject classObject, EStructuralFeature feature, int index, Object[] value)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public int size(ObjyObject classObject, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void initialize(Class_Object class_Object, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void clear(ObjyObject classObject, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public Object remove(ObjyObject classObject, EStructuralFeature feature, int index)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void delete(ObjyObject class_Object, EStructuralFeature feature)
+ {
+ }
+
+ public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValue)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ManyReferenceMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ManyReferenceMapper.java
index f38891aeda..9894117d0f 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ManyReferenceMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ManyReferenceMapper.java
@@ -1,342 +1,342 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListId;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.TypeConvert;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.d_Class;
-import com.objy.db.ObjyRuntimeException;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooTreeListX;
-
-/**
- * @author Simon McDuff
- */
-public class ManyReferenceMapper extends BasicTypeMapper implements IManyTypeMapper
-{
- static d_Class dClassObject = null;
-
- static ManyReferenceMapper INSTANCE = new ManyReferenceMapper();
-
- @SuppressWarnings("unused")
- private static d_Class getArrayListClass()
- {
- if (dClassObject == null)
- {
- dClassObject = ObjySchema.getTopModule().resolve_class(ObjyArrayListId.className);
- }
- return dClassObject;
- }
-
- public boolean createSchema(Proposed_Class propClass, EStructuralFeature feature)
- {
- try
- {
- // ooArrayListId.buildSchema();
-
- propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
- d_Access_Kind.d_PUBLIC, // Access kind
- feature.getName(), // Attribute name
- 1, // # elements in fixed-size array
- ObjyArrayListId.className, false); // Default value // Default value
-
- return true;
- }
- catch (ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- return false;
- }
- }
-
- public Object getValue(ObjyObject internal, EStructuralFeature feature, int index)
- {
- ObjyArrayListId list = getList(internal, feature);
- if (list != null)
- {
- return list.get(index);
- }
-
- try
- {
- throw new Exception("Trying to getValue of object while the list is null.");
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return null;
- }
-
- public void setValue(ObjyObject internal, EStructuralFeature feature, int index, Object newValue)
- {
- ObjyArrayListId list = getList(internal, feature);
-
- try
- {
- if (list != null)
- {
- list.set(index, TypeConvert.toOoId(newValue));
- }
- else
- {
- throw new Exception("Trying to setValue for object while the list is null.");
- }
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- public ObjyArrayListId getList(ObjyObject objyObject, EStructuralFeature feature)
- {
- // System.out.println("getList() for : " + objyObject.ooId().getStoreString() + " feature: " + feature.getName());
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- ObjyArrayListId list = (ObjyArrayListId)objyObject.getFeatureList(attributeName/* position */);
- if (list == null)
- {
- try
- {
- ooId oid = objyObject.get_ooId(attributeName/* position */);
- if (!oid.isNull())
- {
- list = new ObjyArrayListId(Class_Object.class_object_from_oid(oid));
- objyObject.setFeatureList(attributeName/* position */, list);
- }
- // System.out.println("... getList() -> gotOID: " + oid.getStoreString());
- }
- catch (ObjyRuntimeException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- return list;
- }
-
- public int size(ObjyObject objyObject, EStructuralFeature feature)
- {
- ObjyArrayListId list = getList(objyObject, feature);
-
- return (int)(list == null ? 0 : list.size());
- }
-
- public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value)
- {
- ooId obj = TypeConvert.toOoId(value);
- ObjyArrayListId list = getList(objyObject, feature);
- if (list != null)
- {
- list.add(index, obj);
- }
- else
- {
- try
- {
- throw new Exception("Trying to add objects while the list is null.");
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- public void addAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] value)
- {
- ObjyArrayListId list = getList(objyObject, feature);
- if (list != null)
- {
- list.addAll(index, value);
- }
- else
- {
- try
- {
- throw new Exception("Trying to addAll objects while the list is null.");
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- }
-
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- System.out.println("OBJYIMPL: ManyReferenceMapper.validate() - not implemented.");
- return true;
- }
-
- public void initialize(Class_Object classObject, EStructuralFeature feature)
- {
- // Class_Position position = classObject.position_in_class(getAttributeName(feature));
- // Class_Object newClassObject = Class_Object
- // .new_persistent_object(getArrayListClass(), classObject.objectID(), false);
- ooTreeListX list = new ooTreeListX(2, false);
- // ObjyObjectManager.newInternalObjCount++;
- ooObj anObj = ooObj.create_ooObj(classObject.objectID());
- anObj.cluster(list);
- classObject.nset_ooId(getAttributeName(feature), list.getOid());
- // classObject.set_ooId(position, newClassObject.objectID());
- // ObjyArrayListId.initObject(newClassObject);
- }
-
- public void delete(ObjyObject objyObject, EStructuralFeature feature)
- {
- // System.out.println("delete() for : " + objyObject.ooId().getStoreString() + " feature: " + feature.getName());
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- ooId tobeDeleted = objyObject.get_ooId(attributeName/* position */);
- ooObj objectToDelete = ooObj.create_ooObj(tobeDeleted);
- objectToDelete.delete();
- // set the reference to null.
- objyObject.set_ooId(getAttributeName(feature)/* position */, null);
- objyObject.setFeatureList(attributeName/* position */, null);
- }
-
- public void clear(ObjyObject objyObject, EStructuralFeature feature)
- {
- ObjyArrayListId list = getList(objyObject, feature);
- if (list != null)
- {
- list.clear();
- }
- else
- {
- try
- {
- throw new Exception("Trying to clear objects while the list is null.");
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- }
-
- public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
- {
- // System.out.println("remove() for : " + objyObject.ooId().getStoreString() + " feature: " + feature.getName() +
- // " index: "+index);
- Object oldValue = getValue(objyObject, feature, index);
- ObjyArrayListId list = getList(objyObject, feature);
-
- if (list != null)
- {
- list.remove(index);
- }
- else
- {
- try
- {
- throw new Exception("Trying to remove element while the list is null.");
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- return oldValue;
- }
-
- public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
- {
- int size = size(objyObject, feature);
-
- if (chunkSize != CDORevision.UNCHUNKED)
- {
- size = Math.min(size, chunkSize);
- }
-
- // CDOList cdoList = CDOListFactory.DEFAULT.createList(size, size, 0);
- ooId[] ooIds = null;
- ObjyArrayListId list = getList(objyObject, feature);
-
- if (list != null)
- {
- ooIds = list.getAll(index, size);
- }
- else
- {
- try
- {
- throw new Exception("Trying to getAll objects while the list is null.");
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- return ooIds;
- }
-
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
- {
- addAll(objyObject, feature, 0, newValues);
- }
-
- public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
- {
- ObjyArrayListId list = getList(objyObject, feature);
-
- if (list != null)
- {
- list.move(targetIndex, sourceIndex);
- }
- else
- {
- try
- {
- throw new Exception("Trying to move element while the list is null.");
- }
- catch (Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListId;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.TypeConvert;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.d_Class;
+import com.objy.db.ObjyRuntimeException;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeListX;
+
+/**
+ * @author Simon McDuff
+ */
+public class ManyReferenceMapper extends BasicTypeMapper implements IManyTypeMapper
+{
+ static d_Class dClassObject = null;
+
+ static ManyReferenceMapper INSTANCE = new ManyReferenceMapper();
+
+ @SuppressWarnings("unused")
+ private static d_Class getArrayListClass()
+ {
+ if (dClassObject == null)
+ {
+ dClassObject = ObjySchema.getTopModule().resolve_class(ObjyArrayListId.className);
+ }
+ return dClassObject;
+ }
+
+ public boolean createSchema(Proposed_Class propClass, EStructuralFeature feature)
+ {
+ try
+ {
+ // ooArrayListId.buildSchema();
+
+ propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ feature.getName(), // Attribute name
+ 1, // # elements in fixed-size array
+ ObjyArrayListId.className, false); // Default value // Default value
+
+ return true;
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ return false;
+ }
+ }
+
+ public Object getValue(ObjyObject internal, EStructuralFeature feature, int index)
+ {
+ ObjyArrayListId list = getList(internal, feature);
+ if (list != null)
+ {
+ return list.get(index);
+ }
+
+ try
+ {
+ throw new Exception("Trying to getValue of object while the list is null.");
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public void setValue(ObjyObject internal, EStructuralFeature feature, int index, Object newValue)
+ {
+ ObjyArrayListId list = getList(internal, feature);
+
+ try
+ {
+ if (list != null)
+ {
+ list.set(index, TypeConvert.toOoId(newValue));
+ }
+ else
+ {
+ throw new Exception("Trying to setValue for object while the list is null.");
+ }
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ public ObjyArrayListId getList(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // System.out.println("getList() for : " + objyObject.ooId().getStoreString() + " feature: " + feature.getName());
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ ObjyArrayListId list = (ObjyArrayListId)objyObject.getFeatureList(attributeName/* position */);
+ if (list == null)
+ {
+ try
+ {
+ ooId oid = objyObject.get_ooId(attributeName/* position */);
+ if (!oid.isNull())
+ {
+ list = new ObjyArrayListId(Class_Object.class_object_from_oid(oid));
+ objyObject.setFeatureList(attributeName/* position */, list);
+ }
+ // System.out.println("... getList() -> gotOID: " + oid.getStoreString());
+ }
+ catch (ObjyRuntimeException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return list;
+ }
+
+ public int size(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ ObjyArrayListId list = getList(objyObject, feature);
+
+ return (int)(list == null ? 0 : list.size());
+ }
+
+ public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value)
+ {
+ ooId obj = TypeConvert.toOoId(value);
+ ObjyArrayListId list = getList(objyObject, feature);
+ if (list != null)
+ {
+ list.add(index, obj);
+ }
+ else
+ {
+ try
+ {
+ throw new Exception("Trying to add objects while the list is null.");
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void addAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] value)
+ {
+ ObjyArrayListId list = getList(objyObject, feature);
+ if (list != null)
+ {
+ list.addAll(index, value);
+ }
+ else
+ {
+ try
+ {
+ throw new Exception("Trying to addAll objects while the list is null.");
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ System.out.println("OBJYIMPL: ManyReferenceMapper.validate() - not implemented.");
+ return true;
+ }
+
+ public void initialize(Class_Object classObject, EStructuralFeature feature)
+ {
+ // Class_Position position = classObject.position_in_class(getAttributeName(feature));
+ // Class_Object newClassObject = Class_Object
+ // .new_persistent_object(getArrayListClass(), classObject.objectID(), false);
+ ooTreeListX list = new ooTreeListX(2, false);
+ // ObjyObjectManager.newInternalObjCount++;
+ ooObj anObj = ooObj.create_ooObj(classObject.objectID());
+ anObj.cluster(list);
+ classObject.nset_ooId(getAttributeName(feature), list.getOid());
+ // classObject.set_ooId(position, newClassObject.objectID());
+ // ObjyArrayListId.initObject(newClassObject);
+ }
+
+ public void delete(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // System.out.println("delete() for : " + objyObject.ooId().getStoreString() + " feature: " + feature.getName());
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ ooId tobeDeleted = objyObject.get_ooId(attributeName/* position */);
+ ooObj objectToDelete = ooObj.create_ooObj(tobeDeleted);
+ objectToDelete.delete();
+ // set the reference to null.
+ objyObject.set_ooId(getAttributeName(feature)/* position */, null);
+ objyObject.setFeatureList(attributeName/* position */, null);
+ }
+
+ public void clear(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ ObjyArrayListId list = getList(objyObject, feature);
+ if (list != null)
+ {
+ list.clear();
+ }
+ else
+ {
+ try
+ {
+ throw new Exception("Trying to clear objects while the list is null.");
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
+ {
+ // System.out.println("remove() for : " + objyObject.ooId().getStoreString() + " feature: " + feature.getName() +
+ // " index: "+index);
+ Object oldValue = getValue(objyObject, feature, index);
+ ObjyArrayListId list = getList(objyObject, feature);
+
+ if (list != null)
+ {
+ list.remove(index);
+ }
+ else
+ {
+ try
+ {
+ throw new Exception("Trying to remove element while the list is null.");
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return oldValue;
+ }
+
+ public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
+ {
+ int size = size(objyObject, feature);
+
+ if (chunkSize != CDORevision.UNCHUNKED)
+ {
+ size = Math.min(size, chunkSize);
+ }
+
+ // CDOList cdoList = CDOListFactory.DEFAULT.createList(size, size, 0);
+ ooId[] ooIds = null;
+ ObjyArrayListId list = getList(objyObject, feature);
+
+ if (list != null)
+ {
+ ooIds = list.getAll(index, size);
+ }
+ else
+ {
+ try
+ {
+ throw new Exception("Trying to getAll objects while the list is null.");
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return ooIds;
+ }
+
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
+ {
+ addAll(objyObject, feature, 0, newValues);
+ }
+
+ public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
+ {
+ ObjyArrayListId list = getList(objyObject, feature);
+
+ if (list != null)
+ {
+ list.move(targetIndex, sourceIndex);
+ }
+ else
+ {
+ try
+ {
+ throw new Exception("Trying to move element while the list is null.");
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/MultipleTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/MultipleTypeMapper.java
index 22f58d23c0..6c4b7ed102 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/MultipleTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/MultipleTypeMapper.java
@@ -1,159 +1,159 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Attribute;
-
-import java.util.ArrayList;
-
-// TODO - verify the need for this, and perhaps extend the implementation to the
-// colletion of mappers.
-public class MultipleTypeMapper extends BasicTypeMapper implements IManyTypeMapper
-{
- ArrayList<IManyTypeMapper> mapperList = new ArrayList<IManyTypeMapper>();
-
- public void add(IManyTypeMapper attributeBridge)
- {
- mapperList.add(attributeBridge);
- }
-
- // @Override
- public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
- {
- boolean result = true;
- for (IManyTypeMapper manyMapper : mapperList)
- {
- result &= manyMapper.createSchema(proposedClasses, feature);
- }
- return result;
- }
-
- // @Override
- public Object getValue(ObjyObject class_Object, EStructuralFeature feature, int index)
- {
- return mapperList.get(0).getValue(class_Object, feature, index);
- }
-
- // @Override
- public void initialize(Class_Object class_Object, EStructuralFeature feature)
- {
- for (ITypeMapper manyMapper : mapperList)
- {
- manyMapper.initialize(class_Object, feature);
- }
- }
-
- // @Override
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- for (IManyTypeMapper manyMapper : mapperList)
- {
- manyMapper.modifySchema(proposedooClass, feature);
- }
- }
-
- // @Override
- public void setValue(ObjyObject class_Object, EStructuralFeature feature, int index, Object newValue)
- {
- mapperList.get(0).setValue(class_Object, feature, index, newValue);
- }
-
- // @Override
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
-
- boolean result = true;
- for (ITypeMapper manyMapper : mapperList)
- {
- result &= manyMapper.validate(ooAttribute, feature);
- }
- return result;
-
- }
-
- // @Override
- public void add(ObjyObject classObject, EStructuralFeature feature, int index, Object value)
- {
- for (IManyTypeMapper manyMapper : mapperList)
- {
- manyMapper.add(classObject, feature, index, value);
- }
-
- }
-
- public void addAll(ObjyObject classObject, EStructuralFeature feature, int index, Object[] value)
- {
- for (IManyTypeMapper manyMapper : mapperList)
- {
- manyMapper.addAll(classObject, feature, index, value);
- }
- }
-
- // @Override
- public int size(ObjyObject classObject, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- return mapperList.get(0).size(classObject, feature);
- }
-
- // @Override
- public void clear(ObjyObject classObject, EStructuralFeature feature)
- {
- for (IManyTypeMapper manyMapper : mapperList)
- {
- manyMapper.clear(classObject, feature);
- }
-
- }
-
- // @Override
- public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
- {
- Object returnValue = null;
- int i = 0;
- for (IManyTypeMapper manyMapper : mapperList)
- {
- Object object = manyMapper.remove(objyObject, feature, index);
- if (i == 0)
- {
- returnValue = object;
- }
- }
- return returnValue;
- }
-
- public void delete(ObjyObject objyObject, EStructuralFeature feature)
- {
- }
-
- public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
- {
- return mapperList.get(0).getAll(objyObject, feature, index, chunkSize);
- }
-
- public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
- {
- mapperList.get(0).setAll(objyObject, feature, index, newValues);
- }
-
- public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
- {
- mapperList.get(0).move(objyObject, feature, targetIndex, sourceIndex);
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Attribute;
+
+import java.util.ArrayList;
+
+// TODO - verify the need for this, and perhaps extend the implementation to the
+// colletion of mappers.
+public class MultipleTypeMapper extends BasicTypeMapper implements IManyTypeMapper
+{
+ ArrayList<IManyTypeMapper> mapperList = new ArrayList<IManyTypeMapper>();
+
+ public void add(IManyTypeMapper attributeBridge)
+ {
+ mapperList.add(attributeBridge);
+ }
+
+ // @Override
+ public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
+ {
+ boolean result = true;
+ for (IManyTypeMapper manyMapper : mapperList)
+ {
+ result &= manyMapper.createSchema(proposedClasses, feature);
+ }
+ return result;
+ }
+
+ // @Override
+ public Object getValue(ObjyObject class_Object, EStructuralFeature feature, int index)
+ {
+ return mapperList.get(0).getValue(class_Object, feature, index);
+ }
+
+ // @Override
+ public void initialize(Class_Object class_Object, EStructuralFeature feature)
+ {
+ for (ITypeMapper manyMapper : mapperList)
+ {
+ manyMapper.initialize(class_Object, feature);
+ }
+ }
+
+ // @Override
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ for (IManyTypeMapper manyMapper : mapperList)
+ {
+ manyMapper.modifySchema(proposedooClass, feature);
+ }
+ }
+
+ // @Override
+ public void setValue(ObjyObject class_Object, EStructuralFeature feature, int index, Object newValue)
+ {
+ mapperList.get(0).setValue(class_Object, feature, index, newValue);
+ }
+
+ // @Override
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+
+ boolean result = true;
+ for (ITypeMapper manyMapper : mapperList)
+ {
+ result &= manyMapper.validate(ooAttribute, feature);
+ }
+ return result;
+
+ }
+
+ // @Override
+ public void add(ObjyObject classObject, EStructuralFeature feature, int index, Object value)
+ {
+ for (IManyTypeMapper manyMapper : mapperList)
+ {
+ manyMapper.add(classObject, feature, index, value);
+ }
+
+ }
+
+ public void addAll(ObjyObject classObject, EStructuralFeature feature, int index, Object[] value)
+ {
+ for (IManyTypeMapper manyMapper : mapperList)
+ {
+ manyMapper.addAll(classObject, feature, index, value);
+ }
+ }
+
+ // @Override
+ public int size(ObjyObject classObject, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ return mapperList.get(0).size(classObject, feature);
+ }
+
+ // @Override
+ public void clear(ObjyObject classObject, EStructuralFeature feature)
+ {
+ for (IManyTypeMapper manyMapper : mapperList)
+ {
+ manyMapper.clear(classObject, feature);
+ }
+
+ }
+
+ // @Override
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
+ {
+ Object returnValue = null;
+ int i = 0;
+ for (IManyTypeMapper manyMapper : mapperList)
+ {
+ Object object = manyMapper.remove(objyObject, feature, index);
+ if (i == 0)
+ {
+ returnValue = object;
+ }
+ }
+ return returnValue;
+ }
+
+ public void delete(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ }
+
+ public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
+ {
+ return mapperList.get(0).getAll(objyObject, feature, index, chunkSize);
+ }
+
+ public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
+ {
+ mapperList.get(0).setAll(objyObject, feature, index, newValues);
+ }
+
+ public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
+ {
+ mapperList.get(0).move(objyObject, feature, targetIndex, sourceIndex);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericManyTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericManyTypeMapper.java
index 57e6e9c246..86796d8cc1 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericManyTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericManyTypeMapper.java
@@ -1,701 +1,701 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Basic_Attribute;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.Proposed_Property;
-import com.objy.as.app.VArray_Object;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.d_Class;
-import com.objy.as.app.d_Module;
-import com.objy.as.app.ooBaseType;
-
-import java.util.Date;
-
-/**
- * @author Ibrahim Sallam
- */
-public abstract class NumericManyTypeMapper extends BasicTypeMapper implements IManyTypeMapper
-{
-
- protected abstract Object fromNumericValue(Numeric_Value numericValue, boolean isNull);
-
- protected abstract Numeric_Value toNumericValue(Object value);
-
- protected abstract ooBaseType getObjyBaseType();
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, NumericManyTypeMapper.class);
-
- public static NumericManyTypeMapper.TMBoolean TMBOOLEAN = new TMBoolean();
-
- public static NumericManyTypeMapper.TMByte TMBYTE = new TMByte();
-
- public static NumericManyTypeMapper.TMChar TMCHAR = new TMChar();
-
- public static NumericManyTypeMapper.TMDate TMDATE = new TMDate();
-
- public static NumericManyTypeMapper.TMDouble TMDOUBLE = new TMDouble();
-
- public static NumericManyTypeMapper.TMFloat TMFLOAT = new TMFloat();
-
- public static NumericManyTypeMapper.TMInteger TMINTEGER = new TMInteger();
-
- public static NumericManyTypeMapper.TMLong TMLONG = new TMLong();
-
- public static NumericManyTypeMapper.TMShort TMSHORT = new TMShort();
-
- // ---------------------------------
- // Schema
- // ---------------------------------
-
- private String embeddedClassName()
- {
- return "oo_" + getObjyBaseType() + "_Class";
- }
-
- private d_Class getEmbeddedClass()
- {
- d_Class embeddedClass = ObjySchema.getTopModule().resolve_class(embeddedClassName());
- // System.out.println("OBJY: Resolving className: " + embeddedClassName() + " - d_Class: " + embeddedClass);
- return embeddedClass;
- }
-
- private boolean createEmbeddedClass()
- {
- boolean bDone = true;
-
- d_Module top_mod = ObjySchema.getTopModule();
- boolean inProcess = top_mod.proposed_classes().hasNext();
-
- Proposed_Class propClass = top_mod.propose_new_class(embeddedClassName());
-
- propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- embeddedAttributeName, // Attribute name
- 1, // # elements in fixed-size array
- getObjyBaseType() // Type of numeric data
- ); // Default value
-
- propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- embeddedAttributeNull, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooBOOLEAN// Type of numeric data
- ); // Default value
-
- // System.out.println("OBJY: Propose Creating new class: " + embeddedClassName());
-
- // ObjySchema.getTopModule().propose_new_class(propClass);
- if (!inProcess)
- {
- top_mod.activate_proposals(true, true);
- }
-
- return bDone;
- }
-
- /**
- *
- */
- public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Adding attribute " + feature.getName() + " " + this.getClass().getName());
- }
-
- // create an embedded class (attributeType, attributeIsNull).
- // TODO - we might need to move this to the .objectivity.schema, since it's
- // independent of the model classes.
-
- if (getEmbeddedClass() == null && !createEmbeddedClass())
- {
- return false;
- }
-
- // create array of embedded class type.
- proposedClass.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- getAttributeName(feature), // Attribute name
- 1, embeddedClassName());
-
- return false;
- }
-
- /**
- * TODO - this is a simple change to the attribute, make it handle more complex cases. I also don't think it does
- * handle the arrays.
- *
- * @param proposedooClass
- * @param feature
- */
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- Proposed_Property prop = proposedooClass.resolve_property(getAttributeName(feature));
-
- if (prop instanceof Proposed_Basic_Attribute)
- {
- Proposed_Basic_Attribute attr = (Proposed_Basic_Attribute)prop;
- attr.change_base_type(getObjyBaseType());
- }
- }
-
- /**
- * TBD - Fixed size array attributes can't be accessed, so we can't validate This!!! OFJ (Fix it)
- */
- public boolean validate(d_Attribute dAttribute, EStructuralFeature feature)
- {
- System.out.println(">>>OBJYIMPL: NumericManyTypeMapper.validate() - not implemented.");
- return true;
- // d_Class varrayClass = dAttribute.class_type_of();
- // d_Class embeddedClass = varrayClass.
- // Class_Position position = embeddedClass.position_in_class(getAttributeName(feature));
- // //d_Type type = ooAttribute.type_of();
- // d_Type type = embeddedClass.attribute_at_position(position).type_of();
- // if (TRACER_DEBUG.isEnabled()) {
- // TRACER_DEBUG.trace(getAttributeName(feature) + " "
- // + ((Basic_Type) type).base_type() + " basic type "
- // + type.is_basic_type() + " - " + getObjyBaseType());
- // }
- // return type.is_basic_type()
- // && ((Basic_Type) type).base_type() == getObjyBaseType();
- }
-
- // ---------------------------------
- // Object
- // ---------------------------------
-
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, int index, Object newValue)
- {
- // System.out.println("OBJY: Set value in VArray at index: "+ index + " - value: " + newValue);
- boolean isNull = newValue == null;
- Numeric_Value numericValue = toNumericValue(newValue);
- Numeric_Value isNullValue = isNull ? numericTrue : numericFalse;
-
- Class_Object embedded = getArray(objyObject, feature).get_class_obj(index);
-
- embedded.set_numeric(valueAttributePosition, numericValue);
- embedded.set_numeric(nullAttributePosition, isNullValue);
- }
-
- // get a single object/value at index.
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature, int index)
- {
- Numeric_Value numericValue = null;
-
- Class_Object embedded = getArray(objyObject, feature).get_class_obj(index);
-
- numericValue = embedded.get_numeric(valueAttributePosition);
- boolean isNull = embedded.get_numeric(nullAttributePosition).booleanValue();
-
- return fromNumericValue(numericValue, isNull);
- }
-
- // remove a single value at index, it will set the value to default, and mark it
- // as "null", i.e. unset.
- public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
- {
- // we'll just get the original value, and set the value to null.
- // Numeric_Value numericValue = null;
-
- long size = (int)getArray(objyObject, feature).size();
- for (int i = index; i < size - 1; i++)
- {
- setValue(objyObject, feature, i, getValue(objyObject, feature, i + 1));
- }
- // resize the array.
- getArray(objyObject, feature).resize(size - 1);
- /*
- * Class_Object embedded = getArray(objyObject, feature).get_class_obj(index); numericValue =
- * embedded.get_numeric(valueAttributePosition); boolean isNull =
- * embedded.get_numeric(nullAttributePosition).booleanValue(); Object oldValue = fromNumericValue(numericValue,
- * isNull); numericValue = toNumericValue(null); embedded.set_numeric(valueAttributePosition, numericValue);
- * embedded.set_numeric(nullAttributePosition, numericTrue);
- */
- return null;
- }
-
- // add value at index (extend the collection size).
- public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value)
- {
- int arraySize = size(objyObject, feature);
- // System.out.println("OBJY: Adding object inside VArray at index: "+ index + " - value: " + value);
- if (index < arraySize - 1)
- {
- // throw new UnsupportedOperationException("adding object inside VArray?!!... Implement Me!!!");
- // resize the VArray.
- VArray_Object array = getArray(objyObject, feature);
- array.resize(arraySize + 1);
- for (int i = arraySize; i > index; i--)
- {
- Class_Object newEmbedded = array.get_class_obj(i);
- Class_Object oldEmbedded = array.get_class_obj(i - 1);
- newEmbedded.set_numeric(valueAttributePosition, oldEmbedded.get_numeric(valueAttributePosition));
- newEmbedded.set_numeric(nullAttributePosition, oldEmbedded.get_numeric(nullAttributePosition));
- }
- }
- if (index != -1 && index > arraySize)
- {
- throw new UnsupportedOperationException("adding object beyond VArray size()?!!... Implement Me!!!");
- }
-
- getArray(objyObject, feature).resize(arraySize + 1);
-
- setValue(objyObject, feature, index, value);
- }
-
- public// add all objects starting from an index. (extend the collection size).
- void addAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] values)
- {
- // System.out.println("OBJY: AddAll objects inside VArray at index: "+ index + " - values: " + values);
- int arraySize = size(objyObject, feature);
- if (index < arraySize - 1)
- {
- throw new UnsupportedOperationException("adding objects inside VArray?!!... Implement Me!!!");
- }
-
- if (index != -1 && index > arraySize)
- {
- throw new UnsupportedOperationException("adding objects beyond VArray size()?!!... Implement Me!!!");
- }
-
- int newSize = arraySize + values.length;
- getArray(objyObject, feature).resize(newSize);
-
- for (int i = 0; i < values.length; i++)
- {
- setValue(objyObject, feature, arraySize + i, values[i]);
- }
- }
-
- // clear all collection.
- public void clear(ObjyObject objyObject, EStructuralFeature feature)
- {
- // set the varray size to 0.
- getArray(objyObject, feature).resize(0);
- }
-
- // this is similar to addAll, but it replaces the existing ones.
- public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
- {
-
- VArray_Object array = getArray(objyObject, feature);
-
- array.resize(newValues.length);
- for (int i = 0; i < newValues.length; i++)
- {
- // TODO - we might need to optimize this!!!
- setValue(objyObject, feature, i, newValues[i]);
- }
- }
-
- // get all objects/values starting from an index.
- public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
- {
- int size = size(objyObject, feature);
-
- if (chunkSize != CDORevision.UNCHUNKED)
- {
- size = Math.min(size, chunkSize);
- }
-
- Object[] values = new Object[size];
-
- // TODO - we might need to optimize this!!!!
- for (int i = 0; i < size; i++)
- {
- values[i] = getValue(objyObject, feature, i + index);
- }
- return values;
- }
-
- // return the size of the collection.
- public int size(ObjyObject objyObject, EStructuralFeature feature)
- {
- return (int)getArray(objyObject, feature).size();
- }
-
- public void delete(ObjyObject objyObject, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
- {
- if (targetIndex == sourceIndex)
- {
- return;
- }
-
- // get the object at sourceIndex.
- Object value = getValue(objyObject, feature, sourceIndex);
-
- // long size = (int)getArray(objyObject, feature).size();
- // TODO - check boundaries...
-
- if (sourceIndex > targetIndex)
- {
- for (int i = sourceIndex; i > targetIndex; i--)
- {
- setValue(objyObject, feature, i, getValue(objyObject, feature, i - 1));
- }
- }
- else if (sourceIndex < targetIndex)
- {
- for (int i = sourceIndex; i < targetIndex; i++)
- {
- setValue(objyObject, feature, i, getValue(objyObject, feature, i + 1));
- }
- }
- // set the saved value at target
- setValue(objyObject, feature, targetIndex, value);
-
- }
-
- public void initialize(Class_Object classObject, EStructuralFeature feature)
- {
- // TODO - verify if we need to do any initialization!!!
- }
-
- protected VArray_Object getArray(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- return objyObject.get_varray(attributeName/* position */);
- }
-
- // ------------------------------------------------------------------------
- // ------------------- Various types --------------------------
- // ------------------------------------------------------------------------
-
- // ---------------------------
- // Boolean
- // ---------------------------
- public static class TMBoolean extends NumericManyTypeMapper
- {
- @Override
- protected ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooBOOLEAN;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Boolean value = null;
- if (!isNull)
- {
- value = numericValue.booleanValue();
- }
- return value;
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(false);
- }
-
- return new Numeric_Value(((Boolean)value).booleanValue());
- }
- }
-
- // ---------------------------
- // Byte
- // ---------------------------
- public static class TMByte extends NumericManyTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT8;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Byte value = null;
- if (!isNull)
- {
- value = numericValue.byteValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Byte)value).byteValue());
- }
- }
-
- // ---------------------------
- // Char
- // ---------------------------
- public static class TMChar extends NumericManyTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT8;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Character value = null;
- if (!isNull)
- {
- value = numericValue.charValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Character)value).charValue());
- }
- }
-
- // ---------------------------
- // Date
- // ---------------------------
- public static class TMDate extends NumericManyTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT64;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Date value = null;
- if (!isNull)
- {
- value = new Date(numericValue.longValue());
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Date)value).getTime());
- }
- }
-
- // ---------------------------
- // Double
- // ---------------------------
- public static class TMDouble extends NumericManyTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooFLOAT64;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Double value = null;
- if (!isNull)
- {
- value = numericValue.doubleValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0.0);
- }
-
- return new Numeric_Value(((Double)value).doubleValue());
- }
- }
-
- // ---------------------------
- // Float
- // ---------------------------
- public static class TMFloat extends NumericManyTypeMapper
- {
- @Override
- protected ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooFLOAT64;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Float value = null;
- if (!isNull)
- {
- value = numericValue.floatValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0.0);
- }
-
- return new Numeric_Value(((Float)value).floatValue());
- }
- }
-
- // ---------------------------
- // Integer
- // ---------------------------
- public static class TMInteger extends NumericManyTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT32;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Integer value = null;
- if (!isNull)
- {
- value = numericValue.intValue();
- }
- return value;
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Integer)value).intValue());
- }
- }
-
- // ---------------------------
- // Long
- // ---------------------------
- public static class TMLong extends NumericManyTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT64;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Long value = null;
- if (!isNull)
- {
- value = numericValue.longValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Long)value).longValue());
- }
- }
-
- // ---------------------------
- // Short
- // ---------------------------
- public static class TMShort extends NumericManyTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT16;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Short value = null;
- if (!isNull)
- {
- value = numericValue.shortValue();
- }
- return value;
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Short)value).shortValue());
- }
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Basic_Attribute;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.Proposed_Property;
+import com.objy.as.app.VArray_Object;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.d_Class;
+import com.objy.as.app.d_Module;
+import com.objy.as.app.ooBaseType;
+
+import java.util.Date;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public abstract class NumericManyTypeMapper extends BasicTypeMapper implements IManyTypeMapper
+{
+
+ protected abstract Object fromNumericValue(Numeric_Value numericValue, boolean isNull);
+
+ protected abstract Numeric_Value toNumericValue(Object value);
+
+ protected abstract ooBaseType getObjyBaseType();
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, NumericManyTypeMapper.class);
+
+ public static NumericManyTypeMapper.TMBoolean TMBOOLEAN = new TMBoolean();
+
+ public static NumericManyTypeMapper.TMByte TMBYTE = new TMByte();
+
+ public static NumericManyTypeMapper.TMChar TMCHAR = new TMChar();
+
+ public static NumericManyTypeMapper.TMDate TMDATE = new TMDate();
+
+ public static NumericManyTypeMapper.TMDouble TMDOUBLE = new TMDouble();
+
+ public static NumericManyTypeMapper.TMFloat TMFLOAT = new TMFloat();
+
+ public static NumericManyTypeMapper.TMInteger TMINTEGER = new TMInteger();
+
+ public static NumericManyTypeMapper.TMLong TMLONG = new TMLong();
+
+ public static NumericManyTypeMapper.TMShort TMSHORT = new TMShort();
+
+ // ---------------------------------
+ // Schema
+ // ---------------------------------
+
+ private String embeddedClassName()
+ {
+ return "oo_" + getObjyBaseType() + "_Class";
+ }
+
+ private d_Class getEmbeddedClass()
+ {
+ d_Class embeddedClass = ObjySchema.getTopModule().resolve_class(embeddedClassName());
+ // System.out.println("OBJY: Resolving className: " + embeddedClassName() + " - d_Class: " + embeddedClass);
+ return embeddedClass;
+ }
+
+ private boolean createEmbeddedClass()
+ {
+ boolean bDone = true;
+
+ d_Module top_mod = ObjySchema.getTopModule();
+ boolean inProcess = top_mod.proposed_classes().hasNext();
+
+ Proposed_Class propClass = top_mod.propose_new_class(embeddedClassName());
+
+ propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ embeddedAttributeName, // Attribute name
+ 1, // # elements in fixed-size array
+ getObjyBaseType() // Type of numeric data
+ ); // Default value
+
+ propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ embeddedAttributeNull, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooBOOLEAN// Type of numeric data
+ ); // Default value
+
+ // System.out.println("OBJY: Propose Creating new class: " + embeddedClassName());
+
+ // ObjySchema.getTopModule().propose_new_class(propClass);
+ if (!inProcess)
+ {
+ top_mod.activate_proposals(true, true);
+ }
+
+ return bDone;
+ }
+
+ /**
+ *
+ */
+ public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Adding attribute " + feature.getName() + " " + this.getClass().getName());
+ }
+
+ // create an embedded class (attributeType, attributeIsNull).
+ // TODO - we might need to move this to the .objectivity.schema, since it's
+ // independent of the model classes.
+
+ if (getEmbeddedClass() == null && !createEmbeddedClass())
+ {
+ return false;
+ }
+
+ // create array of embedded class type.
+ proposedClass.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ getAttributeName(feature), // Attribute name
+ 1, embeddedClassName());
+
+ return false;
+ }
+
+ /**
+ * TODO - this is a simple change to the attribute, make it handle more complex cases. I also don't think it does
+ * handle the arrays.
+ *
+ * @param proposedooClass
+ * @param feature
+ */
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ Proposed_Property prop = proposedooClass.resolve_property(getAttributeName(feature));
+
+ if (prop instanceof Proposed_Basic_Attribute)
+ {
+ Proposed_Basic_Attribute attr = (Proposed_Basic_Attribute)prop;
+ attr.change_base_type(getObjyBaseType());
+ }
+ }
+
+ /**
+ * TBD - Fixed size array attributes can't be accessed, so we can't validate This!!! OFJ (Fix it)
+ */
+ public boolean validate(d_Attribute dAttribute, EStructuralFeature feature)
+ {
+ System.out.println(">>>OBJYIMPL: NumericManyTypeMapper.validate() - not implemented.");
+ return true;
+ // d_Class varrayClass = dAttribute.class_type_of();
+ // d_Class embeddedClass = varrayClass.
+ // Class_Position position = embeddedClass.position_in_class(getAttributeName(feature));
+ // //d_Type type = ooAttribute.type_of();
+ // d_Type type = embeddedClass.attribute_at_position(position).type_of();
+ // if (TRACER_DEBUG.isEnabled()) {
+ // TRACER_DEBUG.trace(getAttributeName(feature) + " "
+ // + ((Basic_Type) type).base_type() + " basic type "
+ // + type.is_basic_type() + " - " + getObjyBaseType());
+ // }
+ // return type.is_basic_type()
+ // && ((Basic_Type) type).base_type() == getObjyBaseType();
+ }
+
+ // ---------------------------------
+ // Object
+ // ---------------------------------
+
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, int index, Object newValue)
+ {
+ // System.out.println("OBJY: Set value in VArray at index: "+ index + " - value: " + newValue);
+ boolean isNull = newValue == null;
+ Numeric_Value numericValue = toNumericValue(newValue);
+ Numeric_Value isNullValue = isNull ? numericTrue : numericFalse;
+
+ Class_Object embedded = getArray(objyObject, feature).get_class_obj(index);
+
+ embedded.set_numeric(valueAttributePosition, numericValue);
+ embedded.set_numeric(nullAttributePosition, isNullValue);
+ }
+
+ // get a single object/value at index.
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature, int index)
+ {
+ Numeric_Value numericValue = null;
+
+ Class_Object embedded = getArray(objyObject, feature).get_class_obj(index);
+
+ numericValue = embedded.get_numeric(valueAttributePosition);
+ boolean isNull = embedded.get_numeric(nullAttributePosition).booleanValue();
+
+ return fromNumericValue(numericValue, isNull);
+ }
+
+ // remove a single value at index, it will set the value to default, and mark it
+ // as "null", i.e. unset.
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
+ {
+ // we'll just get the original value, and set the value to null.
+ // Numeric_Value numericValue = null;
+
+ long size = (int)getArray(objyObject, feature).size();
+ for (int i = index; i < size - 1; i++)
+ {
+ setValue(objyObject, feature, i, getValue(objyObject, feature, i + 1));
+ }
+ // resize the array.
+ getArray(objyObject, feature).resize(size - 1);
+ /*
+ * Class_Object embedded = getArray(objyObject, feature).get_class_obj(index); numericValue =
+ * embedded.get_numeric(valueAttributePosition); boolean isNull =
+ * embedded.get_numeric(nullAttributePosition).booleanValue(); Object oldValue = fromNumericValue(numericValue,
+ * isNull); numericValue = toNumericValue(null); embedded.set_numeric(valueAttributePosition, numericValue);
+ * embedded.set_numeric(nullAttributePosition, numericTrue);
+ */
+ return null;
+ }
+
+ // add value at index (extend the collection size).
+ public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value)
+ {
+ int arraySize = size(objyObject, feature);
+ // System.out.println("OBJY: Adding object inside VArray at index: "+ index + " - value: " + value);
+ if (index < arraySize - 1)
+ {
+ // throw new UnsupportedOperationException("adding object inside VArray?!!... Implement Me!!!");
+ // resize the VArray.
+ VArray_Object array = getArray(objyObject, feature);
+ array.resize(arraySize + 1);
+ for (int i = arraySize; i > index; i--)
+ {
+ Class_Object newEmbedded = array.get_class_obj(i);
+ Class_Object oldEmbedded = array.get_class_obj(i - 1);
+ newEmbedded.set_numeric(valueAttributePosition, oldEmbedded.get_numeric(valueAttributePosition));
+ newEmbedded.set_numeric(nullAttributePosition, oldEmbedded.get_numeric(nullAttributePosition));
+ }
+ }
+ if (index != -1 && index > arraySize)
+ {
+ throw new UnsupportedOperationException("adding object beyond VArray size()?!!... Implement Me!!!");
+ }
+
+ getArray(objyObject, feature).resize(arraySize + 1);
+
+ setValue(objyObject, feature, index, value);
+ }
+
+ public// add all objects starting from an index. (extend the collection size).
+ void addAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] values)
+ {
+ // System.out.println("OBJY: AddAll objects inside VArray at index: "+ index + " - values: " + values);
+ int arraySize = size(objyObject, feature);
+ if (index < arraySize - 1)
+ {
+ throw new UnsupportedOperationException("adding objects inside VArray?!!... Implement Me!!!");
+ }
+
+ if (index != -1 && index > arraySize)
+ {
+ throw new UnsupportedOperationException("adding objects beyond VArray size()?!!... Implement Me!!!");
+ }
+
+ int newSize = arraySize + values.length;
+ getArray(objyObject, feature).resize(newSize);
+
+ for (int i = 0; i < values.length; i++)
+ {
+ setValue(objyObject, feature, arraySize + i, values[i]);
+ }
+ }
+
+ // clear all collection.
+ public void clear(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // set the varray size to 0.
+ getArray(objyObject, feature).resize(0);
+ }
+
+ // this is similar to addAll, but it replaces the existing ones.
+ public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
+ {
+
+ VArray_Object array = getArray(objyObject, feature);
+
+ array.resize(newValues.length);
+ for (int i = 0; i < newValues.length; i++)
+ {
+ // TODO - we might need to optimize this!!!
+ setValue(objyObject, feature, i, newValues[i]);
+ }
+ }
+
+ // get all objects/values starting from an index.
+ public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
+ {
+ int size = size(objyObject, feature);
+
+ if (chunkSize != CDORevision.UNCHUNKED)
+ {
+ size = Math.min(size, chunkSize);
+ }
+
+ Object[] values = new Object[size];
+
+ // TODO - we might need to optimize this!!!!
+ for (int i = 0; i < size; i++)
+ {
+ values[i] = getValue(objyObject, feature, i + index);
+ }
+ return values;
+ }
+
+ // return the size of the collection.
+ public int size(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ return (int)getArray(objyObject, feature).size();
+ }
+
+ public void delete(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
+ {
+ if (targetIndex == sourceIndex)
+ {
+ return;
+ }
+
+ // get the object at sourceIndex.
+ Object value = getValue(objyObject, feature, sourceIndex);
+
+ // long size = (int)getArray(objyObject, feature).size();
+ // TODO - check boundaries...
+
+ if (sourceIndex > targetIndex)
+ {
+ for (int i = sourceIndex; i > targetIndex; i--)
+ {
+ setValue(objyObject, feature, i, getValue(objyObject, feature, i - 1));
+ }
+ }
+ else if (sourceIndex < targetIndex)
+ {
+ for (int i = sourceIndex; i < targetIndex; i++)
+ {
+ setValue(objyObject, feature, i, getValue(objyObject, feature, i + 1));
+ }
+ }
+ // set the saved value at target
+ setValue(objyObject, feature, targetIndex, value);
+
+ }
+
+ public void initialize(Class_Object classObject, EStructuralFeature feature)
+ {
+ // TODO - verify if we need to do any initialization!!!
+ }
+
+ protected VArray_Object getArray(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ return objyObject.get_varray(attributeName/* position */);
+ }
+
+ // ------------------------------------------------------------------------
+ // ------------------- Various types --------------------------
+ // ------------------------------------------------------------------------
+
+ // ---------------------------
+ // Boolean
+ // ---------------------------
+ public static class TMBoolean extends NumericManyTypeMapper
+ {
+ @Override
+ protected ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooBOOLEAN;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Boolean value = null;
+ if (!isNull)
+ {
+ value = numericValue.booleanValue();
+ }
+ return value;
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(false);
+ }
+
+ return new Numeric_Value(((Boolean)value).booleanValue());
+ }
+ }
+
+ // ---------------------------
+ // Byte
+ // ---------------------------
+ public static class TMByte extends NumericManyTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT8;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Byte value = null;
+ if (!isNull)
+ {
+ value = numericValue.byteValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Byte)value).byteValue());
+ }
+ }
+
+ // ---------------------------
+ // Char
+ // ---------------------------
+ public static class TMChar extends NumericManyTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT8;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Character value = null;
+ if (!isNull)
+ {
+ value = numericValue.charValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Character)value).charValue());
+ }
+ }
+
+ // ---------------------------
+ // Date
+ // ---------------------------
+ public static class TMDate extends NumericManyTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT64;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Date value = null;
+ if (!isNull)
+ {
+ value = new Date(numericValue.longValue());
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Date)value).getTime());
+ }
+ }
+
+ // ---------------------------
+ // Double
+ // ---------------------------
+ public static class TMDouble extends NumericManyTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooFLOAT64;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Double value = null;
+ if (!isNull)
+ {
+ value = numericValue.doubleValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0.0);
+ }
+
+ return new Numeric_Value(((Double)value).doubleValue());
+ }
+ }
+
+ // ---------------------------
+ // Float
+ // ---------------------------
+ public static class TMFloat extends NumericManyTypeMapper
+ {
+ @Override
+ protected ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooFLOAT64;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Float value = null;
+ if (!isNull)
+ {
+ value = numericValue.floatValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0.0);
+ }
+
+ return new Numeric_Value(((Float)value).floatValue());
+ }
+ }
+
+ // ---------------------------
+ // Integer
+ // ---------------------------
+ public static class TMInteger extends NumericManyTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT32;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Integer value = null;
+ if (!isNull)
+ {
+ value = numericValue.intValue();
+ }
+ return value;
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Integer)value).intValue());
+ }
+ }
+
+ // ---------------------------
+ // Long
+ // ---------------------------
+ public static class TMLong extends NumericManyTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT64;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Long value = null;
+ if (!isNull)
+ {
+ value = numericValue.longValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Long)value).longValue());
+ }
+ }
+
+ // ---------------------------
+ // Short
+ // ---------------------------
+ public static class TMShort extends NumericManyTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT16;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Short value = null;
+ if (!isNull)
+ {
+ value = numericValue.shortValue();
+ }
+ return value;
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Short)value).shortValue());
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericTypeMapper.java
index 19a125911a..285ccb36a5 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/NumericTypeMapper.java
@@ -1,523 +1,523 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Basic_Type;
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Basic_Attribute;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.Proposed_Property;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.d_Type;
-import com.objy.as.app.ooBaseType;
-
-import java.util.Date;
-
-/**
- * @author Ibrahim Sallam
- */
-public abstract class NumericTypeMapper extends BasicTypeMapper implements ISingleTypeMapper
-{
-
- abstract protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull);
-
- abstract protected Numeric_Value toNumericValue(Object value);
-
- abstract protected ooBaseType getObjyBaseType();
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, NumericTypeMapper.class);
-
- public static NumericTypeMapper.TMBoolean TMBOOLEAN = new TMBoolean();
-
- public static NumericTypeMapper.TMByte TMBYTE = new TMByte();
-
- public static NumericTypeMapper.TMChar TMCHAR = new TMChar();
-
- public static NumericTypeMapper.TMDate TMDATE = new TMDate();
-
- public static NumericTypeMapper.TMDouble TMDOUBLE = new TMDouble();
-
- public static NumericTypeMapper.TMFloat TMFLOAT = new TMFloat();
-
- public static NumericTypeMapper.TMInteger TMINTEGER = new TMInteger();
-
- public static NumericTypeMapper.TMLong TMLONG = new TMLong();
-
- public static NumericTypeMapper.TMShort TMSHORT = new TMShort();
-
- // ---------------------------------
- // Schema
- // ---------------------------------
- /**
- *
- */
- public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Adding attribute " + feature.getName() + " " + this.getClass().getName());
- }
-
- proposedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- getAttributeName(feature), // Attribute name
- 1, // # elements in fixed-size array
- getObjyBaseType() // Default value
- );
-
- proposedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- getNullAttributeName(feature), // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooBOOLEAN // Default value
- );
- return false;
- }
-
- /**
- * TODO - this is a simple change to the attribute, make it handle more complex cases.
- *
- * @param proposedooClass
- * @param feature
- */
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- Proposed_Property prop = proposedooClass.resolve_property(getAttributeName(feature));
-
- if (prop instanceof Proposed_Basic_Attribute)
- {
- Proposed_Basic_Attribute attr = (Proposed_Basic_Attribute)prop;
- attr.change_base_type(getObjyBaseType());
- }
- }
-
- /**
- *
- */
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- d_Type type = ooAttribute.type_of();
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace(getAttributeName(feature) + " " + ((Basic_Type)type).base_type() + " basic type "
- + type.is_basic_type() + " - " + getObjyBaseType());
- }
- return type.is_basic_type() && ((Basic_Type)type).base_type() == getObjyBaseType();
- }
-
- /**
- * The numeric attribute is an embedded class with (basic/boolean) pair. The boolean represent objects of basic types
- * with null value. TODO - I thought this should work.... find out why not!!!
- */
- // public boolean validate(d_Attribute dAttribute, EStructuralFeature feature)
- // {
- // d_Class embeddedClass = dAttribute.class_type_of();
- // Class_Position position = embeddedClass.position_in_class(getAttributeName(feature));
- // //d_Type type = ooAttribute.type_of();
- // d_Type type = embeddedClass.attribute_at_position(position).type_of();
- // if (TRACER_DEBUG.isEnabled()) {
- // TRACER_DEBUG.trace(getAttributeName(feature) + " "
- // + ((Basic_Type) type).base_type() + " basic type "
- // + type.is_basic_type() + " - " + getObjyBaseType());
- // }
- // return type.is_basic_type()
- // && ((Basic_Type) type).base_type() == getObjyBaseType();
- // }
-
- // ---------------------------------
- // Object
- // ---------------------------------
-
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
- {
- Numeric_Value numericValue = null;
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
-
- boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
-
- // if (isNull && feature.isUnsettable())
- // return CDORevisionData.NIL;
-
- if (!isNull)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- numericValue = objyObject.get_numeric(attributeName/* position */);
- }
-
- return fromNumericValue(numericValue, isNull);
- }
-
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
- {
- boolean isNull = newValue == null || newValue == CDORevisionData.NIL;
- Numeric_Value isNullValue = isNull ? numericTrue : numericFalse;
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
-
- if (!isNull)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- Numeric_Value numericValue = toNumericValue(newValue);
- objyObject.set_numeric(attributeName/* position */, numericValue);
- }
-
- objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
- }
-
- public Object remove(ObjyObject objyObject, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void delete(ObjyObject objyObject, EStructuralFeature feature)
- {
- // throw new UnsupportedOperationException("Implement me!!");
- // we just set the numeric _null to "true"
- // Class_Position position = getNullAttributePosition(objyObject, feature);
- // String nullAttributeName = getNullAttributeName(feature);
- objyObject.set_numeric(getNullAttributeName(feature)/* position */, numericTrue);
- }
-
- public void initialize(Class_Object classObject, EStructuralFeature feature)
- {
- // Class_Position position = classObject.type_of().position_in_class(getNullAttributeName(feature));
- classObject.nset_numeric(getNullAttributeName(feature) /* position */, numericTrue);
- }
-
- // various numeric types....
- // ---------------------------
- // Boolean
- // ---------------------------
- public static class TMBoolean extends NumericTypeMapper
- {
- @Override
- protected ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooBOOLEAN;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Boolean value = null;
- if (!isNull)
- {
- value = numericValue.booleanValue();
- }
- return value;
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(false);
- }
-
- return new Numeric_Value(((Boolean)value).booleanValue());
- }
- }
-
- // ---------------------------
- // Byte
- // ---------------------------
- public static class TMByte extends NumericTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT8;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Byte value = null;
- if (!isNull)
- {
- value = numericValue.byteValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Byte)value).byteValue());
- }
- }
-
- // ---------------------------
- // Char
- // ---------------------------
- public static class TMChar extends NumericTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT8;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Character value = null;
- if (!isNull)
- {
- value = numericValue.charValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Character)value).charValue());
- }
- }
-
- // ---------------------------
- // Date
- // ---------------------------
- public static class TMDate extends NumericTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT64;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Date value = null;
- if (!isNull)
- {
- value = new Date(numericValue.longValue());
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Date)value).getTime());
- }
- }
-
- // ---------------------------
- // Double
- // ---------------------------
- public static class TMDouble extends NumericTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooFLOAT64;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Double value = null;
- if (!isNull)
- {
- value = numericValue.doubleValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0.0);
- }
-
- return new Numeric_Value(((Double)value).doubleValue());
- }
- }
-
- // ---------------------------
- // Float
- // ---------------------------
- public static class TMFloat extends NumericTypeMapper
- {
- @Override
- protected ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooFLOAT64;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Float value = null;
- if (!isNull)
- {
- value = numericValue.floatValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0.0);
- }
-
- return new Numeric_Value(((Float)value).floatValue());
- }
- }
-
- // ---------------------------
- // Integer
- // ---------------------------
- public static class TMInteger extends NumericTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT32;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Integer value = null;
- if (!isNull)
- {
- value = numericValue.intValue();
- }
- return value;
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Integer)value).intValue());
- }
- }
-
- // ---------------------------
- // Long
- // ---------------------------
- public static class TMLong extends NumericTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT64;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Long value = null;
- if (!isNull)
- {
- value = numericValue.longValue();
- }
- return value;
-
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Long)value).longValue());
- }
- }
-
- // ---------------------------
- // Short
- // ---------------------------
- public static class TMShort extends NumericTypeMapper
- {
- @Override
- public ooBaseType getObjyBaseType()
- {
- return ooBaseType.ooINT16;
- }
-
- @Override
- protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
- {
- Short value = null;
- if (!isNull)
- {
- value = numericValue.shortValue();
- }
- return value;
- }
-
- @Override
- protected Numeric_Value toNumericValue(Object value)
- {
- if (value == null)
- {
- return new Numeric_Value(0);
- }
-
- return new Numeric_Value(((Short)value).shortValue());
- }
- }
-
- // ---------------------------
- // Boolean
- // ---------------------------
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Basic_Type;
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Basic_Attribute;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.Proposed_Property;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.d_Type;
+import com.objy.as.app.ooBaseType;
+
+import java.util.Date;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public abstract class NumericTypeMapper extends BasicTypeMapper implements ISingleTypeMapper
+{
+
+ abstract protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull);
+
+ abstract protected Numeric_Value toNumericValue(Object value);
+
+ abstract protected ooBaseType getObjyBaseType();
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, NumericTypeMapper.class);
+
+ public static NumericTypeMapper.TMBoolean TMBOOLEAN = new TMBoolean();
+
+ public static NumericTypeMapper.TMByte TMBYTE = new TMByte();
+
+ public static NumericTypeMapper.TMChar TMCHAR = new TMChar();
+
+ public static NumericTypeMapper.TMDate TMDATE = new TMDate();
+
+ public static NumericTypeMapper.TMDouble TMDOUBLE = new TMDouble();
+
+ public static NumericTypeMapper.TMFloat TMFLOAT = new TMFloat();
+
+ public static NumericTypeMapper.TMInteger TMINTEGER = new TMInteger();
+
+ public static NumericTypeMapper.TMLong TMLONG = new TMLong();
+
+ public static NumericTypeMapper.TMShort TMSHORT = new TMShort();
+
+ // ---------------------------------
+ // Schema
+ // ---------------------------------
+ /**
+ *
+ */
+ public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Adding attribute " + feature.getName() + " " + this.getClass().getName());
+ }
+
+ proposedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ getAttributeName(feature), // Attribute name
+ 1, // # elements in fixed-size array
+ getObjyBaseType() // Default value
+ );
+
+ proposedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ getNullAttributeName(feature), // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooBOOLEAN // Default value
+ );
+ return false;
+ }
+
+ /**
+ * TODO - this is a simple change to the attribute, make it handle more complex cases.
+ *
+ * @param proposedooClass
+ * @param feature
+ */
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ Proposed_Property prop = proposedooClass.resolve_property(getAttributeName(feature));
+
+ if (prop instanceof Proposed_Basic_Attribute)
+ {
+ Proposed_Basic_Attribute attr = (Proposed_Basic_Attribute)prop;
+ attr.change_base_type(getObjyBaseType());
+ }
+ }
+
+ /**
+ *
+ */
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ d_Type type = ooAttribute.type_of();
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace(getAttributeName(feature) + " " + ((Basic_Type)type).base_type() + " basic type "
+ + type.is_basic_type() + " - " + getObjyBaseType());
+ }
+ return type.is_basic_type() && ((Basic_Type)type).base_type() == getObjyBaseType();
+ }
+
+ /**
+ * The numeric attribute is an embedded class with (basic/boolean) pair. The boolean represent objects of basic types
+ * with null value. TODO - I thought this should work.... find out why not!!!
+ */
+ // public boolean validate(d_Attribute dAttribute, EStructuralFeature feature)
+ // {
+ // d_Class embeddedClass = dAttribute.class_type_of();
+ // Class_Position position = embeddedClass.position_in_class(getAttributeName(feature));
+ // //d_Type type = ooAttribute.type_of();
+ // d_Type type = embeddedClass.attribute_at_position(position).type_of();
+ // if (TRACER_DEBUG.isEnabled()) {
+ // TRACER_DEBUG.trace(getAttributeName(feature) + " "
+ // + ((Basic_Type) type).base_type() + " basic type "
+ // + type.is_basic_type() + " - " + getObjyBaseType());
+ // }
+ // return type.is_basic_type()
+ // && ((Basic_Type) type).base_type() == getObjyBaseType();
+ // }
+
+ // ---------------------------------
+ // Object
+ // ---------------------------------
+
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ Numeric_Value numericValue = null;
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+
+ boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
+
+ // if (isNull && feature.isUnsettable())
+ // return CDORevisionData.NIL;
+
+ if (!isNull)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ numericValue = objyObject.get_numeric(attributeName/* position */);
+ }
+
+ return fromNumericValue(numericValue, isNull);
+ }
+
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
+ {
+ boolean isNull = newValue == null || newValue == CDORevisionData.NIL;
+ Numeric_Value isNullValue = isNull ? numericTrue : numericFalse;
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+
+ if (!isNull)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ Numeric_Value numericValue = toNumericValue(newValue);
+ objyObject.set_numeric(attributeName/* position */, numericValue);
+ }
+
+ objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
+ }
+
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void delete(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // throw new UnsupportedOperationException("Implement me!!");
+ // we just set the numeric _null to "true"
+ // Class_Position position = getNullAttributePosition(objyObject, feature);
+ // String nullAttributeName = getNullAttributeName(feature);
+ objyObject.set_numeric(getNullAttributeName(feature)/* position */, numericTrue);
+ }
+
+ public void initialize(Class_Object classObject, EStructuralFeature feature)
+ {
+ // Class_Position position = classObject.type_of().position_in_class(getNullAttributeName(feature));
+ classObject.nset_numeric(getNullAttributeName(feature) /* position */, numericTrue);
+ }
+
+ // various numeric types....
+ // ---------------------------
+ // Boolean
+ // ---------------------------
+ public static class TMBoolean extends NumericTypeMapper
+ {
+ @Override
+ protected ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooBOOLEAN;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Boolean value = null;
+ if (!isNull)
+ {
+ value = numericValue.booleanValue();
+ }
+ return value;
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(false);
+ }
+
+ return new Numeric_Value(((Boolean)value).booleanValue());
+ }
+ }
+
+ // ---------------------------
+ // Byte
+ // ---------------------------
+ public static class TMByte extends NumericTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT8;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Byte value = null;
+ if (!isNull)
+ {
+ value = numericValue.byteValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Byte)value).byteValue());
+ }
+ }
+
+ // ---------------------------
+ // Char
+ // ---------------------------
+ public static class TMChar extends NumericTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT8;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Character value = null;
+ if (!isNull)
+ {
+ value = numericValue.charValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Character)value).charValue());
+ }
+ }
+
+ // ---------------------------
+ // Date
+ // ---------------------------
+ public static class TMDate extends NumericTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT64;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Date value = null;
+ if (!isNull)
+ {
+ value = new Date(numericValue.longValue());
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Date)value).getTime());
+ }
+ }
+
+ // ---------------------------
+ // Double
+ // ---------------------------
+ public static class TMDouble extends NumericTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooFLOAT64;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Double value = null;
+ if (!isNull)
+ {
+ value = numericValue.doubleValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0.0);
+ }
+
+ return new Numeric_Value(((Double)value).doubleValue());
+ }
+ }
+
+ // ---------------------------
+ // Float
+ // ---------------------------
+ public static class TMFloat extends NumericTypeMapper
+ {
+ @Override
+ protected ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooFLOAT64;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Float value = null;
+ if (!isNull)
+ {
+ value = numericValue.floatValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0.0);
+ }
+
+ return new Numeric_Value(((Float)value).floatValue());
+ }
+ }
+
+ // ---------------------------
+ // Integer
+ // ---------------------------
+ public static class TMInteger extends NumericTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT32;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Integer value = null;
+ if (!isNull)
+ {
+ value = numericValue.intValue();
+ }
+ return value;
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Integer)value).intValue());
+ }
+ }
+
+ // ---------------------------
+ // Long
+ // ---------------------------
+ public static class TMLong extends NumericTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT64;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Long value = null;
+ if (!isNull)
+ {
+ value = numericValue.longValue();
+ }
+ return value;
+
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Long)value).longValue());
+ }
+ }
+
+ // ---------------------------
+ // Short
+ // ---------------------------
+ public static class TMShort extends NumericTypeMapper
+ {
+ @Override
+ public ooBaseType getObjyBaseType()
+ {
+ return ooBaseType.ooINT16;
+ }
+
+ @Override
+ protected Object fromNumericValue(Numeric_Value numericValue, boolean isNull)
+ {
+ Short value = null;
+ if (!isNull)
+ {
+ value = numericValue.shortValue();
+ }
+ return value;
+ }
+
+ @Override
+ protected Numeric_Value toNumericValue(Object value)
+ {
+ if (value == null)
+ {
+ return new Numeric_Value(0);
+ }
+
+ return new Numeric_Value(((Short)value).shortValue());
+ }
+ }
+
+ // ---------------------------
+ // Boolean
+ // ---------------------------
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java
index be35609e61..2e5bf1d569 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/ObjyMapper.java
@@ -1,192 +1,192 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.util.HashMap;
-
-public class ObjyMapper
-{
- public static ObjyMapper INSTANCE = new ObjyMapper();
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyMapper.class);
-
- protected HashMap<EClassifier, ITypeMapper> typeMap = new HashMap<EClassifier, ITypeMapper>();
-
- protected HashMap<EClassifier, ITypeMapper> manyTypeMap = new HashMap<EClassifier, ITypeMapper>();
-
- private ITypeMapper manyRef = ManyReferenceMapper.INSTANCE;
-
- // private AttributeBridge manyRef = new ManyReferenceMapperTreeListX();
- private ITypeMapper singleRef = new SingleReferenceMapper();
-
- // private ITypeMapper singleContRef = new SingleContainementReferenceMapper();
-
- public ObjyMapper()
- {
- // TODO - this is from the old code. Verify if we still need it?!!!!
- // MultipleTypeMapper multipleMapper = new MultipleTypeMapper();
- // multipleMapper.add((IManyTypeMapper)manyRef);
- // multipleMapper.add(new IndexesReferenceMapper());
- // manyRef = multipleMapper;
-
- initMap();
- initManyMap();
- }
-
- public ITypeMapper getTypeMapper(EStructuralFeature feature)
- {
- if (feature == null || !EMFUtil.isPersistent(feature))
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("feature is transient " + feature);
- }
- return null;
- }
-
- boolean isMany = false;
-
- if (feature.isMany())
- {
- isMany = true;
- }
-
- if (feature instanceof EAttribute)
- {
- // PROBLEM
- EObject type = feature.getEType();
- if (type.eIsProxy())
- {
- URI a = EcoreUtil.getURI(type);
- type = EcorePackage.eINSTANCE.eResource().getEObject(a.fragment());
- }
- ITypeMapper attrMapper = null;
- if (isMany)
- {
- attrMapper = manyTypeMap.get(type);
- }
- else
- {
- attrMapper = typeMap.get(type);
- }
- if (attrMapper != null)
- {
- return attrMapper;
- }
-
- if (type instanceof EEnum)
- {
- return EnumTypeMapper.INSTANCE;
- }
-
- /*** handle custom types... ***/
- if (type instanceof EDataType)
- {
- if (isMany)
- {
- return CustomDataManyTypeMapper.INSTANCE;
- }
-
- return CustomDataTypeMapper.INSTANCE;
- }
- }
- else if (feature instanceof EReference)
- {
- if (isMany)
- {
- return manyRef;
- }
-
- return singleRef;
- }
-
- TRACER_DEBUG.trace("ERROR: " + feature.getEType() + " not supported for feature "
- + ((EClassifier)feature.eContainer()).getName() + "." + feature.getName());
- throw new RuntimeException(feature.getEType() + " not supported for feature "
- + ((EClassifier)feature.eContainer()).getName() + "." + feature.getName());
- }
-
- protected void initMap()
- {
- // TODO Do not support these type yet
- typeMap.put(EcorePackage.eINSTANCE.getEBoolean(), NumericTypeMapper.TMBOOLEAN);
- typeMap.put(EcorePackage.eINSTANCE.getEByte(), NumericTypeMapper.TMBYTE);
- typeMap.put(EcorePackage.eINSTANCE.getEChar(), NumericTypeMapper.TMCHAR);
- typeMap.put(EcorePackage.eINSTANCE.getEDate(), NumericTypeMapper.TMDATE);
- typeMap.put(EcorePackage.eINSTANCE.getEDouble(), NumericTypeMapper.TMDOUBLE);
- typeMap.put(EcorePackage.eINSTANCE.getEFloat(), NumericTypeMapper.TMFLOAT);
- typeMap.put(EcorePackage.eINSTANCE.getEInt(), NumericTypeMapper.TMINTEGER);
- typeMap.put(EcorePackage.eINSTANCE.getELong(), NumericTypeMapper.TMLONG);
- typeMap.put(EcorePackage.eINSTANCE.getEShort(), NumericTypeMapper.TMSHORT);
- typeMap.put(EcorePackage.eINSTANCE.getEString(), StringTypeMapper.INSTANCE);
-
- typeMap.put(EcorePackage.eINSTANCE.getEBooleanObject(), NumericTypeMapper.TMBOOLEAN);
- typeMap.put(EcorePackage.eINSTANCE.getEByteObject(), NumericTypeMapper.TMBYTE);
- typeMap.put(EcorePackage.eINSTANCE.getECharacterObject(), NumericTypeMapper.TMCHAR);
- typeMap.put(EcorePackage.eINSTANCE.getEDoubleObject(), NumericTypeMapper.TMDOUBLE);
- typeMap.put(EcorePackage.eINSTANCE.getEIntegerObject(), NumericTypeMapper.TMINTEGER);
- typeMap.put(EcorePackage.eINSTANCE.getELongObject(), NumericTypeMapper.TMLONG);
- typeMap.put(EcorePackage.eINSTANCE.getEFloatObject(), NumericTypeMapper.TMFLOAT);
-
- // the EByteArray doesn't show us as isMany()== true?!!!!
- typeMap.put(EcorePackage.eINSTANCE.getEByteArray(), ByteArrayTypeMapper.INSTANCE);
- typeMap.put(EcorePackage.eINSTANCE.getEBigDecimal(), BigDecimalTypeMapper.INSTANCE);
- typeMap.put(EcorePackage.eINSTANCE.getEBigInteger(), BigIntegerTypeMapper.INSTANCE);
-
- }
-
- private void initManyMap()
- {
- // TODO Do not support these type yet
- // typeMap.put(EcorePackage.eINSTANCE.getEBigDecimal()
- // typeMap.put(EcorePackage.eINSTANCE.getEBigInteger()
-
- manyTypeMap.put(EcorePackage.eINSTANCE.getEBoolean(), NumericManyTypeMapper.TMBOOLEAN);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEByte(), NumericManyTypeMapper.TMBYTE);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEChar(), NumericManyTypeMapper.TMCHAR);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEDate(), NumericManyTypeMapper.TMDATE);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEDouble(), NumericManyTypeMapper.TMDOUBLE);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEFloat(), NumericManyTypeMapper.TMFLOAT);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEInt(), NumericManyTypeMapper.TMINTEGER);
- manyTypeMap.put(EcorePackage.eINSTANCE.getELong(), NumericManyTypeMapper.TMLONG);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEShort(), NumericManyTypeMapper.TMSHORT);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEString(), StringManyTypeMapper.INSTANCE);
-
- manyTypeMap.put(EcorePackage.eINSTANCE.getEBooleanObject(), NumericManyTypeMapper.TMBOOLEAN);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEByteObject(), NumericManyTypeMapper.TMBYTE);
- manyTypeMap.put(EcorePackage.eINSTANCE.getECharacterObject(), NumericManyTypeMapper.TMCHAR);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEDoubleObject(), NumericManyTypeMapper.TMDOUBLE);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEFloatObject(), NumericManyTypeMapper.TMFLOAT);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEIntegerObject(), NumericManyTypeMapper.TMINTEGER);
- manyTypeMap.put(EcorePackage.eINSTANCE.getELongObject(), NumericManyTypeMapper.TMLONG);
-
- manyTypeMap.put(EcorePackage.eINSTANCE.getEByteArray(), NumericManyTypeMapper.TMBYTE);
- manyTypeMap.put(EcorePackage.eINSTANCE.getEFeatureMapEntry(), FeatureMapTypeMapper.INSTANCE);
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.HashMap;
+
+public class ObjyMapper
+{
+ public static ObjyMapper INSTANCE = new ObjyMapper();
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyMapper.class);
+
+ protected HashMap<EClassifier, ITypeMapper> typeMap = new HashMap<EClassifier, ITypeMapper>();
+
+ protected HashMap<EClassifier, ITypeMapper> manyTypeMap = new HashMap<EClassifier, ITypeMapper>();
+
+ private ITypeMapper manyRef = ManyReferenceMapper.INSTANCE;
+
+ // private AttributeBridge manyRef = new ManyReferenceMapperTreeListX();
+ private ITypeMapper singleRef = new SingleReferenceMapper();
+
+ // private ITypeMapper singleContRef = new SingleContainementReferenceMapper();
+
+ public ObjyMapper()
+ {
+ // TODO - this is from the old code. Verify if we still need it?!!!!
+ // MultipleTypeMapper multipleMapper = new MultipleTypeMapper();
+ // multipleMapper.add((IManyTypeMapper)manyRef);
+ // multipleMapper.add(new IndexesReferenceMapper());
+ // manyRef = multipleMapper;
+
+ initMap();
+ initManyMap();
+ }
+
+ public ITypeMapper getTypeMapper(EStructuralFeature feature)
+ {
+ if (feature == null || !EMFUtil.isPersistent(feature))
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("feature is transient " + feature);
+ }
+ return null;
+ }
+
+ boolean isMany = false;
+
+ if (feature.isMany())
+ {
+ isMany = true;
+ }
+
+ if (feature instanceof EAttribute)
+ {
+ // PROBLEM
+ EObject type = feature.getEType();
+ if (type.eIsProxy())
+ {
+ URI a = EcoreUtil.getURI(type);
+ type = EcorePackage.eINSTANCE.eResource().getEObject(a.fragment());
+ }
+ ITypeMapper attrMapper = null;
+ if (isMany)
+ {
+ attrMapper = manyTypeMap.get(type);
+ }
+ else
+ {
+ attrMapper = typeMap.get(type);
+ }
+ if (attrMapper != null)
+ {
+ return attrMapper;
+ }
+
+ if (type instanceof EEnum)
+ {
+ return EnumTypeMapper.INSTANCE;
+ }
+
+ /*** handle custom types... ***/
+ if (type instanceof EDataType)
+ {
+ if (isMany)
+ {
+ return CustomDataManyTypeMapper.INSTANCE;
+ }
+
+ return CustomDataTypeMapper.INSTANCE;
+ }
+ }
+ else if (feature instanceof EReference)
+ {
+ if (isMany)
+ {
+ return manyRef;
+ }
+
+ return singleRef;
+ }
+
+ TRACER_DEBUG.trace("ERROR: " + feature.getEType() + " not supported for feature "
+ + ((EClassifier)feature.eContainer()).getName() + "." + feature.getName());
+ throw new RuntimeException(feature.getEType() + " not supported for feature "
+ + ((EClassifier)feature.eContainer()).getName() + "." + feature.getName());
+ }
+
+ protected void initMap()
+ {
+ // TODO Do not support these type yet
+ typeMap.put(EcorePackage.eINSTANCE.getEBoolean(), NumericTypeMapper.TMBOOLEAN);
+ typeMap.put(EcorePackage.eINSTANCE.getEByte(), NumericTypeMapper.TMBYTE);
+ typeMap.put(EcorePackage.eINSTANCE.getEChar(), NumericTypeMapper.TMCHAR);
+ typeMap.put(EcorePackage.eINSTANCE.getEDate(), NumericTypeMapper.TMDATE);
+ typeMap.put(EcorePackage.eINSTANCE.getEDouble(), NumericTypeMapper.TMDOUBLE);
+ typeMap.put(EcorePackage.eINSTANCE.getEFloat(), NumericTypeMapper.TMFLOAT);
+ typeMap.put(EcorePackage.eINSTANCE.getEInt(), NumericTypeMapper.TMINTEGER);
+ typeMap.put(EcorePackage.eINSTANCE.getELong(), NumericTypeMapper.TMLONG);
+ typeMap.put(EcorePackage.eINSTANCE.getEShort(), NumericTypeMapper.TMSHORT);
+ typeMap.put(EcorePackage.eINSTANCE.getEString(), StringTypeMapper.INSTANCE);
+
+ typeMap.put(EcorePackage.eINSTANCE.getEBooleanObject(), NumericTypeMapper.TMBOOLEAN);
+ typeMap.put(EcorePackage.eINSTANCE.getEByteObject(), NumericTypeMapper.TMBYTE);
+ typeMap.put(EcorePackage.eINSTANCE.getECharacterObject(), NumericTypeMapper.TMCHAR);
+ typeMap.put(EcorePackage.eINSTANCE.getEDoubleObject(), NumericTypeMapper.TMDOUBLE);
+ typeMap.put(EcorePackage.eINSTANCE.getEIntegerObject(), NumericTypeMapper.TMINTEGER);
+ typeMap.put(EcorePackage.eINSTANCE.getELongObject(), NumericTypeMapper.TMLONG);
+ typeMap.put(EcorePackage.eINSTANCE.getEFloatObject(), NumericTypeMapper.TMFLOAT);
+
+ // the EByteArray doesn't show us as isMany()== true?!!!!
+ typeMap.put(EcorePackage.eINSTANCE.getEByteArray(), ByteArrayTypeMapper.INSTANCE);
+ typeMap.put(EcorePackage.eINSTANCE.getEBigDecimal(), BigDecimalTypeMapper.INSTANCE);
+ typeMap.put(EcorePackage.eINSTANCE.getEBigInteger(), BigIntegerTypeMapper.INSTANCE);
+
+ }
+
+ private void initManyMap()
+ {
+ // TODO Do not support these type yet
+ // typeMap.put(EcorePackage.eINSTANCE.getEBigDecimal()
+ // typeMap.put(EcorePackage.eINSTANCE.getEBigInteger()
+
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEBoolean(), NumericManyTypeMapper.TMBOOLEAN);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEByte(), NumericManyTypeMapper.TMBYTE);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEChar(), NumericManyTypeMapper.TMCHAR);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEDate(), NumericManyTypeMapper.TMDATE);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEDouble(), NumericManyTypeMapper.TMDOUBLE);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEFloat(), NumericManyTypeMapper.TMFLOAT);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEInt(), NumericManyTypeMapper.TMINTEGER);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getELong(), NumericManyTypeMapper.TMLONG);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEShort(), NumericManyTypeMapper.TMSHORT);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEString(), StringManyTypeMapper.INSTANCE);
+
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEBooleanObject(), NumericManyTypeMapper.TMBOOLEAN);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEByteObject(), NumericManyTypeMapper.TMBYTE);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getECharacterObject(), NumericManyTypeMapper.TMCHAR);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEDoubleObject(), NumericManyTypeMapper.TMDOUBLE);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEFloatObject(), NumericManyTypeMapper.TMFLOAT);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEIntegerObject(), NumericManyTypeMapper.TMINTEGER);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getELongObject(), NumericManyTypeMapper.TMLONG);
+
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEByteArray(), NumericManyTypeMapper.TMBYTE);
+ manyTypeMap.put(EcorePackage.eINSTANCE.getEFeatureMapEntry(), FeatureMapTypeMapper.INSTANCE);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleContainementReferenceMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleContainementReferenceMapper.java
index 5bdc4f2828..b9a99841e0 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleContainementReferenceMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleContainementReferenceMapper.java
@@ -1,98 +1,98 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring comments for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.db.app.ooId;
-
-/**
- * @author Simon McDuff
- */
-// 100202:IS - this is leftover from the refactoring... verify if we need it.
-@Deprecated
-public class SingleContainementReferenceMapper extends BasicTypeMapper implements ISingleTypeMapper
-{
-
- public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
- {
- EClassifier destination = feature.getEType();
-
- String destinationClassName = ObjySchema.getObjectivityClassName(destination);
- // Containment relationship
- // We do not detect recursive embedded relationship
- proposedClasses.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, // Access kind
- d_Access_Kind.d_PUBLIC, // Access kind
- feature.getName(), // Attribute name
- 1, // # elements in fixed-size array
- destinationClassName); // Default value
- return false;
- }
-
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- // TODO Auto-generated method stub
- ooId id2 = objyObject.get_ooId(attributeName/* position */);
- if (id2 == null || id2.isNull())
- {
- return null;
- }
- Class_Object childObject = objyObject.get_class_obj(attributeName/* position */);
- return childObject;
- }
-
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- objyObject.set_ooId(attributeName/* position */, (ooId)newValue);
- }
-
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void delete(ObjyObject class_Object, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void initialize(Class_Object classObject, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public Object remove(ObjyObject objyObject, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring comments for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.db.app.ooId;
+
+/**
+ * @author Simon McDuff
+ */
+// 100202:IS - this is leftover from the refactoring... verify if we need it.
+@Deprecated
+public class SingleContainementReferenceMapper extends BasicTypeMapper implements ISingleTypeMapper
+{
+
+ public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
+ {
+ EClassifier destination = feature.getEType();
+
+ String destinationClassName = ObjySchema.getObjectivityClassName(destination);
+ // Containment relationship
+ // We do not detect recursive embedded relationship
+ proposedClasses.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ feature.getName(), // Attribute name
+ 1, // # elements in fixed-size array
+ destinationClassName); // Default value
+ return false;
+ }
+
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ // TODO Auto-generated method stub
+ ooId id2 = objyObject.get_ooId(attributeName/* position */);
+ if (id2 == null || id2.isNull())
+ {
+ return null;
+ }
+ Class_Object childObject = objyObject.get_class_obj(attributeName/* position */);
+ return childObject;
+ }
+
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ objyObject.set_ooId(attributeName/* position */, (ooId)newValue);
+ }
+
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void delete(ObjyObject class_Object, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void initialize(Class_Object classObject, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleReferenceMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleReferenceMapper.java
index ca4fc4145f..0ee6792e66 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleReferenceMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/SingleReferenceMapper.java
@@ -1,155 +1,155 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.id.CDOIDExternal;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.TypeConvert;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.db.app.ooId;
-
-/**
- * @author Simon McDuff
- */
-// TODO - we ignore the boolean value for null references....
-public class SingleReferenceMapper extends BasicTypeMapper implements ISingleTypeMapper
-{
- static public SingleReferenceMapper INSTANCE = new SingleReferenceMapper();
-
- public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
- {
- EClassifier destination = feature.getEType();
-
- String destinationClassName = ObjySchema.getObjectivityClassName(destination);
-
- proposedClasses.add_ref_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- feature.getName(), // Attribute name
- 1, // # elements in fixed-size array
- destinationClassName, // Type of numeric data
- false); // Short reference
- return false;
- }
-
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
- {
- /***
- * ooId id2 = internal.ooClassObject().get_ooId(position); if (id2 == null || id2.isNull()) { return null; }
- ***/
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- return getValue(objyObject, attributeName/* position */);
- }
-
- // called by ObjyObject to get some resource elements.
- public Object getValue(ObjyObject objyObject, String attributeName/* Class_Position position */)
- {
- ooId childObject = objyObject.get_ooId(attributeName/* position */);
-
- if (!childObject.isNull())
- {
- // check for external reference.
- // TODO -
- // we can optimize this by making sure the object is flagged by having external
- // references, and only do the following if true.
- // System.out.println("-->> IS: getting Class_Object from OID: " + childObject.getStoreString());
- Class_Object refClassObject = Class_Object.class_object_from_oid(childObject);
-
- if (refClassObject.type_of().name().equals(ObjyProxy.className))
- {
- ObjyProxy proxyObject = new ObjyProxy(refClassObject);
- return OBJYCDOIDUtil.createCDIDExternal(proxyObject);
- }
- }
- // convert to CDOID, revese of the setValue()
- return OBJYCDOIDUtil.getCDOID(childObject);
- }
-
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- setValue(objyObject, attributeName/* position */, newValue);
- }
-
- // called by ObjyObject to set resource elements.
- public void setValue(ObjyObject objyObject, String attributeName/* Class_Position position */, Object newValue)
- {
- ooId ooid = null;
-
- if (newValue instanceof CDOIDExternal)
- {
- System.out.println("... CDOIDExternal inserted, content:" + ((CDOIDExternal)newValue).getURI());
- // create an ObjyProxy object to hold the the value.
- ObjyProxy proxyObject = ObjyProxy.createObject(objyObject.ooId());
- proxyObject.setUri(((CDOIDExternal)newValue).getURI());
- ooid = proxyObject.ooId();
- }
- else
- {
- ooid = TypeConvert.toOoId(newValue);
- }
-
- objyObject.set_ooId(attributeName/* position */, ooid);
- }
-
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- System.out.println(">>>OBJYIMPL: SingleRefernceMapper.validate() - not implemented.");
- return true;
- }
-
- public void delete(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- ooId childOid = objyObject.get_ooId(attributeName/* position */);
- if (!childOid.isNull())
- {
- // This is a single reference, so we shouldn't be deleting the reference
- // object, just set the reference to NULL.
- // ooObj childObject = ooObj.create_ooObj(childOid);
- // childObject.delete();
- setValue(objyObject, feature, null);
- }
- }
-
- public void initialize(Class_Object classObject, EStructuralFeature feature)
- {
- // TODO Implement the initialization, if any....
- }
-
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public Object remove(ObjyObject objyObject, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.id.CDOIDExternal;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.TypeConvert;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.db.app.ooId;
+
+/**
+ * @author Simon McDuff
+ */
+// TODO - we ignore the boolean value for null references....
+public class SingleReferenceMapper extends BasicTypeMapper implements ISingleTypeMapper
+{
+ static public SingleReferenceMapper INSTANCE = new SingleReferenceMapper();
+
+ public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
+ {
+ EClassifier destination = feature.getEType();
+
+ String destinationClassName = ObjySchema.getObjectivityClassName(destination);
+
+ proposedClasses.add_ref_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ feature.getName(), // Attribute name
+ 1, // # elements in fixed-size array
+ destinationClassName, // Type of numeric data
+ false); // Short reference
+ return false;
+ }
+
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ /***
+ * ooId id2 = internal.ooClassObject().get_ooId(position); if (id2 == null || id2.isNull()) { return null; }
+ ***/
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ return getValue(objyObject, attributeName/* position */);
+ }
+
+ // called by ObjyObject to get some resource elements.
+ public Object getValue(ObjyObject objyObject, String attributeName/* Class_Position position */)
+ {
+ ooId childObject = objyObject.get_ooId(attributeName/* position */);
+
+ if (!childObject.isNull())
+ {
+ // check for external reference.
+ // TODO -
+ // we can optimize this by making sure the object is flagged by having external
+ // references, and only do the following if true.
+ // System.out.println("-->> IS: getting Class_Object from OID: " + childObject.getStoreString());
+ Class_Object refClassObject = Class_Object.class_object_from_oid(childObject);
+
+ if (refClassObject.type_of().name().equals(ObjyProxy.className))
+ {
+ ObjyProxy proxyObject = new ObjyProxy(refClassObject);
+ return OBJYCDOIDUtil.createCDIDExternal(proxyObject);
+ }
+ }
+ // convert to CDOID, revese of the setValue()
+ return OBJYCDOIDUtil.getCDOID(childObject);
+ }
+
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ setValue(objyObject, attributeName/* position */, newValue);
+ }
+
+ // called by ObjyObject to set resource elements.
+ public void setValue(ObjyObject objyObject, String attributeName/* Class_Position position */, Object newValue)
+ {
+ ooId ooid = null;
+
+ if (newValue instanceof CDOIDExternal)
+ {
+ System.out.println("... CDOIDExternal inserted, content:" + ((CDOIDExternal)newValue).getURI());
+ // create an ObjyProxy object to hold the the value.
+ ObjyProxy proxyObject = ObjyProxy.createObject(objyObject.ooId());
+ proxyObject.setUri(((CDOIDExternal)newValue).getURI());
+ ooid = proxyObject.ooId();
+ }
+ else
+ {
+ ooid = TypeConvert.toOoId(newValue);
+ }
+
+ objyObject.set_ooId(attributeName/* position */, ooid);
+ }
+
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ System.out.println(">>>OBJYIMPL: SingleRefernceMapper.validate() - not implemented.");
+ return true;
+ }
+
+ public void delete(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ ooId childOid = objyObject.get_ooId(attributeName/* position */);
+ if (!childOid.isNull())
+ {
+ // This is a single reference, so we shouldn't be deleting the reference
+ // object, just set the reference to NULL.
+ // ooObj childObject = ooObj.create_ooObj(childOid);
+ // childObject.delete();
+ setValue(objyObject, feature, null);
+ }
+ }
+
+ public void initialize(Class_Object classObject, EStructuralFeature feature)
+ {
+ // TODO Implement the initialization, if any....
+ }
+
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringManyTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringManyTypeMapper.java
index 0e7689ab2d..8438081cda 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringManyTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringManyTypeMapper.java
@@ -1,191 +1,191 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListString;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.db.ObjyRuntimeException;
-
-/**
- * @author Ibrahim Sallam
- */
-public class StringManyTypeMapper extends BasicTypeMapper implements IManyTypeMapper
-{
- public static StringManyTypeMapper INSTANCE = new StringManyTypeMapper();
-
- public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
- {
- try
- {
-
- ObjyArrayListString.buildSchema();
-
- proposedClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
- d_Access_Kind.d_PUBLIC, // Access kind
- getAttributeName(feature), // Attribute name
- 1, // # elements in fixed-size array
- ObjyArrayListString.ClassName, false); // Default value // Default value
-
- }
- catch (ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- }
- return false;
- }
-
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- // TODO Need to implement this.
- // throw new UnsupportedOperationException("Implement me!!");
- System.out.println(">>>OBJYIMPL: StringManyTypeMapper.validate() - not implemented.");
- return true;
- }
-
- protected String stringFromObject(EStructuralFeature feature, Object objectValue)
- {
- if (objectValue instanceof String)
- {
- return (String)objectValue;
- }
-
- return null;
- }
-
- protected Object objectFromString(EStructuralFeature feature, String stringValue)
- {
- return stringValue;
- }
-
- protected ObjyArrayListString getList(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
-
- ObjyArrayListString list = (ObjyArrayListString)objyObject.getFeatureList(attributeName/* position */);
- if (list == null)
- {
- list = new ObjyArrayListString(objyObject.get_class_obj(attributeName/* position */));
- objyObject.setFeatureList(attributeName/* position */, list);
- }
- return list;
- }
-
- public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value)
- {
- assert value instanceof String;
- getList(objyObject, feature).add(stringFromObject(feature, value));
- }
-
- public void addAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] values)
- {
- // CDOList list = (CDOList) value;
- String[] strings = new String[values.length];
- for (int i = 0; i < values.length; i++)
- {
- // strings[i] = stringFromObject(feature, values[i]);
- strings[i] = (String)values[i];
- }
- getList(objyObject, feature).addAll(index, strings);
- }
-
- public void clear(ObjyObject objyObject, EStructuralFeature feature)
- {
- getList(objyObject, feature).clear();
- }
-
- public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
- {
- int size = size(objyObject, feature);
-
- if (chunkSize != CDORevision.UNCHUNKED)
- {
- size = Math.min(size, chunkSize);
- }
-
- String[] strings = getList(objyObject, feature).getAll(index, size);
-
- Object[] objects = new Object[strings.length];
-
- for (int i = 0; i < strings.length; i++)
- {
- objects[i] = objectFromString(feature, strings[i]);
- }
-
- return strings;
- }
-
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature, int index)
- {
- return objectFromString(feature, getList(objyObject, feature).get(index));
- }
-
- public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
- {
- Object oldValue = objectFromString(feature, getList(objyObject, feature).get(index));
- getList(objyObject, feature).remove(index);
- return oldValue;
- }
-
- public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
- {
- addAll(objyObject, feature, 0, newValues);
- }
-
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, int index, Object newValue)
- {
- assert newValue instanceof String;
-
- getList(objyObject, feature).set(index, stringFromObject(feature, newValue));
- }
-
- public int size(ObjyObject objyObject, EStructuralFeature feature)
- {
- return (int)getList(objyObject, feature).size();
- }
-
- public void delete(ObjyObject objyObject, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void initialize(Class_Object classObject, EStructuralFeature feature)
- {
- // Class_Position position = classObject.type_of().position_in_class(getAttributeName(feature));
- Class_Object newClassObject = Class_Object.new_persistent_object(
- ObjySchema.getObjyClass(ObjyArrayListString.ClassName).getASClass(), classObject.objectID(), false);
- // ObjyObjectManager.newInternalObjCount++;
- classObject.nset_ooId(getAttributeName(feature), newClassObject.objectID());
- ObjyArrayListString.initObject(newClassObject);
- }
-
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyArrayListString;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.db.ObjyRuntimeException;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public class StringManyTypeMapper extends BasicTypeMapper implements IManyTypeMapper
+{
+ public static StringManyTypeMapper INSTANCE = new StringManyTypeMapper();
+
+ public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
+ {
+ try
+ {
+
+ ObjyArrayListString.buildSchema();
+
+ proposedClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ getAttributeName(feature), // Attribute name
+ 1, // # elements in fixed-size array
+ ObjyArrayListString.ClassName, false); // Default value // Default value
+
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ return false;
+ }
+
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ // TODO Need to implement this.
+ // throw new UnsupportedOperationException("Implement me!!");
+ System.out.println(">>>OBJYIMPL: StringManyTypeMapper.validate() - not implemented.");
+ return true;
+ }
+
+ protected String stringFromObject(EStructuralFeature feature, Object objectValue)
+ {
+ if (objectValue instanceof String)
+ {
+ return (String)objectValue;
+ }
+
+ return null;
+ }
+
+ protected Object objectFromString(EStructuralFeature feature, String stringValue)
+ {
+ return stringValue;
+ }
+
+ protected ObjyArrayListString getList(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+
+ ObjyArrayListString list = (ObjyArrayListString)objyObject.getFeatureList(attributeName/* position */);
+ if (list == null)
+ {
+ list = new ObjyArrayListString(objyObject.get_class_obj(attributeName/* position */));
+ objyObject.setFeatureList(attributeName/* position */, list);
+ }
+ return list;
+ }
+
+ public void add(ObjyObject objyObject, EStructuralFeature feature, int index, Object value)
+ {
+ assert value instanceof String;
+ getList(objyObject, feature).add(stringFromObject(feature, value));
+ }
+
+ public void addAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] values)
+ {
+ // CDOList list = (CDOList) value;
+ String[] strings = new String[values.length];
+ for (int i = 0; i < values.length; i++)
+ {
+ // strings[i] = stringFromObject(feature, values[i]);
+ strings[i] = (String)values[i];
+ }
+ getList(objyObject, feature).addAll(index, strings);
+ }
+
+ public void clear(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ getList(objyObject, feature).clear();
+ }
+
+ public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
+ {
+ int size = size(objyObject, feature);
+
+ if (chunkSize != CDORevision.UNCHUNKED)
+ {
+ size = Math.min(size, chunkSize);
+ }
+
+ String[] strings = getList(objyObject, feature).getAll(index, size);
+
+ Object[] objects = new Object[strings.length];
+
+ for (int i = 0; i < strings.length; i++)
+ {
+ objects[i] = objectFromString(feature, strings[i]);
+ }
+
+ return strings;
+ }
+
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature, int index)
+ {
+ return objectFromString(feature, getList(objyObject, feature).get(index));
+ }
+
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
+ {
+ Object oldValue = objectFromString(feature, getList(objyObject, feature).get(index));
+ getList(objyObject, feature).remove(index);
+ return oldValue;
+ }
+
+ public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
+ {
+ addAll(objyObject, feature, 0, newValues);
+ }
+
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, int index, Object newValue)
+ {
+ assert newValue instanceof String;
+
+ getList(objyObject, feature).set(index, stringFromObject(feature, newValue));
+ }
+
+ public int size(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ return (int)getList(objyObject, feature).size();
+ }
+
+ public void delete(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void initialize(Class_Object classObject, EStructuralFeature feature)
+ {
+ // Class_Position position = classObject.type_of().position_in_class(getAttributeName(feature));
+ Class_Object newClassObject = Class_Object.new_persistent_object(
+ ObjySchema.getObjyClass(ObjyArrayListString.ClassName).getASClass(), classObject.objectID(), false);
+ // ObjyObjectManager.newInternalObjCount++;
+ classObject.nset_ooId(getAttributeName(feature), newClassObject.objectID());
+ ObjyArrayListString.initObject(newClassObject);
+ }
+
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringTypeMapper.java
index 038851a209..b4972415de 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringTypeMapper.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/mapper/StringTypeMapper.java
@@ -1,136 +1,136 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
-
-import org.eclipse.emf.cdo.common.revision.CDORevisionData;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.String_Value;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Attribute;
-import com.objy.as.app.ooBaseType;
-import com.objy.db.ObjyRuntimeException;
-
-/**
- * @author Simon McDuff
- */
-public class StringTypeMapper extends BasicTypeMapper implements ISingleTypeMapper
-{
- public static StringTypeMapper INSTANCE = new StringTypeMapper();
-
- @Override
- protected String getNullAttributeName(EStructuralFeature feature)
- {
- return feature.getName() + "_isNull";
- }
-
- public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
- {
- try
- {
-
- proposedClass.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, // Access kind
- d_Access_Kind.d_PUBLIC, // Access kind
- feature.getName(), // Attribute name
- 1, // # elements in fixed-size array
- "ooUtf8String"); // Default value
-
- proposedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- getNullAttributeName(feature), // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooBOOLEAN // Default value
- );
- }
- catch (ObjyRuntimeException ex)
- {
- ex.printStackTrace();
- }
- return false;
- }
-
- public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
- String_Value stringValue = objyObject.get_string(attributeName/* position */);
- boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
- Object value = null;
-
- if (!isNull)
- {
- value = stringValue.toString();
- // else if (feature.isUnsettable())
- // value = CDORevisionData.NIL;
- }
-
- return value;
- }
-
- public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
- {
- boolean isNull = newValue == null || newValue == CDORevisionData.NIL;
- // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
-
- if (!isNull)
- {
- // Class_Position position = getAttributePosition(objyObject, feature);
- String attributeName = getAttributeName(feature);
- String_Value stringValue = objyObject.get_string(attributeName/* position */);
- stringValue.update();
- stringValue.set((String)newValue);
- }
- Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse;
- objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
- }
-
- public Object remove(ObjyObject objyObject, EStructuralFeature feature)
- {
- throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void delete(ObjyObject objyObject, EStructuralFeature feature)
- {
- // we could set the string value to "", but it would be easier to just set
- // the numeric _null to "true"
- // Class_Position position = getNullAttributePosition(objyObject, feature);
- String nullAttributeName = getNullAttributeName(feature);
- objyObject.set_numeric(nullAttributeName/* position */, numericTrue);
- // throw new UnsupportedOperationException("Implement me!!");
- }
-
- public void initialize(Class_Object classObject, EStructuralFeature feature)
- {
- // Class_Position position = classObject.type_of().position_in_class(getNullAttributeName(feature));
- classObject.nset_numeric(getNullAttributeName(feature), numericTrue);
- }
-
- public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
-
- }
-
- public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
- {
- // TODO Auto-generated method stub
- System.out.println(">>>OBJYIMPL: StringTypeMapper.validate() - not implemented.");
- return true;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.mapper;
+
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.String_Value;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Attribute;
+import com.objy.as.app.ooBaseType;
+import com.objy.db.ObjyRuntimeException;
+
+/**
+ * @author Simon McDuff
+ */
+public class StringTypeMapper extends BasicTypeMapper implements ISingleTypeMapper
+{
+ public static StringTypeMapper INSTANCE = new StringTypeMapper();
+
+ @Override
+ protected String getNullAttributeName(EStructuralFeature feature)
+ {
+ return feature.getName() + "_isNull";
+ }
+
+ public boolean createSchema(Proposed_Class proposedClass, EStructuralFeature feature)
+ {
+ try
+ {
+
+ proposedClass.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ feature.getName(), // Attribute name
+ 1, // # elements in fixed-size array
+ "ooUtf8String"); // Default value
+
+ proposedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ getNullAttributeName(feature), // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooBOOLEAN // Default value
+ );
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ return false;
+ }
+
+ public Object getValue(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+ String_Value stringValue = objyObject.get_string(attributeName/* position */);
+ boolean isNull = objyObject.get_numeric(nullAttributeName/* nullPosition */).booleanValue();
+ Object value = null;
+
+ if (!isNull)
+ {
+ value = stringValue.toString();
+ // else if (feature.isUnsettable())
+ // value = CDORevisionData.NIL;
+ }
+
+ return value;
+ }
+
+ public void setValue(ObjyObject objyObject, EStructuralFeature feature, Object newValue)
+ {
+ boolean isNull = newValue == null || newValue == CDORevisionData.NIL;
+ // Class_Position nullPosition = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+
+ if (!isNull)
+ {
+ // Class_Position position = getAttributePosition(objyObject, feature);
+ String attributeName = getAttributeName(feature);
+ String_Value stringValue = objyObject.get_string(attributeName/* position */);
+ stringValue.update();
+ stringValue.set((String)newValue);
+ }
+ Numeric_Value isNullValue = newValue == null ? numericTrue : numericFalse;
+ objyObject.set_numeric(nullAttributeName/* nullPosition */, isNullValue);
+ }
+
+ public Object remove(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void delete(ObjyObject objyObject, EStructuralFeature feature)
+ {
+ // we could set the string value to "", but it would be easier to just set
+ // the numeric _null to "true"
+ // Class_Position position = getNullAttributePosition(objyObject, feature);
+ String nullAttributeName = getNullAttributeName(feature);
+ objyObject.set_numeric(nullAttributeName/* position */, numericTrue);
+ // throw new UnsupportedOperationException("Implement me!!");
+ }
+
+ public void initialize(Class_Object classObject, EStructuralFeature feature)
+ {
+ // Class_Position position = classObject.type_of().position_in_class(getNullAttributeName(feature));
+ classObject.nset_numeric(getNullAttributeName(feature), numericTrue);
+ }
+
+ public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
+ {
+ // TODO Auto-generated method stub
+ System.out.println(">>>OBJYIMPL: StringTypeMapper.validate() - not implemented.");
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayList.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayList.java
index b449e12e94..52a2dae67a 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayList.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayList.java
@@ -1,256 +1,256 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.VArray_Object;
-import com.objy.db.app.ooId;
-
-/**
- * @author Simon McDuff
- */
-public abstract class ObjyArrayList<T>
-{
- final static String sizeName = "elementCount";
-
- final static String arrayName = "curr";
-
- protected Class_Object classObject;
-
- private VArray_Object vArray;
-
- protected transient long cacheSize;
-
- transient long position;
-
- public static void initObject(Class_Object classObject)
- {
- // set the size to 0;
- classObject.nset_numeric(sizeName, new Numeric_Value(0));
- }
-
- public ObjyArrayList(Class_Object classObject)
- {
- this.classObject = classObject;
- this.cacheSize = -1;
-
- }
-
- public ooId getID()
- {
- return classObject.objectID();
- }
-
- // /**
- // * TODO - verify need.
- // */
- // private Class_Object getClassObject()
- // {
- // return classObject;
- // }
-
- public void clear()
- {
- getVArray().resize(0);
- cacheSize = 0;
- saveSize();
- }
-
- private void shiftRight(int index)
- {
- shiftRight(index, 1);
- }
-
- private void shiftRight(int index, int sizeToShift)
- {
- long size = this.cachedSize();
-
- for (long i = size - 1; i >= index; i--)
- {
- setValue(i + sizeToShift, getValue(i));
- }
-
- cacheSize += sizeToShift;
- saveSize();
- }
-
- private void shiftLeft(int index)
- {
- long size = this.cachedSize();
- for (long i = index; i < size - 1; i++)
- {
- setValue(i, getValue(i + 1));
- }
-
- cacheSize--;
- saveSize();
- }
-
- /**
- *
- */
- protected void grow(int item)
- {
- getVArray().resize(getVArraySize() + Math.max(item + 10, 10));
- }
-
- /**
- *
- */
- private void prepareToInsert(int numberToAdd)
- {
- long size = cachedSize();
- update();
-
- if (size + numberToAdd > getVArraySize())
- {
- grow(numberToAdd);
- }
- }
-
- protected long getVArraySize()
- {
- return getVArray().size();
- }
-
- protected void update()
- {
- getVArray().update();
- }
-
- protected VArray_Object getVArray()
- {
- if (vArray == null)
- {
- vArray = classObject.nget_varray(arrayName);
- }
- return vArray;
- }
-
- public void add(int index, T newValue)
- {
- prepareToInsert(1);
- shiftRight(index);
- basicSet(index, newValue);
- }
-
- public void addAll(int index, Object[] newValue)
- {
- prepareToInsert(newValue.length);
- shiftRight(index, newValue.length);
-
- for (int i = 0; i < newValue.length; i++)
- {
- @SuppressWarnings("unchecked")
- T value = (T)newValue[i];
- basicSet(index + i, value);
- }
- }
-
- public void remove(int index)
- {
- shiftLeft(index);
- }
-
- public void add(T newValue)
- {
- long size = cachedSize();
-
- prepareToInsert(1);
- setValue(size, newValue);
- cacheSize++;
- saveSize();
- }
-
- public void set(long index, T newValue)
- {
- basicSet(index, newValue);
- // cacheSize = -1;
- }
-
- public void move(long newPosition, long oldPosition)
- {
- if (oldPosition == newPosition)
- {
- return;
- }
-
- // get the object at oldPosition.
- T value = getValue(oldPosition);
- // remove the oldPosition.
- remove((int)oldPosition);
- // make a space at the newPosition by shifting elements
- shiftRight((int)newPosition);
- set(newPosition, value);
- }
-
- protected void basicSet(long index, T newValue)
- {
- if (index >= cachedSize())
- {
- throw new ArrayIndexOutOfBoundsException();
- }
-
- update();
-
- setValue(index, newValue);
- }
-
- public T get(long index)
- {
- if (index >= size())
- {
- throw new ArrayIndexOutOfBoundsException();
- }
-
- return getValue(index);
- }
-
- protected abstract void setValue(long index, T newValue);
-
- protected abstract T getValue(long index);
-
- protected void saveSize()
- {
- // System.out.println(">>> classObject: " + classObject.objectID().getStoreString() + " <<<");
- // System.out.println("ooArrayList.saveSize() - value to store in objy is: " + cacheSize);
- classObject.nset_numeric(sizeName, new Numeric_Value(cacheSize));
- resetCachedSize();
- }
-
- protected void resetCachedSize()
- {
- cacheSize = -1;
- }
-
- protected long cachedSize()
- {
- if (cacheSize == -1)
- {
- cacheSize = classObject.nget_numeric(sizeName).longValue();
- // System.out.println(">>> classObject: " + classObject.objectID().getStoreString() + " <<<");
- // System.out.println("ooArrayList.privateSize() - cacheSize was -1, value from objy is: " + cacheSize);
- }
- return cacheSize;
- }
-
- public long size()
- {
- // System.out.println(">>> classObject: " + classObject.objectID().getStoreString() + " <<<");
- // Numeric_Value nValue = classObject.nget_numeric(sizeName);
- // System.out.println("ooArrayList.size() - nValue: " + nValue.toString());
- // return classObject.nget_numeric(sizeName).longValue();
- return cachedSize();
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.VArray_Object;
+import com.objy.db.app.ooId;
+
+/**
+ * @author Simon McDuff
+ */
+public abstract class ObjyArrayList<T>
+{
+ final static String sizeName = "elementCount";
+
+ final static String arrayName = "curr";
+
+ protected Class_Object classObject;
+
+ private VArray_Object vArray;
+
+ protected transient long cacheSize;
+
+ transient long position;
+
+ public static void initObject(Class_Object classObject)
+ {
+ // set the size to 0;
+ classObject.nset_numeric(sizeName, new Numeric_Value(0));
+ }
+
+ public ObjyArrayList(Class_Object classObject)
+ {
+ this.classObject = classObject;
+ this.cacheSize = -1;
+
+ }
+
+ public ooId getID()
+ {
+ return classObject.objectID();
+ }
+
+ // /**
+ // * TODO - verify need.
+ // */
+ // private Class_Object getClassObject()
+ // {
+ // return classObject;
+ // }
+
+ public void clear()
+ {
+ getVArray().resize(0);
+ cacheSize = 0;
+ saveSize();
+ }
+
+ private void shiftRight(int index)
+ {
+ shiftRight(index, 1);
+ }
+
+ private void shiftRight(int index, int sizeToShift)
+ {
+ long size = this.cachedSize();
+
+ for (long i = size - 1; i >= index; i--)
+ {
+ setValue(i + sizeToShift, getValue(i));
+ }
+
+ cacheSize += sizeToShift;
+ saveSize();
+ }
+
+ private void shiftLeft(int index)
+ {
+ long size = this.cachedSize();
+ for (long i = index; i < size - 1; i++)
+ {
+ setValue(i, getValue(i + 1));
+ }
+
+ cacheSize--;
+ saveSize();
+ }
+
+ /**
+ *
+ */
+ protected void grow(int item)
+ {
+ getVArray().resize(getVArraySize() + Math.max(item + 10, 10));
+ }
+
+ /**
+ *
+ */
+ private void prepareToInsert(int numberToAdd)
+ {
+ long size = cachedSize();
+ update();
+
+ if (size + numberToAdd > getVArraySize())
+ {
+ grow(numberToAdd);
+ }
+ }
+
+ protected long getVArraySize()
+ {
+ return getVArray().size();
+ }
+
+ protected void update()
+ {
+ getVArray().update();
+ }
+
+ protected VArray_Object getVArray()
+ {
+ if (vArray == null)
+ {
+ vArray = classObject.nget_varray(arrayName);
+ }
+ return vArray;
+ }
+
+ public void add(int index, T newValue)
+ {
+ prepareToInsert(1);
+ shiftRight(index);
+ basicSet(index, newValue);
+ }
+
+ public void addAll(int index, Object[] newValue)
+ {
+ prepareToInsert(newValue.length);
+ shiftRight(index, newValue.length);
+
+ for (int i = 0; i < newValue.length; i++)
+ {
+ @SuppressWarnings("unchecked")
+ T value = (T)newValue[i];
+ basicSet(index + i, value);
+ }
+ }
+
+ public void remove(int index)
+ {
+ shiftLeft(index);
+ }
+
+ public void add(T newValue)
+ {
+ long size = cachedSize();
+
+ prepareToInsert(1);
+ setValue(size, newValue);
+ cacheSize++;
+ saveSize();
+ }
+
+ public void set(long index, T newValue)
+ {
+ basicSet(index, newValue);
+ // cacheSize = -1;
+ }
+
+ public void move(long newPosition, long oldPosition)
+ {
+ if (oldPosition == newPosition)
+ {
+ return;
+ }
+
+ // get the object at oldPosition.
+ T value = getValue(oldPosition);
+ // remove the oldPosition.
+ remove((int)oldPosition);
+ // make a space at the newPosition by shifting elements
+ shiftRight((int)newPosition);
+ set(newPosition, value);
+ }
+
+ protected void basicSet(long index, T newValue)
+ {
+ if (index >= cachedSize())
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ update();
+
+ setValue(index, newValue);
+ }
+
+ public T get(long index)
+ {
+ if (index >= size())
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ return getValue(index);
+ }
+
+ protected abstract void setValue(long index, T newValue);
+
+ protected abstract T getValue(long index);
+
+ protected void saveSize()
+ {
+ // System.out.println(">>> classObject: " + classObject.objectID().getStoreString() + " <<<");
+ // System.out.println("ooArrayList.saveSize() - value to store in objy is: " + cacheSize);
+ classObject.nset_numeric(sizeName, new Numeric_Value(cacheSize));
+ resetCachedSize();
+ }
+
+ protected void resetCachedSize()
+ {
+ cacheSize = -1;
+ }
+
+ protected long cachedSize()
+ {
+ if (cacheSize == -1)
+ {
+ cacheSize = classObject.nget_numeric(sizeName).longValue();
+ // System.out.println(">>> classObject: " + classObject.objectID().getStoreString() + " <<<");
+ // System.out.println("ooArrayList.privateSize() - cacheSize was -1, value from objy is: " + cacheSize);
+ }
+ return cacheSize;
+ }
+
+ public long size()
+ {
+ // System.out.println(">>> classObject: " + classObject.objectID().getStoreString() + " <<<");
+ // Numeric_Value nValue = classObject.nget_numeric(sizeName);
+ // System.out.println("ooArrayList.size() - nValue: " + nValue.toString());
+ // return classObject.nget_numeric(sizeName).longValue();
+ return cachedSize();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListId.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListId.java
index 3d30a89794..dbaeff74dd 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListId.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListId.java
@@ -1,250 +1,250 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-
-import com.objy.as.app.Class_Object;
-import com.objy.db.app.Session;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooTreeListX;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Simon McDuff
- * @author ibrahim 100920 - IS: modified to use ooTreeListX instead of ObjyArrayList<ooId>. minimize the changes for the
- * 3.0.x build. 100927 - IS: changed to wrap ooTreeListX to avoid using extra class/Class_Object creation
- */
-public class ObjyArrayListId
-{
-
- static public String className = "ooTreeListX";
-
- private ooTreeListX list = null;
-
- // private int size = 0;
-
- public static void buildSchema()
- {
- return;
- // d_Module top_mod = ObjySchema.getTopModule();
- // if (top_mod.resolve_class(ObjyArrayListId.className) == null
- // && top_mod.resolve_proposed_class(ObjyArrayListId.className) == null)
- // {
- //
- // if (TRACER_DEBUG.isEnabled())
- // {
- // TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
- // }
- //
- // boolean inProcess = top_mod.proposed_classes().hasNext();
- //
- // // Proposed_Class A = new Proposed_Class(ooArrayListId.ClassName);
- // Proposed_Class A = top_mod.propose_new_class(ObjyArrayListId.className);
- //
- // A.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj" /* "ooObj" */);
- //
- // A.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- // ObjyArrayList.sizeName, // Attribute name
- // 1, // # elements in fixed-size array
- // ooBaseType.ooINT32 // Type of numeric data
- // ); // Default value
- //
- // A.add_ref_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- // ObjyArrayList.arrayName, // Attribute name
- // 1, // # elements in fixed-size array
- // "ooTreeListX", false);
- //
- // // top_mod.propose_new_class(A);
- // if (!inProcess)
- // {
- // top_mod.activate_proposals(true, true);
- // }
- //
- // if (TRACER_DEBUG.isEnabled())
- // {
- // TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
- // }
- // }
-
- }
-
- public static void initObject(Class_Object classObject)
- {
- return;
- // // set the size to 0;
- // classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(0));
- // // create the ooTreeListX.
- // ooTreeListX list = new ooTreeListX();
- // ooObj anObj = ooObj.create_ooObj(classObject.objectID());
- // anObj.cluster(list);
- // // System.out.println("initObject: " + anObj.getOid().getStoreString() + " treeListX: "
- // // + list.getOid().getStoreString());
- // classObject.nset_ooId(ObjyArrayList.arrayName, list.getOid());
- }
-
- public ObjyArrayListId(Class_Object classObject)
- {
- // get the ooTreeList object.
- ooId listId = classObject.objectID();
- list = (ooTreeListX)Session.getCurrent().getFD().objectFrom(listId);
- }
-
- protected void setValue(long index, ooObj newValue)
- {
- list.set((int)index, newValue);
- }
-
- protected ooObj getValue(long index)
- {
- return (ooObj)list.get((int)index);
- }
-
- protected ooId getOidValue(long index)
- {
- // System.out.println(" - ooArrayListId.getValue() at index: " + index +
- // " for classObject: " + classObject.objectID().getStoreString() );
- return getValue(index).getOid();
- }
-
- public ooId get(long index)
- {
- if (index >= size())
- {
- throw new ArrayIndexOutOfBoundsException();
- }
-
- return getOidValue(index);
- }
-
- public void set(long index, ooId newValue)
- {
- setValue(index, ooObj.create_ooObj(newValue));
- setSize();
- }
-
- public ooId[] getAll(int index, int chunkSize)
- {
- long size = size();
-
- if (chunkSize != CDORevision.UNCHUNKED)
- {
- size = Math.min(size, chunkSize);
- }
- if (size == 0)
- {
- return null;
- }
-
- ooId[] ooIds = new ooId[(int)size];
- for (int i = 0; i < size; i++)
- {
- ooIds[i] = getOidValue(i + index);
- }
- return ooIds;
- }
-
- public void add(ooId newValue)
- {
- list.add(ooObj.create_ooObj(newValue));
- // size++;
- }
-
- public void add(int index, ooId newValue)
- {
- try
- {
- list.add(index, ooObj.create_ooObj(newValue));
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- // size++;
- }
-
- public void addAll(int index, Object[] newValue)
- {
- List<Object> objList = new ArrayList<Object>();
- for (int i = 0; i < newValue.length; i++)
- {
- objList.add(ooObj.create_ooObj((ooId)newValue[i]));
- }
-
- list.addAll(index, objList);
- // setSize();
- }
-
- public void move(long newPosition, long oldPosition)
- {
- if (oldPosition == newPosition)
- {
- return;
- }
-
- // get the object at oldPosition.
- ooObj value = getValue(oldPosition);
-
- // remove the oldPosition.
- remove((int)oldPosition);
- list.add((int)newPosition, value);
- }
-
- public void remove(int index)
- {
- list.remove(index);
- // setSize();
- }
-
- public void clear()
- {
- list.clear();
- // size = 0;
- // setSize();
- }
-
- protected void setSize()
- {
- // System.out.println(">>> classObject: " + classObject.objectID().getStoreString() + " <<<");
- // System.out.println("ooArrayList.saveSize() - value to store in objy is: " + cacheSize);
- // classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(size));
- }
-
- public long size()
- {
- // size = (int)classObject.nget_numeric(ObjyArrayList.sizeName).longValue();
- int size = list.size();
- return size;
- }
-
- public ooObj copy(ooObj nearObj)
- {
-
- ooTreeListX newList = new ooTreeListX(2/* (int)size() */, false);
- // ObjyObjectManager.newInternalObjCount++;
-
- nearObj.cluster(newList);
- if (size() > 0)
- {
- newList.addAll(list);
- }
-
- // Class_Object newClassObject = new Class_Object(newObj);
- // newClassObject.nset_ooId(ObjyArrayList.arrayName, newList.getOid());
-
- return newList;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+
+import com.objy.as.app.Class_Object;
+import com.objy.db.app.Session;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeListX;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Simon McDuff
+ * @author ibrahim 100920 - IS: modified to use ooTreeListX instead of ObjyArrayList<ooId>. minimize the changes for the
+ * 3.0.x build. 100927 - IS: changed to wrap ooTreeListX to avoid using extra class/Class_Object creation
+ */
+public class ObjyArrayListId
+{
+
+ static public String className = "ooTreeListX";
+
+ private ooTreeListX list = null;
+
+ // private int size = 0;
+
+ public static void buildSchema()
+ {
+ return;
+ // d_Module top_mod = ObjySchema.getTopModule();
+ // if (top_mod.resolve_class(ObjyArrayListId.className) == null
+ // && top_mod.resolve_proposed_class(ObjyArrayListId.className) == null)
+ // {
+ //
+ // if (TRACER_DEBUG.isEnabled())
+ // {
+ // TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
+ // }
+ //
+ // boolean inProcess = top_mod.proposed_classes().hasNext();
+ //
+ // // Proposed_Class A = new Proposed_Class(ooArrayListId.ClassName);
+ // Proposed_Class A = top_mod.propose_new_class(ObjyArrayListId.className);
+ //
+ // A.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj" /* "ooObj" */);
+ //
+ // A.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ // ObjyArrayList.sizeName, // Attribute name
+ // 1, // # elements in fixed-size array
+ // ooBaseType.ooINT32 // Type of numeric data
+ // ); // Default value
+ //
+ // A.add_ref_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ // ObjyArrayList.arrayName, // Attribute name
+ // 1, // # elements in fixed-size array
+ // "ooTreeListX", false);
+ //
+ // // top_mod.propose_new_class(A);
+ // if (!inProcess)
+ // {
+ // top_mod.activate_proposals(true, true);
+ // }
+ //
+ // if (TRACER_DEBUG.isEnabled())
+ // {
+ // TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
+ // }
+ // }
+
+ }
+
+ public static void initObject(Class_Object classObject)
+ {
+ return;
+ // // set the size to 0;
+ // classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(0));
+ // // create the ooTreeListX.
+ // ooTreeListX list = new ooTreeListX();
+ // ooObj anObj = ooObj.create_ooObj(classObject.objectID());
+ // anObj.cluster(list);
+ // // System.out.println("initObject: " + anObj.getOid().getStoreString() + " treeListX: "
+ // // + list.getOid().getStoreString());
+ // classObject.nset_ooId(ObjyArrayList.arrayName, list.getOid());
+ }
+
+ public ObjyArrayListId(Class_Object classObject)
+ {
+ // get the ooTreeList object.
+ ooId listId = classObject.objectID();
+ list = (ooTreeListX)Session.getCurrent().getFD().objectFrom(listId);
+ }
+
+ protected void setValue(long index, ooObj newValue)
+ {
+ list.set((int)index, newValue);
+ }
+
+ protected ooObj getValue(long index)
+ {
+ return (ooObj)list.get((int)index);
+ }
+
+ protected ooId getOidValue(long index)
+ {
+ // System.out.println(" - ooArrayListId.getValue() at index: " + index +
+ // " for classObject: " + classObject.objectID().getStoreString() );
+ return getValue(index).getOid();
+ }
+
+ public ooId get(long index)
+ {
+ if (index >= size())
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ return getOidValue(index);
+ }
+
+ public void set(long index, ooId newValue)
+ {
+ setValue(index, ooObj.create_ooObj(newValue));
+ setSize();
+ }
+
+ public ooId[] getAll(int index, int chunkSize)
+ {
+ long size = size();
+
+ if (chunkSize != CDORevision.UNCHUNKED)
+ {
+ size = Math.min(size, chunkSize);
+ }
+ if (size == 0)
+ {
+ return null;
+ }
+
+ ooId[] ooIds = new ooId[(int)size];
+ for (int i = 0; i < size; i++)
+ {
+ ooIds[i] = getOidValue(i + index);
+ }
+ return ooIds;
+ }
+
+ public void add(ooId newValue)
+ {
+ list.add(ooObj.create_ooObj(newValue));
+ // size++;
+ }
+
+ public void add(int index, ooId newValue)
+ {
+ try
+ {
+ list.add(index, ooObj.create_ooObj(newValue));
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ // size++;
+ }
+
+ public void addAll(int index, Object[] newValue)
+ {
+ List<Object> objList = new ArrayList<Object>();
+ for (int i = 0; i < newValue.length; i++)
+ {
+ objList.add(ooObj.create_ooObj((ooId)newValue[i]));
+ }
+
+ list.addAll(index, objList);
+ // setSize();
+ }
+
+ public void move(long newPosition, long oldPosition)
+ {
+ if (oldPosition == newPosition)
+ {
+ return;
+ }
+
+ // get the object at oldPosition.
+ ooObj value = getValue(oldPosition);
+
+ // remove the oldPosition.
+ remove((int)oldPosition);
+ list.add((int)newPosition, value);
+ }
+
+ public void remove(int index)
+ {
+ list.remove(index);
+ // setSize();
+ }
+
+ public void clear()
+ {
+ list.clear();
+ // size = 0;
+ // setSize();
+ }
+
+ protected void setSize()
+ {
+ // System.out.println(">>> classObject: " + classObject.objectID().getStoreString() + " <<<");
+ // System.out.println("ooArrayList.saveSize() - value to store in objy is: " + cacheSize);
+ // classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(size));
+ }
+
+ public long size()
+ {
+ // size = (int)classObject.nget_numeric(ObjyArrayList.sizeName).longValue();
+ int size = list.size();
+ return size;
+ }
+
+ public ooObj copy(ooObj nearObj)
+ {
+
+ ooTreeListX newList = new ooTreeListX(2/* (int)size() */, false);
+ // ObjyObjectManager.newInternalObjCount++;
+
+ nearObj.cluster(newList);
+ if (size() > 0)
+ {
+ newList.addAll(list);
+ }
+
+ // Class_Object newClassObject = new Class_Object(newObj);
+ // newClassObject.nset_ooId(ObjyArrayList.arrayName, newList.getOid());
+
+ return newList;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListLong.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListLong.java
index 9091c544c7..90cec59e89 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListLong.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListLong.java
@@ -1,94 +1,94 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Module;
-import com.objy.as.app.ooBaseType;
-
-/**
- * @author Simon McDuff
- */
-public class ObjyArrayListLong extends ObjyArrayList<Long>
-{
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyArrayListLong.class);
-
- static public String ArrayName = "ObjyArrayListLong";
-
- public static void buildSchema()
- {
- d_Module top_mod = ObjySchema.getTopModule();
- if (top_mod.resolve_class(ObjyArrayListLong.ArrayName) == null)
- {
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
- }
-
- boolean inProcess = top_mod.proposed_classes().hasNext();
-
- // Proposed_Class A = new Proposed_Class(ooArrayListLong.ArrayName);
- Proposed_Class A = top_mod.propose_new_class(ObjyArrayListLong.ArrayName);
-
- A.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
-
- A.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyArrayList.sizeName, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooINT32 // Type of numeric data
- ); // Default value
-
- A.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyArrayList.arrayName, // Attribute name
- 1, ooBaseType.ooINT64);
-
- // top_mod.propose_new_class(A);
-
- if (!inProcess)
- {
- top_mod.activate_proposals(true, true);
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
- }
- }
- }
-
- public ObjyArrayListLong(Class_Object classObject)
- {
- super(classObject);
- }
-
- @Override
- protected void setValue(long index, Long newValue)
- {
- getVArray().set_numeric(index, new Numeric_Value(newValue.longValue()));
- }
-
- @Override
- protected Long getValue(long index)
- {
- return getVArray().get_numeric(index).longValue();
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Module;
+import com.objy.as.app.ooBaseType;
+
+/**
+ * @author Simon McDuff
+ */
+public class ObjyArrayListLong extends ObjyArrayList<Long>
+{
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyArrayListLong.class);
+
+ static public String ArrayName = "ObjyArrayListLong";
+
+ public static void buildSchema()
+ {
+ d_Module top_mod = ObjySchema.getTopModule();
+ if (top_mod.resolve_class(ObjyArrayListLong.ArrayName) == null)
+ {
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
+ }
+
+ boolean inProcess = top_mod.proposed_classes().hasNext();
+
+ // Proposed_Class A = new Proposed_Class(ooArrayListLong.ArrayName);
+ Proposed_Class A = top_mod.propose_new_class(ObjyArrayListLong.ArrayName);
+
+ A.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
+
+ A.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyArrayList.sizeName, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooINT32 // Type of numeric data
+ ); // Default value
+
+ A.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyArrayList.arrayName, // Attribute name
+ 1, ooBaseType.ooINT64);
+
+ // top_mod.propose_new_class(A);
+
+ if (!inProcess)
+ {
+ top_mod.activate_proposals(true, true);
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
+ }
+ }
+ }
+
+ public ObjyArrayListLong(Class_Object classObject)
+ {
+ super(classObject);
+ }
+
+ @Override
+ protected void setValue(long index, Long newValue)
+ {
+ getVArray().set_numeric(index, new Numeric_Value(newValue.longValue()));
+ }
+
+ @Override
+ protected Long getValue(long index)
+ {
+ return getVArray().get_numeric(index).longValue();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListString.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListString.java
index 5ddb3a4dbf..e28ddb12f0 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListString.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyArrayListString.java
@@ -1,406 +1,406 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyClass;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.String_Value;
-import com.objy.as.app.VArray_Object;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Module;
-import com.objy.as.app.ooBaseType;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-
-/**
- * @author Simon McDuff
- */
-/***
- * This class we use VArray of fixed array of Strings, otherwise we have to create strigns as objects, which is
- * expensive.
- */
-public class ObjyArrayListString
-{
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyArrayListString.class);
-
- public static String ClassName = "ObjyArrayListString";
-
- // embedded class parts.
- private static String embeddedClassName = "oo_StringElement";
-
- private static String embeddedAttributeName = "value";
-
- private static String embeddedAttributeNull = "isNull";
-
- // fixed array class parts.
- private static String FixedArrayClassName = "ObjyFixedStringArray";
-
- private static String FixedElementsName = "elements";
-
- private static final long FixedElementsSize = 10;
-
- protected Class_Object classObject;
-
- private VArray_Object vArray;
-
- transient long cacheSize = -1;
-
- transient long position;
-
- public static void buildSchema()
- {
- d_Module top_mod = ObjySchema.getTopModule();
-
- if (top_mod.resolve_class(ObjyArrayListString.ClassName) == null)
- {
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Schema not found for ooArrayListString. Adding ooArrayListString");
- }
-
- boolean inProcess = top_mod.proposed_classes().hasNext();
-
- // using embedded class (string, isNull)
- // Proposed_Class embeddedClass = new Proposed_Class(embeddedClassName);
- Proposed_Class embeddedClass = top_mod.propose_new_class(embeddedClassName);
-
- embeddedClass.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- embeddedAttributeName, // Attribute name
- 1, // # elements in fixed-size array
- "ooUtf8String" // Type of numeric data
- ); // Default value
-
- embeddedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- embeddedAttributeNull, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooBOOLEAN // Type of numeric data
- ); // Default value
-
- // top_mod.propose_new_class(embeddedClass);
-
- // first the child class.
- // Proposed_Class fixedArrayClass = new Proposed_Class(ooArrayListString.FixedArrayClassName);
- Proposed_Class fixedArrayClass = top_mod.propose_new_class(ObjyArrayListString.FixedArrayClassName);
-
- fixedArrayClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
-
- fixedArrayClass.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyArrayListString.FixedElementsName, // Attribute name
- ObjyArrayListString.FixedElementsSize, // # elements in fixed-size array
- embeddedClassName // Type of numeric data
- ); // Default value
-
- // top_mod.propose_new_class(fixedArrayClass);
-
- // Proposed_Class StringArrayClass = new Proposed_Class(ooArrayListString.ClassName);
- Proposed_Class StringArrayClass = top_mod.propose_new_class(ObjyArrayListString.ClassName);
-
- StringArrayClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
-
- StringArrayClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyArrayList.sizeName, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooINT32 // Type of numeric data
- ); // Default value
-
- StringArrayClass.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyArrayList.arrayName, // Attribute name
- 1, false, ObjyArrayListString.FixedArrayClassName);
-
- // top_mod.propose_new_class(StringArrayClass);
- if (!inProcess)
- {
- top_mod.activate_proposals(true, true);
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("SCHEMA changed : ooArrayListString added");
- }
- }
- }
-
- public static void initObject(Class_Object classObject)
- {
- // set the size to 0;
- classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(0));
- }
-
- public ObjyArrayListString(Class_Object classObject)
- {
- this.classObject = classObject;
- }
-
- // TODO - there is no check if the index is out of bound.
- protected void setValue(long index, String newValue)
- {
- // find the chunk.
- long chunkItem = index / FixedElementsSize;
- long chunkIndex = index % FixedElementsSize;
- Class_Object chunkObject = getVArray().get_class_obj(chunkItem);
- // String_Value value = chunkObject.nget_string(FixedElementsName, chunkIndex);
- Class_Object embeddedElement = chunkObject.nget_class_obj(FixedElementsName, chunkIndex);
- // TODO - I don't like using magic numbers!!! we are using "1" to index into the embedded object.
- embeddedElement.set_numeric(1, newValue == null ? ITypeMapper.numericTrue : ITypeMapper.numericFalse);
- // String_Value value = embeddedElement.get_string(0); // TODO - I don't like using magic numbers!!!
- String_Value value = embeddedElement.nget_string(embeddedAttributeName);
- value.update();
- if (newValue == null)
- {
- newValue = "";
- }
- value.set(newValue);
- }
-
- protected String getValue(long index)
- {
- // find the chunk.
- long chunkItem = index / FixedElementsSize;
- long chunkIndex = index % FixedElementsSize;
- Class_Object chunkObject = getVArray().get_class_obj(chunkItem);
- // String_Value value = chunkObject.nget_string(FixedElementsName, chunkIndex);
- Class_Object embeddedElement = chunkObject.nget_class_obj(FixedElementsName, chunkIndex); // TODO - I don't like
- // using magic numbers!!!
- String_Value value = embeddedElement.nget_string(embeddedAttributeName);
- Numeric_Value isNull = embeddedElement.get_numeric(1);
- return isNull == ITypeMapper.numericTrue ? null : value.toString();
- }
-
- public String[] getAll(int index, int chunkSize)
- {
- int size = (int)cachedSize();
-
- if (chunkSize != CDORevision.UNCHUNKED)
- {
- size = Math.min(size, chunkSize);
- }
-
- String[] strings = new String[size];
- Class_Object currentChunkObject = null;
- long currentChunkItem = -1;
-
- for (int i = 0; i < size; i++)
- {
- // find the chunk.
- long chunkItem = (i + index) / FixedElementsSize;
- long chunkIndex = (i + index) % FixedElementsSize;
- if (currentChunkItem != chunkItem)
- {
- currentChunkItem = chunkItem;
- currentChunkObject = getVArray().get_class_obj(currentChunkItem);
- }
- Class_Object embeddedElement = currentChunkObject.nget_class_obj(FixedElementsName, chunkIndex);
- String_Value value = embeddedElement.nget_string(embeddedAttributeName);
- Numeric_Value isNull = embeddedElement.get_numeric(1);
- if (isNull == ITypeMapper.numericTrue)
- {
- strings[i] = null;
- }
- else
- {
- strings[i] = value.toString();
- }
- }
- return strings;
- }
-
- public void clear()
- {
- // remove all the fixed array objects...
- for (int i = 0; i < getVArray().size(); i++)
- {
- ooId oid = getVArray().get_ooId(i);
- ooObj.create_ooObj(oid).delete();
- }
- getVArray().resize(0);
- cacheSize = 0;
- saveSize();
- }
-
- private void shiftRight(int index)
- {
- shiftRight(index, 1);
- }
-
- private void shiftRight(int index, int sizeToShift)
- {
- long size = cachedSize();
-
- for (long i = size - 1; i >= index; i--)
- {
- setValue(i + sizeToShift, getValue(i));
- }
-
- cacheSize += sizeToShift;
- }
-
- private void shiftLeft(int index)
- {
- long size = cachedSize();
- for (long i = index; i < size - 1; i++)
- {
- setValue(i, getValue(i + 1));
- }
-
- cacheSize--;
-
- saveSize();
- }
-
- /**
- *
- */
- private void grow(int numToAdd)
- {
- long arraySize = cachedSize();
- long numChunks = (numToAdd + (int)arraySize) / FixedElementsSize + 1;
- long newChunks = numChunks - arraySize;
- if (newChunks > 0)
- {
- getVArray().resize(numChunks);
- // TODO - this could be cached somewhere...
- ObjyClass chunkClass = ObjySchema.getObjyClass(FixedArrayClassName);
- for (int i = 0; i < newChunks; i++)
- {
- // create a new chunk.
- Class_Object newChunk = Class_Object.new_persistent_object(chunkClass.getASClass(), classObject.objectID(),
- false);
- getVArray().set_ooId(arraySize + i, newChunk.objectID());
- }
- cacheSize = -1;
- }
- }
-
- /**
- *
- */
- private void prepareToInsert(int numberToAdd)
- {
- long size = cachedSize();
- getVArray().update();
-
- if (size + numberToAdd > getVArray().size())
- {
- grow(numberToAdd);
- }
- }
-
- protected VArray_Object getVArray()
- {
- if (vArray == null)
- {
- vArray = classObject.nget_varray(ObjyArrayList.arrayName);
- }
- return vArray;
- }
-
- public void add(int index, String newValue)
- {
- prepareToInsert(1);
-
- shiftRight(index);
-
- basicSet(index, newValue);
-
- saveSize();
- }
-
- public void addAll(int index, Object[] newValue)
- {
- prepareToInsert(newValue.length);
- shiftRight(index, newValue.length);
-
- for (int i = 0; i < newValue.length; i++)
- {
- basicSet(index + i, (String)newValue[i]);
- }
-
- saveSize();
- }
-
- public void remove(int index)
- {
- shiftLeft(index);
- }
-
- public void add(String newValue)
- {
- long size = cachedSize();
-
- prepareToInsert(1);
-
- setValue(size, newValue);
-
- cacheSize++;
-
- saveSize();
- }
-
- public void set(long index, String newValue)
- {
- basicSet(index, newValue);
- cacheSize = -1;
- }
-
- protected void basicSet(long index, String newValue)
- {
- if (index >= cachedSize())
- {
- throw new ArrayIndexOutOfBoundsException();
- }
-
- getVArray().update();
-
- setValue(index, newValue);
- }
-
- public String get(long index)
- {
- if (index >= size())
- {
- throw new ArrayIndexOutOfBoundsException();
- }
-
- return getValue(index);
- }
-
- private void saveSize()
- {
- classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(cacheSize));
- cacheSize = -1;
- }
-
- public long cachedSize()
- {
- if (cacheSize == -1)
- {
- cacheSize = classObject.nget_numeric(ObjyArrayList.sizeName).longValue();
- }
- return cacheSize;
- }
-
- public long size()
- {
- return classObject.nget_numeric(ObjyArrayList.sizeName).longValue();
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyClass;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+import org.eclipse.emf.cdo.server.internal.objectivity.mapper.ITypeMapper;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.String_Value;
+import com.objy.as.app.VArray_Object;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Module;
+import com.objy.as.app.ooBaseType;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+
+/**
+ * @author Simon McDuff
+ */
+/***
+ * This class we use VArray of fixed array of Strings, otherwise we have to create strigns as objects, which is
+ * expensive.
+ */
+public class ObjyArrayListString
+{
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyArrayListString.class);
+
+ public static String ClassName = "ObjyArrayListString";
+
+ // embedded class parts.
+ private static String embeddedClassName = "oo_StringElement";
+
+ private static String embeddedAttributeName = "value";
+
+ private static String embeddedAttributeNull = "isNull";
+
+ // fixed array class parts.
+ private static String FixedArrayClassName = "ObjyFixedStringArray";
+
+ private static String FixedElementsName = "elements";
+
+ private static final long FixedElementsSize = 10;
+
+ protected Class_Object classObject;
+
+ private VArray_Object vArray;
+
+ transient long cacheSize = -1;
+
+ transient long position;
+
+ public static void buildSchema()
+ {
+ d_Module top_mod = ObjySchema.getTopModule();
+
+ if (top_mod.resolve_class(ObjyArrayListString.ClassName) == null)
+ {
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Schema not found for ooArrayListString. Adding ooArrayListString");
+ }
+
+ boolean inProcess = top_mod.proposed_classes().hasNext();
+
+ // using embedded class (string, isNull)
+ // Proposed_Class embeddedClass = new Proposed_Class(embeddedClassName);
+ Proposed_Class embeddedClass = top_mod.propose_new_class(embeddedClassName);
+
+ embeddedClass.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ embeddedAttributeName, // Attribute name
+ 1, // # elements in fixed-size array
+ "ooUtf8String" // Type of numeric data
+ ); // Default value
+
+ embeddedClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ embeddedAttributeNull, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooBOOLEAN // Type of numeric data
+ ); // Default value
+
+ // top_mod.propose_new_class(embeddedClass);
+
+ // first the child class.
+ // Proposed_Class fixedArrayClass = new Proposed_Class(ooArrayListString.FixedArrayClassName);
+ Proposed_Class fixedArrayClass = top_mod.propose_new_class(ObjyArrayListString.FixedArrayClassName);
+
+ fixedArrayClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
+
+ fixedArrayClass.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyArrayListString.FixedElementsName, // Attribute name
+ ObjyArrayListString.FixedElementsSize, // # elements in fixed-size array
+ embeddedClassName // Type of numeric data
+ ); // Default value
+
+ // top_mod.propose_new_class(fixedArrayClass);
+
+ // Proposed_Class StringArrayClass = new Proposed_Class(ooArrayListString.ClassName);
+ Proposed_Class StringArrayClass = top_mod.propose_new_class(ObjyArrayListString.ClassName);
+
+ StringArrayClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
+
+ StringArrayClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyArrayList.sizeName, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooINT32 // Type of numeric data
+ ); // Default value
+
+ StringArrayClass.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyArrayList.arrayName, // Attribute name
+ 1, false, ObjyArrayListString.FixedArrayClassName);
+
+ // top_mod.propose_new_class(StringArrayClass);
+ if (!inProcess)
+ {
+ top_mod.activate_proposals(true, true);
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("SCHEMA changed : ooArrayListString added");
+ }
+ }
+ }
+
+ public static void initObject(Class_Object classObject)
+ {
+ // set the size to 0;
+ classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(0));
+ }
+
+ public ObjyArrayListString(Class_Object classObject)
+ {
+ this.classObject = classObject;
+ }
+
+ // TODO - there is no check if the index is out of bound.
+ protected void setValue(long index, String newValue)
+ {
+ // find the chunk.
+ long chunkItem = index / FixedElementsSize;
+ long chunkIndex = index % FixedElementsSize;
+ Class_Object chunkObject = getVArray().get_class_obj(chunkItem);
+ // String_Value value = chunkObject.nget_string(FixedElementsName, chunkIndex);
+ Class_Object embeddedElement = chunkObject.nget_class_obj(FixedElementsName, chunkIndex);
+ // TODO - I don't like using magic numbers!!! we are using "1" to index into the embedded object.
+ embeddedElement.set_numeric(1, newValue == null ? ITypeMapper.numericTrue : ITypeMapper.numericFalse);
+ // String_Value value = embeddedElement.get_string(0); // TODO - I don't like using magic numbers!!!
+ String_Value value = embeddedElement.nget_string(embeddedAttributeName);
+ value.update();
+ if (newValue == null)
+ {
+ newValue = "";
+ }
+ value.set(newValue);
+ }
+
+ protected String getValue(long index)
+ {
+ // find the chunk.
+ long chunkItem = index / FixedElementsSize;
+ long chunkIndex = index % FixedElementsSize;
+ Class_Object chunkObject = getVArray().get_class_obj(chunkItem);
+ // String_Value value = chunkObject.nget_string(FixedElementsName, chunkIndex);
+ Class_Object embeddedElement = chunkObject.nget_class_obj(FixedElementsName, chunkIndex); // TODO - I don't like
+ // using magic numbers!!!
+ String_Value value = embeddedElement.nget_string(embeddedAttributeName);
+ Numeric_Value isNull = embeddedElement.get_numeric(1);
+ return isNull == ITypeMapper.numericTrue ? null : value.toString();
+ }
+
+ public String[] getAll(int index, int chunkSize)
+ {
+ int size = (int)cachedSize();
+
+ if (chunkSize != CDORevision.UNCHUNKED)
+ {
+ size = Math.min(size, chunkSize);
+ }
+
+ String[] strings = new String[size];
+ Class_Object currentChunkObject = null;
+ long currentChunkItem = -1;
+
+ for (int i = 0; i < size; i++)
+ {
+ // find the chunk.
+ long chunkItem = (i + index) / FixedElementsSize;
+ long chunkIndex = (i + index) % FixedElementsSize;
+ if (currentChunkItem != chunkItem)
+ {
+ currentChunkItem = chunkItem;
+ currentChunkObject = getVArray().get_class_obj(currentChunkItem);
+ }
+ Class_Object embeddedElement = currentChunkObject.nget_class_obj(FixedElementsName, chunkIndex);
+ String_Value value = embeddedElement.nget_string(embeddedAttributeName);
+ Numeric_Value isNull = embeddedElement.get_numeric(1);
+ if (isNull == ITypeMapper.numericTrue)
+ {
+ strings[i] = null;
+ }
+ else
+ {
+ strings[i] = value.toString();
+ }
+ }
+ return strings;
+ }
+
+ public void clear()
+ {
+ // remove all the fixed array objects...
+ for (int i = 0; i < getVArray().size(); i++)
+ {
+ ooId oid = getVArray().get_ooId(i);
+ ooObj.create_ooObj(oid).delete();
+ }
+ getVArray().resize(0);
+ cacheSize = 0;
+ saveSize();
+ }
+
+ private void shiftRight(int index)
+ {
+ shiftRight(index, 1);
+ }
+
+ private void shiftRight(int index, int sizeToShift)
+ {
+ long size = cachedSize();
+
+ for (long i = size - 1; i >= index; i--)
+ {
+ setValue(i + sizeToShift, getValue(i));
+ }
+
+ cacheSize += sizeToShift;
+ }
+
+ private void shiftLeft(int index)
+ {
+ long size = cachedSize();
+ for (long i = index; i < size - 1; i++)
+ {
+ setValue(i, getValue(i + 1));
+ }
+
+ cacheSize--;
+
+ saveSize();
+ }
+
+ /**
+ *
+ */
+ private void grow(int numToAdd)
+ {
+ long arraySize = cachedSize();
+ long numChunks = (numToAdd + (int)arraySize) / FixedElementsSize + 1;
+ long newChunks = numChunks - arraySize;
+ if (newChunks > 0)
+ {
+ getVArray().resize(numChunks);
+ // TODO - this could be cached somewhere...
+ ObjyClass chunkClass = ObjySchema.getObjyClass(FixedArrayClassName);
+ for (int i = 0; i < newChunks; i++)
+ {
+ // create a new chunk.
+ Class_Object newChunk = Class_Object.new_persistent_object(chunkClass.getASClass(), classObject.objectID(),
+ false);
+ getVArray().set_ooId(arraySize + i, newChunk.objectID());
+ }
+ cacheSize = -1;
+ }
+ }
+
+ /**
+ *
+ */
+ private void prepareToInsert(int numberToAdd)
+ {
+ long size = cachedSize();
+ getVArray().update();
+
+ if (size + numberToAdd > getVArray().size())
+ {
+ grow(numberToAdd);
+ }
+ }
+
+ protected VArray_Object getVArray()
+ {
+ if (vArray == null)
+ {
+ vArray = classObject.nget_varray(ObjyArrayList.arrayName);
+ }
+ return vArray;
+ }
+
+ public void add(int index, String newValue)
+ {
+ prepareToInsert(1);
+
+ shiftRight(index);
+
+ basicSet(index, newValue);
+
+ saveSize();
+ }
+
+ public void addAll(int index, Object[] newValue)
+ {
+ prepareToInsert(newValue.length);
+ shiftRight(index, newValue.length);
+
+ for (int i = 0; i < newValue.length; i++)
+ {
+ basicSet(index + i, (String)newValue[i]);
+ }
+
+ saveSize();
+ }
+
+ public void remove(int index)
+ {
+ shiftLeft(index);
+ }
+
+ public void add(String newValue)
+ {
+ long size = cachedSize();
+
+ prepareToInsert(1);
+
+ setValue(size, newValue);
+
+ cacheSize++;
+
+ saveSize();
+ }
+
+ public void set(long index, String newValue)
+ {
+ basicSet(index, newValue);
+ cacheSize = -1;
+ }
+
+ protected void basicSet(long index, String newValue)
+ {
+ if (index >= cachedSize())
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ getVArray().update();
+
+ setValue(index, newValue);
+ }
+
+ public String get(long index)
+ {
+ if (index >= size())
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+
+ return getValue(index);
+ }
+
+ private void saveSize()
+ {
+ classObject.nset_numeric(ObjyArrayList.sizeName, new Numeric_Value(cacheSize));
+ cacheSize = -1;
+ }
+
+ public long cachedSize()
+ {
+ if (cacheSize == -1)
+ {
+ cacheSize = classObject.nget_numeric(ObjyArrayList.sizeName).longValue();
+ }
+ return cacheSize;
+ }
+
+ public long size()
+ {
+ return classObject.nget_numeric(ObjyArrayList.sizeName).longValue();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBase.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBase.java
index bfe386204e..f0843e7d3d 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBase.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBase.java
@@ -1,147 +1,147 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.Rel_Copy;
-import com.objy.as.app.Rel_Propagation;
-import com.objy.as.app.Rel_Versioning;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Module;
-import com.objy.as.app.ooBaseType;
-
-/**
- * EMF Classes in Objectivity are enhanced with this base class. This class is use for the revision data as a base for
- * other classes created.
- *
- * @author ibrahim
- */
-public class ObjyBase
-{
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyBase.class);
-
- public static final String CLASS_NAME = "ObjyBase";
-
- public static final String ATT_CONTAINERID = "oo_containerId";
-
- public static final String ATT_CONTAINER_FEATUERID = "oo_containerFeatureId";
-
- public static final String ATT_RESOURCEID = "oo_resourceId";
-
- public static final String ATT_VERSION = "oo_version";
-
- public static final String ATT_REVISED_TIME = "oo_revisedTime";
-
- public static final String ATT_CREATION_TIME = "oo_creationTime";
-
- public static final String ATT_REVISIONS = "oo_revisions";
-
- public static final String ATT_BRANCHID = "oo_branchId";
-
- public static final String ATT_BASE = "oo_base";
-
- public static final String ATT_LAST_REVISION = "oo_lastRevision";
-
- public static void buildSchema()
- {
- d_Module top_mod = ObjySchema.getTopModule();
- if (top_mod.resolve_class(ObjyBase.CLASS_NAME) == null
- && top_mod.resolve_proposed_class(ObjyBase.CLASS_NAME) == null)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Schema not found for ooBase. Adding it.");
- }
-
- boolean inProcess = top_mod.proposed_classes().hasNext();
-
- Proposed_Class propClass = top_mod.propose_new_class(ObjyBase.CLASS_NAME);
-
- propClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
-
- propClass.add_bidirectional_relationship(d_Module.LAST, d_Access_Kind.d_PUBLIC, ObjyBase.ATT_REVISIONS,
- ObjyBase.CLASS_NAME, false, false, true, Rel_Copy.DELETE, Rel_Versioning.COPY,
- Rel_Propagation.LOCK_YES_DELETE_YES, ObjyBase.ATT_BASE, false);
-
- // propClass.add_bidirectional_relationship(position, visibility,
- // name, destinationClassName, isInline, isShort, isToMany,
- // copyMode, versioning, propagation, inverseName, inverseIsToMany)
-
- propClass.add_bidirectional_relationship(d_Module.LAST, d_Access_Kind.d_PUBLIC, ObjyBase.ATT_BASE,
- ObjyBase.CLASS_NAME, false, false, false, Rel_Copy.DELETE, Rel_Versioning.COPY,
- Rel_Propagation.LOCK_YES_DELETE_YES, ObjyBase.ATT_REVISIONS, true);
-
- propClass.add_unidirectional_relationship(d_Module.LAST, d_Access_Kind.d_PUBLIC, ObjyBase.ATT_LAST_REVISION,
- ObjyBase.CLASS_NAME, true, false, false, Rel_Copy.DELETE, Rel_Versioning.COPY,
- Rel_Propagation.LOCK_YES_DELETE_YES);
-
- propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyBase.ATT_CONTAINER_FEATUERID, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooINT32 // Type of numeric data
- ); // Default value
-
- propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
- d_Access_Kind.d_PUBLIC, // Access kind
- ObjyBase.ATT_CONTAINERID, // Attribute name
- 1, // # elements in fixed-size array
- "ooObj", false); // Default value // Default value
-
- propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
- d_Access_Kind.d_PUBLIC, // Access kind
- ObjyBase.ATT_RESOURCEID, // Attribute name
- 1, // # elements in fixed-size array
- "ooObj", false); // Default value // Default value
-
- propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyBase.ATT_VERSION, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooINT32 // Type of numeric data
- ); // Default value
-
- propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyBase.ATT_BRANCHID, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooINT32 // Type of numeric data
- ); // Default value
-
- propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyBase.ATT_CREATION_TIME, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooINT64 // Type of numeric data
- ); // Default value
-
- propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyBase.ATT_REVISED_TIME, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooINT64 // Type of numeric data
- ); // Default value
-
- if (!inProcess)
- {
- top_mod.activate_proposals(true, true);
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("SCHEMA changed : ooBaseClass added");
- }
- }
-
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.Rel_Copy;
+import com.objy.as.app.Rel_Propagation;
+import com.objy.as.app.Rel_Versioning;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Module;
+import com.objy.as.app.ooBaseType;
+
+/**
+ * EMF Classes in Objectivity are enhanced with this base class. This class is use for the revision data as a base for
+ * other classes created.
+ *
+ * @author ibrahim
+ */
+public class ObjyBase
+{
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyBase.class);
+
+ public static final String CLASS_NAME = "ObjyBase";
+
+ public static final String ATT_CONTAINERID = "oo_containerId";
+
+ public static final String ATT_CONTAINER_FEATUERID = "oo_containerFeatureId";
+
+ public static final String ATT_RESOURCEID = "oo_resourceId";
+
+ public static final String ATT_VERSION = "oo_version";
+
+ public static final String ATT_REVISED_TIME = "oo_revisedTime";
+
+ public static final String ATT_CREATION_TIME = "oo_creationTime";
+
+ public static final String ATT_REVISIONS = "oo_revisions";
+
+ public static final String ATT_BRANCHID = "oo_branchId";
+
+ public static final String ATT_BASE = "oo_base";
+
+ public static final String ATT_LAST_REVISION = "oo_lastRevision";
+
+ public static void buildSchema()
+ {
+ d_Module top_mod = ObjySchema.getTopModule();
+ if (top_mod.resolve_class(ObjyBase.CLASS_NAME) == null
+ && top_mod.resolve_proposed_class(ObjyBase.CLASS_NAME) == null)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Schema not found for ooBase. Adding it.");
+ }
+
+ boolean inProcess = top_mod.proposed_classes().hasNext();
+
+ Proposed_Class propClass = top_mod.propose_new_class(ObjyBase.CLASS_NAME);
+
+ propClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
+
+ propClass.add_bidirectional_relationship(d_Module.LAST, d_Access_Kind.d_PUBLIC, ObjyBase.ATT_REVISIONS,
+ ObjyBase.CLASS_NAME, false, false, true, Rel_Copy.DELETE, Rel_Versioning.COPY,
+ Rel_Propagation.LOCK_YES_DELETE_YES, ObjyBase.ATT_BASE, false);
+
+ // propClass.add_bidirectional_relationship(position, visibility,
+ // name, destinationClassName, isInline, isShort, isToMany,
+ // copyMode, versioning, propagation, inverseName, inverseIsToMany)
+
+ propClass.add_bidirectional_relationship(d_Module.LAST, d_Access_Kind.d_PUBLIC, ObjyBase.ATT_BASE,
+ ObjyBase.CLASS_NAME, false, false, false, Rel_Copy.DELETE, Rel_Versioning.COPY,
+ Rel_Propagation.LOCK_YES_DELETE_YES, ObjyBase.ATT_REVISIONS, true);
+
+ propClass.add_unidirectional_relationship(d_Module.LAST, d_Access_Kind.d_PUBLIC, ObjyBase.ATT_LAST_REVISION,
+ ObjyBase.CLASS_NAME, true, false, false, Rel_Copy.DELETE, Rel_Versioning.COPY,
+ Rel_Propagation.LOCK_YES_DELETE_YES);
+
+ propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyBase.ATT_CONTAINER_FEATUERID, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooINT32 // Type of numeric data
+ ); // Default value
+
+ propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyBase.ATT_CONTAINERID, // Attribute name
+ 1, // # elements in fixed-size array
+ "ooObj", false); // Default value // Default value
+
+ propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyBase.ATT_RESOURCEID, // Attribute name
+ 1, // # elements in fixed-size array
+ "ooObj", false); // Default value // Default value
+
+ propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyBase.ATT_VERSION, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooINT32 // Type of numeric data
+ ); // Default value
+
+ propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyBase.ATT_BRANCHID, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooINT32 // Type of numeric data
+ ); // Default value
+
+ propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyBase.ATT_CREATION_TIME, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooINT64 // Type of numeric data
+ ); // Default value
+
+ propClass.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyBase.ATT_REVISED_TIME, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooINT64 // Type of numeric data
+ ); // Default value
+
+ if (!inProcess)
+ {
+ top_mod.activate_proposals(true, true);
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("SCHEMA changed : ooBaseClass added");
+ }
+ }
+
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranch.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranch.java
index d6a56041e8..6e35dc8b6e 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranch.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranch.java
@@ -1,150 +1,150 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooTreeSetX;
-
-import java.util.SortedSet;
-
-/**
- * @author Ibrahim Sallam
- */
-/**
- * @author Ibrahim Sallam
- */
-/**
- * @author Ibrahim Sallam
- */
-public class ObjyBranch extends ooObj
-{
- protected int branchId;
-
- protected int baseBranchId;
-
- protected long baseBranchTimeStamp;
-
- protected String branchName;
-
- protected ooTreeSetX revisions;
-
- public static ObjyBranch create(ooObj clusterObj, int branchId, int baseBranchId, String branchName, long timeStamp)
- {
- ObjyBranch objyBranch = new ObjyBranch(branchId, baseBranchId, branchName, timeStamp);
- clusterObj.cluster(objyBranch);
- objyBranch.createRevisionsSet();
- return objyBranch;
- }
-
- public static ObjyBranch create(ooObj clusterObj, int branchId, BranchInfo branchInfo)
- {
- ObjyBranch objyBranch = new ObjyBranch(branchId, branchInfo);
- clusterObj.cluster(objyBranch);
- objyBranch.createRevisionsSet();
- return objyBranch;
- }
-
- private ObjyBranch(int id, BranchInfo branchInfo)
- {
- branchId = id;
- baseBranchId = branchInfo.getBaseBranchID();
- baseBranchTimeStamp = branchInfo.getBaseTimeStamp();
- branchName = branchInfo.getName();
- revisions = null;
- }
-
- private ObjyBranch(int branchId, int baseBranchId, String branchName, long timeStamp)
- {
- this.branchId = branchId;
- this.baseBranchId = baseBranchId;
- baseBranchTimeStamp = timeStamp;
- this.branchName = branchName;
- revisions = null;
- }
-
- public int getBranchId()
- {
- fetch();
- return branchId;
- }
-
- public int getBaseBranchId()
- {
- fetch();
- return baseBranchId;
- }
-
- public long getBaseBranchTimeStamp()
- {
- fetch();
- return baseBranchTimeStamp;
- }
-
- public String getBranchName()
- {
- fetch();
- return branchName;
- }
-
- public void addRevision(ooObj anObj)
- {
- markModified();
- if (revisions == null) // we'll only allocate if needed.
- {
- revisions = new ooTreeSetX();
- this.cluster(revisions);
- }
- revisions.add(anObj);
- }
-
- public int numberOfRevisions()
- {
- fetch();
- return revisions.size();
- }
-
- public SortedSet<?> getRevisions()
- {
- fetch();
- // // we don't want to allocate the ooTreeSetX object if the branch is empty.
- // if (revisions == null)
- // {
- // return new ArrayList<Object>().iterator();
- // }
-
- return revisions;
- }
-
- public BranchInfo getBranchInfo()
- {
- fetch();
- BranchInfo branchInfo = new BranchInfo(getBranchName(), getBaseBranchId(), getBaseBranchTimeStamp());
- return branchInfo;
- }
-
- public boolean deleteRevision(Object anObject)
- {
- markModified();
- return revisions.remove(anObject);
- }
-
- private void createRevisionsSet()
- {
- if (revisions == null) // we'll only allocate if needed.
- {
- revisions = new ooTreeSetX();
- this.cluster(revisions);
- }
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
+
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeSetX;
+
+import java.util.SortedSet;
+
+/**
+ * @author Ibrahim Sallam
+ */
+/**
+ * @author Ibrahim Sallam
+ */
+/**
+ * @author Ibrahim Sallam
+ */
+public class ObjyBranch extends ooObj
+{
+ protected int branchId;
+
+ protected int baseBranchId;
+
+ protected long baseBranchTimeStamp;
+
+ protected String branchName;
+
+ protected ooTreeSetX revisions;
+
+ public static ObjyBranch create(ooObj clusterObj, int branchId, int baseBranchId, String branchName, long timeStamp)
+ {
+ ObjyBranch objyBranch = new ObjyBranch(branchId, baseBranchId, branchName, timeStamp);
+ clusterObj.cluster(objyBranch);
+ objyBranch.createRevisionsSet();
+ return objyBranch;
+ }
+
+ public static ObjyBranch create(ooObj clusterObj, int branchId, BranchInfo branchInfo)
+ {
+ ObjyBranch objyBranch = new ObjyBranch(branchId, branchInfo);
+ clusterObj.cluster(objyBranch);
+ objyBranch.createRevisionsSet();
+ return objyBranch;
+ }
+
+ private ObjyBranch(int id, BranchInfo branchInfo)
+ {
+ branchId = id;
+ baseBranchId = branchInfo.getBaseBranchID();
+ baseBranchTimeStamp = branchInfo.getBaseTimeStamp();
+ branchName = branchInfo.getName();
+ revisions = null;
+ }
+
+ private ObjyBranch(int branchId, int baseBranchId, String branchName, long timeStamp)
+ {
+ this.branchId = branchId;
+ this.baseBranchId = baseBranchId;
+ baseBranchTimeStamp = timeStamp;
+ this.branchName = branchName;
+ revisions = null;
+ }
+
+ public int getBranchId()
+ {
+ fetch();
+ return branchId;
+ }
+
+ public int getBaseBranchId()
+ {
+ fetch();
+ return baseBranchId;
+ }
+
+ public long getBaseBranchTimeStamp()
+ {
+ fetch();
+ return baseBranchTimeStamp;
+ }
+
+ public String getBranchName()
+ {
+ fetch();
+ return branchName;
+ }
+
+ public void addRevision(ooObj anObj)
+ {
+ markModified();
+ if (revisions == null) // we'll only allocate if needed.
+ {
+ revisions = new ooTreeSetX();
+ this.cluster(revisions);
+ }
+ revisions.add(anObj);
+ }
+
+ public int numberOfRevisions()
+ {
+ fetch();
+ return revisions.size();
+ }
+
+ public SortedSet<?> getRevisions()
+ {
+ fetch();
+ // // we don't want to allocate the ooTreeSetX object if the branch is empty.
+ // if (revisions == null)
+ // {
+ // return new ArrayList<Object>().iterator();
+ // }
+
+ return revisions;
+ }
+
+ public BranchInfo getBranchInfo()
+ {
+ fetch();
+ BranchInfo branchInfo = new BranchInfo(getBranchName(), getBaseBranchId(), getBaseBranchTimeStamp());
+ return branchInfo;
+ }
+
+ public boolean deleteRevision(Object anObject)
+ {
+ markModified();
+ return revisions.remove(anObject);
+ }
+
+ private void createRevisionsSet()
+ {
+ if (revisions == null) // we'll only allocate if needed.
+ {
+ revisions = new ooTreeSetX();
+ this.cluster(revisions);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranchManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranchManager.java
index 7705ff72a0..fee6ed3b8d 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranchManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyBranchManager.java
@@ -1,229 +1,229 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-
-import org.eclipse.net4j.util.collection.Pair;
-
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooTreeSetX;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Ibrahim Sallam
- */
-public class ObjyBranchManager extends ooObj
-{
- protected int nextBranchId;
-
- protected int nextLocalBranchId;
-
- protected ooTreeSetX branchSet;
-
- private ObjyBranchManager()
- {
- nextBranchId = 0;
- nextLocalBranchId = 0;
- }
-
- protected void createTreeSet(ooObj clusterObject)
- {
- branchSet = new ooTreeSetX();
- clusterObject.cluster(branchSet);
- }
-
- public int getLastBranchId()
- {
- fetch();
- return nextBranchId;
- }
-
- public int nextBranchId()
- {
- markModified();
- return ++nextBranchId;
- }
-
- public int getlastLocalBranchId()
- {
- fetch();
- return nextLocalBranchId;
- }
-
- public int nextLocalBranchId()
- {
- markModified();
- return --nextLocalBranchId;
- }
-
- public Pair<Integer, Long> createBranch(int branchId, BranchInfo branchInfo)
- {
- markModified();
-
- if (branchId == BranchLoader.NEW_BRANCH)
- {
- branchId = nextBranchId();
- }
- else if (branchId == BranchLoader.NEW_LOCAL_BRANCH)
- {
- branchId = nextLocalBranchId();
- }
-
- ObjyBranch newObjyBranch = ObjyBranch.create(this, branchId, branchInfo);
- // if the baseBranchId is 0, then we just added to our branchSet, otherwise
- // we'll lookup the ObjyBranch with the id, and add the newly created
- // ObjyBranch to it's sub-branches set.
- // int baseBranchId = branchInfo.getBaseBranchID();
-
- // Initially I thought we could make a tree of branches, but for the
- // first implementation we can just create a TreeSet of all branches,
- // then resolve sub-branches dynamically by checking baseBranchId.
- branchSet.add(newObjyBranch); // implicit clustering.
-
- // if (baseBranchId == 0) // main branch.
- // {
- // branchSet.add(newObjyBranch); // implicit clustering.
- // }
- // else
- // {
- // Iterator<ObjyBranch> treeItr = branchSet.iterator();
- // ObjyBranch objyBranch = null;
- // boolean found = false;
- // while (treeItr.hasNext() && !found)
- // {
- // objyBranch = treeItr.next();
- // if (baseBranchId == objyBranch.getBaseBranchId())
- // {
- // found = true;
- // continue;
- // }
- // objyBranch = null;
- // }
- //
- // objyBranch.addSubBranch(newObjyBranch);
- // }
-
- return new Pair<Integer, Long>(branchId, branchInfo.getBaseTimeStamp());
- }
-
- public ObjyBranch getBranch(int branchId)
- {
- fetch();
-
- @SuppressWarnings("unchecked")
- Iterator<ObjyBranch> treeItr = branchSet.iterator();
- ObjyBranch objyBranch = null;
- while (treeItr.hasNext())
- {
- ObjyBranch tempObjyBranch = treeItr.next();
- if (branchId == tempObjyBranch.getBranchId())
- {
- objyBranch = tempObjyBranch;
- break;
- }
- }
-
- return objyBranch;
- }
-
- public static ObjyBranchManager create(ooId scopeContOid)
- {
- ObjyBranchManager branchManager = new ObjyBranchManager();
- ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
- clusterObject.cluster(branchManager);
-
- branchManager.createTreeSet(branchManager);
- branchManager.createMainBranch();
-
- return branchManager;
- }
-
- public void createMainBranch()
- {
- ObjyBranch newObjyBranch = ObjyBranch.create(this, CDOBranch.MAIN_BRANCH_ID, CDOBranch.MAIN_BRANCH_ID,
- CDOBranch.MAIN_BRANCH_NAME, 0);
- branchSet.add(newObjyBranch); // implicit clustering.
- }
-
- public boolean deleteBranch(int branchId)
- {
- boolean done = false;
-
- markModified();
-
- @SuppressWarnings("unchecked")
- Iterator<ObjyBranch> treeItr = branchSet.iterator();
- ObjyBranch objyBranch = null;
- while (treeItr.hasNext())
- {
- objyBranch = treeItr.next();
- if (branchId == objyBranch.getBranchId())
- {
- done = branchSet.remove(objyBranch);
- break;
- }
- }
-
- return done;
- }
-
- public List<ObjyBranch> getSubBranches(int baseBranchId)
- {
- fetch();
- List<ObjyBranch> objyBranchList = new ArrayList<ObjyBranch>();
-
- Iterator<?> treeItr = branchSet.iterator();
- ObjyBranch objyBranch = null;
- while (treeItr.hasNext())
- {
- objyBranch = (ObjyBranch)treeItr.next();
- if (objyBranch.getBranchId() == objyBranch.getBaseBranchId())
- {
- continue;
- }
- if (objyBranch.getBaseBranchId() == baseBranchId)
- {
- objyBranchList.add(objyBranch);
- }
- }
- return objyBranchList;
- }
-
- public List<ObjyBranch> getBranches(int startId, int endId)
- {
- fetch();
- List<ObjyBranch> objyBranchList = new ArrayList<ObjyBranch>();
-
- int lastId = endId != 0 ? endId : Integer.MAX_VALUE;
-
- @SuppressWarnings("unchecked")
- Iterator<ObjyBranch> treeItr = branchSet.iterator();
- ObjyBranch objyBranch = null;
- while (treeItr.hasNext())
- {
- objyBranch = treeItr.next();
- int id = objyBranch.getBranchId();
- if (id >= startId && id <= lastId)
- {
- objyBranchList.add(objyBranch);
- }
- }
- return objyBranchList;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
+
+import org.eclipse.net4j.util.collection.Pair;
+
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeSetX;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public class ObjyBranchManager extends ooObj
+{
+ protected int nextBranchId;
+
+ protected int nextLocalBranchId;
+
+ protected ooTreeSetX branchSet;
+
+ private ObjyBranchManager()
+ {
+ nextBranchId = 0;
+ nextLocalBranchId = 0;
+ }
+
+ protected void createTreeSet(ooObj clusterObject)
+ {
+ branchSet = new ooTreeSetX();
+ clusterObject.cluster(branchSet);
+ }
+
+ public int getLastBranchId()
+ {
+ fetch();
+ return nextBranchId;
+ }
+
+ public int nextBranchId()
+ {
+ markModified();
+ return ++nextBranchId;
+ }
+
+ public int getlastLocalBranchId()
+ {
+ fetch();
+ return nextLocalBranchId;
+ }
+
+ public int nextLocalBranchId()
+ {
+ markModified();
+ return --nextLocalBranchId;
+ }
+
+ public Pair<Integer, Long> createBranch(int branchId, BranchInfo branchInfo)
+ {
+ markModified();
+
+ if (branchId == BranchLoader.NEW_BRANCH)
+ {
+ branchId = nextBranchId();
+ }
+ else if (branchId == BranchLoader.NEW_LOCAL_BRANCH)
+ {
+ branchId = nextLocalBranchId();
+ }
+
+ ObjyBranch newObjyBranch = ObjyBranch.create(this, branchId, branchInfo);
+ // if the baseBranchId is 0, then we just added to our branchSet, otherwise
+ // we'll lookup the ObjyBranch with the id, and add the newly created
+ // ObjyBranch to it's sub-branches set.
+ // int baseBranchId = branchInfo.getBaseBranchID();
+
+ // Initially I thought we could make a tree of branches, but for the
+ // first implementation we can just create a TreeSet of all branches,
+ // then resolve sub-branches dynamically by checking baseBranchId.
+ branchSet.add(newObjyBranch); // implicit clustering.
+
+ // if (baseBranchId == 0) // main branch.
+ // {
+ // branchSet.add(newObjyBranch); // implicit clustering.
+ // }
+ // else
+ // {
+ // Iterator<ObjyBranch> treeItr = branchSet.iterator();
+ // ObjyBranch objyBranch = null;
+ // boolean found = false;
+ // while (treeItr.hasNext() && !found)
+ // {
+ // objyBranch = treeItr.next();
+ // if (baseBranchId == objyBranch.getBaseBranchId())
+ // {
+ // found = true;
+ // continue;
+ // }
+ // objyBranch = null;
+ // }
+ //
+ // objyBranch.addSubBranch(newObjyBranch);
+ // }
+
+ return new Pair<Integer, Long>(branchId, branchInfo.getBaseTimeStamp());
+ }
+
+ public ObjyBranch getBranch(int branchId)
+ {
+ fetch();
+
+ @SuppressWarnings("unchecked")
+ Iterator<ObjyBranch> treeItr = branchSet.iterator();
+ ObjyBranch objyBranch = null;
+ while (treeItr.hasNext())
+ {
+ ObjyBranch tempObjyBranch = treeItr.next();
+ if (branchId == tempObjyBranch.getBranchId())
+ {
+ objyBranch = tempObjyBranch;
+ break;
+ }
+ }
+
+ return objyBranch;
+ }
+
+ public static ObjyBranchManager create(ooId scopeContOid)
+ {
+ ObjyBranchManager branchManager = new ObjyBranchManager();
+ ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
+ clusterObject.cluster(branchManager);
+
+ branchManager.createTreeSet(branchManager);
+ branchManager.createMainBranch();
+
+ return branchManager;
+ }
+
+ public void createMainBranch()
+ {
+ ObjyBranch newObjyBranch = ObjyBranch.create(this, CDOBranch.MAIN_BRANCH_ID, CDOBranch.MAIN_BRANCH_ID,
+ CDOBranch.MAIN_BRANCH_NAME, 0);
+ branchSet.add(newObjyBranch); // implicit clustering.
+ }
+
+ public boolean deleteBranch(int branchId)
+ {
+ boolean done = false;
+
+ markModified();
+
+ @SuppressWarnings("unchecked")
+ Iterator<ObjyBranch> treeItr = branchSet.iterator();
+ ObjyBranch objyBranch = null;
+ while (treeItr.hasNext())
+ {
+ objyBranch = treeItr.next();
+ if (branchId == objyBranch.getBranchId())
+ {
+ done = branchSet.remove(objyBranch);
+ break;
+ }
+ }
+
+ return done;
+ }
+
+ public List<ObjyBranch> getSubBranches(int baseBranchId)
+ {
+ fetch();
+ List<ObjyBranch> objyBranchList = new ArrayList<ObjyBranch>();
+
+ Iterator<?> treeItr = branchSet.iterator();
+ ObjyBranch objyBranch = null;
+ while (treeItr.hasNext())
+ {
+ objyBranch = (ObjyBranch)treeItr.next();
+ if (objyBranch.getBranchId() == objyBranch.getBaseBranchId())
+ {
+ continue;
+ }
+ if (objyBranch.getBaseBranchId() == baseBranchId)
+ {
+ objyBranchList.add(objyBranch);
+ }
+ }
+ return objyBranchList;
+ }
+
+ public List<ObjyBranch> getBranches(int startId, int endId)
+ {
+ fetch();
+ List<ObjyBranch> objyBranchList = new ArrayList<ObjyBranch>();
+
+ int lastId = endId != 0 ? endId : Integer.MAX_VALUE;
+
+ @SuppressWarnings("unchecked")
+ Iterator<ObjyBranch> treeItr = branchSet.iterator();
+ ObjyBranch objyBranch = null;
+ while (treeItr.hasNext())
+ {
+ objyBranch = treeItr.next();
+ int id = objyBranch.getBranchId();
+ if (id >= startId && id <= lastId)
+ {
+ objyBranchList.add(objyBranch);
+ }
+ }
+ return objyBranchList;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyCommitInfo.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyCommitInfo.java
index 81a70bbf6d..e16f31465f 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyCommitInfo.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyCommitInfo.java
@@ -1,68 +1,68 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import com.objy.db.app.ooObj;
-
-public class ObjyCommitInfo extends ooObj
-{
- protected int branchId;
-
- protected long timeStamp;
-
- protected long previousTimeStamp;
-
- protected String userId;
-
- protected String comment;
-
- /***
- * OoCommitInfo will be a readonly object.
- */
- public ObjyCommitInfo(int branchId, long timeStamp, long previousTimeStamp, String userId, String comment)
- {
- this.branchId = branchId;
- this.timeStamp = timeStamp;
- this.previousTimeStamp = previousTimeStamp;
- this.userId = userId;
- this.comment = comment;
- }
-
- public int getBranchId()
- {
- fetch();
- return branchId;
- }
-
- public long getTimeStamp()
- {
- fetch();
- return timeStamp;
- }
-
- public long getPreviousTimeStamp()
- {
- fetch();
- return previousTimeStamp;
- }
-
- public String getUserId()
- {
- fetch();
- return userId;
- }
-
- public String getComment()
- {
- fetch();
- return comment;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import com.objy.db.app.ooObj;
+
+public class ObjyCommitInfo extends ooObj
+{
+ protected int branchId;
+
+ protected long timeStamp;
+
+ protected long previousTimeStamp;
+
+ protected String userId;
+
+ protected String comment;
+
+ /***
+ * OoCommitInfo will be a readonly object.
+ */
+ public ObjyCommitInfo(int branchId, long timeStamp, long previousTimeStamp, String userId, String comment)
+ {
+ this.branchId = branchId;
+ this.timeStamp = timeStamp;
+ this.previousTimeStamp = previousTimeStamp;
+ this.userId = userId;
+ this.comment = comment;
+ }
+
+ public int getBranchId()
+ {
+ fetch();
+ return branchId;
+ }
+
+ public long getTimeStamp()
+ {
+ fetch();
+ return timeStamp;
+ }
+
+ public long getPreviousTimeStamp()
+ {
+ fetch();
+ return previousTimeStamp;
+ }
+
+ public String getUserId()
+ {
+ fetch();
+ return userId;
+ }
+
+ public String getComment()
+ {
+ fetch();
+ return comment;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapArrayList.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapArrayList.java
index 204d0f6894..90804ed5bc 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapArrayList.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapArrayList.java
@@ -1,129 +1,129 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Module;
-import com.objy.as.app.ooBaseType;
-
-/**
- * @author Simon McDuff
- */
-public class ObjyFeatureMapArrayList extends ObjyArrayList<ObjyFeatureMapEntry>
-{
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyFeatureMapArrayList.class);
-
- static public String ClassName = "ObjyFeatureMapArrayList";
-
- // public class FeatureMapEntry
- // {
- // private org.eclipse.emf.cdo.server.internal.objectivity.schema.FeatureMapEntry data = new
- // org.eclipse.emf.cdo.server.internal.objectivity.schema.FeatureMapEntry();
- //
- // public FeatureMapEntry(String featureName, ooId object)
- // {
- // super();
- // this.data.featureName = featureName;
- // this.data.object = object;
- // }
- //
- // public String getFeatureName()
- // {
- // return data.featureName;
- // }
- //
- // public ooId getObject()
- // {
- // return data.object;
- // }
- // };
-
- public static void buildSchema()
- {
- // Connection.current().registerClass(MapEntryClassName);
- d_Module top_mod = ObjySchema.getTopModule();
- if (top_mod.resolve_class(ObjyFeatureMapArrayList.ClassName) == null
- && top_mod.resolve_proposed_class(ObjyFeatureMapArrayList.ClassName) == null)
- {
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
- }
-
- boolean inProcess = top_mod.proposed_classes().hasNext();
-
- ObjyFeatureMapEntry.buildSchema();
-
- // Proposed_Class A = new Proposed_Class(ooFeatureMapArrayList.ClassName);
- Proposed_Class A = top_mod.propose_new_class(ObjyFeatureMapArrayList.ClassName);
-
- A.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
-
- A.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyArrayList.sizeName, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooINT32 // Type of numeric data
- ); // Default value
- A.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyArrayList.arrayName, // Attribute name
- 1, false, ObjyFeatureMapEntry.MapEntryClassName);
-
- // top_mod.propose_new_class(A);
- if (!inProcess)
- {
- top_mod.activate_proposals(true, true);
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
- }
- }
- }
-
- public ObjyFeatureMapArrayList(Class_Object classObject)
- {
- super(classObject);
- }
-
- @Override
- protected void setValue(long index, ObjyFeatureMapEntry featureMapEntry)
- {
-
- getVArray().set_ooId(index, featureMapEntry.getOid());
-
- // String_Value value2 = classObject.nget_string("uri");
- // System.out.println(value2);
- }
-
- @Override
- protected ObjyFeatureMapEntry getValue(long index)
- {
- Class_Object classObject = getVArray().get_class_obj(index);
-
- return new ObjyFeatureMapEntry(classObject);
-
- /***
- * FeatureMapEntry featureMapEntry = (FeatureMapEntry) ooObj.create_ooObj(getVArray().get_ooId(index)); return
- * featureMapEntry;
- ***/
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Module;
+import com.objy.as.app.ooBaseType;
+
+/**
+ * @author Simon McDuff
+ */
+public class ObjyFeatureMapArrayList extends ObjyArrayList<ObjyFeatureMapEntry>
+{
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyFeatureMapArrayList.class);
+
+ static public String ClassName = "ObjyFeatureMapArrayList";
+
+ // public class FeatureMapEntry
+ // {
+ // private org.eclipse.emf.cdo.server.internal.objectivity.schema.FeatureMapEntry data = new
+ // org.eclipse.emf.cdo.server.internal.objectivity.schema.FeatureMapEntry();
+ //
+ // public FeatureMapEntry(String featureName, ooId object)
+ // {
+ // super();
+ // this.data.featureName = featureName;
+ // this.data.object = object;
+ // }
+ //
+ // public String getFeatureName()
+ // {
+ // return data.featureName;
+ // }
+ //
+ // public ooId getObject()
+ // {
+ // return data.object;
+ // }
+ // };
+
+ public static void buildSchema()
+ {
+ // Connection.current().registerClass(MapEntryClassName);
+ d_Module top_mod = ObjySchema.getTopModule();
+ if (top_mod.resolve_class(ObjyFeatureMapArrayList.ClassName) == null
+ && top_mod.resolve_proposed_class(ObjyFeatureMapArrayList.ClassName) == null)
+ {
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
+ }
+
+ boolean inProcess = top_mod.proposed_classes().hasNext();
+
+ ObjyFeatureMapEntry.buildSchema();
+
+ // Proposed_Class A = new Proposed_Class(ooFeatureMapArrayList.ClassName);
+ Proposed_Class A = top_mod.propose_new_class(ObjyFeatureMapArrayList.ClassName);
+
+ A.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
+
+ A.add_basic_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyArrayList.sizeName, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooINT32 // Type of numeric data
+ ); // Default value
+ A.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyArrayList.arrayName, // Attribute name
+ 1, false, ObjyFeatureMapEntry.MapEntryClassName);
+
+ // top_mod.propose_new_class(A);
+ if (!inProcess)
+ {
+ top_mod.activate_proposals(true, true);
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
+ }
+ }
+ }
+
+ public ObjyFeatureMapArrayList(Class_Object classObject)
+ {
+ super(classObject);
+ }
+
+ @Override
+ protected void setValue(long index, ObjyFeatureMapEntry featureMapEntry)
+ {
+
+ getVArray().set_ooId(index, featureMapEntry.getOid());
+
+ // String_Value value2 = classObject.nget_string("uri");
+ // System.out.println(value2);
+ }
+
+ @Override
+ protected ObjyFeatureMapEntry getValue(long index)
+ {
+ Class_Object classObject = getVArray().get_class_obj(index);
+
+ return new ObjyFeatureMapEntry(classObject);
+
+ /***
+ * FeatureMapEntry featureMapEntry = (FeatureMapEntry) ooObj.create_ooObj(getVArray().get_ooId(index)); return
+ * featureMapEntry;
+ ***/
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapEntry.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapEntry.java
index 858594959d..07edde6ca9 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapEntry.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyFeatureMapEntry.java
@@ -1,121 +1,121 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Numeric_Value;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Module;
-import com.objy.as.app.ooBaseType;
-import com.objy.db.app.ooId;
-
-public class ObjyFeatureMapEntry
-{
- protected int tagId;
-
- protected ooId object;
-
- protected Class_Object classObject;
-
- public static final String MapEntryClassName = "ObjyFeatureMapEntry";
-
- public static final String EntryName = "tagId";
-
- public static final String EntryObject = "object";
-
- public static void buildSchema()
- {
- d_Module top_mod = ObjySchema.getTopModule();
- if (top_mod.resolve_class(MapEntryClassName) == null && top_mod.resolve_proposed_class(MapEntryClassName) == null)
- {
- // Proposed_Class B = new Proposed_Class(MapEntryClassName);
- Proposed_Class B = top_mod.propose_new_class(MapEntryClassName);
- B.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
-
- B.add_basic_attribute(com.objy.as.app.d_Module.LAST, // Access kind
- d_Access_Kind.d_PUBLIC, // Access kind
- ObjyFeatureMapEntry.EntryName, // Attribute name
- 1, // # elements in fixed-size array
- ooBaseType.ooINT32); // type
- B.add_ref_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- ObjyFeatureMapEntry.EntryObject, // Attribute name
- 1, // # elements in fixed-size array
- "ooObj", // Type of numeric data
- false); // Short reference
-
- // top_mod.propose_new_class(B);
- }
- }
-
- /****
- * Factory.
- *
- * @param tagId
- * @param oid
- */
- public ObjyFeatureMapEntry(int tagId, ooId oid, ooId near)
- {
- this.tagId = tagId;
- object = oid;
-
- classObject = Class_Object.new_persistent_object(ObjySchema.getObjyClass(MapEntryClassName).getASClass(), near,
- false);
-
- classObject.nset_ooId(EntryObject, object);
- classObject.nset_numeric(EntryName, new Numeric_Value(tagId));
- }
-
- public ObjyFeatureMapEntry(Class_Object classObject)
- {
- this.classObject = classObject;
- tagId = classObject.nget_numeric(EntryName).intValue();
- object = classObject.nget_ooId(EntryObject);
- }
-
- protected void fetchObject()
- {
- tagId = classObject.nget_numeric(EntryName).intValue();
- object = classObject.nget_ooId(EntryObject);
- }
-
- public int getTagId()
- {
- fetchObject();
- return tagId;
- }
-
- public void setTagId(int tagId)
- {
- classObject.nset_numeric(EntryName, new Numeric_Value(tagId));
- this.tagId = tagId;
- }
-
- public ooId getObject()
- {
- fetchObject();
- return object;
- }
-
- public void setObject(ooId object)
- {
- classObject.nset_ooId(EntryObject, object);
- this.object = object;
- }
-
- public ooId getOid()
- {
- return classObject.objectID();
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Numeric_Value;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Module;
+import com.objy.as.app.ooBaseType;
+import com.objy.db.app.ooId;
+
+public class ObjyFeatureMapEntry
+{
+ protected int tagId;
+
+ protected ooId object;
+
+ protected Class_Object classObject;
+
+ public static final String MapEntryClassName = "ObjyFeatureMapEntry";
+
+ public static final String EntryName = "tagId";
+
+ public static final String EntryObject = "object";
+
+ public static void buildSchema()
+ {
+ d_Module top_mod = ObjySchema.getTopModule();
+ if (top_mod.resolve_class(MapEntryClassName) == null && top_mod.resolve_proposed_class(MapEntryClassName) == null)
+ {
+ // Proposed_Class B = new Proposed_Class(MapEntryClassName);
+ Proposed_Class B = top_mod.propose_new_class(MapEntryClassName);
+ B.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
+
+ B.add_basic_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyFeatureMapEntry.EntryName, // Attribute name
+ 1, // # elements in fixed-size array
+ ooBaseType.ooINT32); // type
+ B.add_ref_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyFeatureMapEntry.EntryObject, // Attribute name
+ 1, // # elements in fixed-size array
+ "ooObj", // Type of numeric data
+ false); // Short reference
+
+ // top_mod.propose_new_class(B);
+ }
+ }
+
+ /****
+ * Factory.
+ *
+ * @param tagId
+ * @param oid
+ */
+ public ObjyFeatureMapEntry(int tagId, ooId oid, ooId near)
+ {
+ this.tagId = tagId;
+ object = oid;
+
+ classObject = Class_Object.new_persistent_object(ObjySchema.getObjyClass(MapEntryClassName).getASClass(), near,
+ false);
+
+ classObject.nset_ooId(EntryObject, object);
+ classObject.nset_numeric(EntryName, new Numeric_Value(tagId));
+ }
+
+ public ObjyFeatureMapEntry(Class_Object classObject)
+ {
+ this.classObject = classObject;
+ tagId = classObject.nget_numeric(EntryName).intValue();
+ object = classObject.nget_ooId(EntryObject);
+ }
+
+ protected void fetchObject()
+ {
+ tagId = classObject.nget_numeric(EntryName).intValue();
+ object = classObject.nget_ooId(EntryObject);
+ }
+
+ public int getTagId()
+ {
+ fetchObject();
+ return tagId;
+ }
+
+ public void setTagId(int tagId)
+ {
+ classObject.nset_numeric(EntryName, new Numeric_Value(tagId));
+ this.tagId = tagId;
+ }
+
+ public ooId getObject()
+ {
+ fetchObject();
+ return object;
+ }
+
+ public void setObject(ooId object)
+ {
+ classObject.nset_ooId(EntryObject, object);
+ this.object = object;
+ }
+
+ public ooId getOid()
+ {
+ return classObject.objectID();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java
index 38f7e5a171..366d81e7fd 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockArea.java
@@ -1,167 +1,167 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
-import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
-
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooTreeSetX;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * @author Ibrahim Sallam
- */
-public class ObjyLockArea extends ooObj
-{
-
- public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32;
-
- private String durableLockingID;
-
- private String userID;
-
- private ObjyBranch branchPoint;
-
- private boolean readOnly;
-
- private ooTreeSetX readLockSet;
-
- private ooTreeSetX writeLockSet;
-
- private ooTreeSetX readWriteLockSet;
-
- protected ObjyLockArea(String durableLockingID, String userID, ObjyBranch branchPoint, boolean readOnly)
- {
- this.durableLockingID = durableLockingID;
- this.userID = userID;
- this.branchPoint = branchPoint;
- this.readOnly = readOnly;
- }
-
- public static ObjyLockArea create(ooId scopeContOid, String durableLockingID, String userID, ObjyBranch branchPoint,
- boolean readOnly, Map<CDOID, LockGrade> locks)
- {
- ObjyLockArea objyLockArea = new ObjyLockArea(durableLockingID, userID, branchPoint, readOnly);
- ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
- clusterObject.cluster(objyLockArea);
-
- objyLockArea.createLockSets(locks);
-
- return objyLockArea;
- }
-
- protected void createLockSets(Map<CDOID, LockGrade> locks)
- {
- readLockSet = new ooTreeSetX();
- this.cluster(readLockSet);
- writeLockSet = new ooTreeSetX();
- this.cluster(writeLockSet);
- readWriteLockSet = new ooTreeSetX();
- this.cluster(readWriteLockSet);
-
- for (Entry<CDOID, LockGrade> entry : locks.entrySet())
- {
- CDOID id = entry.getKey();
- LockGrade grade = entry.getValue();
-
- switch (grade)
- {
- case READ_WRITE:
- readWriteLockSet.add(id);
- break;
- case READ:
- readLockSet.add(id);
- break;
- case WRITE:
- writeLockSet.add(id);
- break;
- }
- }
-
- }
-
- public String getDurableLockingID()
- {
- fetch();
- return durableLockingID;
- }
-
- public String getUserID()
- {
- fetch();
- return userID;
- }
-
- public ObjyBranch getBranch()
- {
- fetch();
- return branchPoint;
- }
-
- public long getTimeStamp()
- {
- fetch();
- return branchPoint.getBranchInfo().getBaseTimeStamp();
- }
-
- public boolean isReadOnly()
- {
- fetch();
- return readOnly;
- }
-
- public Map<CDOID, LockGrade> getLocks()
- {
- fetch();
-
- Map<CDOID, LockGrade> locks = new HashMap<CDOID, LockGrade>();
-
- @SuppressWarnings("rawtypes")
- Iterator itr = readLockSet.iterator();
- while (itr.hasNext())
- {
- locks.put(OBJYCDOIDUtil.getCDOID(((ooObj)itr.next()).getOid()), LockGrade.READ);
- }
-
- itr = writeLockSet.iterator();
- while (itr.hasNext())
- {
- locks.put(OBJYCDOIDUtil.getCDOID(((ooObj)itr.next()).getOid()), LockGrade.WRITE);
- }
-
- itr = readWriteLockSet.iterator();
- while (itr.hasNext())
- {
- locks.put(OBJYCDOIDUtil.getCDOID(((ooObj)itr.next()).getOid()), LockGrade.READ_WRITE);
- }
-
- return locks;
- }
-
- @Override
- public String toString()
- {
- fetch();
- return MessageFormat
- .format(
- "ObjyLockArea[id={0}, user={1}, branchPoint={2}, readOnly={3}, readlocks={4}, writeLocks{5}, readWriteLocks{6}",
- durableLockingID, userID, branchPoint, readOnly, readLockSet.size(), writeLockSet.size(),
- readWriteLockSet.size());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
+import org.eclipse.emf.cdo.server.internal.objectivity.utils.OBJYCDOIDUtil;
+
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeSetX;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public class ObjyLockArea extends ooObj
+{
+
+ public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32;
+
+ private String durableLockingID;
+
+ private String userID;
+
+ private ObjyBranch branchPoint;
+
+ private boolean readOnly;
+
+ private ooTreeSetX readLockSet;
+
+ private ooTreeSetX writeLockSet;
+
+ private ooTreeSetX readWriteLockSet;
+
+ protected ObjyLockArea(String durableLockingID, String userID, ObjyBranch branchPoint, boolean readOnly)
+ {
+ this.durableLockingID = durableLockingID;
+ this.userID = userID;
+ this.branchPoint = branchPoint;
+ this.readOnly = readOnly;
+ }
+
+ public static ObjyLockArea create(ooId scopeContOid, String durableLockingID, String userID, ObjyBranch branchPoint,
+ boolean readOnly, Map<CDOID, LockGrade> locks)
+ {
+ ObjyLockArea objyLockArea = new ObjyLockArea(durableLockingID, userID, branchPoint, readOnly);
+ ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
+ clusterObject.cluster(objyLockArea);
+
+ objyLockArea.createLockSets(locks);
+
+ return objyLockArea;
+ }
+
+ protected void createLockSets(Map<CDOID, LockGrade> locks)
+ {
+ readLockSet = new ooTreeSetX();
+ this.cluster(readLockSet);
+ writeLockSet = new ooTreeSetX();
+ this.cluster(writeLockSet);
+ readWriteLockSet = new ooTreeSetX();
+ this.cluster(readWriteLockSet);
+
+ for (Entry<CDOID, LockGrade> entry : locks.entrySet())
+ {
+ CDOID id = entry.getKey();
+ LockGrade grade = entry.getValue();
+
+ switch (grade)
+ {
+ case READ_WRITE:
+ readWriteLockSet.add(id);
+ break;
+ case READ:
+ readLockSet.add(id);
+ break;
+ case WRITE:
+ writeLockSet.add(id);
+ break;
+ }
+ }
+
+ }
+
+ public String getDurableLockingID()
+ {
+ fetch();
+ return durableLockingID;
+ }
+
+ public String getUserID()
+ {
+ fetch();
+ return userID;
+ }
+
+ public ObjyBranch getBranch()
+ {
+ fetch();
+ return branchPoint;
+ }
+
+ public long getTimeStamp()
+ {
+ fetch();
+ return branchPoint.getBranchInfo().getBaseTimeStamp();
+ }
+
+ public boolean isReadOnly()
+ {
+ fetch();
+ return readOnly;
+ }
+
+ public Map<CDOID, LockGrade> getLocks()
+ {
+ fetch();
+
+ Map<CDOID, LockGrade> locks = new HashMap<CDOID, LockGrade>();
+
+ @SuppressWarnings("rawtypes")
+ Iterator itr = readLockSet.iterator();
+ while (itr.hasNext())
+ {
+ locks.put(OBJYCDOIDUtil.getCDOID(((ooObj)itr.next()).getOid()), LockGrade.READ);
+ }
+
+ itr = writeLockSet.iterator();
+ while (itr.hasNext())
+ {
+ locks.put(OBJYCDOIDUtil.getCDOID(((ooObj)itr.next()).getOid()), LockGrade.WRITE);
+ }
+
+ itr = readWriteLockSet.iterator();
+ while (itr.hasNext())
+ {
+ locks.put(OBJYCDOIDUtil.getCDOID(((ooObj)itr.next()).getOid()), LockGrade.READ_WRITE);
+ }
+
+ return locks;
+ }
+
+ @Override
+ public String toString()
+ {
+ fetch();
+ return MessageFormat
+ .format(
+ "ObjyLockArea[id={0}, user={1}, branchPoint={2}, readOnly={3}, readlocks={4}, writeLocks{5}, readWriteLocks{6}",
+ durableLockingID, userID, branchPoint, readOnly, readLockSet.size(), writeLockSet.size(),
+ readWriteLockSet.size());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockAreaManager.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockAreaManager.java
index 7a15c4609d..d9e123aef8 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockAreaManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyLockAreaManager.java
@@ -1,80 +1,80 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea.Handler;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-
-import com.objy.db.app.Iterator;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooMap;
-
-/**
- * @author Ibrahim Sallam
- */
-public class ObjyLockAreaManager extends ooObj
-{
-
- private ooMap lockAreasMap;
-
- private ObjyLockAreaManager()
- {
- }
-
- protected void createMap(ooObj clusterObject)
- {
- lockAreasMap = new ooMap();
- clusterObject.cluster(lockAreasMap);
- }
-
- public static ObjyLockAreaManager create(ooId scopeContOid)
- {
- ObjyLockAreaManager manager = new ObjyLockAreaManager();
- ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
- clusterObject.cluster(manager);
-
- manager.createMap(manager);
-
- return manager;
- }
-
- public void getLockAreas(InternalCDOBranchManager branchManager, String userIDPrefix, Handler handler)
- {
- fetch();
- Iterator itr = lockAreasMap.elements();
- while (itr.hasNext())
- {
- ObjyLockArea objyLockArea = (ObjyLockArea)itr.next();
- String userID = objyLockArea.getUserID();
- if (userID != null && userID.startsWith(userIDPrefix))
- {
- if (!handler.handleLockArea(makeLockArea(branchManager, objyLockArea)))
- {
- return;
- }
- }
- }
- }
-
- private LockArea makeLockArea(InternalCDOBranchManager branchManager, ObjyLockArea objyLockArea)
- {
- ObjyBranch objyBranch = objyLockArea.getBranch();
- CDOBranchPoint branchPoint = branchManager.getBranch(objyBranch.getBranchId())
- .getPoint(objyLockArea.getTimeStamp());
- return CDOLockUtil.createLockArea(objyLockArea.getDurableLockingID(), objyLockArea.getUserID(), branchPoint,
- objyLockArea.isReadOnly(), objyLockArea.getLocks());
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea.Handler;
+import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
+
+import com.objy.db.app.Iterator;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooMap;
+
+/**
+ * @author Ibrahim Sallam
+ */
+public class ObjyLockAreaManager extends ooObj
+{
+
+ private ooMap lockAreasMap;
+
+ private ObjyLockAreaManager()
+ {
+ }
+
+ protected void createMap(ooObj clusterObject)
+ {
+ lockAreasMap = new ooMap();
+ clusterObject.cluster(lockAreasMap);
+ }
+
+ public static ObjyLockAreaManager create(ooId scopeContOid)
+ {
+ ObjyLockAreaManager manager = new ObjyLockAreaManager();
+ ooObj clusterObject = ooObj.create_ooObj(scopeContOid);
+ clusterObject.cluster(manager);
+
+ manager.createMap(manager);
+
+ return manager;
+ }
+
+ public void getLockAreas(InternalCDOBranchManager branchManager, String userIDPrefix, Handler handler)
+ {
+ fetch();
+ Iterator itr = lockAreasMap.elements();
+ while (itr.hasNext())
+ {
+ ObjyLockArea objyLockArea = (ObjyLockArea)itr.next();
+ String userID = objyLockArea.getUserID();
+ if (userID != null && userID.startsWith(userIDPrefix))
+ {
+ if (!handler.handleLockArea(makeLockArea(branchManager, objyLockArea)))
+ {
+ return;
+ }
+ }
+ }
+ }
+
+ private LockArea makeLockArea(InternalCDOBranchManager branchManager, ObjyLockArea objyLockArea)
+ {
+ ObjyBranch objyBranch = objyLockArea.getBranch();
+ CDOBranchPoint branchPoint = branchManager.getBranch(objyBranch.getBranchId())
+ .getPoint(objyLockArea.getTimeStamp());
+ return CDOLockUtil.createLockArea(objyLockArea.getDurableLockingID(), objyLockArea.getUserID(), branchPoint,
+ objyLockArea.isReadOnly(), objyLockArea.getLocks());
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageInfo.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageInfo.java
index 3a8c5de46b..ceddd448dc 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageInfo.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageInfo.java
@@ -1,123 +1,123 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import com.objy.db.app.ManyToOne;
-import com.objy.db.app.Relationship;
-import com.objy.db.app.ToOneRelationship;
-import com.objy.db.app.ooObj;
-
-public class ObjyPackageInfo extends ooObj
-{
-
- protected String packageURI;
-
- protected String parentURI;
-
- protected String unitID;
-
- protected ToOneRelationship packageUnit;
-
- private String name;
-
- public static ManyToOne packageUnit_Relationship()
- {
- return new ManyToOne("packageUnit", // field name
- "org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageUnit", // name of related class
- "packageInfos", // inverse relationship field name
- Relationship.COPY_DELETE, Relationship.VERSION_DELETE, false, false, Relationship.INLINE_NONE); // none-inline
- // association
- }
-
- /**
- * set parent packageUnit
- */
- public void setPackageUnit(ObjyPackageUnit objyPackageUnit)
- {
- markModified();
- packageUnit.form(objyPackageUnit);
- }
-
- /**
- * get related parent Node
- */
- public ObjyPackageUnit getPackageUnit()
- {
- fetch();
- return (ObjyPackageUnit)packageUnit.get();
- }
-
- /**
- * clear parent relationship
- */
- public void removePackageUnit()
- {
- markModified();
- packageUnit.clear();
- }
-
- public String getPackageURI()
- {
- fetch();
- return packageURI;
- }
-
- public void setPackageURI(String packageURI)
- {
- markModified();
- this.packageURI = packageURI;
- }
-
- public String getParentURI()
- {
- fetch();
- return parentURI;
- }
-
- public void setParentURI(String parentURI)
- {
- markModified();
- this.parentURI = parentURI;
- }
-
- public String getUnitID()
- {
- fetch();
- return unitID;
- }
-
- public void setUnitID(String unitID)
- {
- markModified();
- this.unitID = unitID;
- }
-
- public void setPackageName(String name)
- {
- markModified();
- this.name = name;
- }
-
- public String getPackageName()
- {
- fetch();
- return name;
- }
-
- // package unique name is Hash of the URI.
- public String getPackageUniqueName()
- {
- fetch();
- String uriHash = new Integer(Math.abs(getPackageURI().hashCode())).toString();
- return uriHash;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import com.objy.db.app.ManyToOne;
+import com.objy.db.app.Relationship;
+import com.objy.db.app.ToOneRelationship;
+import com.objy.db.app.ooObj;
+
+public class ObjyPackageInfo extends ooObj
+{
+
+ protected String packageURI;
+
+ protected String parentURI;
+
+ protected String unitID;
+
+ protected ToOneRelationship packageUnit;
+
+ private String name;
+
+ public static ManyToOne packageUnit_Relationship()
+ {
+ return new ManyToOne("packageUnit", // field name
+ "org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageUnit", // name of related class
+ "packageInfos", // inverse relationship field name
+ Relationship.COPY_DELETE, Relationship.VERSION_DELETE, false, false, Relationship.INLINE_NONE); // none-inline
+ // association
+ }
+
+ /**
+ * set parent packageUnit
+ */
+ public void setPackageUnit(ObjyPackageUnit objyPackageUnit)
+ {
+ markModified();
+ packageUnit.form(objyPackageUnit);
+ }
+
+ /**
+ * get related parent Node
+ */
+ public ObjyPackageUnit getPackageUnit()
+ {
+ fetch();
+ return (ObjyPackageUnit)packageUnit.get();
+ }
+
+ /**
+ * clear parent relationship
+ */
+ public void removePackageUnit()
+ {
+ markModified();
+ packageUnit.clear();
+ }
+
+ public String getPackageURI()
+ {
+ fetch();
+ return packageURI;
+ }
+
+ public void setPackageURI(String packageURI)
+ {
+ markModified();
+ this.packageURI = packageURI;
+ }
+
+ public String getParentURI()
+ {
+ fetch();
+ return parentURI;
+ }
+
+ public void setParentURI(String parentURI)
+ {
+ markModified();
+ this.parentURI = parentURI;
+ }
+
+ public String getUnitID()
+ {
+ fetch();
+ return unitID;
+ }
+
+ public void setUnitID(String unitID)
+ {
+ markModified();
+ this.unitID = unitID;
+ }
+
+ public void setPackageName(String name)
+ {
+ markModified();
+ this.name = name;
+ }
+
+ public String getPackageName()
+ {
+ fetch();
+ return name;
+ }
+
+ // package unique name is Hash of the URI.
+ public String getPackageUniqueName()
+ {
+ fetch();
+ String uriHash = new Integer(Math.abs(getPackageURI().hashCode())).toString();
+ return uriHash;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageUnit.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageUnit.java
index ef2fbf4bb6..6ca4665da8 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageUnit.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyPackageUnit.java
@@ -1,143 +1,143 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import com.objy.db.app.OneToMany;
-import com.objy.db.app.Relationship;
-import com.objy.db.app.ToManyRelationship;
-import com.objy.db.app.ooObj;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ObjyPackageUnit extends ooObj
-{
-
- protected String id;
-
- protected int ordinal;
-
- protected long timeStamp;
-
- protected byte[] packageAsBytes;
-
- private ToManyRelationship packageInfos;
-
- public ObjyPackageUnit(int bufferSize)
- {
- packageAsBytes = new byte[bufferSize];
- }
-
- public static OneToMany packageInfos_Relationship()
- {
- return new OneToMany("packageInfos", // field name
- "org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageInfo", // name of related class
- "packageUnit", // inverse relationship field name
- Relationship.COPY_DELETE, Relationship.VERSION_DELETE, false, false, Relationship.INLINE_NONE); // none-inline
- // association
- }
-
- /**
- * get all related children
- *
- * @return list of ObjyPackageInfo objects.
- */
- public List<ObjyPackageInfo> getPackageInfos()
- {
- List<ObjyPackageInfo> list = new ArrayList<ObjyPackageInfo>();
- fetch();
- com.objy.db.app.Iterator itr;
- itr = packageInfos.scan();
- while (itr.hasNext())
- {
- list.add((ObjyPackageInfo)itr.next());
- }
-
- return list;
- }
-
- /**
- * add packageInfo
- */
- public void addPackageInfo(ObjyPackageInfo packageInfo)
- {
- markModified();
- packageInfos.add(packageInfo);
- }
-
- /**
- * clear all related packageInfo
- */
- public void clearChildren()
- {
- markModified();
- packageInfos.clear();
- }
-
- /**
- * removePackageInfo.
- */
- public void removePackageInfo(ObjyPackageInfo packageInfo)
- {
- markModified();
- packageInfos.remove(packageInfo);
- }
-
- public String getId()
- {
- fetch();
- return id;
- }
-
- public void setId(String id)
- {
- markModified();
- this.id = id;
- }
-
- public int getOrdinal()
- {
- fetch();
- return ordinal;
- }
-
- public void setOrdinal(int ordinal)
- {
- markModified();
- this.ordinal = ordinal;
- }
-
- public long getTimeStamp()
- {
- fetch();
- return timeStamp;
- }
-
- public void setTimeStamp(long timeStamp)
- {
- markModified();
- this.timeStamp = timeStamp;
- }
-
- public byte[] getPackageAsBytes()
- {
- fetch();
- return packageAsBytes;
- }
-
- public void setPackageAsBytes(byte[] packageAsBytes)
- {
- markModified();
- this.packageAsBytes = packageAsBytes;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import com.objy.db.app.OneToMany;
+import com.objy.db.app.Relationship;
+import com.objy.db.app.ToManyRelationship;
+import com.objy.db.app.ooObj;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ObjyPackageUnit extends ooObj
+{
+
+ protected String id;
+
+ protected int ordinal;
+
+ protected long timeStamp;
+
+ protected byte[] packageAsBytes;
+
+ private ToManyRelationship packageInfos;
+
+ public ObjyPackageUnit(int bufferSize)
+ {
+ packageAsBytes = new byte[bufferSize];
+ }
+
+ public static OneToMany packageInfos_Relationship()
+ {
+ return new OneToMany("packageInfos", // field name
+ "org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyPackageInfo", // name of related class
+ "packageUnit", // inverse relationship field name
+ Relationship.COPY_DELETE, Relationship.VERSION_DELETE, false, false, Relationship.INLINE_NONE); // none-inline
+ // association
+ }
+
+ /**
+ * get all related children
+ *
+ * @return list of ObjyPackageInfo objects.
+ */
+ public List<ObjyPackageInfo> getPackageInfos()
+ {
+ List<ObjyPackageInfo> list = new ArrayList<ObjyPackageInfo>();
+ fetch();
+ com.objy.db.app.Iterator itr;
+ itr = packageInfos.scan();
+ while (itr.hasNext())
+ {
+ list.add((ObjyPackageInfo)itr.next());
+ }
+
+ return list;
+ }
+
+ /**
+ * add packageInfo
+ */
+ public void addPackageInfo(ObjyPackageInfo packageInfo)
+ {
+ markModified();
+ packageInfos.add(packageInfo);
+ }
+
+ /**
+ * clear all related packageInfo
+ */
+ public void clearChildren()
+ {
+ markModified();
+ packageInfos.clear();
+ }
+
+ /**
+ * removePackageInfo.
+ */
+ public void removePackageInfo(ObjyPackageInfo packageInfo)
+ {
+ markModified();
+ packageInfos.remove(packageInfo);
+ }
+
+ public String getId()
+ {
+ fetch();
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ markModified();
+ this.id = id;
+ }
+
+ public int getOrdinal()
+ {
+ fetch();
+ return ordinal;
+ }
+
+ public void setOrdinal(int ordinal)
+ {
+ markModified();
+ this.ordinal = ordinal;
+ }
+
+ public long getTimeStamp()
+ {
+ fetch();
+ return timeStamp;
+ }
+
+ public void setTimeStamp(long timeStamp)
+ {
+ markModified();
+ this.timeStamp = timeStamp;
+ }
+
+ public byte[] getPackageAsBytes()
+ {
+ fetch();
+ return packageAsBytes;
+ }
+
+ public void setPackageAsBytes(byte[] packageAsBytes)
+ {
+ markModified();
+ this.packageAsBytes = packageAsBytes;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProperty.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProperty.java
index ec31b83715..0575ff2213 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProperty.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProperty.java
@@ -1,50 +1,50 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import com.objy.db.app.ooObj;
-
-public class ObjyProperty extends ooObj
-{
- protected String name;
-
- protected String value;
-
- public ObjyProperty(String name, String value)
- {
- this.name = name;
- this.value = value;
- }
-
- public String getKey()
- {
- fetch();
- return name;
- }
-
- public void setName(String name)
- {
- markModified();
- this.name = name;
- }
-
- public String getValue()
- {
- fetch();
- return value;
- }
-
- public void setValue(String value)
- {
- markModified();
- this.value = value;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import com.objy.db.app.ooObj;
+
+public class ObjyProperty extends ooObj
+{
+ protected String name;
+
+ protected String value;
+
+ public ObjyProperty(String name, String value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getKey()
+ {
+ fetch();
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ markModified();
+ this.name = name;
+ }
+
+ public String getValue()
+ {
+ fetch();
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ markModified();
+ this.value = value;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProxy.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProxy.java
index 5d86529f62..ca32db64d8 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProxy.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyProxy.java
@@ -1,111 +1,111 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.String_Value;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Module;
-import com.objy.db.app.ooId;
-
-public class ObjyProxy
-{
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyProxy.class);
-
- static public String className = "ObjyProxy";
-
- static public String uriAttributeName = "uri";
-
- protected Class_Object classObject;
-
- public static void buildSchema()
- {
- d_Module top_mod = ObjySchema.getTopModule();
- if (top_mod.resolve_class(ObjyProxy.className) == null
- && top_mod.resolve_proposed_class(ObjyProxy.className) == null)
- {
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
- }
-
- boolean inProcess = top_mod.proposed_classes().hasNext();
-
- Proposed_Class propClass = top_mod.propose_new_class(ObjyProxy.className);
-
- propClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
-
- // propClass.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
- // ooProxy.uriAttributeName, // Attribute name
- // 1, // # elements in fixed-size array
- // ooBaseType.ooCHAR// Type of string data
- // );
- //
- propClass.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PROTECTED, // access kind
- ObjyProxy.uriAttributeName, // Attribute name
- 1, // # elements in fixed-size array
- "ooUtf8String" // name of embedded class
- );
-
- // top_mod.propose_new_class(propClass);
- if (!inProcess)
- {
- top_mod.activate_proposals(true, true);
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("SCHEMA changed : ooProxy added");
- }
- }
-
- }
-
- // factory.
- public static ObjyProxy createObject(ooId nearObject)
- {
- Class_Object newClassObject = Class_Object.new_persistent_object(ObjySchema.getObjyClass(ObjyProxy.className)
- .getASClass(), nearObject, false);
- ObjyProxy proxyObject = new ObjyProxy(newClassObject);
- return proxyObject;
- }
-
- public ObjyProxy(Class_Object classObject)
- {
- this.classObject = classObject;
- }
-
- public void setUri(String uri)
- {
- String_Value stringValue = classObject.nget_string(ObjyProxy.uriAttributeName);
- stringValue.set(uri);
- }
-
- public String getUri()
- {
- String_Value stringValue = classObject.nget_string(ObjyProxy.uriAttributeName);
- return stringValue.toString();
- }
-
- public ooId ooId()
- {
- return classObject.objectID();
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.String_Value;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Module;
+import com.objy.db.app.ooId;
+
+public class ObjyProxy
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyProxy.class);
+
+ static public String className = "ObjyProxy";
+
+ static public String uriAttributeName = "uri";
+
+ protected Class_Object classObject;
+
+ public static void buildSchema()
+ {
+ d_Module top_mod = ObjySchema.getTopModule();
+ if (top_mod.resolve_class(ObjyProxy.className) == null
+ && top_mod.resolve_proposed_class(ObjyProxy.className) == null)
+ {
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
+ }
+
+ boolean inProcess = top_mod.proposed_classes().hasNext();
+
+ Proposed_Class propClass = top_mod.propose_new_class(ObjyProxy.className);
+
+ propClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC, "ooObj");
+
+ // propClass.add_varray_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PUBLIC, // Access kind
+ // ooProxy.uriAttributeName, // Attribute name
+ // 1, // # elements in fixed-size array
+ // ooBaseType.ooCHAR// Type of string data
+ // );
+ //
+ propClass.add_embedded_class_attribute(com.objy.as.app.d_Module.LAST, d_Access_Kind.d_PROTECTED, // access kind
+ ObjyProxy.uriAttributeName, // Attribute name
+ 1, // # elements in fixed-size array
+ "ooUtf8String" // name of embedded class
+ );
+
+ // top_mod.propose_new_class(propClass);
+ if (!inProcess)
+ {
+ top_mod.activate_proposals(true, true);
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("SCHEMA changed : ooProxy added");
+ }
+ }
+
+ }
+
+ // factory.
+ public static ObjyProxy createObject(ooId nearObject)
+ {
+ Class_Object newClassObject = Class_Object.new_persistent_object(ObjySchema.getObjyClass(ObjyProxy.className)
+ .getASClass(), nearObject, false);
+ ObjyProxy proxyObject = new ObjyProxy(newClassObject);
+ return proxyObject;
+ }
+
+ public ObjyProxy(Class_Object classObject)
+ {
+ this.classObject = classObject;
+ }
+
+ public void setUri(String uri)
+ {
+ String_Value stringValue = classObject.nget_string(ObjyProxy.uriAttributeName);
+ stringValue.set(uri);
+ }
+
+ public String getUri()
+ {
+ String_Value stringValue = classObject.nget_string(ObjyProxy.uriAttributeName);
+ return stringValue.toString();
+ }
+
+ public ooId ooId()
+ {
+ return classObject.objectID();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyResourceList.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyResourceList.java
index 0cee1b8fad..0893ccd092 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyResourceList.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyResourceList.java
@@ -1,283 +1,283 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreAccessor;
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObjectManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import com.objy.as.app.Class_Object;
-import com.objy.as.app.Proposed_Class;
-import com.objy.as.app.d_Access_Kind;
-import com.objy.as.app.d_Module;
-import com.objy.db.ObjyRuntimeException;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-import com.objy.db.util.ooTreeListX;
-
-/***
- * OoResouceList is a specialized ooArrayListId, where all elements are of type Resourc(Node|Folder). The class will
- * allow adding, validating and removing resources From the list.
- *
- * @author ibrahim
- */
-public class ObjyResourceList
-{
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyProxy.class);
-
- static public String className = "ooResourceList";
-
- static public String Attribute_arrayName = "oo_array";
-
- private ObjySession objySession;
-
- protected Class_Object classObject;
-
- protected ObjyArrayListId list = null;
-
- protected ooId objectId;
-
- private static final EStructuralFeature featureName = EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME;
-
- // we could use this "EresourcePackage.eINSTANCE.getCDOResourceNode_Name()" instead of above.
-
- public static void buildSchema()
- {
- d_Module top_mod = ObjySchema.getTopModule();
- if (top_mod.resolve_class(ObjyResourceList.className) == null
- && top_mod.resolve_proposed_class(ObjyResourceList.className) == null)
- {
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
- }
-
- boolean inProcess = top_mod.proposed_classes().hasNext();
-
- // Proposed_Class A = new Proposed_Class(ooArrayListId.ClassName);
- Proposed_Class propClass = top_mod.propose_new_class(ObjyResourceList.className);
-
- propClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC,
- ObjyBase.CLASS_NAME /* "ooObj" */);
-
- propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
- d_Access_Kind.d_PUBLIC, // Access kind
- ObjyResourceList.Attribute_arrayName, // Attribute name
- 1, // # elements in fixed-size array
- ObjyArrayListId.className, false); // Default value // Default value
-
- // top_mod.propose_new_class(A);
- if (!inProcess)
- {
- top_mod.activate_proposals(true, true);
- }
-
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
- }
- }
-
- }
-
- public ObjyResourceList(ObjySession objySession, ObjyObject objyObject)
- {
- classObject = objyObject.ooClassObject();
- this.objySession = objySession;
- objectId = objyObject.ooId();
- }
-
- // public OoResourceList(ObjySession objySession, Class_Object classObject)
- // {
- // this.classObject = classObject;
- // this.objySession = objySession;
- // }
-
- private ObjyArrayListId getList()
- {
- if (list != null)
- {
- return list;
- }
-
- try
- {
- // Class_Position position = classObject.position_in_class(ObjyResourceList.Attribute_arrayName);
- ooId oid = classObject.nget_ooId(ObjyResourceList.Attribute_arrayName);
- if (!oid.isNull())
- {
- list = new ObjyArrayListId(Class_Object.class_object_from_oid(oid));
- }
- }
- catch (ObjyRuntimeException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return list;
- }
-
- public void remove(ObjyObject objyObject)
- {
- int size = (int)getList().size();
- for (int i = 0; i < size; i++)
- {
- if (objyObject.ooId().equals(getList().get(i)))
- {
- getList().remove(i);
- break;
- }
- }
- }
-
- public void add(ObjyObject objyObject)
- {
- // TODO - we need to make sure that objyObject is a resource!!!
- getList().add(objyObject.ooId());
- }
-
- // public void checkDuplicateResources(ObjectivityStoreAccessor storeAccessor, CDORevision revision)
- // throws IllegalStateException
- // {
- // CDOID folderID = (CDOID)revision.data().getContainerID();
- // String name = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0);
- // CDOID existingID = storeAccessor.readResourceID(folderID, name, revision.getBranch().getHead());
- // if (existingID != CDOID.NULL && !existingID.equals(revision.getID()))
- // {
- // throw new IllegalStateException("Duplicate resource or folder: " + name + " in folder " + folderID); //$NON-NLS-1$ //$NON-NLS-2$
- // }
- // }
-
- public void checkDuplicateResources(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision)
- throws IllegalStateException
- {
- // CDOID folderID = (CDOID)revision.data().getContainerID();
- CDOID folderId = (CDOID)revision.data().getContainerID();
- String name = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0);
-
- // ooId folderId = objyObject.getEContainerAsOid();
- // String name = OoResourceList.getResourceName(objyObject);
-
- // iterate over all resource in the list, and verify if we have both name and folderID.
- int size = (int)getList().size();
- ObjyObjectManager objyObjectManager = storeAccessor.getObjySession().getObjectManager();
- for (int i = 0; i < size; i++)
- {
- ObjyObject resource = getResource(i);
- ObjyObject resourceRevision = resource;
- // get the proper revision of the resource (might need to refactor this code, see readRevision())
- if (storeAccessor.getStore().isRequiredToSupportBranches())
- {
- try
- {
- resourceRevision = resource.getRevision(revision.getTimeStamp(), revision.getBranch().getID(),
- objyObjectManager);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
- else if (storeAccessor.getStore().isRequiredToSupportAudits())
- {
- try
- {
- resourceRevision = resource.getRevision(revision.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID, objyObjectManager);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
- }
-
- if (resourceRevision == null || resourceRevision.getVersion() < 0)
- {
- continue;
- }
-
- // int v = resource.getVersion();
- CDOID resourceFolderId = (CDOID)resourceRevision.getEContainer();
- String resourceName = ObjyResourceList.getResourceName(resourceRevision);
- if (resourceFolderId != null && resourceFolderId.equals(folderId) && resourceName != null
- && resourceName.equals(name))
- {
- throw new IllegalStateException("Duplicate resource or folder: " + name + " in folder: " + folderId); //$NON-NLS-1$
- }
- }
- }
-
- public ObjyObject getResource(int index)
- {
- return objySession.getObjectManager().getObject(getList().get(index));
- }
-
- public static String getResourceName(ObjyObject objyObject)
- {
- String name = (String)objyObject.get(featureName);
- return name;
- }
-
- public static ObjyObject create(ooId nearOid)
- {
- Class_Object classObject = Class_Object.new_persistent_object(ObjySchema.getObjyClass(ObjyResourceList.className)
- .getASClass(), nearOid, false);
- // ObjyObjectManager.newInternalObjCount++;
- // Class_Position position = classObject.position_in_class(ObjyResourceList.Attribute_arrayName);
- // Class_Object arrayClassObject = Class_Object.new_persistent_object(
- // ObjySchema.getTopModule().resolve_class(ObjyArrayListId.className), classObject.objectID(), false);
- // // ooId arrayOid = arrayClassObject.objectID();
- ooTreeListX list = new ooTreeListX(10, false);
- // ObjyObjectManager.newInternalObjCount++;
- ooObj anObj = ooObj.create_ooObj(classObject.objectID());
- anObj.cluster(list);
- // System.out.println("initObject: " + anObj.getOid().getStoreString() + " treeListX: "
- // // + list.getOid().getStoreString());
- classObject.nset_ooId(ObjyResourceList.Attribute_arrayName, list.getOid());
-
- // classObject.set_ooId(position, arrayClassObject.objectID());
- // ObjyArrayListId.initObject(arrayClassObject);
- ObjyObject objyObject = null;
- try
- {
- objyObject = new ObjyObject(classObject);
- }
- catch (RuntimeException ex)
- {
- ex.printStackTrace();
- }
-
- return objyObject;
- }
-
- public ooId ooId()
- {
- return objectId;
- }
-
- public int size()
- {
- return (int)getList().size();
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.eresource.EresourcePackage;
+import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreAccessor;
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObjectManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySchema;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjySession;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import com.objy.as.app.Class_Object;
+import com.objy.as.app.Proposed_Class;
+import com.objy.as.app.d_Access_Kind;
+import com.objy.as.app.d_Module;
+import com.objy.db.ObjyRuntimeException;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+import com.objy.db.util.ooTreeListX;
+
+/***
+ * OoResouceList is a specialized ooArrayListId, where all elements are of type Resourc(Node|Folder). The class will
+ * allow adding, validating and removing resources From the list.
+ *
+ * @author ibrahim
+ */
+public class ObjyResourceList
+{
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyProxy.class);
+
+ static public String className = "ooResourceList";
+
+ static public String Attribute_arrayName = "oo_array";
+
+ private ObjySession objySession;
+
+ protected Class_Object classObject;
+
+ protected ObjyArrayListId list = null;
+
+ protected ooId objectId;
+
+ private static final EStructuralFeature featureName = EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME;
+
+ // we could use this "EresourcePackage.eINSTANCE.getCDOResourceNode_Name()" instead of above.
+
+ public static void buildSchema()
+ {
+ d_Module top_mod = ObjySchema.getTopModule();
+ if (top_mod.resolve_class(ObjyResourceList.className) == null
+ && top_mod.resolve_proposed_class(ObjyResourceList.className) == null)
+ {
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("Schema not found for ooArrayListId. Adding ooArrayListId");
+ }
+
+ boolean inProcess = top_mod.proposed_classes().hasNext();
+
+ // Proposed_Class A = new Proposed_Class(ooArrayListId.ClassName);
+ Proposed_Class propClass = top_mod.propose_new_class(ObjyResourceList.className);
+
+ propClass.add_base_class(com.objy.as.app.d_Module.LAST, com.objy.as.app.d_Access_Kind.d_PUBLIC,
+ ObjyBase.CLASS_NAME /* "ooObj" */);
+
+ propClass.add_ref_attribute(com.objy.as.app.d_Module.LAST, // Access kind
+ d_Access_Kind.d_PUBLIC, // Access kind
+ ObjyResourceList.Attribute_arrayName, // Attribute name
+ 1, // # elements in fixed-size array
+ ObjyArrayListId.className, false); // Default value // Default value
+
+ // top_mod.propose_new_class(A);
+ if (!inProcess)
+ {
+ top_mod.activate_proposals(true, true);
+ }
+
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.trace("SCHEMA changed : ooArrayListId added");
+ }
+ }
+
+ }
+
+ public ObjyResourceList(ObjySession objySession, ObjyObject objyObject)
+ {
+ classObject = objyObject.ooClassObject();
+ this.objySession = objySession;
+ objectId = objyObject.ooId();
+ }
+
+ // public OoResourceList(ObjySession objySession, Class_Object classObject)
+ // {
+ // this.classObject = classObject;
+ // this.objySession = objySession;
+ // }
+
+ private ObjyArrayListId getList()
+ {
+ if (list != null)
+ {
+ return list;
+ }
+
+ try
+ {
+ // Class_Position position = classObject.position_in_class(ObjyResourceList.Attribute_arrayName);
+ ooId oid = classObject.nget_ooId(ObjyResourceList.Attribute_arrayName);
+ if (!oid.isNull())
+ {
+ list = new ObjyArrayListId(Class_Object.class_object_from_oid(oid));
+ }
+ }
+ catch (ObjyRuntimeException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return list;
+ }
+
+ public void remove(ObjyObject objyObject)
+ {
+ int size = (int)getList().size();
+ for (int i = 0; i < size; i++)
+ {
+ if (objyObject.ooId().equals(getList().get(i)))
+ {
+ getList().remove(i);
+ break;
+ }
+ }
+ }
+
+ public void add(ObjyObject objyObject)
+ {
+ // TODO - we need to make sure that objyObject is a resource!!!
+ getList().add(objyObject.ooId());
+ }
+
+ // public void checkDuplicateResources(ObjectivityStoreAccessor storeAccessor, CDORevision revision)
+ // throws IllegalStateException
+ // {
+ // CDOID folderID = (CDOID)revision.data().getContainerID();
+ // String name = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0);
+ // CDOID existingID = storeAccessor.readResourceID(folderID, name, revision.getBranch().getHead());
+ // if (existingID != CDOID.NULL && !existingID.equals(revision.getID()))
+ // {
+ // throw new IllegalStateException("Duplicate resource or folder: " + name + " in folder " + folderID); //$NON-NLS-1$ //$NON-NLS-2$
+ // }
+ // }
+
+ public void checkDuplicateResources(ObjectivityStoreAccessor storeAccessor, InternalCDORevision revision)
+ throws IllegalStateException
+ {
+ // CDOID folderID = (CDOID)revision.data().getContainerID();
+ CDOID folderId = (CDOID)revision.data().getContainerID();
+ String name = (String)revision.data().get(EresourcePackage.eINSTANCE.getCDOResourceNode_Name(), 0);
+
+ // ooId folderId = objyObject.getEContainerAsOid();
+ // String name = OoResourceList.getResourceName(objyObject);
+
+ // iterate over all resource in the list, and verify if we have both name and folderID.
+ int size = (int)getList().size();
+ ObjyObjectManager objyObjectManager = storeAccessor.getObjySession().getObjectManager();
+ for (int i = 0; i < size; i++)
+ {
+ ObjyObject resource = getResource(i);
+ ObjyObject resourceRevision = resource;
+ // get the proper revision of the resource (might need to refactor this code, see readRevision())
+ if (storeAccessor.getStore().isRequiredToSupportBranches())
+ {
+ try
+ {
+ resourceRevision = resource.getRevision(revision.getTimeStamp(), revision.getBranch().getID(),
+ objyObjectManager);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ else if (storeAccessor.getStore().isRequiredToSupportAudits())
+ {
+ try
+ {
+ resourceRevision = resource.getRevision(revision.getTimeStamp(), CDOBranch.MAIN_BRANCH_ID, objyObjectManager);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ if (resourceRevision == null || resourceRevision.getVersion() < 0)
+ {
+ continue;
+ }
+
+ // int v = resource.getVersion();
+ CDOID resourceFolderId = (CDOID)resourceRevision.getEContainer();
+ String resourceName = ObjyResourceList.getResourceName(resourceRevision);
+ if (resourceFolderId != null && resourceFolderId.equals(folderId) && resourceName != null
+ && resourceName.equals(name))
+ {
+ throw new IllegalStateException("Duplicate resource or folder: " + name + " in folder: " + folderId); //$NON-NLS-1$
+ }
+ }
+ }
+
+ public ObjyObject getResource(int index)
+ {
+ return objySession.getObjectManager().getObject(getList().get(index));
+ }
+
+ public static String getResourceName(ObjyObject objyObject)
+ {
+ String name = (String)objyObject.get(featureName);
+ return name;
+ }
+
+ public static ObjyObject create(ooId nearOid)
+ {
+ Class_Object classObject = Class_Object.new_persistent_object(ObjySchema.getObjyClass(ObjyResourceList.className)
+ .getASClass(), nearOid, false);
+ // ObjyObjectManager.newInternalObjCount++;
+ // Class_Position position = classObject.position_in_class(ObjyResourceList.Attribute_arrayName);
+ // Class_Object arrayClassObject = Class_Object.new_persistent_object(
+ // ObjySchema.getTopModule().resolve_class(ObjyArrayListId.className), classObject.objectID(), false);
+ // // ooId arrayOid = arrayClassObject.objectID();
+ ooTreeListX list = new ooTreeListX(10, false);
+ // ObjyObjectManager.newInternalObjCount++;
+ ooObj anObj = ooObj.create_ooObj(classObject.objectID());
+ anObj.cluster(list);
+ // System.out.println("initObject: " + anObj.getOid().getStoreString() + " treeListX: "
+ // // + list.getOid().getStoreString());
+ classObject.nset_ooId(ObjyResourceList.Attribute_arrayName, list.getOid());
+
+ // classObject.set_ooId(position, arrayClassObject.objectID());
+ // ObjyArrayListId.initObject(arrayClassObject);
+ ObjyObject objyObject = null;
+ try
+ {
+ objyObject = new ObjyObject(classObject);
+ }
+ catch (RuntimeException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return objyObject;
+ }
+
+ public ooId ooId()
+ {
+ return objectId;
+ }
+
+ public int size()
+ {
+ return (int)getList().size();
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyStoreInfo.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyStoreInfo.java
index 2c3c6b1262..9ee7ec39ba 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyStoreInfo.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/schema/ObjyStoreInfo.java
@@ -1,41 +1,41 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.schema;
-
-import com.objy.db.app.ooObj;
-
-public class ObjyStoreInfo extends ooObj
-{
- protected long creationTime;
-
- protected String comment;
-
- /***
- * ObjyStoreInfo is a read only object.
- */
- public ObjyStoreInfo(long creationTime, String comment)
- {
- this.creationTime = creationTime;
- this.comment = comment;
- }
-
- public long getCreationTime()
- {
- fetch();
- return creationTime;
- }
-
- public String getComment()
- {
- fetch();
- return comment;
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.schema;
+
+import com.objy.db.app.ooObj;
+
+public class ObjyStoreInfo extends ooObj
+{
+ protected long creationTime;
+
+ protected String comment;
+
+ /***
+ * ObjyStoreInfo is a read only object.
+ */
+ public ObjyStoreInfo(long creationTime, String comment)
+ {
+ this.creationTime = creationTime;
+ this.comment = comment;
+ }
+
+ public long getCreationTime()
+ {
+ fetch();
+ return creationTime;
+ }
+
+ public String getComment()
+ {
+ fetch();
+ return comment;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/OBJYCDOIDUtil.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/OBJYCDOIDUtil.java
index 415b87859a..5d496377ca 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/OBJYCDOIDUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/OBJYCDOIDUtil.java
@@ -1,142 +1,142 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.utils;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDExternal;
-import org.eclipse.emf.cdo.common.id.CDOIDObject;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy;
-
-import com.objy.db.app.ooId;
-
-/**
- * TODO - this file was taken from the old code without verification for
- * all its functionality's requirement to the new code.
- *
- * - We might need to cleanup the various CDOID transformations.
- *
- * * The idea is to convert the OID parts into long value, except that
- * we only use the 6-bits from the DB, the rest is used to mark
- * the OID as
- */
-
-/**
- * @author Simon McDuff
- */
-public class OBJYCDOIDUtil
-{
-
- public static CDOID createLong(long value)
- {
- if (value == 0L)
- {
- return CDOID.NULL;
- }
- return CDOIDUtil.createLong(value);
- }
-
- public static CDOID getCDOID(ooId id)
- {
- return createLong(getLong(id));
- }
-
- public static CDOID getCDOID(long id)
- {
- return createLong(id);
- }
-
- public static long getLong(ooId id)
- {
- long value = 0;
-
- if (id != null)
- {
- value = (long)id.getSlot() << 48 | (long)id.getPage() << 32 | (long)id.getOC() << 16 | id.getDB();
- }
-
- return value;
- }
-
- public static long addProxy(long ooid)
- {
- return ooid | (long)1 << 63;
- }
-
- public static long removeProxy(long ooid)
- {
- return ooid << 1 >>> 1;
- }
-
- public static boolean isProxy(long ooid)
- {
- return ooid >>> 63 == 1;
- }
-
- public static long adaptOOID(long ooid)
- {
- return removeProxy(ooid);
- }
-
- // 2.0 code
- public static boolean isValidObjyId(CDOID id)
- {
- if (id instanceof CDOIDObject)
- {
- try
- {
- return CDOIDUtil.getLong(id) > 1717828929;
- }
- catch (Exception ignore)
- {
- // Fall through
- }
- }
-
- return false;
- }
-
- public static ooId getooId(long longCdoID)
- {
- int slot = (int)(longCdoID >> 48 & 0xFFFF);
- int page = (int)(longCdoID >> 32 & 0xFFFF);
- int OC = (int)(longCdoID >> 16 & 0xFFFF);
- int DB = (int)(longCdoID & 0xFFFF);
- return new com.objy.pm.ooId(DB, OC, page, slot, 0);
- }
-
- public static ooId getContainerId(long longCdoID)
- {
- int slot = 1;
- int page = 1;
- int OC = (int)(longCdoID >> 16 & 0xFFFF);
- int DB = (int)(longCdoID & 0xFFFF);
- return new com.objy.pm.ooId(DB, OC, page, slot, 0);
- }
-
- public static ooId getooId(CDOID id)
- {
- long longCdoID = CDOIDUtil.getLong(id);
- return getooId(longCdoID);
- }
-
- public static ooId getContainerId(CDOID id)
- {
- long longCdoID = org.eclipse.emf.cdo.common.id.CDOIDUtil.getLong(id);
- return getContainerId(longCdoID);
- }
-
- public static CDOIDExternal createCDIDExternal(ObjyProxy proxyObject)
- {
- return CDOIDUtil.createExternal(proxyObject.getUri());
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.utils;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDExternal;
+import org.eclipse.emf.cdo.common.id.CDOIDObject;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyProxy;
+
+import com.objy.db.app.ooId;
+
+/**
+ * TODO - this file was taken from the old code without verification for
+ * all its functionality's requirement to the new code.
+ *
+ * - We might need to cleanup the various CDOID transformations.
+ *
+ * * The idea is to convert the OID parts into long value, except that
+ * we only use the 6-bits from the DB, the rest is used to mark
+ * the OID as
+ */
+
+/**
+ * @author Simon McDuff
+ */
+public class OBJYCDOIDUtil
+{
+
+ public static CDOID createLong(long value)
+ {
+ if (value == 0L)
+ {
+ return CDOID.NULL;
+ }
+ return CDOIDUtil.createLong(value);
+ }
+
+ public static CDOID getCDOID(ooId id)
+ {
+ return createLong(getLong(id));
+ }
+
+ public static CDOID getCDOID(long id)
+ {
+ return createLong(id);
+ }
+
+ public static long getLong(ooId id)
+ {
+ long value = 0;
+
+ if (id != null)
+ {
+ value = (long)id.getSlot() << 48 | (long)id.getPage() << 32 | (long)id.getOC() << 16 | id.getDB();
+ }
+
+ return value;
+ }
+
+ public static long addProxy(long ooid)
+ {
+ return ooid | (long)1 << 63;
+ }
+
+ public static long removeProxy(long ooid)
+ {
+ return ooid << 1 >>> 1;
+ }
+
+ public static boolean isProxy(long ooid)
+ {
+ return ooid >>> 63 == 1;
+ }
+
+ public static long adaptOOID(long ooid)
+ {
+ return removeProxy(ooid);
+ }
+
+ // 2.0 code
+ public static boolean isValidObjyId(CDOID id)
+ {
+ if (id instanceof CDOIDObject)
+ {
+ try
+ {
+ return CDOIDUtil.getLong(id) > 1717828929;
+ }
+ catch (Exception ignore)
+ {
+ // Fall through
+ }
+ }
+
+ return false;
+ }
+
+ public static ooId getooId(long longCdoID)
+ {
+ int slot = (int)(longCdoID >> 48 & 0xFFFF);
+ int page = (int)(longCdoID >> 32 & 0xFFFF);
+ int OC = (int)(longCdoID >> 16 & 0xFFFF);
+ int DB = (int)(longCdoID & 0xFFFF);
+ return new com.objy.pm.ooId(DB, OC, page, slot, 0);
+ }
+
+ public static ooId getContainerId(long longCdoID)
+ {
+ int slot = 1;
+ int page = 1;
+ int OC = (int)(longCdoID >> 16 & 0xFFFF);
+ int DB = (int)(longCdoID & 0xFFFF);
+ return new com.objy.pm.ooId(DB, OC, page, slot, 0);
+ }
+
+ public static ooId getooId(CDOID id)
+ {
+ long longCdoID = CDOIDUtil.getLong(id);
+ return getooId(longCdoID);
+ }
+
+ public static ooId getContainerId(CDOID id)
+ {
+ long longCdoID = org.eclipse.emf.cdo.common.id.CDOIDUtil.getLong(id);
+ return getContainerId(longCdoID);
+ }
+
+ public static CDOIDExternal createCDIDExternal(ObjyProxy proxyObject)
+ {
+ return CDOIDUtil.createExternal(proxyObject.getUri());
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/ObjyDb.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/ObjyDb.java
index f255a66d49..59415d694c 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/ObjyDb.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/ObjyDb.java
@@ -1,243 +1,243 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Ibrahim Sallam - initial API and implementation
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.utils;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyCommitInfoHandler;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPackageHandler;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPropertyMapHandler;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager;
-import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.db.ObjyRuntimeException;
-import com.objy.db.app.ooId;
-
-public class ObjyDb
-{
-
- public static final String CONFIGDB_NAME = "ConfigDb";
-
- public static final String RESOURCELIST_NAME = "ResourceList";
-
- public static final String RESOURCELIST_CONT_NAME = "ResourceListCont";
-
- public static final String PACKAGESTORE_CONT_NAME = "PackageCont";
-
- public static final String COMMITINFOSET_CONT_NAME = "CommitInfoCont";
-
- public static final String COMMITINFOSET_NAME = "CommitInfoSet";
-
- public static final String PROPERTYMAP_NAME = "PropertyMap";
-
- public static final String PROPERTYMAP_CONT_NAME = "PropertyCont";
-
- public static final String OBJYSTOREINFO_NAME = "ObjyStoreInfo";
-
- public static final String DEFAULT_CONT_NAME = "_ooDefaultContObj"; // this is objy default cont name.
-
- public static final String BRANCHMANAGER_NAME = "BranchManager";
-
- public static final String BRANCHING_CONT_NAME = "BranchingCont";
-
- public static final String LOCKAREAMANAGER_NAME = "LockAreaManager";
-
- public static final String LOCKAREA_CONT_NAME = "LockAreaCont";
-
- private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyDb.class);
-
- // private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyDb.class);
-
- private static final String PACKAGEMAP_NAME = "PackageMap";
-
- /***
- * Unitily functions..
- */
-
- /***
- * This function will return the resourceList after creation. Each repository (stored in its own DB) will have its own
- * ResourceList.
- */
- public static ObjyObject getOrCreateResourceList(String repositoryName)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("getOrCreateResourceList() for " + repositoryName); //$NON-NLS-1$
- }
- ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.RESOURCELIST_CONT_NAME);
- ObjyObject objyObject = null;
- try
- {
- objyObject = objyScope.lookupObjyObject(ObjyDb.RESOURCELIST_NAME);
- }
- catch (ObjyRuntimeException ex)
- {
- // we need to create the resource.
- objyObject = createResourceList(objyScope);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- return objyObject;
- }
-
- protected static ObjyObject createResourceList(ObjyScope objyScope)
- {
- if (TRACER_DEBUG.isEnabled())
- {
- TRACER_DEBUG.format("createResourceList()"); //$NON-NLS-1$
- }
- // TODO - this need refactoring...
- ObjyObject resourceList = ObjyResourceList.create(objyScope.getScopeContOid());
- objyScope.nameObj(ObjyDb.RESOURCELIST_NAME, resourceList);
- return resourceList;
- }
-
- protected static ooId createCommitInfoList(ObjyScope objyScope)
- {
- // TODO - this need refactoring...
- ooId commitInfoListId = ObjyCommitInfoHandler.create(objyScope.getScopeContOid());
- objyScope.nameObj(ObjyDb.COMMITINFOSET_NAME, commitInfoListId);
- return commitInfoListId;
- }
-
- public static ooId getOrCreateCommitInfoList(String repositoryName)
- {
- ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.COMMITINFOSET_CONT_NAME);
- ooId commitInfoListId = null;
- try
- {
- commitInfoListId = objyScope.lookupObjectOid(ObjyDb.COMMITINFOSET_NAME);
- }
- catch (ObjyRuntimeException ex)
- {
- commitInfoListId = createCommitInfoList(objyScope);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- return commitInfoListId;
- }
-
- protected static ooId createPropertyMap(ObjyScope objyScope)
- {
- // TODO - this need refactoring...
- ooId propertyMapId = ObjyPropertyMapHandler.create(objyScope.getScopeContOid());
- objyScope.nameObj(ObjyDb.PROPERTYMAP_NAME, propertyMapId);
- return propertyMapId;
- }
-
- public static ooId getOrCreatePropertyMap(String repositoryName)
- {
- ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.PROPERTYMAP_CONT_NAME);
- ooId propertyMapId = null;
- try
- {
- propertyMapId = objyScope.lookupObjectOid(ObjyDb.PROPERTYMAP_NAME);
- }
- catch (ObjyRuntimeException ex)
- {
- propertyMapId = createPropertyMap(objyScope);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- return propertyMapId;
- }
-
- protected static ObjyBranchManager createBranchManager(ObjyScope objyScope)
- {
- ObjyBranchManager objyBranchManager = ObjyBranchManager.create(objyScope.getScopeContOid());
- objyScope.nameObj(ObjyDb.BRANCHMANAGER_NAME, objyBranchManager.getOid());
- return objyBranchManager;
- }
-
- public static ObjyBranchManager getOrCreateBranchManager(String repositoryName)
- {
- ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.BRANCHING_CONT_NAME);
- ObjyBranchManager objyBranchManager = null;
- try
- {
- objyBranchManager = (ObjyBranchManager)objyScope.lookupObject(ObjyDb.BRANCHMANAGER_NAME);
- }
- catch (ObjyRuntimeException ex)
- {
- objyBranchManager = createBranchManager(objyScope);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- return objyBranchManager;
- }
-
- protected static ObjyLockAreaManager createLockAreaManager(ObjyScope objyScope)
- {
- ObjyLockAreaManager objyLockAreaManager = ObjyLockAreaManager.create(objyScope.getScopeContOid());
- objyScope.nameObj(ObjyDb.LOCKAREAMANAGER_NAME, objyLockAreaManager.getOid());
- return objyLockAreaManager;
- }
-
- public static ObjyLockAreaManager getOrCreateLockAreaManager(String repositoryName)
- {
- ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.LOCKAREA_CONT_NAME);
- ObjyLockAreaManager objyLockAreaManager = null;
- try
- {
- objyLockAreaManager = (ObjyLockAreaManager)objyScope.lookupObject(ObjyDb.LOCKAREAMANAGER_NAME);
- }
- catch (ObjyRuntimeException ex)
- {
- objyLockAreaManager = createLockAreaManager(objyScope);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- return objyLockAreaManager;
- }
-
- protected static ooId createPackageMap(ObjyScope objyScope)
- {
- // TODO - this need refactoring...
- ooId packageMapId = ObjyPackageHandler.create(objyScope.getScopeContOid());
- objyScope.nameObj(ObjyDb.PACKAGEMAP_NAME, packageMapId);
- return packageMapId;
- }
-
- public static ooId getOrCreatePackageMap(String repositoryName)
- {
- ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.PACKAGESTORE_CONT_NAME);
- ooId packageMapId = null;
- try
- {
- packageMapId = objyScope.lookupObjectOid(ObjyDb.PACKAGEMAP_NAME);
- }
- catch (ObjyRuntimeException ex)
- {
- packageMapId = createPackageMap(objyScope);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- return packageMapId;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ibrahim Sallam - initial API and implementation
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.utils;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyCommitInfoHandler;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPackageHandler;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyPropertyMapHandler;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyScope;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyBranchManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyLockAreaManager;
+import org.eclipse.emf.cdo.server.internal.objectivity.schema.ObjyResourceList;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.db.ObjyRuntimeException;
+import com.objy.db.app.ooId;
+
+public class ObjyDb
+{
+
+ public static final String CONFIGDB_NAME = "ConfigDb";
+
+ public static final String RESOURCELIST_NAME = "ResourceList";
+
+ public static final String RESOURCELIST_CONT_NAME = "ResourceListCont";
+
+ public static final String PACKAGESTORE_CONT_NAME = "PackageCont";
+
+ public static final String COMMITINFOSET_CONT_NAME = "CommitInfoCont";
+
+ public static final String COMMITINFOSET_NAME = "CommitInfoSet";
+
+ public static final String PROPERTYMAP_NAME = "PropertyMap";
+
+ public static final String PROPERTYMAP_CONT_NAME = "PropertyCont";
+
+ public static final String OBJYSTOREINFO_NAME = "ObjyStoreInfo";
+
+ public static final String DEFAULT_CONT_NAME = "_ooDefaultContObj"; // this is objy default cont name.
+
+ public static final String BRANCHMANAGER_NAME = "BranchManager";
+
+ public static final String BRANCHING_CONT_NAME = "BranchingCont";
+
+ public static final String LOCKAREAMANAGER_NAME = "LockAreaManager";
+
+ public static final String LOCKAREA_CONT_NAME = "LockAreaCont";
+
+ private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, ObjyDb.class);
+
+ // private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, ObjyDb.class);
+
+ private static final String PACKAGEMAP_NAME = "PackageMap";
+
+ /***
+ * Unitily functions..
+ */
+
+ /***
+ * This function will return the resourceList after creation. Each repository (stored in its own DB) will have its own
+ * ResourceList.
+ */
+ public static ObjyObject getOrCreateResourceList(String repositoryName)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("getOrCreateResourceList() for " + repositoryName); //$NON-NLS-1$
+ }
+ ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.RESOURCELIST_CONT_NAME);
+ ObjyObject objyObject = null;
+ try
+ {
+ objyObject = objyScope.lookupObjyObject(ObjyDb.RESOURCELIST_NAME);
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ // we need to create the resource.
+ objyObject = createResourceList(objyScope);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return objyObject;
+ }
+
+ protected static ObjyObject createResourceList(ObjyScope objyScope)
+ {
+ if (TRACER_DEBUG.isEnabled())
+ {
+ TRACER_DEBUG.format("createResourceList()"); //$NON-NLS-1$
+ }
+ // TODO - this need refactoring...
+ ObjyObject resourceList = ObjyResourceList.create(objyScope.getScopeContOid());
+ objyScope.nameObj(ObjyDb.RESOURCELIST_NAME, resourceList);
+ return resourceList;
+ }
+
+ protected static ooId createCommitInfoList(ObjyScope objyScope)
+ {
+ // TODO - this need refactoring...
+ ooId commitInfoListId = ObjyCommitInfoHandler.create(objyScope.getScopeContOid());
+ objyScope.nameObj(ObjyDb.COMMITINFOSET_NAME, commitInfoListId);
+ return commitInfoListId;
+ }
+
+ public static ooId getOrCreateCommitInfoList(String repositoryName)
+ {
+ ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.COMMITINFOSET_CONT_NAME);
+ ooId commitInfoListId = null;
+ try
+ {
+ commitInfoListId = objyScope.lookupObjectOid(ObjyDb.COMMITINFOSET_NAME);
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ commitInfoListId = createCommitInfoList(objyScope);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return commitInfoListId;
+ }
+
+ protected static ooId createPropertyMap(ObjyScope objyScope)
+ {
+ // TODO - this need refactoring...
+ ooId propertyMapId = ObjyPropertyMapHandler.create(objyScope.getScopeContOid());
+ objyScope.nameObj(ObjyDb.PROPERTYMAP_NAME, propertyMapId);
+ return propertyMapId;
+ }
+
+ public static ooId getOrCreatePropertyMap(String repositoryName)
+ {
+ ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.PROPERTYMAP_CONT_NAME);
+ ooId propertyMapId = null;
+ try
+ {
+ propertyMapId = objyScope.lookupObjectOid(ObjyDb.PROPERTYMAP_NAME);
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ propertyMapId = createPropertyMap(objyScope);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return propertyMapId;
+ }
+
+ protected static ObjyBranchManager createBranchManager(ObjyScope objyScope)
+ {
+ ObjyBranchManager objyBranchManager = ObjyBranchManager.create(objyScope.getScopeContOid());
+ objyScope.nameObj(ObjyDb.BRANCHMANAGER_NAME, objyBranchManager.getOid());
+ return objyBranchManager;
+ }
+
+ public static ObjyBranchManager getOrCreateBranchManager(String repositoryName)
+ {
+ ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.BRANCHING_CONT_NAME);
+ ObjyBranchManager objyBranchManager = null;
+ try
+ {
+ objyBranchManager = (ObjyBranchManager)objyScope.lookupObject(ObjyDb.BRANCHMANAGER_NAME);
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ objyBranchManager = createBranchManager(objyScope);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return objyBranchManager;
+ }
+
+ protected static ObjyLockAreaManager createLockAreaManager(ObjyScope objyScope)
+ {
+ ObjyLockAreaManager objyLockAreaManager = ObjyLockAreaManager.create(objyScope.getScopeContOid());
+ objyScope.nameObj(ObjyDb.LOCKAREAMANAGER_NAME, objyLockAreaManager.getOid());
+ return objyLockAreaManager;
+ }
+
+ public static ObjyLockAreaManager getOrCreateLockAreaManager(String repositoryName)
+ {
+ ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.LOCKAREA_CONT_NAME);
+ ObjyLockAreaManager objyLockAreaManager = null;
+ try
+ {
+ objyLockAreaManager = (ObjyLockAreaManager)objyScope.lookupObject(ObjyDb.LOCKAREAMANAGER_NAME);
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ objyLockAreaManager = createLockAreaManager(objyScope);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return objyLockAreaManager;
+ }
+
+ protected static ooId createPackageMap(ObjyScope objyScope)
+ {
+ // TODO - this need refactoring...
+ ooId packageMapId = ObjyPackageHandler.create(objyScope.getScopeContOid());
+ objyScope.nameObj(ObjyDb.PACKAGEMAP_NAME, packageMapId);
+ return packageMapId;
+ }
+
+ public static ooId getOrCreatePackageMap(String repositoryName)
+ {
+ ObjyScope objyScope = new ObjyScope(repositoryName, ObjyDb.PACKAGESTORE_CONT_NAME);
+ ooId packageMapId = null;
+ try
+ {
+ packageMapId = objyScope.lookupObjectOid(ObjyDb.PACKAGEMAP_NAME);
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ packageMapId = createPackageMap(objyScope);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return packageMapId;
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/SmartLock.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/SmartLock.java
index 201085674d..6ce635bc08 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/SmartLock.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/SmartLock.java
@@ -1,194 +1,194 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- */
-
-package org.eclipse.emf.cdo.server.internal.objectivity.utils;
-
-import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import com.objy.db.FetchCompletedWithErrors;
-import com.objy.db.ObjyRuntimeException;
-import com.objy.db.app.Session;
-import com.objy.db.app.oo;
-import com.objy.db.app.ooContObj;
-import com.objy.db.app.ooObj;
-import com.objy.db.iapp.ActivateInfo;
-import com.objy.db.iapp.FetchErrorInfo;
-
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Vector;
-
-/**
- * @author Simon McDuff To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class SmartLock
-{
- // private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, SmartLock.class);
-
- private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, SmartLock.class);
-
- private static final ContextTracer TRACER_ERROR = new ContextTracer(OM.ERROR, SmartLock.class);
-
- public static boolean lock(ObjyObject objyObject)
- {
- ooObj objectToLock = (ooObj)Session.getCurrent().getFD().objectFrom(objyObject.ooId());
- if (!objectToLock.isPersistent())
- {
- return false;
- }
- ooContObj container = null;
- if (objectToLock instanceof ooContObj)
- {
- container = (ooContObj)objectToLock;
- }
- else
- {
- container = objectToLock.getContainer();
- }
- return lock(container);
- }
-
- public static boolean readLock(ooContObj container)
- {
- container.fetch();
- if (container.isUpdated())
- {
- container.refresh(oo.READ);
- return true;
- }
-
- try
- {
- container.lock(oo.READ);
- }
- catch (Exception e)
- {
- // In MROW Mode, an Exception occur if we try to upgrade the lock from read to write when the container is
- // Locked by someone else.
- container.refresh(oo.READ);
- }
-
- return false;
- }
-
- public static boolean lock(ooContObj container)
- {
- container.fetch();
- if (container.isUpdated())
- {
- container.refresh(oo.WRITE);
- return true;
- }
-
- try
- {
- container.lock(oo.WRITE);
- }
- catch (Exception e)
- {
- // In MROW Mode, an Exception occur if we try to upgrade the lock from read to write when the container is
- // Locked by someone else.
- container.refresh(oo.WRITE);
- }
-
- return false;
- }
-
- public static boolean unlock(ooObj objectToLock)
- {
- // ooContObj container = objectToLock.getContainer();
- Session.getCurrent().checkpoint(oo.DOWNGRADE_ALL);
- return false;
- }
-
- /**
- * This should replace ooObj.activate. We do not need to call super.activate because we implemented the code in
- * ooObj.activate in here. This safeActivate will refresh container in case of errors. >> ... Msg: objref member: test
- * with oid: #26-387-1-2 not found or accessible
- *
- * @param object
- * @param fcweEx
- */
- @SuppressWarnings("unchecked")
- public static void safeActivate(ooObj object, ActivateInfo fcweEx)
- {
- if (!fcweEx.hasFetchErrors())
- {
- return;
- }
- if (TRACER_INFO.isEnabled())
- {
- TRACER_INFO.trace(" >> Object: " + object.getOid().getStoreString() + " Fetch with errors");
- }
- Vector<Object> errors = fcweEx.getFetchErrors();
- // Make sure there are fetch-error information objects
- if (errors != null)
- {
- // Get Enumeration from Vector
- Enumeration<Object> errs = errors.elements();
- FetchErrorInfo feInfo = null;
- HashSet<Object> hashSet = new HashSet<Object>();
- hashSet.add(object.getContainer());
- while (errs.hasMoreElements())
- {
- feInfo = (FetchErrorInfo)errs.nextElement();
- TRACER_INFO.trace(" >> ... fieldName: " + feInfo.getFieldName());
- TRACER_INFO.trace(" >> ... Msg: " + feInfo.getErrorMessage());
- String needFetchingOID = feInfo.getOid().getStoreString();
- TRACER_INFO.trace(" >> ... OID: " + needFetchingOID);
- try
- {
- TRACER_INFO.trace(" >> Trying to refetch the object....");
- String contID = "#" + feInfo.getOid().getDB() + "-" + feInfo.getOid().getOC() + "-" + "1-1";
- TRACER_INFO.trace("contID: " + contID);
- ooContObj tempCont = (ooContObj)Session.getCurrent().getFD().objectFrom(contID);
- if (!hashSet.contains(tempCont))
- {
- hashSet.add(tempCont);
- }
- }
- catch (ObjyRuntimeException ex)
- {
- TRACER_ERROR.trace("FATAL", ex);
- }
-
- }
- Iterator<Object> itrCont = hashSet.iterator();
- int numCont = 0;
- while (itrCont.hasNext())
- {
- ooContObj cont = (ooContObj)itrCont.next();
- if (cont.isUpdated())
- {
- TRACER_INFO.trace("RECOVER : REFRESH CONT " + cont.getOid().getStoreString());
- cont.refresh(oo.READ);
- numCont++;
- }
- }
- if (numCont != 0)
- {
- // End while more fetch-error information objects
- object.markFetchRequired();
- object.fetch();
- }
- else
- {
- throw new FetchCompletedWithErrors("Fetch completed but errors occurred", object, fcweEx.getFetchErrors());
- }
- }
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ */
+
+package org.eclipse.emf.cdo.server.internal.objectivity.utils;
+
+import org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import com.objy.db.FetchCompletedWithErrors;
+import com.objy.db.ObjyRuntimeException;
+import com.objy.db.app.Session;
+import com.objy.db.app.oo;
+import com.objy.db.app.ooContObj;
+import com.objy.db.app.ooObj;
+import com.objy.db.iapp.ActivateInfo;
+import com.objy.db.iapp.FetchErrorInfo;
+
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Vector;
+
+/**
+ * @author Simon McDuff To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class SmartLock
+{
+ // private static final ContextTracer TRACER_DEBUG = new ContextTracer(OM.DEBUG, SmartLock.class);
+
+ private static final ContextTracer TRACER_INFO = new ContextTracer(OM.INFO, SmartLock.class);
+
+ private static final ContextTracer TRACER_ERROR = new ContextTracer(OM.ERROR, SmartLock.class);
+
+ public static boolean lock(ObjyObject objyObject)
+ {
+ ooObj objectToLock = (ooObj)Session.getCurrent().getFD().objectFrom(objyObject.ooId());
+ if (!objectToLock.isPersistent())
+ {
+ return false;
+ }
+ ooContObj container = null;
+ if (objectToLock instanceof ooContObj)
+ {
+ container = (ooContObj)objectToLock;
+ }
+ else
+ {
+ container = objectToLock.getContainer();
+ }
+ return lock(container);
+ }
+
+ public static boolean readLock(ooContObj container)
+ {
+ container.fetch();
+ if (container.isUpdated())
+ {
+ container.refresh(oo.READ);
+ return true;
+ }
+
+ try
+ {
+ container.lock(oo.READ);
+ }
+ catch (Exception e)
+ {
+ // In MROW Mode, an Exception occur if we try to upgrade the lock from read to write when the container is
+ // Locked by someone else.
+ container.refresh(oo.READ);
+ }
+
+ return false;
+ }
+
+ public static boolean lock(ooContObj container)
+ {
+ container.fetch();
+ if (container.isUpdated())
+ {
+ container.refresh(oo.WRITE);
+ return true;
+ }
+
+ try
+ {
+ container.lock(oo.WRITE);
+ }
+ catch (Exception e)
+ {
+ // In MROW Mode, an Exception occur if we try to upgrade the lock from read to write when the container is
+ // Locked by someone else.
+ container.refresh(oo.WRITE);
+ }
+
+ return false;
+ }
+
+ public static boolean unlock(ooObj objectToLock)
+ {
+ // ooContObj container = objectToLock.getContainer();
+ Session.getCurrent().checkpoint(oo.DOWNGRADE_ALL);
+ return false;
+ }
+
+ /**
+ * This should replace ooObj.activate. We do not need to call super.activate because we implemented the code in
+ * ooObj.activate in here. This safeActivate will refresh container in case of errors. >> ... Msg: objref member: test
+ * with oid: #26-387-1-2 not found or accessible
+ *
+ * @param object
+ * @param fcweEx
+ */
+ @SuppressWarnings("unchecked")
+ public static void safeActivate(ooObj object, ActivateInfo fcweEx)
+ {
+ if (!fcweEx.hasFetchErrors())
+ {
+ return;
+ }
+ if (TRACER_INFO.isEnabled())
+ {
+ TRACER_INFO.trace(" >> Object: " + object.getOid().getStoreString() + " Fetch with errors");
+ }
+ Vector<Object> errors = fcweEx.getFetchErrors();
+ // Make sure there are fetch-error information objects
+ if (errors != null)
+ {
+ // Get Enumeration from Vector
+ Enumeration<Object> errs = errors.elements();
+ FetchErrorInfo feInfo = null;
+ HashSet<Object> hashSet = new HashSet<Object>();
+ hashSet.add(object.getContainer());
+ while (errs.hasMoreElements())
+ {
+ feInfo = (FetchErrorInfo)errs.nextElement();
+ TRACER_INFO.trace(" >> ... fieldName: " + feInfo.getFieldName());
+ TRACER_INFO.trace(" >> ... Msg: " + feInfo.getErrorMessage());
+ String needFetchingOID = feInfo.getOid().getStoreString();
+ TRACER_INFO.trace(" >> ... OID: " + needFetchingOID);
+ try
+ {
+ TRACER_INFO.trace(" >> Trying to refetch the object....");
+ String contID = "#" + feInfo.getOid().getDB() + "-" + feInfo.getOid().getOC() + "-" + "1-1";
+ TRACER_INFO.trace("contID: " + contID);
+ ooContObj tempCont = (ooContObj)Session.getCurrent().getFD().objectFrom(contID);
+ if (!hashSet.contains(tempCont))
+ {
+ hashSet.add(tempCont);
+ }
+ }
+ catch (ObjyRuntimeException ex)
+ {
+ TRACER_ERROR.trace("FATAL", ex);
+ }
+
+ }
+ Iterator<Object> itrCont = hashSet.iterator();
+ int numCont = 0;
+ while (itrCont.hasNext())
+ {
+ ooContObj cont = (ooContObj)itrCont.next();
+ if (cont.isUpdated())
+ {
+ TRACER_INFO.trace("RECOVER : REFRESH CONT " + cont.getOid().getStoreString());
+ cont.refresh(oo.READ);
+ numCont++;
+ }
+ }
+ if (numCont != 0)
+ {
+ // End while more fetch-error information objects
+ object.markFetchRequired();
+ object.fetch();
+ }
+ else
+ {
+ throw new FetchCompletedWithErrors("Fetch completed but errors occurred", object, fcweEx.getFetchErrors());
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/TypeConvert.java b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/TypeConvert.java
index 186d422376..bcd6ee7720 100644
--- a/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/TypeConvert.java
+++ b/plugins/org.eclipse.emf.cdo.server.objectivity/src/org/eclipse/emf/cdo/server/internal/objectivity/utils/TypeConvert.java
@@ -1,118 +1,118 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Simon McDuff - initial API and implementation
- * Ibrahim Sallam - code refactoring for CDO 3.0
- */
-package org.eclipse.emf.cdo.server.internal.objectivity.utils;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
-
-import com.objy.as.app.Class_Object;
-import com.objy.db.app.ooId;
-import com.objy.db.app.ooObj;
-
-/**
- * Originally EOOUtil TBD: verify if we really need this class...
- *
- * @author ibrahim
- */
-public class TypeConvert
-{
-
- static public ooId toOoId(Object target)
- {
- if (target == null)
- {
- return null;
- }
- if (target instanceof CDOID)
- {
- if ((CDOID)target == CDOID.NULL)
- {
- return null;
- }
-
- return OBJYCDOIDUtil.getooId((CDOID)target);
- }
- if (target instanceof ooId)
- {
- return (ooId)target;
- }
- else if (target instanceof ObjyObject)
- {
- return ((ObjyObject)target).ooId();
- }
- else if (target instanceof ooObj)
- {
- return ((ooObj)target).getOid();
- }
-
- throw new IllegalArgumentException(target.toString());
- }
-
- static public ooObj toOoObj(Object target)
- {
- if (target instanceof ObjyObject)
- {
- target = ((ObjyObject)target).ooId();
- }
- if (target instanceof ooId)
- {
- return ooObj.create_ooObj((ooId)target);
- }
- throw new IllegalArgumentException(target.toString());
- }
-
- static public Class_Object toClassObject(Object target)
- {
- if (target == null)
- {
- return null;
- }
- if (target instanceof Class_Object)
- {
- return (Class_Object)target;
- }
- else if (target instanceof ooObj)
- {
- return new Class_Object(target);
- }
- else if (target instanceof ooId)
- {
- return Class_Object.class_object_from_oid((ooId)target);
- }
-
- throw new IllegalArgumentException("Not supported " + target);
-
- }
-
- static public ObjyObject toObjyObject(Object target)
- {
- if (target == null)
- {
- return null;
- }
-
- if (target instanceof ObjyObject)
- {
- return (ObjyObject)target;
- }
- else if (target instanceof Class_Object)
- {
- throw new IllegalArgumentException("Not supported " + target);
- }
- else if (target instanceof ooId)
- {
- throw new IllegalArgumentException("Not supported " + target);
- }
- return null;
- }
-
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Simon McDuff - initial API and implementation
+ * Ibrahim Sallam - code refactoring for CDO 3.0
+ */
+package org.eclipse.emf.cdo.server.internal.objectivity.utils;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;
+
+import com.objy.as.app.Class_Object;
+import com.objy.db.app.ooId;
+import com.objy.db.app.ooObj;
+
+/**
+ * Originally EOOUtil TBD: verify if we really need this class...
+ *
+ * @author ibrahim
+ */
+public class TypeConvert
+{
+
+ static public ooId toOoId(Object target)
+ {
+ if (target == null)
+ {
+ return null;
+ }
+ if (target instanceof CDOID)
+ {
+ if ((CDOID)target == CDOID.NULL)
+ {
+ return null;
+ }
+
+ return OBJYCDOIDUtil.getooId((CDOID)target);
+ }
+ if (target instanceof ooId)
+ {
+ return (ooId)target;
+ }
+ else if (target instanceof ObjyObject)
+ {
+ return ((ObjyObject)target).ooId();
+ }
+ else if (target instanceof ooObj)
+ {
+ return ((ooObj)target).getOid();
+ }
+
+ throw new IllegalArgumentException(target.toString());
+ }
+
+ static public ooObj toOoObj(Object target)
+ {
+ if (target instanceof ObjyObject)
+ {
+ target = ((ObjyObject)target).ooId();
+ }
+ if (target instanceof ooId)
+ {
+ return ooObj.create_ooObj((ooId)target);
+ }
+ throw new IllegalArgumentException(target.toString());
+ }
+
+ static public Class_Object toClassObject(Object target)
+ {
+ if (target == null)
+ {
+ return null;
+ }
+ if (target instanceof Class_Object)
+ {
+ return (Class_Object)target;
+ }
+ else if (target instanceof ooObj)
+ {
+ return new Class_Object(target);
+ }
+ else if (target instanceof ooId)
+ {
+ return Class_Object.class_object_from_oid((ooId)target);
+ }
+
+ throw new IllegalArgumentException("Not supported " + target);
+
+ }
+
+ static public ObjyObject toObjyObject(Object target)
+ {
+ if (target == null)
+ {
+ return null;
+ }
+
+ if (target instanceof ObjyObject)
+ {
+ return (ObjyObject)target;
+ }
+ else if (target instanceof Class_Object)
+ {
+ throw new IllegalArgumentException("Not supported " + target);
+ }
+ else if (target instanceof ooId)
+ {
+ throw new IllegalArgumentException("Not supported " + target);
+ }
+ return null;
+ }
+
+}

Back to the top