use of org.contextmapper.tactic.dsl.tacticdsl.EnumValue 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.EnumValue in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreatorTest method canCreateEnum.
@Test
public void canCreateEnum() {
// given
BoundedContext boundedContext = ContextMappingDSLFactory.eINSTANCE.createBoundedContext();
Aggregate aggregate = ContextMappingDSLFactory.eINSTANCE.createAggregate();
aggregate.setName("testAggregate");
boundedContext.getAggregates().add(aggregate);
Enum enumm = TacticdslFactory.eINSTANCE.createEnum();
enumm.setName("TestType");
EnumValue value1 = TacticdslFactory.eINSTANCE.createEnumValue();
value1.setName("VAL1");
EnumValue value2 = TacticdslFactory.eINSTANCE.createEnumValue();
value2.setName("VAL2");
enumm.getValues().add(value1);
enumm.getValues().add(value2);
aggregate.getDomainObjects().add(enumm);
// when
String plantUML = this.creator.createDiagram(boundedContext);
// then
assertTrue(plantUML.contains(" enum TestType {" + System.lineSeparator() + " VAL1" + System.lineSeparator() + " VAL2" + System.lineSeparator() + " }" + System.lineSeparator()));
}
use of org.contextmapper.tactic.dsl.tacticdsl.EnumValue in project context-mapper-dsl by ContextMapper.
the class AbstractPlantUMLClassDiagramCreator method printEnum.
private void printEnum(Enum theEnum, int indentation) {
printIndentation(indentation);
sb.append("enum").append(" ").append(theEnum.getName()).append(" {");
linebreak();
for (EnumValue value : theEnum.getValues()) {
printIndentation(indentation + 1);
sb.append(value.getName());
linebreak();
}
printIndentation(indentation);
sb.append("}");
linebreak();
}
use of org.contextmapper.tactic.dsl.tacticdsl.EnumValue in project context-mapper-dsl by ContextMapper.
the class MDSLDataTypeCreator method createAttributesForEnum.
private List<DataTypeAttribute> createAttributesForEnum(Enum enumm) {
List<DataTypeAttribute> attributes = new ArrayList<>();
for (EnumValue value : enumm.getValues()) {
DataTypeAttribute attribute = new DataTypeAttribute();
attribute.setName(mdslNameEncoder.encodeName(value.getName()));
attribute.setType(mdslNameEncoder.encodeName(enumm.getName()));
attributes.add(attribute);
}
return attributes;
}
use of org.contextmapper.tactic.dsl.tacticdsl.EnumValue 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