Esempio n. 1
0
  protected void writeRevision(InternalCDORevision revision, OMMonitor monitor) {
    Async async = null;
    monitor.begin(10);

    try {
      try {
        async = monitor.forkAsync();
        if (revision.isResourceNode()) {
          checkDuplicateResources(revision);
        }
      } finally {
        if (async != null) {
          async.stop();
        }
      }

      // TODO removal of previous version implies query, this should be optimized

      long start = System.currentTimeMillis();
      CDOID id = revision.getID();
      DB4OStore.removeRevision(getObjectContainer(), id);
      DB4ORevision primitiveRevision = DB4ORevision.getDB4ORevision(revision);
      writeObject(primitiveRevision, monitor);
      long end = System.currentTimeMillis();
      OM.LOG.debug("Writing revision " + id + " took: " + (end - start) + " milliseconds");
    } finally {
      monitor.done();
    }
  }
Esempio n. 2
0
  protected void reviseOldRevisions(InternalCDORevision[] newRevisions) {
    if (TRACER.isEnabled()) {
      TRACER.format("reviseOldRevisions: {0}", Arrays.asList(newRevisions)); // $NON-NLS-1$
    }

    try {
      if (reviseOldRevisionsStatement == null) {
        String sql = index.objects.sqlReviseOldRevisions();
        reviseOldRevisionsStatement = connection.prepareStatement(sql);
      }

      for (int i = 0; i < newRevisions.length; i++) {
        InternalCDORevision revision = newRevisions[i];
        int column = 0;

        long revised = revision.getTimeStamp() - 1;
        reviseOldRevisionsStatement.setLong(++column, revised);

        CDOID oid = revision.getID();
        index.setCDOID(reviseOldRevisionsStatement, ++column, oid);

        if (supportingBranches) {
          int branchID = revision.getBranch().getID();
          reviseOldRevisionsStatement.setInt(++column, branchID);
        }

        int version = Math.abs(revision.getVersion()) - 1;
        reviseOldRevisionsStatement.setInt(++column, version);

        execute(reviseOldRevisionsStatement);
      }
    } catch (SQLException ex) {
      throw new DBException(ex);
    }
  }
  public void cdoInternalPostDetach(boolean remote) {
    if (remote) {
      setInstanceContainer(null, eContainerFeatureID());
      setInstanceResource(null);
      return;
    }

    // This loop adjusts the opposite wrapper objects to support dangling references. See
    // Bugzilla_251263_Test
    InternalCDORevision revision = cdoRevision();
    for (EReference reference : classInfo.getAllPersistentReferences()) {
      if (!reference.isContainer() && classInfo.hasPersistentOpposite(reference)) {
        if (reference.isMany()) {
          EReference oppositeReference = reference.getEOpposite();

          int size = revision.size(reference);
          for (int i = 0; i < size; i++) {
            EObject object = (EObject) getValueFromRevision(reference, i);
            adjustPersistentOppositeReference(this, object, oppositeReference);
          }
        } else {
          EObject oppositeObject = (EObject) instance.eGet(reference);
          if (oppositeObject != null) {
            EReference oppositeReference = reference.getEOpposite();
            adjustPersistentOppositeReference(this, oppositeObject, oppositeReference);
          }
        }
      }
    }
  }
  /**
   * CDO persists the isUnset state of an eObject in the database. The indicator for this is that
   * the feature is null in the revision (see CDOStore.isSet()). When committing a legacy object all
   * values in the instance for native attributes are set with the java default values. So, these
   * values will be stored in the revision and CDO cannot distinguish whether the feature is set or
   * not. This method must ensure that the value will be set to null if the feature is not set.
   */
  public void cdoInternalPreCommit() {
    // We have to set this here because the CDOLegacyAdapter will not be notified when the instance
    // is the target of a
    // single-directional containment reference.
    // If the container is not an legacy Object the system will get no information
    instanceToRevisionContainment();

    InternalCDORevision revision = cdoRevision();
    for (EStructuralFeature feature : classInfo.getAllPersistentFeatures()) {
      if (feature.isUnsettable()) {
        if (!isSetInstanceValue(instance, feature)) {
          if (feature.isMany()) {
            @SuppressWarnings("unchecked")
            InternalEList<Object> list = (InternalEList<Object>) instance.eGet(feature);
            clearEList(list);
          } else {
            revision.set(feature, EStore.NO_INDEX, null);
          }
        } else if (instance.eGet(feature) == null) {
          // Must be single-valued!
          revision.set(feature, EStore.NO_INDEX, CDORevisionData.NIL);
        }
      }
    }
  }
  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;
  }
  public CDOPermission cdoPermission() {
    InternalCDORevision revision = cdoRevision(true);
    if (revision == null) {
      return CDOPermission.WRITE;
    }

    return revision.getPermission();
  }
