use of org.contextmapper.dsl.refactoring.SuspendPartnershipMode in project context-mapper-dsl by ContextMapper.
the class SuspendPartnershipCommand method getRefactoring.
@Override
protected SemanticCMLRefactoring getRefactoring(ExecuteCommandParams params) {
JsonArray refactoringParams = (JsonArray) params.getArguments().get(1);
JsonPrimitive participant1 = (JsonPrimitive) refactoringParams.get(0);
JsonPrimitive participant2 = (JsonPrimitive) refactoringParams.get(1);
JsonPrimitive modeAsString = (JsonPrimitive) refactoringParams.get(2);
SuspendPartnershipMode mode = SuspendPartnershipMode.valueOf(modeAsString.getAsString());
if (mode == SuspendPartnershipMode.EXTRACT_NEW_BOUNDED_CONTEXT) {
return new ExtractPartnershipRefactoring(participant1.getAsString(), participant2.getAsString());
// Unfortunately MERGE mode does currently not work because of this Xtext bug:
// https://github.com/eclipse/xtext-core/issues/1494
// } else if (mode == SuspendPartnershipMode.MERGE_BOUNDED_CONTEXTS) {
// return new MergeBoundedContextsRefactoring(participant1.getAsString(), participant2.getAsString());
} else {
String upstream = participant1.getAsString();
String downstream = participant2.getAsString();
JsonPrimitive upstreamContext = (JsonPrimitive) refactoringParams.get(3);
if (upstreamContext.getAsString().equals(downstream)) {
upstream = participant2.getAsString();
downstream = participant1.getAsString();
}
return new ChangePartnershipToUpstreamDownstreamRefactoring(upstream, downstream);
}
}
Aggregations