Search in sources :

Example 11 with Entity

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;
}
Also used : Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity)

Example 12 with 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! */");
}
Also used : Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity)

Example 13 with Entity

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);
    }
}
Also used : Aggregate(org.contextmapper.dsl.contextMappingDSL.Aggregate) SimpleDomainObject(org.contextmapper.tactic.dsl.tacticdsl.SimpleDomainObject) CollectionType(org.contextmapper.tactic.dsl.tacticdsl.CollectionType) BoundedContextType(org.contextmapper.dsl.contextMappingDSL.BoundedContextType) Domain(org.contextmapper.dsl.contextMappingDSL.Domain) Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) Service(org.contextmapper.tactic.dsl.tacticdsl.Service) Feature(org.contextmapper.dsl.contextMappingDSL.Feature) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) Set(java.util.Set) ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) IteratorExtensions(org.eclipse.xtext.xbase.lib.IteratorExtensions) CMLModelObjectsResolvingHelper(org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper) RefactoringInputException(org.contextmapper.dsl.refactoring.exception.RefactoringInputException) Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation) List(java.util.List) DomainPart(org.contextmapper.dsl.contextMappingDSL.DomainPart) Optional(java.util.Optional) SculptorModule(org.contextmapper.dsl.contextMappingDSL.SculptorModule) TacticdslFactory(org.contextmapper.tactic.dsl.tacticdsl.TacticdslFactory) ContextMappingDSLFactory(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory) Subdomain(org.contextmapper.dsl.contextMappingDSL.Subdomain) Reference(org.contextmapper.tactic.dsl.tacticdsl.Reference) ContextMapperApplicationException(org.contextmapper.dsl.exception.ContextMapperApplicationException) Parameter(org.contextmapper.tactic.dsl.tacticdsl.Parameter) BoundedContext(org.contextmapper.dsl.contextMappingDSL.BoundedContext) Reference(org.contextmapper.tactic.dsl.tacticdsl.Reference)

Example 14 with Entity

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);
    }
}
Also used : Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity) Reference(org.contextmapper.tactic.dsl.tacticdsl.Reference) Feature(org.contextmapper.dsl.contextMappingDSL.Feature)

Example 15 with Entity

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);
    }
}
Also used : Arrays(java.util.Arrays) Service(org.contextmapper.tactic.dsl.tacticdsl.Service) Feature(org.contextmapper.dsl.contextMappingDSL.Feature) Set(java.util.Set) CollectionType(org.contextmapper.tactic.dsl.tacticdsl.CollectionType) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) RefactoringInputException(org.contextmapper.dsl.refactoring.exception.RefactoringInputException) Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation) List(java.util.List) Domain(org.contextmapper.dsl.contextMappingDSL.Domain) UserRequirement(org.contextmapper.dsl.contextMappingDSL.UserRequirement) Lists(com.google.common.collect.Lists) Entity(org.contextmapper.tactic.dsl.tacticdsl.Entity) Optional(java.util.Optional) TacticdslFactory(org.contextmapper.tactic.dsl.tacticdsl.TacticdslFactory) ContextMappingDSLFactory(org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory) Subdomain(org.contextmapper.dsl.contextMappingDSL.Subdomain) Reference(org.contextmapper.tactic.dsl.tacticdsl.Reference) Attribute(org.contextmapper.tactic.dsl.tacticdsl.Attribute)

Aggregations

Entity (org.contextmapper.tactic.dsl.tacticdsl.Entity)44 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)28 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)23 Attribute (org.contextmapper.tactic.dsl.tacticdsl.Attribute)22 Test (org.junit.jupiter.api.Test)21 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)15 Reference (org.contextmapper.tactic.dsl.tacticdsl.Reference)15 Subdomain (org.contextmapper.dsl.contextMappingDSL.Subdomain)14 ContextMappingModel (org.contextmapper.dsl.contextMappingDSL.ContextMappingModel)13 Collectors (java.util.stream.Collectors)12 List (java.util.List)11 TacticdslFactory (org.contextmapper.tactic.dsl.tacticdsl.TacticdslFactory)11 Set (java.util.Set)10 CMLResource (org.contextmapper.dsl.cml.CMLResource)10 Sets (com.google.common.collect.Sets)9 ContextMappingDSLFactory (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory)9 RefactoringInputException (org.contextmapper.dsl.refactoring.exception.RefactoringInputException)9 Service (org.contextmapper.tactic.dsl.tacticdsl.Service)9 ServiceOperation (org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation)9 Domain (org.contextmapper.dsl.contextMappingDSL.Domain)8