use of org.contextmapper.tactic.dsl.tacticdsl.Reference in project context-mapper-dsl by ContextMapper.
the class ContextMappingModelToServiceCutterERDConverter method mapDomainObject.
private Entity mapDomainObject(DomainObject dslDomainObject) {
Entity entityEntity = getEntity(dslDomainObject.getName());
entityEntity.setNanoentities(new ArrayList<>());
for (Attribute attribute : dslDomainObject.getAttributes()) {
entityEntity.getNanoentities().add(attribute.getName());
}
for (Reference reference : dslDomainObject.getReferences()) {
entityEntity.getNanoentities().add(reference.getName());
}
target.getEntities().add(entityEntity);
return entityEntity;
}
use of org.contextmapper.tactic.dsl.tacticdsl.Reference in project context-mapper-dsl by ContextMapper.
the class AbstractPlantUMLClassDiagramCreator method printReferenceAttributes.
private void printReferenceAttributes(List<Reference> references, int indentation) {
for (Reference reference : references) {
printIndentation(indentation);
sb.append(getReferenceTypeAsString(reference));
if (reference.isNullable())
sb.append("[0..1]");
sb.append(" ").append(reference.getName());
linebreak();
}
}
use of org.contextmapper.tactic.dsl.tacticdsl.Reference in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirementsTest method canCreateContainmentReference.
@ParameterizedTest
@ValueSource(strings = { "derive-subdomain-from-user-story-test-9-input.cml", "derive-subdomain-from-user-story-test-12-input.cml" })
public void canCreateContainmentReference(String inputFile) throws IOException {
// given
CMLResource input = getResourceCopyOfTestCML(inputFile);
// when
Set<String> userStories = Sets.newHashSet(Arrays.asList(new String[] { "US1_Create" }));
DeriveSubdomainFromUserRequirements ar = new DeriveSubdomainFromUserRequirements("InsuranceDomain", "Customers", userStories);
ar.refactor(input);
ar.persistChanges(serializer);
// then
ContextMappingModel model = reloadResource(input).getContextMappingModel();
Subdomain subdomain = model.getDomains().get(0).getSubdomains().get(0);
assertNotNull(subdomain);
Entity customerEntity = subdomain.getEntities().stream().filter(e -> e.getName().equals("Customer")).findFirst().get();
assertNotNull(customerEntity);
assertEquals(1, customerEntity.getReferences().size());
Reference addressReference = customerEntity.getReferences().stream().filter(r -> r.getName().equals("addressList")).findFirst().get();
assertNotNull(addressReference);
assertEquals(CollectionType.LIST, addressReference.getCollectionType());
assertEquals("Address", addressReference.getDomainObjectType().getName());
}
use of org.contextmapper.tactic.dsl.tacticdsl.Reference in project context-mapper-dsl by ContextMapper.
the class PlantUMLBoundedContextClassDiagramCreatorTest method respectNullableOnReferences.
@Test
public void respectNullableOnReferences() {
// 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");
Entity referencedEntity = TacticdslFactory.eINSTANCE.createEntity();
referencedEntity.setName("ReferencedEntity");
Reference reference = TacticdslFactory.eINSTANCE.createReference();
reference.setName("otherEntity");
reference.setDomainObjectType(referencedEntity);
reference.setNullable(true);
entity.getReferences().add(reference);
aggregate.getDomainObjects().add(entity);
aggregate.getDomainObjects().add(referencedEntity);
// when
String plantUML = this.creator.createDiagram(boundedContext);
// then
assertTrue(plantUML.contains(" class Test <<(E,DarkSeaGreen) Entity>> {" + System.lineSeparator() + " ReferencedEntity[0..1] otherEntity" + System.lineSeparator() + " }" + System.lineSeparator()));
}
use of org.contextmapper.tactic.dsl.tacticdsl.Reference in project context-mapper-dsl by ContextMapper.
the class ExtractSuggestedService method findReferenceInOriginalModel.
private Reference findReferenceInOriginalModel(Reference serviceCutReference) {
if (!(serviceCutReference.eContainer() instanceof DomainObject))
throw new ContextMapperApplicationException("We unexpectedly found references that are not contained by 'DomainObject' objects. We currently only support Entities, ValueObjects and Events here.");
String domainObjectName = ((DomainObject) serviceCutReference.eContainer()).getName();
String attributeName = serviceCutReference.getName();
for (Reference reference : EcoreUtil2.eAllOfType(model, Reference.class).stream().filter(r -> r.getName().equals(attributeName)).collect(Collectors.toList())) {
if (reference.eContainer() instanceof DomainObject && ((DomainObject) reference.eContainer()).getName().equals(domainObjectName))
return reference;
}
return null;
}
Aggregations