Esempio n. 7
0
 @Override
 public void set(Object target, Object value, SessionFactoryImplementor factory)
     throws HibernateException {
   InternalCDORevision revision = (InternalCDORevision) target;
   revision.setVersion(((Number) value).intValue());
   if (!isVirtualProperty()) {
     super.set(target, value, factory);
   }
 }
Esempio n. 8
0
  protected void writeRevisionDelta(
      InternalCDORevisionDelta revisionDelta, CDOBranch branch, long created) {
    CDOID id = revisionDelta.getID();
    InternalCDORevision revision =
        DB4ORevision.getCDORevision(getStore(), DB4OStore.getRevision(getObjectContainer(), id));
    InternalCDORevision newRevision = revision.copy();
    newRevision.adjustForCommit(branch, created);

    revisionDelta.apply(newRevision);
    writeRevision(newRevision, new Monitor());
  }
  /**
   * 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;
  }
  /** TODO See {@link CDOObjectMerger}!!! */
  public static void changeObject(CDOObject object, CDORevisionDelta revisionDelta) {
    readObject(object);

    InternalCDORevision revision = (InternalCDORevision) object.cdoRevision().copy();
    ((InternalCDORevisionDelta) revisionDelta).setVersion(revision.getVersion());

    CDORevisionMerger merger = new CDORevisionMerger();
    merger.merge(revision, revisionDelta);
    ((InternalCDOObject) object).cdoInternalSetRevision(revision);
    ((InternalCDOObject) object).cdoInternalSetState(CDOState.DIRTY);
    ((InternalCDOObject) object).cdoInternalPostLoad();
  }
Esempio n. 11
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();
  }
