private CDORevision applyDelta(CDORevisionDelta revisionDelta) {
   CDOID id = revisionDelta.getID();
   CDORevision changedObject = delegate.getRevision(id).copy();
   revisionDelta.apply(changedObject);
   cachedRevisions.put(id, changedObject);
   return changedObject;
 }
    protected boolean hasFeatureConflicts(
        CDORevisionDelta localDelta, List<CDORevisionDelta> remoteDeltas) {
      Set<EStructuralFeature> features = new HashSet<EStructuralFeature>();
      for (CDOFeatureDelta localFeatureDelta : localDelta.getFeatureDeltas()) {
        features.add(localFeatureDelta.getFeature());
      }

      for (CDORevisionDelta remoteDelta : remoteDeltas) {
        for (CDOFeatureDelta remoteFeatureDelta : remoteDelta.getFeatureDeltas()) {
          EStructuralFeature feature = remoteFeatureDelta.getFeature();
          if (features.contains(feature)) {
            return true;
          }
        }
      }

      return false;
    }
    @Override
    protected void resolveConflict(
        CDOObject conflict, CDORevisionDelta localDelta, List<CDORevisionDelta> remoteDeltas) {
      if (hasFeatureConflicts(localDelta, remoteDeltas)) {
        // TODO localDelta may be corrupt already and the transaction will not be able to restore
        // it!!!
        throw new CDOException(
            Messages.getString("AbstractObjectConflictResolver.0")); // $NON-NLS-1$
      }

      rollbackObject(conflict);

      // Add remote deltas to local delta
      for (CDORevisionDelta remoteDelta : remoteDeltas) {
        for (CDOFeatureDelta remoteFeatureDelta : remoteDelta.getFeatureDeltas()) {
          // TODO Add public API for this:
          ((InternalCDORevisionDelta) localDelta).addFeatureDelta(remoteFeatureDelta);
        }
      }

      changeObject(conflict, localDelta);
    }
示例#4
0
  protected Object changedInTargetAndDetachedInSource(CDORevisionDelta targetDelta) {
    switch (resolutionPreference) {
      case SOURCE_OVER_TARGET:
        return targetDelta.getID();

      case TARGET_OVER_SOURCE:
        return targetDelta; // TODO Do we need to "recreate" the target revision as NEW?

      case NONE:
        return new ChangedInTargetAndDetachedInSourceConflict(targetDelta);

      default:
        throw new IllegalStateException("Illegal resolution preference: " + resolutionPreference);
    }
  }
示例#5
0
 @Override
 public CDOID getID() {
   return targetDelta.getID();
 }
示例#6
0
 @Override
 public CDOID getID() {
   return sourceDelta.getID();
 }