Search in sources :

Example 1 with DeriveSubdomainFromUserRequirements

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();
}
Also used : ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) DeriveSubdomainsFromRequirementsWizard(org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsWizard) Set(java.util.Set) DeriveSubdomainsFromRequirementsContext(org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsContext) EObject(org.eclipse.emf.ecore.EObject) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) HandlerUtil(org.eclipse.ui.handlers.HandlerUtil) DeriveSubdomainFromUserRequirements(org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements) List(java.util.List) Domain(org.contextmapper.dsl.contextMappingDSL.Domain) UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Map(java.util.Map) CMLResource(org.contextmapper.dsl.cml.CMLResource) DeriveSubdomainsFromRequirementsContext(org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsContext) UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) DeriveSubdomainFromUserRequirements(org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements) DeriveSubdomainsFromRequirementsWizard(org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with DeriveSubdomainFromUserRequirements

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

Example 3 with DeriveSubdomainFromUserRequirements

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);
    });
}
Also used : SemanticCMLRefactoring(org.contextmapper.dsl.refactoring.SemanticCMLRefactoring) DeriveSubdomainFromUserRequirements(org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements) CMLResource(org.contextmapper.dsl.cml.CMLResource) Test(org.junit.jupiter.api.Test) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest)

Aggregations

DeriveSubdomainFromUserRequirements (org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements)3 CMLResource (org.contextmapper.dsl.cml.CMLResource)2 Maps (com.google.common.collect.Maps)1 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 Domain (org.contextmapper.dsl.contextMappingDSL.Domain)1 UserRequirement (org.contextmapper.dsl.contextMappingDSL.UserRequirement)1 SemanticCMLRefactoring (org.contextmapper.dsl.refactoring.SemanticCMLRefactoring)1 DeriveSubdomainsFromRequirementsContext (org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsContext)1 DeriveSubdomainsFromRequirementsWizard (org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsWizard)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1 EObject (org.eclipse.emf.ecore.EObject)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1