Esempio n. 12
0
 /** @since 4.0 */
 protected void revisionToInstanceResource() {
   InternalCDORevision revision = cdoRevision();
   if (revision != null) {
     CDOID resourceID = revision.getResourceID();
     if (!CDOIDUtil.isNull(resourceID)) {
       InternalEObject resource = getEObjectFromPotentialID(viewAndState.view, null, resourceID);
       setInstanceResource((Resource.Internal) resource);
       if (resource != null) {
         viewAndState.view.registerObject((InternalCDOObject) resource);
       }
     }
   }
 }
  /**
   * * 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;
  }
  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;
  }
Esempio n. 15
0
  protected void instanceToRevision() {
    InternalCDORevision revision = cdoRevision();
    if (TRACER.isEnabled()) {
      TRACER.format(
          "Transfering instance to revision: {0} --> {1}", instance, revision); // $NON-NLS-1$
    }

    // Handle containment
    instanceToRevisionContainment();

    // Handle values
    for (EStructuralFeature feature : classInfo.getAllPersistentFeatures()) {
      instanceToRevisionFeature(feature);
    }

    revision.setUnchunked();
  }
  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 = CDOIDUtil.createMap();
    for (InternalCDORevision revision : commitContext.getNewObjects()) {
      newObjectsMap.put(revision.getID(), revision);
    }

    idMapper = CDOIDUtil.createMap();

    this.newObjyObjectsMap = newObjyObjectsMap;
  }
  @Override
  public void set(Object target, Object value, SessionFactoryImplementor factory)
      throws HibernateException {
    // Do some checking
    if (value instanceof HibernateMoveableListWrapper) {
      super.set(target, ((HibernateMoveableListWrapper) value).getDelegate(), factory);
      return;
    }

    if (!(value instanceof PersistentCollection)) {
      throw new IllegalArgumentException(
          "Value is not a PersistentCollection but a " + value.getClass().getName()); // $NON-NLS-1$
    }

    if (!(value instanceof List<?>)) {
      throw new IllegalArgumentException(
          "Value is not a list but a " + value.getClass().getName()); // $NON-NLS-1$
    }

    // Only set it in the listholder
    PersistableListHolder.getInstance()
        .putListMapping(target, getEStructuralFeature(), (PersistentCollection) value);

    // check if deep inside the persistentlist there is not already a delegate which is a
    // hibernatemoveable list
    // which contains the list which should really be set in the cdorevision
    // persistentlist, hibernatemoveablelistwrapper, real list, if so then the real list should be
    // set
    final InternalCDORevision revision = (InternalCDORevision) target;
    final Object currentValue = revision.getValue(getEStructuralFeature());
    if (currentValue == null || !(currentValue instanceof List<?>)) {
      @SuppressWarnings("unchecked")
      List<Object> valueList = (List<Object>) value;

      final WrappedHibernateList whl = new WrappedHibernateList(revision, getEStructuralFeature());
      whl.setDelegate(valueList);
      super.set(target, whl, factory);
    }
  }
  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();
    }
  }
Esempio n. 19
0
  protected void instanceToRevisionContainment() {
    InternalCDORevision revision = cdoRevision();

    CDOResource resource = (CDOResource) getInstanceResource(instance);
    revision.setResourceID(resource == null ? CDOID.NULL : resource.cdoID());

    InternalEObject eContainer = getInstanceContainer(instance);
    if (eContainer == null) {
      revision.setContainerID(CDOID.NULL);
      revision.setContainingFeatureID(0);
    } else {
      CDOObject cdoContainer = FSMUtil.adapt(eContainer, viewAndState.view);
      revision.setContainerID(cdoContainer);
      revision.setContainingFeatureID(getInstanceContainerFeatureID(instance));
    }
  }
Esempio n. 20
0
  /** @since 4.0 */
  protected void revisionToInstanceContainer() {
    InternalCDORevision revision = cdoRevision();
    CDOPermission permission = revision.getPermission();
    if (permission != CDOPermission.WRITE) {
      revision.setPermission(CDOPermission.WRITE);
    }

    try {
      Object containerID = revision.getContainerID();
      InternalEObject container = getEObjectFromPotentialID(viewAndState.view, null, containerID);
      EObject oldContainer = instance.eContainer();
      if (oldContainer != container) {
        setInstanceContainer(container, revision.getContainingFeatureID());
      }
    } finally {
      if (permission != CDOPermission.WRITE) {
        revision.setPermission(permission);
      }
    }
  }
