Search in sources :

Example 1 with UserRequirement

use of org.contextmapper.dsl.contextMappingDSL.UserRequirement 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 UserRequirement

use of org.contextmapper.dsl.contextMappingDSL.UserRequirement in project context-mapper-dsl by ContextMapper.

the class CMLModelObjectsResolvingHelper method resolveUserRequirements.

public Set<UserRequirement> resolveUserRequirements(BoundedContext boundedContext) {
    Set<UserRequirement> requirements = Sets.newHashSet();
    for (DomainPart domainPart : boundedContext.getImplementedDomainParts()) {
        if (!(domainPart instanceof Subdomain))
            continue;
        Subdomain subdomain = (Subdomain) domainPart;
        requirements.addAll(subdomain.getSupportedFeatures());
    }
    return requirements;
}
Also used : UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) Subdomain(org.contextmapper.dsl.contextMappingDSL.Subdomain) DomainPart(org.contextmapper.dsl.contextMappingDSL.DomainPart)

Example 3 with UserRequirement

use of org.contextmapper.dsl.contextMappingDSL.UserRequirement in project context-mapper-dsl by ContextMapper.

the class SplitStoryByVerbCommand method getSubject.

@Override
protected EObject getSubject(CMLResource cmlResource, ExecuteCommandParams params) {
    JsonArray quickFixParams = (JsonArray) params.getArguments().get(1);
    JsonPrimitive storyName = (JsonPrimitive) quickFixParams.get(0);
    UserRequirement story = cmlResource.getContextMappingModel().getUserRequirements().stream().filter(ur -> ur.getName().equals(storyName.getAsString())).findFirst().get();
    if (story.getFeatures().size() != 1)
        throw new ContextMapperApplicationException("Wrong validation implementation! This quickfix is only applicable to user stories with one and only one 'I want to' parts (features).");
    return story.getFeatures().get(0);
}
Also used : JsonArray(com.google.gson.JsonArray) UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) JsonPrimitive(com.google.gson.JsonPrimitive) ContextMapperApplicationException(org.contextmapper.dsl.exception.ContextMapperApplicationException)

Example 4 with UserRequirement

use of org.contextmapper.dsl.contextMappingDSL.UserRequirement in project context-mapper-dsl by ContextMapper.

the class ServiceCutterOutputToContextMappingModelConverter method reconstructSubdomainToFeatureReferences.

private void reconstructSubdomainToFeatureReferences(Subdomain subDomain) {
    List<UserRequirement> urReferences = Lists.newLinkedList();
    for (UserRequirement ur : subDomain.getSupportedFeatures()) urReferences.add(model.getUserRequirements().stream().filter(u -> u.getName().equals(ur.getName())).findFirst().get());
    subDomain.getSupportedFeatures().clear();
    subDomain.getSupportedFeatures().addAll(urReferences);
}
Also used : UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement)

Example 5 with UserRequirement

use of org.contextmapper.dsl.contextMappingDSL.UserRequirement in project context-mapper-dsl by ContextMapper.

the class UserRepresentationsBuilder method buildUseCases.

private void buildUseCases() {
    model.getUseCases().clear();
    for (UserRequirement ur : contextMappingModel.getUserRequirements()) {
        Set<String> nanoEntitiesRead = new NanoentityCollector().getNanoentitiesRead(ur);
        Set<String> nanoEntitiesWritten = new NanoentityCollector().getNanoentitiesWritten(ur);
        if (nanoEntitiesRead.isEmpty() && nanoEntitiesWritten.isEmpty())
            continue;
        // create one use case for each user requirement in CML (use case or user story
        // in CML)
        UseCase uc = factory.createUseCase();
        uc.setName(ur.getName());
        uc.getNanoentitiesRead().addAll(nanoEntitiesRead);
        uc.getNanoentitiesWritten().addAll(nanoEntitiesWritten);
        model.getUseCases().add(uc);
    }
}
Also used : UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) UseCase(org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase)

Aggregations

UserRequirement (org.contextmapper.dsl.contextMappingDSL.UserRequirement)6 Domain (org.contextmapper.dsl.contextMappingDSL.Domain)2 Subdomain (org.contextmapper.dsl.contextMappingDSL.Subdomain)2 Maps (com.google.common.collect.Maps)1 JsonArray (com.google.gson.JsonArray)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 CMLResource (org.contextmapper.dsl.cml.CMLResource)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 DomainPart (org.contextmapper.dsl.contextMappingDSL.DomainPart)1 ContextMapperApplicationException (org.contextmapper.dsl.exception.ContextMapperApplicationException)1 DeriveSubdomainFromUserRequirements (org.contextmapper.dsl.refactoring.DeriveSubdomainFromUserRequirements)1 RefactoringInputException (org.contextmapper.dsl.refactoring.exception.RefactoringInputException)1 DeriveSubdomainsFromRequirementsContext (org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsContext)1 DeriveSubdomainsFromRequirementsWizard (org.contextmapper.dsl.ui.handler.wizard.DeriveSubdomainsFromRequirementsWizard)1 UseCase (org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.UseCase)1 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)1