Search in sources :

Example 1 with ComplexType

use of org.contextmapper.tactic.dsl.tacticdsl.ComplexType in project context-mapper-dsl by ContextMapper.

the class GetTypeOfComplexTypeMethod method exec.

@Override
public Object exec(List arguments) throws TemplateModelException {
    if (arguments.size() != 1)
        throw new TemplateModelException("The method 'getType' takes only one parameter (ComplexType object)!");
    Object object = ((WrapperTemplateModel) arguments.get(0)).getWrappedObject();
    if (!(object instanceof ComplexType))
        throw new TemplateModelException("The method 'getType' takes an object of the type ComplexType only! The given value is of the type '" + object.getClass().getName() + "'.");
    ComplexType complexType = (ComplexType) object;
    String type = "Object";
    if (complexType.getDomainObjectType() != null)
        type = complexType.getDomainObjectType().getName();
    else if (complexType.getType() != null)
        type = complexType.getType();
    if (complexType.getCollectionType() != null && !CollectionType.NONE.equals(complexType.getCollectionType()))
        return complexType.getCollectionType().getName() + "<" + type + ">";
    return type;
}
Also used : TemplateModelException(freemarker.template.TemplateModelException) WrapperTemplateModel(freemarker.ext.util.WrapperTemplateModel) ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType)

Example 2 with ComplexType

use of org.contextmapper.tactic.dsl.tacticdsl.ComplexType in project context-mapper-dsl by ContextMapper.

the class MDSLDataTypeCreator method createComplexTypeForReference.

private ComplexType createComplexTypeForReference(Reference reference) {
    ComplexType type = TacticdslFactory.eINSTANCE.createComplexType();
    type.setCollectionType(reference.getCollectionType());
    type.setDomainObjectType(reference.getDomainObjectType());
    return type;
}
Also used : ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType)

Example 3 with ComplexType

use of org.contextmapper.tactic.dsl.tacticdsl.ComplexType in project context-mapper-dsl by ContextMapper.

the class DeriveBoundedContextFromSubdomains method createComplexType.

private ComplexType createComplexType(SimpleDomainObject object, CollectionType collectionType) {
    ComplexType complexType = createComplexType(object);
    complexType.setCollectionType(collectionType);
    return complexType;
}
Also used : ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType)

Example 4 with ComplexType

use of org.contextmapper.tactic.dsl.tacticdsl.ComplexType in project context-mapper-dsl by ContextMapper.

the class DeriveBoundedContextFromSubdomains method copyAndEnhanceOperations.

private void copyAndEnhanceOperations(Aggregate aggregate, Service source, Service target) {
    Set<String> existingOperations = target.getOperations().stream().map(o -> o.getName()).collect(Collectors.toSet());
    for (ServiceOperation sourceOperation : source.getOperations()) {
        if (existingOperations.contains(sourceOperation.getName()))
            continue;
        ServiceOperation targetOperation = TacticdslFactory.eINSTANCE.createServiceOperation();
        targetOperation.setName(sourceOperation.getName());
        targetOperation.setDelegateHolder(sourceOperation.getDelegateHolder());
        targetOperation.setHint(sourceOperation.getHint());
        targetOperation.setDoc(sourceOperation.getDoc());
        targetOperation.setPublish(sourceOperation.getPublish());
        targetOperation.setThrows(sourceOperation.getThrows());
        targetOperation.setVisibility(sourceOperation.getVisibility());
        if (sourceOperation.getReturnType() == null)
            targetOperation.setReturnType(getReturnType4Operation(aggregate, sourceOperation.getName()));
        if (sourceOperation.getParameters().isEmpty()) {
            ComplexType parameterType = getParameterType4Operation(aggregate, sourceOperation.getName());
            addElementToEList(targetOperation.getParameters(), createParameter(getParameterName4ComplexType(parameterType), parameterType));
        }
        addElementToEList(target.getOperations(), targetOperation);
    }
}
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) ServiceOperation(org.contextmapper.tactic.dsl.tacticdsl.ServiceOperation) ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType)

Example 5 with ComplexType

use of org.contextmapper.tactic.dsl.tacticdsl.ComplexType in project context-mapper-dsl by ContextMapper.

the class DeriveBoundedContextFromSubdomains method createComplexType.

private ComplexType createComplexType(SimpleDomainObject object) {
    ComplexType complexType = TacticdslFactory.eINSTANCE.createComplexType();
    complexType.setDomainObjectType(object);
    return complexType;
}
Also used : ComplexType(org.contextmapper.tactic.dsl.tacticdsl.ComplexType)

Aggregations

ComplexType (org.contextmapper.tactic.dsl.tacticdsl.ComplexType)9 Parameter (org.contextmapper.tactic.dsl.tacticdsl.Parameter)3 Aggregate (org.contextmapper.dsl.contextMappingDSL.Aggregate)2 BoundedContext (org.contextmapper.dsl.contextMappingDSL.BoundedContext)2 Entity (org.contextmapper.tactic.dsl.tacticdsl.Entity)2 Sets (com.google.common.collect.Sets)1 WrapperTemplateModel (freemarker.ext.util.WrapperTemplateModel)1 TemplateModelException (freemarker.template.TemplateModelException)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 AbstractCMLInputFileTest (org.contextmapper.dsl.AbstractCMLInputFileTest)1 CMLModelObjectsResolvingHelper (org.contextmapper.dsl.cml.CMLModelObjectsResolvingHelper)1 BoundedContextType (org.contextmapper.dsl.contextMappingDSL.BoundedContextType)1 ContextMappingDSLFactory (org.contextmapper.dsl.contextMappingDSL.ContextMappingDSLFactory)1 Domain (org.contextmapper.dsl.contextMappingDSL.Domain)1 DomainPart (org.contextmapper.dsl.contextMappingDSL.DomainPart)1 Feature (org.contextmapper.dsl.contextMappingDSL.Feature)1 SculptorModule (org.contextmapper.dsl.contextMappingDSL.SculptorModule)1