Search in sources :

Example 1 with SuspendPartnershipContext

use of org.contextmapper.dsl.ui.handler.wizard.SuspendPartnershipContext in project context-mapper-dsl by ContextMapper.

the class SuspendPartnershipRefactoringHandler method executeRefactoring.

@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
    Partnership partnership = (Partnership) getSelectedElement();
    SuspendPartnershipContext refactoringContext = new SuspendPartnershipContext(partnership.getParticipant1().getName(), partnership.getParticipant2().getName());
    new WizardDialog(HandlerUtil.getActiveShell(event), new SuspendPartnershipRefactoringWizard(refactoringContext, executionContext -> {
        if (refactoringContext.getMode() == SuspendPartnershipMode.MERGE_BOUNDED_CONTEXTS) {
            // just use the 'Merge Bounded Contexts' AR in this case ...
            return finishRefactoring(new MergeBoundedContextsRefactoring(executionContext.getMergeModeSelectedBoundedContext1(), executionContext.getMergeModeSelectedBoundedContext2(), executionContext.isMergeModeTakeAttributesFromSecondBoundedContext()), resource, event);
        } else if (refactoringContext.getMode() == SuspendPartnershipMode.EXTRACT_NEW_BOUNDED_CONTEXT) {
            return finishRefactoring(new ExtractPartnershipRefactoring(refactoringContext.getBoundedContext1(), refactoringContext.getBoundedContext2()), resource, event);
        } else {
            String upstream = refactoringContext.getBoundedContext1();
            String downstream = refactoringContext.getBoundedContext2();
            if (refactoringContext.getReplaceModeUpstreamBoundedContext().equals(refactoringContext.getBoundedContext2())) {
                upstream = refactoringContext.getBoundedContext2();
                downstream = refactoringContext.getBoundedContext1();
            }
            return finishRefactoring(new ChangePartnershipToUpstreamDownstreamRefactoring(upstream, downstream), resource, event);
        }
    })).open();
}
Also used : ChangePartnershipToUpstreamDownstreamRefactoring(org.contextmapper.dsl.refactoring.ChangePartnershipToUpstreamDownstreamRefactoring) Partnership(org.contextmapper.dsl.contextMappingDSL.Partnership) SuspendPartnershipRefactoringWizard(org.contextmapper.dsl.ui.handler.wizard.SuspendPartnershipRefactoringWizard) SuspendPartnershipContext(org.contextmapper.dsl.ui.handler.wizard.SuspendPartnershipContext) WizardDialog(org.eclipse.jface.wizard.WizardDialog) MergeBoundedContextsRefactoring(org.contextmapper.dsl.refactoring.MergeBoundedContextsRefactoring) ExtractPartnershipRefactoring(org.contextmapper.dsl.refactoring.ExtractPartnershipRefactoring)

Aggregations

Partnership (org.contextmapper.dsl.contextMappingDSL.Partnership)1 ChangePartnershipToUpstreamDownstreamRefactoring (org.contextmapper.dsl.refactoring.ChangePartnershipToUpstreamDownstreamRefactoring)1 ExtractPartnershipRefactoring (org.contextmapper.dsl.refactoring.ExtractPartnershipRefactoring)1 MergeBoundedContextsRefactoring (org.contextmapper.dsl.refactoring.MergeBoundedContextsRefactoring)1 SuspendPartnershipContext (org.contextmapper.dsl.ui.handler.wizard.SuspendPartnershipContext)1 SuspendPartnershipRefactoringWizard (org.contextmapper.dsl.ui.handler.wizard.SuspendPartnershipRefactoringWizard)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1