Search in sources :

Example 1 with DeriveBoundedContextFromSubdomains

use of org.contextmapper.dsl.refactoring.DeriveBoundedContextFromSubdomains in project context-mapper-dsl by ContextMapper.

the class GenerateBoundedContextFromSubdomainRefactoringHandler method executeRefactoring.

@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
    Set<Subdomain> subdomains = getAllSelectedElements().stream().filter(sd -> sd instanceof Subdomain).map(sd -> (Subdomain) sd).collect(Collectors.toSet());
    Set<String> boundedContexts = resource.getContextMappingModel().getBoundedContexts().stream().map(bc -> bc.getName()).collect(Collectors.toSet());
    Set<String> ids = subdomains.stream().map(sd -> sd.getName()).collect(Collectors.toSet());
    DeriveBoundedContextFromSubdomainsContext refactoringContext = new DeriveBoundedContextFromSubdomainsContext("NewContextFromSubdomains", boundedContexts);
    new WizardDialog(HandlerUtil.getActiveShell(event), new DeriveBoundedContextFromSubdomainsWizard(refactoringContext, executionContext -> {
        return finishRefactoring(new DeriveBoundedContextFromSubdomains(executionContext.getBoundedContextName(), ids), resource, event);
    })).open();
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) DeriveBoundedContextFromSubdomainsWizard(org.contextmapper.dsl.ui.handler.wizard.DeriveBoundedContextFromSubdomainsWizard) DeriveBoundedContextFromSubdomainsContext(org.contextmapper.dsl.ui.handler.wizard.DeriveBoundedContextFromSubdomainsContext) DeriveBoundedContextFromSubdomains(org.contextmapper.dsl.refactoring.DeriveBoundedContextFromSubdomains) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Optional(java.util.Optional) Set(java.util.Set) EObject(org.eclipse.emf.ecore.EObject) Subdomain(org.contextmapper.dsl.contextMappingDSL.Subdomain) Collectors(java.util.stream.Collectors) CMLResource(org.contextmapper.dsl.cml.CMLResource) HandlerUtil(org.eclipse.ui.handlers.HandlerUtil) DeriveBoundedContextFromSubdomains(org.contextmapper.dsl.refactoring.DeriveBoundedContextFromSubdomains) DeriveBoundedContextFromSubdomainsWizard(org.contextmapper.dsl.ui.handler.wizard.DeriveBoundedContextFromSubdomainsWizard) Subdomain(org.contextmapper.dsl.contextMappingDSL.Subdomain) DeriveBoundedContextFromSubdomainsContext(org.contextmapper.dsl.ui.handler.wizard.DeriveBoundedContextFromSubdomainsContext) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with DeriveBoundedContextFromSubdomains

use of org.contextmapper.dsl.refactoring.DeriveBoundedContextFromSubdomains in project context-mapper-dsl by ContextMapper.

the class DeriveBoundedContextFromSubdomainsCommand method getRefactoring.

@Override
protected SemanticCMLRefactoring getRefactoring(ExecuteCommandParams params) {
    JsonArray refactoringParams = (JsonArray) params.getArguments().get(1);
    JsonPrimitive boundedContextName = (JsonPrimitive) refactoringParams.get(0);
    JsonArray selectedSubdomainsArray = (JsonArray) refactoringParams.get(1);
    Set<String> selectedSubdomains = Sets.newHashSet();
    for (JsonElement element : selectedSubdomainsArray) {
        selectedSubdomains.add(element.getAsString());
    }
    return new DeriveBoundedContextFromSubdomains(boundedContextName.getAsString(), selectedSubdomains);
}
Also used : JsonArray(com.google.gson.JsonArray) DeriveBoundedContextFromSubdomains(org.contextmapper.dsl.refactoring.DeriveBoundedContextFromSubdomains) JsonPrimitive(com.google.gson.JsonPrimitive) JsonElement(com.google.gson.JsonElement)

Aggregations

DeriveBoundedContextFromSubdomains (org.contextmapper.dsl.refactoring.DeriveBoundedContextFromSubdomains)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 CMLResource (org.contextmapper.dsl.cml.CMLResource)1 Subdomain (org.contextmapper.dsl.contextMappingDSL.Subdomain)1 DeriveBoundedContextFromSubdomainsContext (org.contextmapper.dsl.ui.handler.wizard.DeriveBoundedContextFromSubdomainsContext)1 DeriveBoundedContextFromSubdomainsWizard (org.contextmapper.dsl.ui.handler.wizard.DeriveBoundedContextFromSubdomainsWizard)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 EObject (org.eclipse.emf.ecore.EObject)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 HandlerUtil (org.eclipse.ui.handlers.HandlerUtil)1