コード例 #1
0
ファイル: DefaultCDOMerger.java プロジェクト: sthibaudeau/cdo
      @Override
      protected CDOFeatureDelta changedInSourceAndTargetManyValued(
          EStructuralFeature feature,
          CDOFeatureDelta targetFeatureDelta,
          CDOFeatureDelta sourceFeatureDelta) {
        if (targetFeatureDelta instanceof CDOListFeatureDelta
            && sourceFeatureDelta instanceof CDOListFeatureDelta) {
          // Initialize work lists with virtual elements
          int originSize = ((CDOListFeatureDelta) sourceFeatureDelta.copy()).getOriginSize();
          BasicEList<Element> ancestorList = new BasicEList<Element>(originSize);
          PerSide<BasicEList<Element>> listPerSide = new PerSide<BasicEList<Element>>();

          initWorkLists(originSize, ancestorList, listPerSide);

          // Apply list changes to source and target work lists
          PerSide<List<CDOFeatureDelta>> changesPerSide =
              new PerSide<List<CDOFeatureDelta>>(
                  copyListChanges(sourceFeatureDelta), copyListChanges(targetFeatureDelta));
          Map<Object, List<Element>> additions = new HashMap<Object, List<Element>>();
          Map<CDOFeatureDelta, Element> allElements = new HashMap<CDOFeatureDelta, Element>();

          applyChangesToWorkList(Side.SOURCE, listPerSide, changesPerSide, allElements, additions);
          applyChangesToWorkList(Side.TARGET, listPerSide, changesPerSide, allElements, additions);

          // Pick changes from source and target sides into the merge result
          CDOListFeatureDelta result = new CDOListFeatureDeltaImpl(feature, originSize);
          List<CDOFeatureDelta> resultChanges = result.getListChanges();

          pickChangesIntoResult(
              Side.SOURCE,
              feature,
              ancestorList,
              changesPerSide,
              allElements,
              additions,
              resultChanges);
          pickChangesIntoResult(
              Side.TARGET,
              feature,
              ancestorList,
              changesPerSide,
              allElements,
              additions,
              resultChanges);

          return result;
        }

        return super.changedInSourceAndTargetManyValued(
            feature, targetFeatureDelta, sourceFeatureDelta);
      }
コード例 #2
0
ファイル: DefaultCDOMerger.java プロジェクト: sthibaudeau/cdo
      private List<CDOFeatureDelta> copyListChanges(CDOFeatureDelta featureDelta) {
        CDOListFeatureDelta listFeatureDelta = (CDOListFeatureDelta) featureDelta.copy();
        List<CDOFeatureDelta> copy = listFeatureDelta.getListChanges();

        if (!copy.isEmpty()) {
          CDOFeatureDelta.Type firstType = copy.get(0).getType();
          if (firstType == Type.CLEAR || firstType == Type.UNSET) {
            copy.remove(0);

            List<CDOFeatureDelta> expandedDeltas = expandClearDelta(listFeatureDelta);
            copy.addAll(0, expandedDeltas);
          }
        }

        return copy;
      }