private boolean take(Object data) { if (data instanceof Pair<?, ?>) { Pair<?, ?> pair = (Pair<?, ?>) data; boolean taken = takeNoPair(pair.getElement1()); taken |= takeNoPair(pair.getElement2()); return taken; } return takeNoPair(data); }
protected CDOSession getSession( String authority, String repositoryName, IProgressMonitor monitor) { Pair<String, String> sessionKey = Pair.create(authority, repositoryName); CDOSession session = sessions.get(sessionKey); if (session == null) { final CDOSessionConfiguration configuration = createSessionConfiguration(authority, repositoryName, monitor); session = InfiniteProgress.call( "Open session", new Callable<CDOSession>() { public CDOSession call() throws Exception { return configuration.openSession(); } }); sessions.put(sessionKey, session); } return session; }
@Override protected Object changedInSourceAndTarget( CDORevisionDelta targetDelta, CDORevisionDelta sourceDelta) { InternalCDORevisionDelta result = new CDORevisionDeltaImpl(targetDelta, false); ChangedInSourceAndTargetConflict conflict = null; Map<EStructuralFeature, CDOFeatureDelta> targetMap = ((InternalCDORevisionDelta) targetDelta).getFeatureDeltaMap(); Map<EStructuralFeature, CDOFeatureDelta> sourceMap = ((InternalCDORevisionDelta) sourceDelta).getFeatureDeltaMap(); for (CDOFeatureDelta targetFeatureDelta : targetMap.values()) { EStructuralFeature feature = targetFeatureDelta.getFeature(); CDOFeatureDelta sourceFeatureDelta = sourceMap.get(feature); if (sourceFeatureDelta == null) { CDOFeatureDelta featureDelta = changedInTarget(targetFeatureDelta); if (featureDelta != null) { result.addFeatureDelta(featureDelta, null); } } else { CDOFeatureDelta featureDelta = changedInSourceAndTarget(targetFeatureDelta, sourceFeatureDelta); if (featureDelta != null) { result.addFeatureDelta(featureDelta, null); } else { if (conflict == null) { ResolutionPreference resolutionPreference = getResolutionPreference(); switch (resolutionPreference) { case SOURCE_OVER_TARGET: // TODO: implement // DefaultCDOMerger.PerFeature.changedInSourceAndTarget(targetDelta, sourceDelta) throw new UnsupportedOperationException(); case TARGET_OVER_SOURCE: // TODO: implement // DefaultCDOMerger.PerFeature.changedInSourceAndTarget(targetDelta, sourceDelta) throw new UnsupportedOperationException(); case NONE: conflict = new ChangedInSourceAndTargetConflict( new CDORevisionDeltaImpl(targetDelta, false), new CDORevisionDeltaImpl(sourceDelta, false)); break; default: throw new IllegalStateException( "Illegal resolution preference: " + resolutionPreference); } } ((InternalCDORevisionDelta) conflict.getTargetDelta()) .addFeatureDelta(targetFeatureDelta, null); ((InternalCDORevisionDelta) conflict.getSourceDelta()) .addFeatureDelta(sourceFeatureDelta, null); } } } for (CDOFeatureDelta sourceFeatureDelta : sourceMap.values()) { EStructuralFeature feature = sourceFeatureDelta.getFeature(); CDOFeatureDelta targetFeatureDelta = targetMap.get(feature); if (targetFeatureDelta == null) { CDOFeatureDelta featureDelta = changedInSource(sourceFeatureDelta); if (featureDelta != null) { result.addFeatureDelta(featureDelta, null); } } } if (result.isEmpty()) { return conflict; } if (conflict != null) { return Pair.create(result, conflict); } return result; }