/** * This method retrieves the value from the feature at the given index. It retrieves the value * either from the views's store or the internal pre-registration Map. * * @param feature the feature to retrieve the value from * @param index the given index of the object in the feature * @return the value from the feature at the given index */ private Object getValueFromRevision(EStructuralFeature feature, int index) { InternalCDORevision revision = cdoRevision(); Object object = revision.get(feature, index); if (object == null) { return null; } if (object instanceof CDOElementProxy) { // Resolve proxy CDOElementProxy proxy = (CDOElementProxy) object; object = viewAndState .view .getSession() .resolveElementProxy(revision, feature, index, proxy.getIndex()); } if (object instanceof CDOLegacyWrapper) { return ((CDOLegacyWrapper) object).cdoInternalInstance(); } CDOType type = CDOModelUtil.getType(feature.getEType()); object = viewAndState.view.getStore().convertToEMF(instance, revision, feature, index, object); if (type == CDOType.OBJECT) { if (object instanceof CDOID) { CDOID id = (CDOID) object; if (id.isNull()) { return null; } object = getRegisteredWrapper(id); if (object != null) { return ((CDOLegacyWrapper) object).cdoInternalInstance(); } if (id.isExternal()) { object = viewAndState .view .getResourceSet() .getEObject(URI.createURI(id.toURIFragment()), true); } else { object = viewAndState.view.getObject(id); } if (object instanceof CDOObjectWrapper) { return ((CDOObjectWrapper) object).cdoInternalInstance(); } } } return object; }
/** * @param feature in case that a proxy has to be created the feature that will determine the * interface type of the proxy and that will be used later to resolve the proxy. <code>null * </code> indicates that proxy creation will be avoided! */ protected InternalEObject getEObjectFromPotentialID( InternalCDOView view, EStructuralFeature feature, Object potentialID) { CDOLegacyWrapper wrapper; if (potentialID instanceof CDOID && (wrapper = getRegisteredWrapper((CDOID) potentialID)) != null) { potentialID = wrapper.instance; if (TRACER.isEnabled()) { TRACER.format( "Getting Object (" + potentialID + ") from localThread instead of the view"); //$NON-NLS-1$ //$NON-NLS-2$ } } else { if (potentialID instanceof CDOID) { CDOID id = (CDOID) potentialID; if (id.isNull()) { return null; } if (id.isExternal()) { URI uri = URI.createURI(id.toURIFragment()); InternalEObject eObject = (InternalEObject) viewAndState.view.getResourceSet().getEObject(uri, true); return eObject; } boolean loadOnDemand = feature == null; potentialID = viewAndState.view.getObject(id, loadOnDemand); if (potentialID == null && !loadOnDemand) { return createProxy(view, feature, id); } } if (potentialID instanceof InternalCDOObject) { return ((InternalCDOObject) potentialID).cdoInternalInstance(); } } return (InternalEObject) potentialID; }
public static Object remapID( Object value, Map<CDOID, CDOID> idMappings, boolean allowUnmappedTempIDs) { if (value instanceof CDOID) { CDOID oldID = (CDOID) value; if (!oldID.isNull()) { CDOID newID = idMappings.get(oldID); if (newID != null) { if (TRACER.isEnabled()) { TRACER.format("Adjusting ID: {0} --> {1}", oldID, newID); } return newID; } if (oldID instanceof CDOIDTemp) { throw new IllegalStateException( MessageFormat.format(Messages.getString("AbstractCDORevision.2"), oldID)); } } } return value; }