Esempio n. 21
0
  /** @since 3.0 */
  protected void revisionToInstanceFeature(EStructuralFeature feature) {
    if (feature.isUnsettable() && !viewAndState.view.getStore().isSet(this, feature)) {
      // Clarify if this is sufficient for bidirectional references
      instance.eUnset(feature);
      return;
    }

    if (feature.isMany()) {
      if (TRACER.isEnabled()) {
        TRACER.format(
            "State of Object ("
                + this
                + "/"
                + instance
                + ") is : "
                + viewAndState.state); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      }

      if (viewAndState.state == CDOState.CLEAN
          || viewAndState.state == CDOState.PROXY
          || viewAndState.state == CDOState.NEW
          || viewAndState.state == CDOState.DIRTY) {
        InternalCDORevision revision = cdoRevision();
        int size = revision.size(feature);

        @SuppressWarnings("unchecked")
        InternalEList<Object> list = (InternalEList<Object>) instance.eGet(feature);

        clearEList(list);
        for (int i = 0; i < size; i++) {
          Object object = getValueFromRevision(feature, i);

          if (TRACER.isEnabled()) {
            TRACER.format(
                "Adding "
                    + object
                    + " to feature "
                    + feature
                    + "in instance "
                    + instance); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          }

          // Disable notifications from value during the
          // invalidation in case of
          // eInverseAdd/eInverseRemove
          boolean eDeliver = false;
          if (object instanceof Notifier) {
            Notifier notifier = (Notifier) object;
            eDeliver = notifier.eDeliver();
            if (eDeliver) {
              notifier.eSetDeliver(false);
            }
          }

          list.basicAdd(object, null);

          if (object instanceof Notifier && eDeliver) {
            Notifier notifier = (Notifier) object;
            notifier.eSetDeliver(eDeliver);
          }
        }
      }
    } else {
      // !feature.isMany()
      Object object = getValueFromRevision(feature, 0);
      if (feature instanceof EAttribute) {
        if (TRACER.isEnabled()) {
          TRACER.format(
              "Setting attribute value "
                  + object
                  + " to feature "
                  + feature
                  + " in instance "
                  + instance); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }

        // Just fake it for the store :(
        if (feature.isUnsettable() && object.equals(CDORevisionData.NIL)) {
          eSet(feature, null);
        } else {
          if (object != null) {
            eSet(feature, object);
          } else {
            // TODO Unset for features with non-null default values would not lead to null values.
            // Probably CDORevisionData.NIL has to be used, but that impacts all IStores. Deferred
            // ;-(
            eUnset(feature);
          }
        }
      } else {
        // EReferences
        if (TRACER.isEnabled()) {
          TRACER.format(
              "Adding object "
                  + object
                  + " to feature "
                  + feature
                  + " in instance "
                  + instance); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }

        // Disable notifications from value during the
        // invalidation in case of
        // eInverseAdd/eInverseRemove
        boolean eDeliver = false;
        if (object instanceof Notifier) {
          Notifier notifier = (Notifier) object;
          eDeliver = notifier.eDeliver();
          if (eDeliver) {
            notifier.eSetDeliver(false);
          }
        }
        EObject oldContainerOfValue = null;
        boolean eDeliverForOldContainerOfValue = false;
        if (object instanceof InternalEObject) {
          InternalEObject eObject = (InternalEObject) object;
          oldContainerOfValue = eObject.eInternalContainer();
          if (oldContainerOfValue != null) {
            eDeliverForOldContainerOfValue = oldContainerOfValue.eDeliver();
            if (eDeliverForOldContainerOfValue) {
              oldContainerOfValue.eSetDeliver(false);
            }
          }
        }

        int featureID = instance.eClass().getFeatureID(feature);
        Class<? extends Object> baseClass = object == null ? null : object.getClass();
        EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal) feature;
        EReference oppositeReference = internalFeature.getEOpposite();

        if (oppositeReference != null) {
          if (object != null && object != instance.eGet(feature)) {
            // If you have a containment reference but the container is not set, but the object is
            // attached to a
            // resource
            // do not set the feature to null. Otherwise the object will be removed from the
            // container which is the
            // resource instead of the original container. As a result the object will be detached.
            // See
            // MapTest.testEObjectToEObjectValueContainedMap for more information
            if (object != instance.eContainer() || !oppositeReference.isContainment()) {
              instance.eInverseAdd((InternalEObject) object, featureID, baseClass, null);
            }

            if (!classInfo.hasPersistentOpposite(internalFeature)) {
              adjustTransientOppositeReference(
                  instance, (InternalEObject) object, oppositeReference);
            }
          }
        } else {
          if (object != CDORevisionData.NIL) {
            EReference reference = (EReference) feature;
            if (reference.isContainment()) {
              if (object != null) {
                // Calling eSet it not the optimal approach, but currently there is no other way to
                // set the value here.
                // To avoid attaching already processed (clean) objects a check was introduced to
                // CDOResourceImpl.attached(EObject).
                // If we find a way to avoid the call of eSet and if we are able to only set the
                // feature value directly
                // this check can be removed from CDOResourceImpl. See also Bug 352204.
                instance.eSet(feature, object);
              } else {
                instance.eSet(feature, null);
              }
            } else {
              instance.eSet(feature, object);
            }
          } else {
            instance.eSet(feature, null);
          }
        }

        if (object instanceof Notifier && eDeliver) {
          Notifier notifier = (Notifier) object;
          notifier.eSetDeliver(eDeliver);
        }
        if (oldContainerOfValue != null && eDeliverForOldContainerOfValue) {
          oldContainerOfValue.eSetDeliver(eDeliverForOldContainerOfValue);
        }

        if (TRACER.isEnabled()) {
          TRACER.format(
              "Added object "
                  + object
                  + " to feature "
                  + feature
                  + " in instance "
                  + instance); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }
      }
    }
  }
