use of ch.hsr.servicecutter.api.model.Service in project context-mapper-dsl by ContextMapper.
the class ServiceCutterOutputToContextMappingModelConverter method reconstructReference.
private void reconstructReference(DomainObject sourceObject, Reference originalReference, String targetTypeName) {
BoundedContext parentBC = new CMLModelObjectsResolvingHelper(originalModelState).resolveBoundedContext(sourceObject);
if (parentBC == null)
// in case this source object is not part of a Bounded Context
return;
List<DomainObject> targetDomainObjects = EcoreUtil2.eAllOfType(model, DomainObject.class).stream().filter(obj -> obj.getName().equals(targetTypeName)).collect(Collectors.toList());
if (targetDomainObjects.size() == 1) {
Reference reference = TacticdslFactory.eINSTANCE.createReference();
reference.setName(originalReference.getName());
reference.setDomainObjectType(targetDomainObjects.get(0));
reference.setCollectionType(originalReference.getCollectionType());
reference.setDoc(originalReference.getDoc());
sourceObject.getReferences().add(reference);
} else {
sourceObject.setComment("/* Service Cut generator: it was not possible to reconstruct the reference '" + originalReference.getName() + "' from " + sourceObject.getName() + " to " + targetTypeName + ". Please re-create that reference manually. */");
}
}
use of ch.hsr.servicecutter.api.model.Service in project context-mapper-dsl by ContextMapper.
the class ServiceCutterOutputToContextMappingModelConverter method convert.
public ContextMappingModel convert(SolverResult serviceCutterResult) {
model = contextMappingFactory.createContextMappingModel();
ContextMap contextMap = contextMappingFactory.createContextMap();
if (originalModelState != null && originalModelState.getMap() != null) {
contextMap.setName(originalModelState.getMap().getName());
contextMap.setState(originalModelState.getMap().getState());
contextMap.setType(originalModelState.getMap().getType());
}
for (Service service : serviceCutterResult.getServices()) {
BoundedContext bc = createOrGetBoundedContext(service.getName());
bc.setComment(generateBCComment(service));
Aggregate aggregate = contextMappingFactory.createAggregate();
aggregate.setName("Aggregate_" + service.getId());
aggregate.getDomainObjects().addAll(convertEntities(service.getId(), service.getNanoentities()));
bc.getAggregates().add(aggregate);
model.getBoundedContexts().add(bc);
contextMap.getBoundedContexts().add(bc);
}
contextMap.getRelationships().addAll(convertRelationships(serviceCutterResult.getRelations()));
model.setMap(contextMap);
reconstructReferencesIfPossible();
copyRootElementsNotAffected();
model.setTopComment(generateTopComment());
return model;
}
Aggregations