use of org.contextmapper.dsl.refactoring.ExtractSuggestedService in project context-mapper-dsl by ContextMapper.
the class ExtractSuggestedServiceRefactoringHandler method executeRefactoring.
@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
BoundedContext bc = (BoundedContext) getSelectedElement();
ChooseName4NewBoundedContextContext refactoringContext = new ChooseName4NewBoundedContextContext("NewBoundedContext");
originalCMLResource = getAllResources().getResource(new ExtractSuggestedService(bc, "TempBC").constructOriginalModelUri(), false);
if (originalCMLResource == null)
throw new ContextMapperApplicationException("We were not able to find the original CML model. Please do not rename the models after generating service cut suggestions.");
new WizardDialog(HandlerUtil.getActiveShell(event), new ChooseName4NewBoundedContextWizard(refactoringContext, executionContext -> {
return finishRefactoring(new ExtractSuggestedService(bc, executionContext.getNewBoundedContextName()), new CMLResource(originalCMLResource), event);
})).open();
}
use of org.contextmapper.dsl.refactoring.ExtractSuggestedService in project context-mapper-dsl by ContextMapper.
the class ExtractSuggestedServiceCommand method getRefactoring.
@Override
protected SemanticCMLRefactoring getRefactoring(ExecuteCommandParams params) {
JsonArray refactoringParams = (JsonArray) params.getArguments().get(1);
JsonPrimitive serviceCutResourceURI = (JsonPrimitive) refactoringParams.get(0);
JsonPrimitive serviceToExtractName = (JsonPrimitive) refactoringParams.get(1);
JsonPrimitive newBoundedContextName = (JsonPrimitive) refactoringParams.get(2);
URI serviceCutURI = URI.createURI(serviceCutResourceURI.getAsString());
CMLResource serviceCutResource = new CMLResource(cmlResource.getResourceSet().getResource(serviceCutURI, true));
Optional<BoundedContext> serviceToExtract = serviceCutResource.getContextMappingModel().getBoundedContexts().stream().filter(bc -> bc.getName().equals(serviceToExtractName.getAsString())).findFirst();
if (!serviceToExtract.isPresent())
throw new ContextMapperApplicationException("A service with the name '" + serviceToExtractName.getAsString() + "' does not exist in the CML model '" + serviceCutResourceURI.getAsString() + "'.");
return new ExtractSuggestedService(serviceToExtract.get(), newBoundedContextName.getAsString());
}
use of org.contextmapper.dsl.refactoring.ExtractSuggestedService in project context-mapper-dsl by ContextMapper.
the class ExtractSuggestedServiceAction method getCommand.
@Override
public Command getCommand() {
BoundedContext bc = getSelectedSystemBoundedContext();
List<Object> commandArguments = Lists.newLinkedList();
URI originalURI = new ExtractSuggestedService(bc, "NoNameBC").constructOriginalModelUri();
commandArguments.add(originalURI.toString());
commandArguments.add(cmlResource.getURI().toString());
commandArguments.add(bc.getName());
return new Command("Extract Suggested Service in Original Model", "cml.ar.extractSuggestedService.proxy", commandArguments);
}
Aggregations