Esempio n. 1
0
  /** @since 4.0 */
  public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster) {
    if (TRACER.isEnabled()) {
      TRACER.format("Adjusting references for revision {0}", this);
    }

    boolean changed = false;

    CDOID id1 =
        (CDOID)
            referenceAdjuster.adjustReference(
                resourceID, CDOContainerFeatureDelta.CONTAINER_FEATURE, CDOFeatureDelta.NO_INDEX);
    if (id1 != resourceID) {
      resourceID = id1;
      changed = true;
    }

    Object id2 =
        referenceAdjuster.adjustReference(
            containerID, CDOContainerFeatureDelta.CONTAINER_FEATURE, CDOFeatureDelta.NO_INDEX);
    if (id2 != containerID) {
      containerID = id2;
      changed = true;
    }

    EStructuralFeature[] features = getAllPersistentFeatures();
    for (int i = 0; i < features.length; i++) {
      EStructuralFeature feature = features[i];
      if (feature instanceof EReference || FeatureMapUtil.isFeatureMap(feature)) {
        if (feature.isMany()) {
          InternalCDOList list = (InternalCDOList) getValueAsList(i);
          if (list != null) {
            changed |= list.adjustReferences(referenceAdjuster, feature);
          }
        } else {
          CDOType type = CDOModelUtil.getType(feature);
          Object oldValue = getValue(i);
          Object newValue =
              type.adjustReferences(referenceAdjuster, oldValue, feature, CDOFeatureDelta.NO_INDEX);
          if (oldValue != newValue) // Just an optimization for NOOP adjusters
          {
            setValue(i, newValue);
            changed = true;
          }
        }
      }
    }

    return changed;
  }
Esempio n. 2
0
  /** @since 4.1 */
  public void freeze() {
    flags |= FROZEN_FLAG;

    if (isReadable()) {
      EStructuralFeature[] features = getAllPersistentFeatures();
      for (int i = 0; i < features.length; i++) {
        EStructuralFeature feature = features[i];
        if (feature.isMany()) {
          InternalCDOList list = (InternalCDOList) doGetValue(i);
          if (list != null) {
            list.freeze();
          }
        }
      }
    }
  }