Esempio n. 22
0
  public void addObjects(InternalCDORevision[] newRevisions, long[] pointers) {
    if (TRACER.isEnabled()) {
      TRACER.format(
          "addObjects: {0}, {1}",
          Arrays.asList(newRevisions), Arrays.asList(pointers)); // $NON-NLS-1$
    }

    try {
      if (addObjectStatement == null) {
        String sql = index.objects.sqlAddRevision();
        addObjectStatement = connection.prepareStatement(sql);
      }

      for (int i = 0; i < newRevisions.length; i++) {
        InternalCDORevision revision = newRevisions[i];
        long pointer = pointers[i];

        boolean detached = revision instanceof DetachedCDORevision;
        int column = 0;

        CDOID oid = revision.getID();
        index.setCDOID(addObjectStatement, ++column, oid);

        if (supportingBranches) {
          int branchID = revision.getBranch().getID();
          addObjectStatement.setInt(++column, branchID);
        }

        if (supportingAudits) {
          long time = revision.getTimeStamp();
          addObjectStatement.setLong(++column, time);

          long revised = revision.getRevised();
          addObjectStatement.setLong(++column, revised);

          int version = revision.getVersion();
          if (detached) {
            version = -version;
          }

          addObjectStatement.setInt(++column, version);
        }

        int cid = getStore().getMetaID(revision.getEClass());
        addObjectStatement.setInt(++column, cid);

        CDOID containerID = detached ? CDOID.NULL : (CDOID) revision.getContainerID();
        index.setCDOID(addObjectStatement, ++column, containerID);

        if (!detached && revision.isResourceNode()) {
          String name =
              (String) revision.data().get(EresourcePackage.Literals.CDO_RESOURCE_NODE__NAME, 0);
          if (name == null) {
            name = CDOURIUtil.SEGMENT_SEPARATOR;
          }

          addObjectStatement.setString(++column, name);
        } else {
          addObjectStatement.setNull(++column, DBType.VARCHAR.getCode());
        }

        addObjectStatement.setLong(++column, pointer);

        execute(addObjectStatement);
      }
    } catch (SQLException ex) {
      throw new DBException(ex);
    }
  }
Esempio n. 23
0
  protected void revisionToInstance() {
    synchronized (recursionCounter) {
      if (underConstruction) {
        // Return if revisionToInstance was called before to avoid doubled calls
        return;
      }

      underConstruction = true;
      InternalCDORevision revision = cdoRevision();

      if (TRACER.isEnabled()) {
        TRACER.format(
            "Transfering revision to instance: {0} --> {1}", revision, instance); // $NON-NLS-1$
      }

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

      Counter counter = recursionCounter.get();
      if (counter == null) {
        counter = new Counter();
        recursionCounter.set(counter);
      }

      InternalCDOResource resource = null;
      boolean bypassPermissionChecks = revision.bypassPermissionChecks(true);

      try {
        registerWrapper(this);
        counter.increment();
        viewAndState.view.registerObject(this);

        revisionToInstanceResource();
        revisionToInstanceContainer();

        Resource eResource = instance.eResource();
        if (eResource instanceof InternalCDOResource) {
          resource = (InternalCDOResource) eResource;
          resource.cdoInternalLoading(instance);
        }

        for (EStructuralFeature feature : classInfo.getAllPersistentFeatures()) {
          revisionToInstanceFeature(feature);
        }
      } catch (RuntimeException ex) {
        OM.LOG.error(ex);
        throw ex;
      } catch (Exception ex) {
        OM.LOG.error(ex);
        throw new CDOException(ex);
      } finally {
        try {
          revision.bypassPermissionChecks(bypassPermissionChecks);

          if (resource != null) {
            resource.cdoInternalLoadingDone(instance);
          }

          if (deliver) {
            instance.eSetDeliver(true);
          }
        } finally {
          if (counter.decrement() == 0) {
            recursionCounter.remove();
          }

          unregisterWrapper(this);
          underConstruction = false;
        }
      }
    }
  }