Ejemplo n.º 1
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);
          }
        }
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  protected void requesting(CDODataOutput out, OMMonitor monitor) throws IOException {
    out.writeInt(viewID);
    out.writeCDOBranchPoint(branchPoint);

    out.writeInt(invalidObjects.size());
    for (InternalCDOObject object : invalidObjects) {
      out.writeCDOID(object.cdoID());
    }
  }
Ejemplo n.º 3
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);
        }
      }
    }
  }
Ejemplo n.º 4
0
  /** @since 2.0 */
  public synchronized void merge(InternalCDOObject object, CDORevisionDelta delta) {
    InternalCDORevision oldRevision = object.cdoRevision();
    InternalCDORevision revision = oldRevision.copy();
    object.cdoInternalSetRevision(revision);

    // NEW object should stay that state.
    if (object.cdoState() != CDOState.NEW) {
      object.cdoInternalSetState(CDOState.DIRTY);
    }

    merge(revision, delta);
    object.cdoInternalPostLoad();
  }
Ejemplo n.º 5
0
  public CDOID provideCDOID(Object idOrObject) {
    CDOID id = getTransaction().provideCDOID(idOrObject);
    if (id instanceof CDOIDTempObjectExternalImpl) {
      if (idOrObject instanceof InternalEObject) {
        CDOIDTempObjectExternalImpl proxyTemp = (CDOIDTempObjectExternalImpl) id;
        if (!requestedIDs.containsKey(proxyTemp)) {
          InternalCDOObject cdoObject =
              (InternalCDOObject) CDOUtil.getCDOObject((InternalEObject) idOrObject);
          InternalCDOTransaction cdoTransaction = (InternalCDOTransaction) cdoObject.cdoView();
          getTransactionManager().add(cdoTransaction, proxyTemp);
          requestedIDs.put(proxyTemp, cdoTransaction);
          objectToID.put(cdoObject, proxyTemp);
        }
      } else {
        throw new ImplementationError(
            MessageFormat.format(
                Messages.getString("CDOXACommitContextImpl.0"), idOrObject)); // $NON-NLS-1$
      }
    }

    return id;
  }
 @Override
 protected CDOLock getLock(InternalCDOObject object) {
   return object.cdoReadLock();
 }