use of org.contextmapper.dsl.validation.ValidationMessages.STATE_VALUE_DOES_NOT_BELONG_TO_AGGREGATE 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.dsl.validation.ValidationMessages.STATE_VALUE_DOES_NOT_BELONG_TO_AGGREGATE in project context-mapper-dsl by ContextMapper.
the class ApplicationFlowSemanticsValidator method checkThatStateTransitionStatesBelongToAggregate.
@Check
public void checkThatStateTransitionStatesBelongToAggregate(final DomainEventProductionStep step) {
if (step.getAggregate() == null)
return;
if (step.getStateTransition() == null)
return;
CMLModelObjectsResolvingHelper helper = new CMLModelObjectsResolvingHelper((ContextMappingModel) EcoreUtil2.getRootContainer(step));
Set<String> aggregateStates = helper.resolveAggregateStates(step.getAggregate());
for (EnumValue value : step.getStateTransition().getFrom()) {
if (!aggregateStates.contains(value.getName()))
error(String.format(STATE_VALUE_DOES_NOT_BELONG_TO_AGGREGATE, value.getName(), step.getAggregate().getName()), step.getStateTransition(), TacticdslPackage.Literals.STATE_TRANSITION__FROM, step.getStateTransition().getFrom().indexOf(value));
}
for (EnumValue value : step.getStateTransition().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(), step.getAggregate().getName()), step.getStateTransition().getTarget(), TacticdslPackage.Literals.STATE_TRANSITION_TARGET__TO, step.getStateTransition().getTarget().getTo().indexOf(value));
}
}
Aggregations