Search in sources :

Example 1 with SuspendPartnershipMode

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);
    }
}
Also used : JsonArray(com.google.gson.JsonArray) ChangePartnershipToUpstreamDownstreamRefactoring(org.contextmapper.dsl.refactoring.ChangePartnershipToUpstreamDownstreamRefactoring) JsonPrimitive(com.google.gson.JsonPrimitive) SuspendPartnershipMode(org.contextmapper.dsl.refactoring.SuspendPartnershipMode) ExtractPartnershipRefactoring(org.contextmapper.dsl.refactoring.ExtractPartnershipRefactoring)

Aggregations

JsonArray (com.google.gson.JsonArray)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 ChangePartnershipToUpstreamDownstreamRefactoring (org.contextmapper.dsl.refactoring.ChangePartnershipToUpstreamDownstreamRefactoring)1 ExtractPartnershipRefactoring (org.contextmapper.dsl.refactoring.ExtractPartnershipRefactoring)1 SuspendPartnershipMode (org.contextmapper.dsl.refactoring.SuspendPartnershipMode)1