Search in sources :

Example 6 with Service

use of org.contextmapper.tactic.dsl.tacticdsl.Service in project context-mapper-dsl by ContextMapper.

the class AbstractPlantUMLClassDiagramCreator method printModule.

protected void printModule(SculptorModule module) {
    sb.append("package ");
    if (module.getBasePackage() != null && !"".equals(module.getBasePackage()))
        sb.append(module.getBasePackage()).append(".").append(module.getName());
    else
        sb.append(module.getName());
    sb.append(" {");
    linebreak();
    for (Aggregate aggregate : module.getAggregates()) {
        printAggregate(aggregate, 1);
    }
    for (SimpleDomainObject simpleDomainObject : module.getDomainObjects()) {
        printDomainObject(simpleDomainObject, 1);
    }
    for (Service service : module.getServices()) {
        printService(service, 1);
    }
    sb.append("}");
    linebreak();
}
Also used : SimpleDomainObject(org.contextmapper.tactic.dsl.tacticdsl.SimpleDomainObject) Service(org.contextmapper.tactic.dsl.tacticdsl.Service) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate)

Example 7 with Service

use of org.contextmapper.tactic.dsl.tacticdsl.Service in project context-mapper-dsl by ContextMapper.

the class PlantUMLBoundedContextClassDiagramCreator method printApplication.

private void printApplication(Application application, int indentation) {
    printIndentation(indentation);
    String name = StringUtils.isNotEmpty(application.getName()) ? application.getName() : "Application";
    sb.append("package ").append("\"'").append(name).append("'").append("\"").append(" <<Rectangle>> ").append("{");
    linebreak();
    if (!application.getFlows().isEmpty()) {
        printIndentation(indentation + 1);
        sb.append("legend left");
        linebreak();
        printIndentation(indentation + 2);
        sb.append("This application layer contains flow definitions (visualization available via BPMN Sketch Miner).");
        linebreak();
        printIndentation(indentation + 1);
        sb.append("end legend");
        linebreak();
    }
    for (DomainEvent event : application.getEvents()) {
        printDomainObject(event, indentation + 1);
    }
    for (CommandEvent command : application.getCommands()) {
        printDomainObject(command, indentation + 1);
    }
    for (Service service : application.getServices()) {
        printService(service, indentation + 1);
    }
    printIndentation(indentation);
    sb.append("}");
    linebreak();
}
Also used : DomainEvent(org.contextmapper.tactic.dsl.tacticdsl.DomainEvent) CommandEvent(org.contextmapper.tactic.dsl.tacticdsl.CommandEvent) Service(org.contextmapper.tactic.dsl.tacticdsl.Service)

Example 8 with Service

use of org.contextmapper.tactic.dsl.tacticdsl.Service in project context-mapper-dsl by ContextMapper.

the class DeriveBoundedContextFromSubdomains method copyAndEnhanceOperations.

private void copyAndEnhanceOperations(Aggregate aggregate, Service source, Service target) {
    Set<String> existingOperations = target.getOperations().stream().map(o -> o.getName()).collect(Collectors.toSet());
    for (ServiceOperation sourceOperation : source.getOperations()) {
        if (existingOperations.contains(sourceOperation.getName()))
            continue;
        ServiceOperation targetOperation = TacticdslFactory.eINSTANCE.createServiceOperation();
        targetOperation.setName(sourceOperation.getName());
        targetOperation.setDelegateHolder(sourceOperation.getDelegateHolder());
        targetOperation.setHint(sourceOperation.getHint());
        targetOperation.setDoc(sourceOperation.getDoc());
        targetOperation.setPublish(sourceOperation.getPublish());
        targetOperation.setThrows(sourceOperation.getThrows());
        targetOperation.setVisibility(sourceOperation.getVisibility());
        if (sourceOperation.getReturnType() == null)
            targetOperation.setReturnType(getReturnType4Operation(aggregate, sourceOperation.getName()));
        if (sourceOperation.getParameters().isEmpty()) {
            ComplexType parameterType = getParameterType4Operation(aggregate, sourceOperation.getName());
            addElementToEList(targetOperation.getParameters(), createParameter(getParameterName4ComplexType(parameterType), parameterType));
        }
        addElementToEList(target.getOperations(), targetOperation);
    }
}
Also used : Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) SimpleDomainObject(org.contextmapper.tactic.dsl.tacticdsl.SimpleDomainObject) CollectionType(org.contextmapper.tactic.dsl.tacticdsl.CollectionType) BoundedContextType(org.contextmapper.dsl.contextMappingDSL.BoundedContextType) Domain(org.contextmapper.dsl.contextMappingDSL.Domain) Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) Service(org.contextmapper.tactic.dsl.tacticdsl.Service) Feature(org.contextmapper.dsl.contextMappingDSL.Feature) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) Set(java.util.Set) ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) IteratorExtensions(org.eclipse.xtext.xbase.lib.IteratorExtensions) CMLModelObjectsResolvingHelper(org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper) RefactoringInputException(org.contextmapper.dsl.refactoring.exception.RefactoringInputException) Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation) List(java.util.List) DomainPart(org.contextmapper.dsl.contextMappingDSL.DomainPart) Optional(java.util.Optional) SculptorModule(org.contextmapper.dsl.contextMappingDSL.SculptorModule) TacticdslFactory(org.contextmapper.tactic.dsl.tacticdsl.TacticdslFactory) ContextMappingDSLFactory(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory) Subdomain(org.contextmapper.dsl.contextMappingDSL.Subdomain) Reference(org.contextmapper.tactic.dsl.tacticdsl.Reference) ContextMapperApplicationException(org.contextmapper.dsl.exception.ContextMapperApplicationException) Parameter(org.contextmapper.tactic.dsl.tacticdsl.Parameter) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation) ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType)

