コード例 #1
0
  /**
   * IMPORTANT: Compile errors in this method might indicate an old version of EMF. Legacy support
   * is only enabled for EMF with fixed bug #247130. These compile errors do not affect native
   * models!
   */
  protected void resolveProxies(EStructuralFeature feature) {
    Object value = getInstanceValue(instance, feature);
    if (value != null) {
      if (feature.isMany()) {
        @SuppressWarnings("unchecked")
        InternalEList<Object> list = (InternalEList<Object>) value;
        int size = list.size();

        boolean deliver = instance.eDeliver();
        if (deliver) {
          instance.eSetDeliver(false);
        }

        for (int i = 0; i < size; i++) {
          Object element = list.get(i);
          if (element instanceof LegacyProxy) {
            CDOID id = ((LegacyProxy) element).getID();
            InternalCDOObject resolved = (InternalCDOObject) viewAndState.view.getObject(id);
            InternalEObject instance = resolved.cdoInternalInstance();

            // TODO LEGACY
            // // TODO Is InternalEList.basicSet() needed???
            // if (list instanceof
            // org.eclipse.emf.ecore.util.DelegatingInternalEList)
            // {
            // list =
            // ((org.eclipse.emf.ecore.util.DelegatingInternalEList)list).getDelegateInternalEList();
            // }

            // if (list instanceof NotifyingListImpl<?>)
            // {
            // ((NotifyingListImpl<Object>)list).basicSet(i, instance, null);
            // }
            // else
            // {
            list.set(i, instance);
            // }
          }
        }

        if (deliver) {
          instance.eSetDeliver(true);
        }
      } else {
        if (value instanceof LegacyProxy) {
          CDOID id = ((LegacyProxy) value).getID();
          InternalCDOObject resolved = (InternalCDOObject) viewAndState.view.getObject(id);
          InternalEObject instance = resolved.cdoInternalInstance();
          setInstanceValue(instance, feature, instance);
        }
      }
    }
  }
コード例 #2
0
  private void adjustPersistentOppositeReference(
      InternalCDOObject cdoObject, EObject oppositeObject, EReference oppositeReference) {
    InternalCDOObject oppositeCDOObject = (InternalCDOObject) CDOUtil.getCDOObject(oppositeObject);
    if (oppositeCDOObject != null) {
      InternalCDOView view = oppositeCDOObject.cdoView();
      if (view != null) {
        CDOStore store = viewAndState.view.getStore();
        if (store != null) {
          if (oppositeReference.isMany()) {
            EObject eObject = oppositeCDOObject.cdoInternalInstance();

            @SuppressWarnings("unchecked")
            EList<Object> list = (EList<Object>) eObject.eGet(oppositeReference);
            int index = list.indexOf(instance);

            if (index != EStore.NO_INDEX && !store.isEmpty(oppositeCDOObject, oppositeReference)) {
              store.set(oppositeCDOObject, oppositeReference, index, cdoObject);
            }
          } else {
            store.set(oppositeCDOObject, oppositeReference, 0, cdoObject);
          }
        }
      }
    }
  }