use of org.contextmapper.tactic.dsl.tacticdsl.Entity in project context-mapper-dsl by ContextMapper.
the class ServiceCutterOutputToContextMappingModelConverter method createOrGetEntity.
private Entity createOrGetEntity(Map<String, Entity> entities, String entityName) {
if (entities.containsKey(entityName))
return entities.get(entityName);
Entity entity = TacticdslFactory.eINSTANCE.createEntity();
entity.setName(entityName);
entities.put(entityName, entity);
return entity;
}
use of org.contextmapper.tactic.dsl.tacticdsl.Entity in project context-mapper-dsl by ContextMapper.
the class UserRepresentationsBuilder method buildEntities.
private void buildEntities() {
model.getEntities().clear();
for (Entity entity : EcoreUtil2.eAllOfType(contextMappingModel, Entity.class)) {
org.contextmapper.servicecutter.dsl.serviceCutterConfigurationDSL.Entity scEntity = factory.createEntity();
scEntity.setName(entity.getName());
scEntity.getNanoentities().addAll(nanoentityResolver.getAllNanoentities(entity));
model.getEntities().add(scEntity);
}
if (!model.getEntities().isEmpty())
model.getEntities().get(0).setDoc("/* These Entities are generated from the CML model. Note that they are overwritten each time you use the service cut generator! */");
}
use of org.contextmapper.tactic.dsl.tacticdsl.Entity in project context-mapper-dsl by ContextMapper.
the class DeriveBoundedContextFromSubdomains method copyReferences.
private void copyReferences(Entity source, Entity target, List<SimpleDomainObject> referenceableObjects) {
Set<String> existingRefs = target.getReferences().stream().map(ref -> ref.getName()).collect(Collectors.toSet());
for (Reference sourceRef : source.getReferences()) {
if (existingRefs.contains(sourceRef.getName()))
continue;
Reference newReference = TacticdslFactory.eINSTANCE.createReference();
newReference.setName(sourceRef.getName());
newReference.setCollectionType(sourceRef.getCollectionType());
newReference.setDomainObjectType(referenceableObjects.stream().filter(o -> o.getName().equals(sourceRef.getDomainObjectType().getName())).findFirst().get());
addElementToEList(target.getReferences(), newReference);
}
}
use of org.contextmapper.tactic.dsl.tacticdsl.Entity in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirements method deriveSubdomainEntityReferences.
private void deriveSubdomainEntityReferences(Subdomain subdomain, List<Feature> features) {
for (Feature feature : features) {
if (feature.getContainerEntity() == null || "".equals(feature.getContainerEntity()))
continue;
String containerEntityName = mapEntityName(feature.getContainerEntity());
String referencedEntityName = mapEntityName(feature.getEntity());
Entity containerEntity = subdomain.getEntities().stream().filter(e -> e.getName().equals(containerEntityName)).findFirst().get();
Entity referencedEntity = subdomain.getEntities().stream().filter(e -> e.getName().equals(referencedEntityName)).findFirst().get();
String refName = referencedEntity.getName().toLowerCase() + "List";
if (containerEntity.getReferences().stream().filter(r -> r.getName().equals(refName)).findAny().isPresent())
continue;
Reference reference = TacticdslFactory.eINSTANCE.createReference();
reference.setName(refName);
reference.setCollectionType(CollectionType.LIST);
reference.setDomainObjectType(referencedEntity);
addElementToEList(containerEntity.getReferences(), reference);
}
}
use of org.contextmapper.tactic.dsl.tacticdsl.Entity in project context-mapper-dsl by ContextMapper.
the class DeriveSubdomainFromUserRequirements method createEntityAttributes.
private void createEntityAttributes(Entity entity, List<String> attributeNames) {
Set<String> existingAttrNames = entity.getAttributes().stream().map(a -> a.getName()).collect(Collectors.toSet());
for (String attributeName : attributeNames) {
if ("".equals(attributeName.trim()))
continue;
String attributeNameEncoded = encodeAttrName(attributeName);
if (existingAttrNames.contains(attributeNameEncoded))
continue;
Attribute attribute = TacticdslFactory.eINSTANCE.createAttribute();
attribute.setName(attributeNameEncoded);
attribute.setType("String");
addElementToEList(entity.getAttributes(), attribute);
}
}
Aggregations