Search in sources :

Example 1 with DomainObjectOperation

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

the class MDSLModelCreator method createEndpoint.

private EndpointContract createEndpoint(Aggregate aggregate, ServiceSpecification specification) {
    EndpointContract endpoint = new EndpointContract();
    String endpointName = mdslEncoder.encodeName(aggregate.getName());
    endpoint.setName(endpointName);
    Optional<DomainObject> aggregateRoot = aggregate.getDomainObjects().stream().filter(o -> o instanceof DomainObject).map(o -> (DomainObject) o).filter(o -> o.isAggregateRoot()).findFirst();
    if (aggregateRoot.isPresent()) {
        for (DomainObjectOperation operation : aggregateRoot.get().getOperations()) {
            if (operation.getVisibility().equals(Visibility.PUBLIC))
                endpoint.addOperation(createOperation(operation, specification));
        }
    }
    List<ServiceOperation> serviceOperations = aggregate.getServices().stream().flatMap(s -> s.getOperations().stream()).collect(Collectors.toList());
    for (ServiceOperation serviceOperation : serviceOperations) {
        if (serviceOperation.getVisibility().equals(Visibility.PUBLIC))
            endpoint.addOperation(createOperation(serviceOperation, specification));
    }
    setEndpointServesAsString(endpoint, aggregate.getDoc());
    return endpoint;
}
Also used : EndpointClient(org.contextmapper.dsl.generator.mdsl.model.EndpointClient) EndpointOperation(org.contextmapper.dsl.generator.mdsl.model.EndpointOperation) ContextMappingModel(org.contextmapper.dsl.contextMappingDSL.ContextMappingModel) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) UpstreamRole(org.contextmapper.dsl.contextMappingDSL.UpstreamRole) EitherCommandOrOperationInvokation(org.contextmapper.dsl.contextMappingDSL.EitherCommandOrOperationInvokation) ServiceSpecification(org.contextmapper.dsl.generator.mdsl.model.ServiceSpecification) CollectionType(org.contextmapper.tactic.dsl.tacticdsl.CollectionType) StringUtils(org.apache.commons.lang3.StringUtils) SingleEventProduction(org.contextmapper.dsl.contextMappingDSL.SingleEventProduction) UpstreamDownstreamRelationship(org.contextmapper.dsl.contextMappingDSL.UpstreamDownstreamRelationship) InvalidParameterException(java.security.InvalidParameterException) EndpointOffer(org.contextmapper.dsl.generator.mdsl.model.EndpointOffer) Map(java.util.Map) DomainObjectOperation(org.contextmapper.tactic.dsl.tacticdsl.DomainObjectOperation) CommandInvokationStep(org.contextmapper.dsl.contextMappingDSL.CommandInvokationStep) ConcurrentCommandInvokation(org.contextmapper.dsl.contextMappingDSL.ConcurrentCommandInvokation) SingleCommandInvokation(org.contextmapper.dsl.contextMappingDSL.SingleCommandInvokation) EventProduction(org.contextmapper.dsl.contextMappingDSL.EventProduction) DomainEvent(org.contextmapper.tactic.dsl.tacticdsl.DomainEvent) MultipleEventProduction(org.contextmapper.dsl.contextMappingDSL.MultipleEventProduction) DownstreamContext(org.contextmapper.dsl.generator.mdsl.generatorcontext.DownstreamContext) Collectors(java.util.stream.Collectors) List(java.util.List) ExclusiveAlternativeCommandInvokation(org.contextmapper.dsl.contextMappingDSL.ExclusiveAlternativeCommandInvokation) APIUsageContext(org.contextmapper.dsl.generator.mdsl.model.APIUsageContext) Optional(java.util.Optional) TacticdslFactory(org.contextmapper.tactic.dsl.tacticdsl.TacticdslFactory) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) InclusiveAlternativeCommandInvokation(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeCommandInvokation) SimpleDomainObject(org.contextmapper.tactic.dsl.tacticdsl.SimpleDomainObject) EitherCommandOrOperation(org.contextmapper.dsl.contextMappingDSL.EitherCommandOrOperation) CommandEvent(org.contextmapper.tactic.dsl.tacticdsl.CommandEvent) Visibility(org.contextmapper.tactic.dsl.tacticdsl.Visibility) Lists(com.google.common.collect.Lists) DataType(org.contextmapper.dsl.generator.mdsl.model.DataType) UpstreamAPIContext(org.contextmapper.dsl.generator.mdsl.generatorcontext.UpstreamAPIContext) EndpointProvider(org.contextmapper.dsl.generator.mdsl.model.EndpointProvider) Application(org.contextmapper.dsl.contextMappingDSL.Application) ExclusiveAlternativeEventProduction(org.contextmapper.dsl.contextMappingDSL.ExclusiveAlternativeEventProduction) EndpointContract(org.contextmapper.dsl.generator.mdsl.model.EndpointContract) ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType) Maps(com.google.common.collect.Maps) EList(org.eclipse.emf.common.util.EList) FlowStep(org.contextmapper.dsl.contextMappingDSL.FlowStep) OrchestrationFlow(org.contextmapper.dsl.generator.mdsl.model.OrchestrationFlow) DomainObject(org.contextmapper.tactic.dsl.tacticdsl.DomainObject) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation) GeneratorInputException(org.contextmapper.dsl.generator.exception.GeneratorInputException) InclusiveAlternativeEventProduction(org.contextmapper.dsl.contextMappingDSL.InclusiveAlternativeEventProduction) DomainEventProductionStep(org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep) Flow(org.contextmapper.dsl.contextMappingDSL.Flow) Parameter(org.contextmapper.tactic.dsl.tacticdsl.Parameter) EndpointContract(org.contextmapper.dsl.generator.mdsl.model.EndpointContract) DomainObjectOperation(org.contextmapper.tactic.dsl.tacticdsl.DomainObjectOperation) SimpleDomainObject(org.contextmapper.tactic.dsl.tacticdsl.SimpleDomainObject) DomainObject(org.contextmapper.tactic.dsl.tacticdsl.DomainObject) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation)

