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;
}
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");
}
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()));
}
Aggregations