use of org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements in project context-mapper-dsl by ContextMapper.
the class GenerateSubdomainFromUserRequirementsRefactoringHandler method executeRefactoring.
@Override
protected void executeRefactoring(CMLResource resource, ExecutionEvent event) {
Set<UserRequirement> userRequirements = getAllSelectedElements().stream().filter(o -> o instanceof UserRequirement).map(o -> (UserRequirement) o).collect(Collectors.toSet());
List<String> allDomains = getCurrentContextMappingModel().getDomains().stream().map(d -> d.getName()).collect(Collectors.toList());
String initialDomain = allDomains.isEmpty() ? "" : allDomains.iterator().next();
DeriveSubdomainsFromRequirementsContext refactoringContext = new DeriveSubdomainsFromRequirementsContext(initialDomain, collectAllDomainsAndSubdomains(getCurrentContextMappingModel()));
new WizardDialog(HandlerUtil.getActiveShell(event), new DeriveSubdomainsFromRequirementsWizard(refactoringContext, executionContext -> {
return finishRefactoring(new DeriveSubdomainFromUserRequirements(executionContext.getDomainName(), executionContext.getSubdomainName(), userRequirements.stream().map(ur -> ur.getName()).collect(Collectors.toSet())), resource, event);
})).open();
}
use of org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirementsCommand method getRefactoring.
@Override
protected SemanticCMLRefactoring getRefactoring(ExecuteCommandParams params) {
JsonArray refactoringParams = (JsonArray) params.getArguments().get(1);
JsonPrimitive domainName = (JsonPrimitive) refactoringParams.get(0);
JsonPrimitive subDomainName = (JsonPrimitive) refactoringParams.get(1);
JsonArray selectedRequirementsArray = (JsonArray) refactoringParams.get(2);
Set<String> selectedRequirements = Sets.newHashSet();
for (JsonElement element : selectedRequirementsArray) {
selectedRequirements.add(element.getAsString());
}
return new DeriveSubdomainFromUserRequirements(domainName.getAsString(), subDomainName.getAsString(), selectedRequirements);
}
use of org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements in project context-mapper-dsl by ContextMapper.
the class RefactoringSerializationExceptionTest method canHandleNoEObjectDescriptionSerializationError.
@Test
public void canHandleNoEObjectDescriptionSerializationError() throws IOException {
// given
CMLResource cmlResource = getResourceCopyOfTestCML("NoEObjectDescriptionExceptionTest.cml");
Set<String> userStories = Sets.newHashSet();
userStories.add("UC1Ads");
SemanticCMLRefactoring ar = new DeriveSubdomainFromUserRequirements("TestDomain", "TestSubdomain", userStories);
// when, then
assertThrows(RefactoringSerializationException.class, () -> {
ar.refactor(cmlResource);
ar.persistChanges(serializer);
});
}
Aggregations