Example 2 with DomainObjectOperation

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

the class PlantUMLStateDiagramCreator4Aggregate method printDiagramContent.

@Override
protected void printDiagramContent(Aggregate aggregate) {
    List<ServiceOperation> serviceOperationsWithStateTransitions = EcoreUtil2.eAllOfType(aggregate, ServiceOperation.class).stream().filter(o -> o.getStateTransition() != null).collect(Collectors.toList());
    List<DomainObjectOperation> domainObjectOperationsWithStateTransitions = EcoreUtil2.eAllOfType(aggregate, DomainObjectOperation.class).stream().filter(o -> o.getStateTransition() != null).collect(Collectors.toList());
    List<StateTransition> allStateTransitions = serviceOperationsWithStateTransitions.stream().map(o -> o.getStateTransition()).collect(Collectors.toList());
    allStateTransitions.addAll(domainObjectOperationsWithStateTransitions.stream().map(o -> o.getStateTransition()).collect(Collectors.toList()));
    for (String state : collectStates(allStateTransitions)) {
        printState(state);
    }
    for (ServiceOperation operation : serviceOperationsWithStateTransitions) printTransition(operation.getStateTransition(), operation.getName());
    for (DomainObjectOperation operation : domainObjectOperationsWithStateTransitions) printTransition(operation.getStateTransition(), operation.getName());
    linebreak(2);
    sb.append("legend top center");
    linebreak();
    sb.append("  " + aggregate.getName() + " Aggregate Lifecycle");
    linebreak();
    sb.append("endlegend");
}
Also used : ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation) List(java.util.List) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) DomainObjectOperation(org.contextmapper.tactic.dsl.tacticdsl.DomainObjectOperation) StateTransition(org.contextmapper.tactic.dsl.tacticdsl.StateTransition) Collectors(java.util.stream.Collectors) DomainObjectOperation(org.contextmapper.tactic.dsl.tacticdsl.DomainObjectOperation) StateTransition(org.contextmapper.tactic.dsl.tacticdsl.StateTransition) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation)

Example 3 with DomainObjectOperation

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

the class PlantUMLBoundedContextClassDiagramCreatorTest method canCreateMethodForDomainObjectOperations.

@Test
public void canCreateMethodForDomainObjectOperations() {
    // given
    BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
    Aggregate aggregate = ContextMappingDSLFactory.eINSTANCE.createAggregate();
    aggregate.setName("testAggregate");
    boundedContext.getAggregates().add(aggregate);
    Entity entity = TacticdslFactory.eINSTANCE.createEntity();
    entity.setName("Test");
    DomainObjectOperation operation = TacticdslFactory.eINSTANCE.createDomainObjectOperation();
    operation.setName("doSomething");
    ComplexType returnType = TacticdslFactory.eINSTANCE.createComplexType();
    returnType.setType("ReturnType");
    operation.setReturnType(returnType);
    ComplexType parameterTypeString = TacticdslFactory.eINSTANCE.createComplexType();
    parameterTypeString.setType("String");
    Parameter parameter = TacticdslFactory.eINSTANCE.createParameter();
    parameter.setName("someParameter");
    parameter.setParameterType(parameterTypeString);
    operation.getParameters().add(parameter);
    entity.getOperations().add(operation);
    aggregate.getDomainObjects().add(entity);
    // when
    String plantUML = this.creator.createDiagram(boundedContext);
    // then
    assertTrue(plantUML.contains("	class Test <<(E,DarkSeaGreen) Entity>> {" + System.lineSeparator() + "		ReturnType doSomething(String someParameter)" + System.lineSeparator() + "	}" + System.lineSeparator()));
}
Also used : Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity) DomainObjectOperation(org.contextmapper.tactic.dsl.tacticdsl.DomainObjectOperation) Parameter(org.contextmapper.tactic.dsl.tacticdsl.Parameter) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType) AbstractCMLInputFileTest(org.contextmapper.dsl.AbstractCMLInputFileTest) Test(org.junit.jupiter.api.Test)

Aggregations

Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)3 DomainObjectOperation (org.contextmapper.tactic.dsl.tacticdsl.DomainObjectOperation)3 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)2 ComplexType (org.contextmapper.tactic.dsl.tacticdsl.ComplexType)2 Parameter (org.contextmapper.tactic.dsl.tacticdsl.Parameter)2 ServiceOperation (org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation)2 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 InvalidParameterException (java.security.InvalidParameterException)1 Map (java.util.Map)1 Optional (java.util.Optional)1 StringUtils (org.apache.commons.lang3.StringUtils)1 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)1 Application (org.contextmapper.dsl.contextMappingDSL.Application)1 CommandInvokationStep (org.contextmapper.dsl.contextMappingDSL.CommandInvokationStep)1 ConcurrentCommandInvokation (org.contextmapper.dsl.contextMappingDSL.ConcurrentCommandInvokation)1 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)1 DomainEventProductionStep (org.contextmapper.dsl.contextMappingDSL.DomainEventProductionStep)1