Example 9 with Service

use of org.contextmapper.tactic.dsl.tacticdsl.Service in project context-mapper-dsl by ContextMapper.

the class DeriveSubdomainFromUserRequirements method deriveSubdomainEntities4Features.

private void deriveSubdomainEntities4Features(Subdomain subdomain, String urName, List<Feature> features) {
    for (Feature feature : features) {
        if (feature.getEntity() == null || "".equals(feature.getEntity()))
            continue;
        // create the entity
        String entityName = createEntityIfNotExisting(feature.getEntity(), subdomain, feature.getEntityAttributes());
        // create the service
        String serviceName = urName.substring(0, 1).toUpperCase() + urName.substring(1) + "Service";
        Optional<Service> alreadyExistingService = subdomain.getServices().stream().filter(s -> serviceName.equals(s.getName())).findFirst();
        Service service;
        if (!alreadyExistingService.isPresent()) {
            service = createService(serviceName, entityName, feature.getVerb());
            addElementToEList(subdomain.getServices(), service);
        } else {
            service = alreadyExistingService.get();
        }
        String operationName = feature.getVerb().replace(" ", "_") + entityName;
        Optional<ServiceOperation> alreadyExistingServiceOperation = service.getOperations().stream().filter(o -> operationName.equals(o.getName())).findFirst();
        if (!alreadyExistingServiceOperation.isPresent())
            addElementToEList(service.getOperations(), createServiceOperation(operationName));
        // create the entity that contains the one created above
        if (feature.getContainerEntity() != null && !"".equals(feature.getContainerEntity()))
            createEntityIfNotExisting(feature.getContainerEntity(), subdomain, Lists.newLinkedList());
    }
}
Also used : Arrays(java.util.Arrays) Service(org.contextmapper.tactic.dsl.tacticdsl.Service) Feature(org.contextmapper.dsl.contextMappingDSL.Feature) Set(java.util.Set) CollectionType(org.contextmapper.tactic.dsl.tacticdsl.CollectionType) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) RefactoringInputException(org.contextmapper.dsl.refactoring.exception.RefactoringInputException) Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation) List(java.util.List) Domain(org.contextmapper.dsl.contextMappingDSL.Domain) UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) Lists(com.google.common.collect.Lists) Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity) Optional(java.util.Optional) TacticdslFactory(org.contextmapper.tactic.dsl.tacticdsl.TacticdslFactory) ContextMappingDSLFactory(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory) Subdomain(org.contextmapper.dsl.contextMappingDSL.Subdomain) Reference(org.contextmapper.tactic.dsl.tacticdsl.Reference) Service(org.contextmapper.tactic.dsl.tacticdsl.Service) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation) Feature(org.contextmapper.dsl.contextMappingDSL.Feature)

Example 10 with Service

use of org.contextmapper.tactic.dsl.tacticdsl.Service in project context-mapper-dsl by ContextMapper.

the class DeriveSubdomainFromUserRequirements method createService.

private Service createService(String serviceName, String entityName, String verb) {
    Service service = TacticdslFactory.eINSTANCE.createService();
    service.setName(serviceName);
    return service;
}
Also used : Service(org.contextmapper.tactic.dsl.tacticdsl.Service)

Aggregations

Service (org.contextmapper.tactic.dsl.tacticdsl.Service)15 ServiceOperation (org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation)7 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)6 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)6 Parameter (org.contextmapper.tactic.dsl.tacticdsl.Parameter)5 Sets (com.google.common.collect.Sets)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 CMLResource (org.contextmapper.dsl.cml.CMLResource)4 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)4 Domain (org.contextmapper.dsl.contextMappingDSL.Domain)4 Subdomain (org.contextmapper.dsl.contextMappingDSL.Subdomain)4 RefactoringInputException (org.contextmapper.dsl.refactoring.exception.RefactoringInputException)4 Attribute (org.contextmapper.tactic.dsl.tacticdsl.Attribute)4 CollectionType (org.contextmapper.tactic.dsl.tacticdsl.CollectionType)4 Entity (org.contextmapper.tactic.dsl.tacticdsl.Entity)4 Reference (org.contextmapper.tactic.dsl.tacticdsl.Reference)4 SimpleDomainObject (org.contextmapper.tactic.dsl.tacticdsl.SimpleDomainObject)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 ValueSource (org.junit.jupiter.params.provider.ValueSource)4