Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2009-03-14 07:07:36 -0400
committerEike Stepper2009-03-14 07:07:36 -0400
commited0e1b1e3bd246b5c11ba88b166e1678703bc887 (patch)
tree42780d403e12ef54d670d0634e7b22c2deda473f /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util
parent04ab084a7995a3303dc3b6e84d7d2c356614927b (diff)
downloadcdo-ed0e1b1e3bd246b5c11ba88b166e1678703bc887.tar.gz
cdo-ed0e1b1e3bd246b5c11ba88b166e1678703bc887.tar.xz
cdo-ed0e1b1e3bd246b5c11ba88b166e1678703bc887.zip
[265435] Replace CDOModelElements by EModelElements
https://bugs.eclipse.org/bugs/show_bug.cgi?id=265435
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/GenUtil.java207
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java438
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java11
4 files changed, 14 insertions, 654 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index 2144e6712b..d4515e90bd 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
import org.eclipse.emf.cdo.util.InvalidObjectException;
import org.eclipse.emf.cdo.util.ObjectNotFoundException;
import org.eclipse.emf.cdo.view.CDOView;
@@ -133,13 +134,16 @@ public final class FSMUtil
object = (InternalEObject)EcoreUtil.resolve(object, view.getResourceSet());
}
- CDOID id = ((InternalCDOView)view).getSession().lookupMetaInstanceID(object);
- if (id != null)
+ try
{
+ InternalCDOPackageRegistry packageRegistry = (InternalCDOPackageRegistry)view.getSession().getPackageRegistry();
+ CDOID id = packageRegistry.getMetaInstanceMapper().lookupMetaInstanceID(object);
return new CDOMetaWrapper((InternalCDOView)view, object, id);
}
-
- return null;
+ catch (RuntimeException ex)
+ {
+ return null;
+ }
}
/*
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/GenUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/GenUtil.java
deleted file mode 100644
index e5354912c2..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/GenUtil.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/**
- * Copyright (c) 2004 - 2009 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.internal.cdo.util;
-
-import org.eclipse.net4j.util.StringUtil;
-
-import org.eclipse.emf.ecore.EClassifier;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public final class GenUtil
-{
- private GenUtil()
- {
- }
-
- /**
- * @see GenGenBaseImpl#isPrimitiveType
- */
- public static boolean isPrimitiveType(EClassifier eType)
- {
- try
- {
- // J9 2.2 has problems assigning null to a Class variable.
- Object result = eType.getInstanceClass();
- if (result == null)
- {
- return false;
- }
- Class<?> instanceClass = (Class<?>)result;
- return instanceClass.isPrimitive();
- }
- catch (Exception e)
- {
- return false;
- }
- }
-
- /**
- * @see GenFeatureImpl#getUpperName
- */
- public static String getFeatureUpperName(String featureName)
- {
- return format(featureName, '_', null, false, true).toUpperCase();
- }
-
- /**
- * @see GenFeatureImpl#getGetAccessor
- */
- public static String getFeatureGetterName(String featureName, boolean isBooleanType)
- {
- String capName = StringUtil.cap(featureName);
- // if (isMapEntryFeature())
- // return "getTyped" + capName;
- String result = isBooleanType ? "is" + capName : "get" + ("Class".equals(capName) ? "Class_" : capName);
-
- // if (isListType() && !isFeatureMapType() && !isMapType() &&
- // getGenModel().isArrayAccessors())
- // {
- // result += "List";
- // }
-
- // GenClass rootImplementsInterface =
- // getGenModel().getRootImplementsInterfaceGenClass();
- // GenClass context = getContext();
- // if (rootImplementsInterface != null &&
- // !rootImplementsInterface.isEObject())
- // {
- // for (GenOperation genOperation :
- // rootImplementsInterface.getAllGenOperations())
- // {
- // if (genOperation.getName().equals(result) &&
- // genOperation.getGenParameters().isEmpty() &&
- // !genOperation.getType(context).equals(getType(context)))
- // {
- // result = result + "_";
- // break;
- // }
- // }
- // }
-
- return result;
- }
-
- /**
- * Formats a name by parsing it into words separated by underscores and/or mixed-casing and then recombining them
- * using the specified separator. A prefix can also be given to be recognized as a separate word or to be trimmed.
- * Leading underscores can be ignored or can cause a leading separator to be prepended.
- */
- public static String format(String name, char separator, String prefix, boolean includePrefix,
- boolean includeLeadingSeparator)
- {
- String leadingSeparators = includeLeadingSeparator ? getLeadingSeparators(name, '_') : null;
- if (leadingSeparators != null)
- {
- name = name.substring(leadingSeparators.length());
- }
-
- List<String> parsedName = new ArrayList<String>();
- if (prefix != null && name.startsWith(prefix) && name.length() > prefix.length()
- && Character.isUpperCase(name.charAt(prefix.length())))
- {
- name = name.substring(prefix.length());
- if (includePrefix)
- {
- parsedName = parseName(prefix, '_');
- }
- }
-
- if (name.length() != 0)
- {
- parsedName.addAll(parseName(name, '_'));
- }
-
- StringBuilder result = new StringBuilder();
-
- for (Iterator<String> nameIter = parsedName.iterator(); nameIter.hasNext();)
- {
- String nameComponent = nameIter.next();
- result.append(nameComponent);
-
- if (nameIter.hasNext() && nameComponent.length() > 1)
- {
- result.append(separator);
- }
- }
-
- if (result.length() == 0 && prefix != null)
- {
- result.append(prefix);
- }
- return leadingSeparators != null ? "_" + result.toString() : result.toString();
- }
-
- /**
- * This method breaks sourceName into words delimited by separator and/or mixed-case naming.
- */
- public static List<String> parseName(String sourceName, char separator)
- {
- List<String> result = new ArrayList<String>();
- if (sourceName != null)
- {
- StringBuilder currentWord = new StringBuilder();
- boolean lastIsLower = false;
- for (int index = 0, length = sourceName.length(); index < length; ++index)
- {
- char curChar = sourceName.charAt(index);
- if (Character.isUpperCase(curChar) || !lastIsLower && Character.isDigit(curChar) || curChar == separator)
- {
- if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0)
- {
- result.add(currentWord.toString());
- currentWord = new StringBuilder();
- }
- lastIsLower = false;
- }
- else
- {
- if (!lastIsLower)
- {
- int currentWordLength = currentWord.length();
- if (currentWordLength > 1)
- {
- char lastChar = currentWord.charAt(--currentWordLength);
- currentWord.setLength(currentWordLength);
- result.add(currentWord.toString());
- currentWord = new StringBuilder();
- currentWord.append(lastChar);
- }
- }
- lastIsLower = true;
- }
-
- if (curChar != separator)
- {
- currentWord.append(curChar);
- }
- }
-
- result.add(currentWord.toString());
- }
- return result;
- }
-
- private static String getLeadingSeparators(String name, char separator)
- {
- int i = 0;
- for (int len = name.length(); i < len && name.charAt(i) == separator; i++)
- {
- // the for loop's condition finds the separator
- }
- return i != 0 ? name.substring(0, i) : null;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
deleted file mode 100644
index 5d0c9047bf..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
+++ /dev/null
@@ -1,438 +0,0 @@
-/**
- * Copyright (c) 2004 - 2009 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
- * Simon McDuff - maintenance
- */
-package org.eclipse.emf.internal.cdo.util;
-
-import org.eclipse.emf.cdo.common.id.CDOIDMetaRange;
-import org.eclipse.emf.cdo.common.model.CDOClass;
-import org.eclipse.emf.cdo.common.model.CDOClassProxy;
-import org.eclipse.emf.cdo.common.model.CDOClassRef;
-import org.eclipse.emf.cdo.common.model.CDOFeature;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackage;
-import org.eclipse.emf.cdo.common.model.CDOPackageManager;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.model.core.CDOCorePackage;
-import org.eclipse.emf.cdo.common.model.resource.CDOResourceClass;
-import org.eclipse.emf.cdo.common.model.resource.CDOResourceFolderClass;
-import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass;
-import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage;
-import org.eclipse.emf.cdo.common.util.CDOException;
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.session.CDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOClass;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOFeature;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackage;
-import org.eclipse.emf.cdo.util.EMFUtil;
-
-import org.eclipse.emf.internal.cdo.bundle.OM;
-import org.eclipse.emf.internal.cdo.session.CDOSessionPackageManagerImpl;
-
-import org.eclipse.net4j.util.ImplementationError;
-import org.eclipse.net4j.util.ObjectUtil;
-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.EDataType;
-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 org.eclipse.emf.ecore.impl.EPackageImpl;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.spi.cdo.InternalCDOSession;
-
-/**
- * @author Eike Stepper
- */
-public final class ModelUtil
-{
- private static final ContextTracer MODEL_TRACER = new ContextTracer(OM.DEBUG_MODEL, ModelUtil.class);
-
- private ModelUtil()
- {
- }
-
- public static String getParentURI(EPackage ePackage)
- {
- EPackage superPackage = ePackage.getESuperPackage();
- String parentURI = superPackage == null ? null : superPackage.getNsURI();
- return parentURI;
- }
-
- public static EPackage getTopLevelPackage(EPackage ePackage)
- {
- EPackage superPackage = ePackage.getESuperPackage();
- return superPackage == null ? ePackage : getTopLevelPackage(superPackage);
- }
-
- public static CDOType getCDOType(EStructuralFeature eFeature)
- {
- if (eFeature instanceof EReference)
- {
- throw new ImplementationError("Should only be called for attributes");
- // return CDOTypeImpl.OBJECT;
- }
-
- EClassifier classifier = eFeature.getEType();
- if (classifier.getEPackage() == EcorePackage.eINSTANCE)
- {
- int classifierID = classifier.getClassifierID();
- switch (classifierID)
- {
- case EcorePackage.EBOOLEAN:
- case EcorePackage.EBOOLEAN_OBJECT:
- case EcorePackage.EBYTE:
- case EcorePackage.EBYTE_OBJECT:
- case EcorePackage.ECHAR:
- case EcorePackage.ECHARACTER_OBJECT:
- case EcorePackage.EDATE:
- case EcorePackage.EDOUBLE:
- case EcorePackage.EDOUBLE_OBJECT:
- case EcorePackage.EFLOAT:
- case EcorePackage.EFLOAT_OBJECT:
- case EcorePackage.EINT:
- case EcorePackage.EINTEGER_OBJECT:
- case EcorePackage.ELONG:
- case EcorePackage.ELONG_OBJECT:
- case EcorePackage.ESHORT:
- case EcorePackage.ESHORT_OBJECT:
- case EcorePackage.EFEATURE_MAP_ENTRY:
- CDOType type = CDOModelUtil.getType(classifierID);
- if (type == CDOType.OBJECT)
- {
- throw new ImplementationError("Attributes can not be of type OBJECT");
- }
-
- return type;
-
- case EcorePackage.ESTRING:
- return CDOType.STRING;
- }
- }
-
- if (classifier instanceof EDataType)
- {
- return CDOType.CUSTOM;
- }
-
- throw new IllegalArgumentException("Invalid attribute type: " + classifier);
- }
-
- public static void initializeCDOPackage(EPackage ePackage, CDOPackage cdoPackage)
- {
- ((InternalCDOPackage)cdoPackage).setClientInfo(ePackage);
- for (EClass eClass : EMFUtil.getPersistentClasses(ePackage))
- {
- CDOClass cdoClass = createCDOClass(eClass, cdoPackage);
- ((InternalCDOPackage)cdoPackage).addClass(cdoClass);
- }
- }
-
- public static CDOPackage getCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
- {
- String packageURI = ePackage.getNsURI();
- CDOPackage cdoPackage = packageManager.lookupPackage(packageURI);
- if (cdoPackage == null)
- {
- EPackage topLevelPackage = getTopLevelPackage(ePackage);
- if (topLevelPackage != ePackage)
- {
- getCDOPackage(topLevelPackage, packageManager);
- cdoPackage = packageManager.lookupPackage(packageURI);
- }
- else
- {
- cdoPackage = addCDOPackage(topLevelPackage, packageManager);
- }
- }
-
- return cdoPackage;
- }
-
- public static CDOClass getCDOClass(EClass eClass, CDOSessionPackageManagerImpl packageManager)
- {
- CDOPackage cdoPackage = getCDOPackage(eClass.getEPackage(), packageManager);
- return cdoPackage.lookupClass(eClass.getClassifierID());
- }
-
- public static CDOFeature getCDOFeature(EStructuralFeature eFeature, CDOSessionPackageManagerImpl packageManager)
- {
- CDOClass cdoClass = getCDOClass(eFeature.getEContainingClass(), packageManager);
- return cdoClass.lookupFeature(eFeature.getFeatureID());
- }
-
- public static CDOPackage addCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
- {
- CDOPackage cdoPackage = createCDOPackage(ePackage, packageManager);
- packageManager.addPackage(cdoPackage);
-
- for (EPackage subPackage : ePackage.getESubpackages())
- {
- addCDOPackage(subPackage, packageManager);
- }
-
- return cdoPackage;
- }
-
- /**
- * @see EMFUtil#getPersistentFeatures(org.eclipse.emf.common.util.EList)
- * @see http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf#26780
- */
- public static CDOPackage createCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
- {
- InternalCDOSession session = packageManager.getSession();
- String uri = ePackage.getNsURI();
- String parentURI = getParentURI(ePackage);
- String name = ePackage.getName();
- boolean dynamic = EMFUtil.isDynamicEPackage(ePackage);
- String ecore = null;
- CDOIDMetaRange idRange = null;
-
- if (parentURI == null)
- {
- if (!EcorePackage.eINSTANCE.getNsURI().equals(uri))
- {
- ecore = EMFUtil.ePackageToString(ePackage, session.getPackageRegistry());
- }
-
- idRange = session.registerEPackage(ePackage);
- }
-
- CDOPackage cdoPackage = CDOModelUtil.createPackage(packageManager, uri, name, ecore, dynamic, idRange, parentURI);
- initializeCDOPackage(ePackage, cdoPackage);
- return cdoPackage;
- }
-
- public static CDOClass createCDOClass(EClass eClass, CDOPackage containingPackage)
- {
- InternalCDOClass cdoClass = (InternalCDOClass)CDOModelUtil.createClass(containingPackage, eClass.getClassifierID(),
- eClass.getName(), eClass.isAbstract());
- cdoClass.setClientInfo(eClass);
-
- for (EClass superType : eClass.getESuperTypes())
- {
- CDOClassRef classRef = createClassRef(superType);
- cdoClass.addSuperType(classRef);
- }
-
- // Bugs: 247978 Make sure featureIndex are properly set for dynamic classes
- eClass.getEAllStructuralFeatures();
-
- for (EStructuralFeature eFeature : EMFUtil.getPersistentFeatures(eClass.getEStructuralFeatures()))
- {
- CDOFeature cdoFeature = createCDOFeature(eFeature, cdoClass);
- cdoClass.addFeature(cdoFeature);
- }
-
- return cdoClass;
- }
-
- public static CDOFeature createCDOFeature(EStructuralFeature eFeature, CDOClass containingClass)
- {
- InternalCDOFeature cdoFeature = (InternalCDOFeature)(EMFUtil.isReference(eFeature) ? createCDOReference(
- (EReference)eFeature, containingClass) : createCDOAttribute((EAttribute)eFeature, containingClass));
- cdoFeature.setClientInfo(eFeature);
- return cdoFeature;
- }
-
- public static CDOFeature createCDOReference(EReference eFeature, CDOClass containingClass)
- {
- CDOPackageManager packageManager = containingClass.getPackageManager();
- int featureID = eFeature.getFeatureID();
- String name = eFeature.getName();
- CDOClassRef classRef = createClassRef(eFeature.getEType());
- boolean many = eFeature.isMany();
- boolean containment = EMFUtil.isContainment(eFeature);
- CDOFeature cdoFeature = CDOModelUtil.createReference(containingClass, featureID, name, new CDOClassProxy(classRef,
- packageManager), many, containment);
-
- EReference opposite = eFeature.getEOpposite();
- if (MODEL_TRACER.isEnabled() && opposite != null)
- {
- MODEL_TRACER.format("Opposite info: package={0}, class={1}, feature={2}", opposite.getEContainingClass()
- .getEPackage().getNsURI(), opposite.getEContainingClass().getName(), opposite.getName());
- }
-
- return cdoFeature;
- }
-
- public static CDOFeature createCDOAttribute(EAttribute eFeature, CDOClass containingClass)
- {
- int featureID = eFeature.getFeatureID();
- String name = eFeature.getName();
- CDOType type = getCDOType(eFeature);
- boolean many = EMFUtil.isMany(eFeature);
- Object defaultValue = eFeature.getDefaultValue();
- if (type == CDOType.CUSTOM)
- {
- try
- {
- defaultValue = EcoreUtil.convertToString((EDataType)eFeature.getEType(), defaultValue);
- }
- catch (RuntimeException ex)
- {
- if (defaultValue != null)
- {
- throw ex;
- }
- }
- }
-
- return CDOModelUtil.createAttribute(containingClass, featureID, name, type, defaultValue, many);
- }
-
- public static EPackage getEPackage(CDOPackage cdoPackage, CDOPackageRegistry packageRegistry)
- {
- EPackage ePackage = (EPackage)cdoPackage.getClientInfo();
- if (ePackage == null)
- {
- String uri = cdoPackage.getPackageURI();
- ePackage = packageRegistry.getEPackage(uri);
- if (ePackage == null)
- {
- ePackage = createEPackage(cdoPackage);
- packageRegistry.put(uri, ePackage);
- }
-
- ((InternalCDOPackage)cdoPackage).setClientInfo(ePackage);
- }
-
- return ePackage;
- }
-
- public static EClass getEClass(CDOClass cdoClass, CDOPackageRegistry packageRegistry)
- {
- EClass eClass = (EClass)cdoClass.getClientInfo();
- if (eClass == null)
- {
- EPackage ePackage = getEPackage(cdoClass.getContainingPackage(), packageRegistry);
- eClass = (EClass)ePackage.getEClassifier(cdoClass.getName());
- ((InternalCDOClass)cdoClass).setClientInfo(eClass);
- }
-
- return eClass;
- }
-
- public static EStructuralFeature getEFeature(CDOFeature cdoFeature, CDOPackageRegistry packageRegistry)
- {
- EStructuralFeature eFeature = (EStructuralFeature)cdoFeature.getClientInfo();
- if (eFeature == null)
- {
- EClass eClass = getEClass(cdoFeature.getContainingClass(), packageRegistry);
- eFeature = eClass.getEStructuralFeature(cdoFeature.getFeatureID());
- ((InternalCDOFeature)cdoFeature).setClientInfo(eFeature);
- }
-
- return eFeature;
- }
-
- public static EPackage createEPackage(CDOPackage cdoPackage)
- {
- if (cdoPackage.isDynamic())
- {
- return createDynamicEPackage(cdoPackage);
- }
-
- EPackage ePackage = getGeneratedEPackage(cdoPackage);
- if (ePackage == null)
- {
- throw new CDOException("Generated package locally not available: " + cdoPackage.getPackageURI());
- }
-
- return ePackage;
- }
-
- public static EPackage getGeneratedEPackage(CDOPackage cdoPackage)
- {
- String packageURI = cdoPackage.getPackageURI();
- if (packageURI.equals(EcorePackage.eINSTANCE.getNsURI()))
- {
- return EcorePackage.eINSTANCE;
- }
-
- EPackage.Registry registry = EPackage.Registry.INSTANCE;
- return registry.getEPackage(packageURI);
- }
-
- public static EPackage createDynamicEPackage(CDOPackage cdoPackage)
- {
- CDOPackage topLevelPackage = cdoPackage.getTopLevelPackage();
- String ecore = topLevelPackage.getEcore();
- EPackageImpl topLevelPackageEPackage = (EPackageImpl)EMFUtil.ePackageFromString(ecore);
- EPackageImpl ePackage = prepareDynamicEPackage(topLevelPackageEPackage, cdoPackage.getPackageURI());
- return ePackage;
- }
-
- public static EPackageImpl prepareDynamicEPackage(EPackageImpl ePackage, String nsURI)
- {
- EMFUtil.prepareDynamicEPackage(ePackage);
- EPackageImpl result = ObjectUtil.equals(ePackage.getNsURI(), nsURI) ? ePackage : null;
- for (EPackage subPackage : ePackage.getESubpackages())
- {
- EPackageImpl p = prepareDynamicEPackage((EPackageImpl)subPackage, nsURI);
- if (p != null && result == null)
- {
- result = p;
- }
- }
-
- return result;
- }
-
- public static CDOClassRef createClassRef(EClassifier classifier)
- {
- if (classifier instanceof EClass)
- {
- String packageURI = classifier.getEPackage().getNsURI();
- int classifierID = classifier.getClassifierID();
- return CDOModelUtil.createClassRef(packageURI, classifierID);
- }
-
- return null;
- }
-
- public static void addModelInfos(CDOSessionPackageManagerImpl packageManager)
- {
- // Ecore
- CDOCorePackage corePackage = packageManager.getCDOCorePackage();
- ((InternalCDOPackage)corePackage).setClientInfo(EcorePackage.eINSTANCE);
- ((InternalCDOClass)corePackage.getCDOObjectClass()).setClientInfo(EcorePackage.eINSTANCE.getEObject());
-
- // Eresource
- if (!ObjectUtil.equals(CDOResourcePackage.PACKAGE_URI, EresourcePackage.eNS_URI))
- {
- throw new ImplementationError();
- }
-
- CDOResourcePackage resourcePackage = packageManager.getCDOResourcePackage();
- ((InternalCDOPackage)resourcePackage).setClientInfo(EresourcePackage.eINSTANCE);
-
- CDOResourceNodeClass resourceNodeClass = resourcePackage.getCDOResourceNodeClass();
- ((InternalCDOClass)resourceNodeClass).setClientInfo(EresourcePackage.eINSTANCE.getCDOResourceNode());
- ((InternalCDOFeature)resourceNodeClass.getCDOFolderFeature()).setClientInfo(EresourcePackage.eINSTANCE
- .getCDOResourceNode_Folder());
- ((InternalCDOFeature)resourceNodeClass.getCDONameFeature()).setClientInfo(EresourcePackage.eINSTANCE
- .getCDOResourceNode_Name());
-
- CDOResourceFolderClass resourceFolderClass = resourcePackage.getCDOResourceFolderClass();
- ((InternalCDOClass)resourceFolderClass).setClientInfo(EresourcePackage.eINSTANCE.getCDOResourceFolder());
- ((InternalCDOFeature)resourceFolderClass.getCDONodesFeature()).setClientInfo(EresourcePackage.eINSTANCE
- .getCDOResourceFolder_Nodes());
-
- CDOResourceClass resourceClass = resourcePackage.getCDOResourceClass();
- ((InternalCDOClass)resourceClass).setClientInfo(EresourcePackage.eINSTANCE.getCDOResource());
- ((InternalCDOFeature)resourceClass.getCDOContentsFeature()).setClientInfo(EresourcePackage.eINSTANCE
- .getCDOResource_Contents());
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java
index 8ee7ab0cb4..0b623e3df2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java
@@ -13,7 +13,6 @@
package org.eclipse.emf.internal.cdo.util;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.revision.CDOReferenceAdjuster;
import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
@@ -25,6 +24,8 @@ import org.eclipse.emf.cdo.internal.common.revision.delta.CDOListFeatureDeltaImp
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.spi.cdo.CDOElementProxy;
/**
@@ -65,9 +66,9 @@ public class RevisionAdjuster extends CDOFeatureDeltaVisitorImpl
@Override
public void visit(CDOSetFeatureDelta delta)
{
- CDOFeature feature = delta.getFeature();
+ EStructuralFeature feature = delta.getFeature();
Object value = delta.getValue();
- if (value != null && feature.isReference() && !(value instanceof CDOElementProxy))
+ if (value != null && feature instanceof EReference && !(value instanceof CDOElementProxy))
{
revision.setValue(feature, referenceAdjuster.adjustReference(value));
}
@@ -76,10 +77,10 @@ public class RevisionAdjuster extends CDOFeatureDeltaVisitorImpl
@Override
public void visit(CDOListFeatureDelta deltas)
{
- CDOFeature feature = deltas.getFeature();
+ EStructuralFeature feature = deltas.getFeature();
InternalCDOList list = (InternalCDOList)revision.getValue(feature);
- if (feature.isReference())
+ if (feature instanceof EReference)
{
int[] indices = ((CDOListFeatureDeltaImpl)deltas).reconstructAddedIndices().getElement2();
for (int i = 1; i <= indices[0]; i++)

Back to the top