use of org.contextmapper.tactic.dsl.tacticdsl.StateTransition in project context-mapper-dsl by ContextMapper.
the class TacticDDDOperationsValidator method validateOperationStates.
private void validateOperationStates(EObject operation, StateTransition stateTransition) {
if (stateTransition == null)
return;
CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(operation));
Aggregate aggregate = helper.resolveAggregate(operation);
if (aggregate == null)
return;
Set<String> aggregateStates = helper.resolveAggregateStates(aggregate);
for (EnumValue value : stateTransition.getFrom()) {
if (!aggregateStates.contains(value.getName()))
error(String.format(STATE_VALUE_DOES_NOT_BELONG_TO_AGGREGATE, value.getName(), aggregate.getName()), stateTransition, TacticdslPackage.Literals.STATE_TRANSITION__FROM, stateTransition.getFrom().indexOf(value));
}
for (EnumValue value : stateTransition.getTarget().getTo().stream().map(s -> s.getValue()).collect(Collectors.toList())) {
if (!aggregateStates.contains(value.getName()))
error(String.format(STATE_VALUE_DOES_NOT_BELONG_TO_AGGREGATE, value.getName(), aggregate.getName()), stateTransition.getTarget(), TacticdslPackage.Literals.STATE_TRANSITION_TARGET__TO, stateTransition.getTarget().getTo().indexOf(value));
}
}
use of org.contextmapper.tactic.dsl.tacticdsl.StateTransition in project context-mapper-dsl by ContextMapper.
the class PlantUMLGenerator method getAggregatesWithStatesAndTransitions.
private List<Aggregate> getAggregatesWithStatesAndTransitions(BoundedContext bc) {
List<Aggregate> aggregates = Lists.newLinkedList();
for (Aggregate aggregate : EcoreUtil2.eAllOfType(bc, Aggregate.class)) {
Optional<org.contextmapper.tactic.dsl.tacticdsl.Enum> statesEnum = EcoreUtil2.eAllOfType(aggregate, org.contextmapper.tactic.dsl.tacticdsl.Enum.class).stream().filter(e -> e.isDefinesAggregateLifecycle()).findFirst();
if (!statesEnum.isPresent())
continue;
List<StateTransition> stateTransitions = EcoreUtil2.eAllOfType(aggregate, StateTransition.class);
if (!stateTransitions.isEmpty())
aggregates.add(aggregate);
}
return aggregates;
}
use of org.contextmapper.tactic.dsl.tacticdsl.StateTransition 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.StateTransition in project context-mapper-dsl by ContextMapper.
the class PlantUMLStateDiagramCreator4Flow method printDiagramContent.
@Override
protected void printDiagramContent(Flow flow) {
List<DomainEventProductionStep> eventProductionStepsWithStateTransitions = flow.getSteps().stream().filter(s -> s instanceof DomainEventProductionStep).map(s -> (DomainEventProductionStep) s).filter(s -> s.getStateTransition() != null).collect(Collectors.toList());
List<StateTransition> allStateTransitions = eventProductionStepsWithStateTransitions.stream().map(s -> s.getStateTransition()).collect(Collectors.toList());
for (String state : collectStates(allStateTransitions)) {
printState(state);
}
for (DomainEventProductionStep step : eventProductionStepsWithStateTransitions) printTransition(step.getStateTransition(), step.getAction().getCommand() != null ? step.getAction().getCommand().getName() : step.getAction().getOperation().getName());
linebreak(2);
sb.append("legend top center");
linebreak();
sb.append(" " + flow.getName() + " State Transitions");
linebreak();
sb.append("endlegend");
}
use of org.contextmapper.tactic.dsl.tacticdsl.StateTransition in project context-mapper-dsl by ContextMapper.
the class AbstractPlantUMLStateDiagramCreator method collectStates.
protected Set<String> collectStates(List<StateTransition> transitions) {
Set<String> states = Sets.newHashSet();
for (StateTransition transition : transitions) {
states.addAll(mapStatesToStrings(transition.getFrom()));
states.addAll(mapStatesToStrings(transition.getTarget().getTo().stream().map(s -> s.getValue()).collect(Collectors.toList())));
}
return states;
}
Aggregations