All Downloads are FREE. Search and download functionalities are using the official Maven repository.

extensions.Names.ext Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
import dom;
import core;
import org::openxma::dsl::generator::component;

extension org::openxma::dsl::common::extensions::LogUtil;
extension extensions::File;
extension extensions::Properties;
extension extensions::SimpleTypeExtension;
extension extensions::JavaUtil reexport;
extension extensions::Strings;

String addImports() :
 getImportsProcessor().addImportsHere();

String registerImport(String name) :
 getImportsProcessor().registerImport(name);

String registerImportEmptyString(String name) :
 getImportsProcessor().registerImport(name).subString(0,0);

private JavaImportPostProcessor getImportsProcessor() :
   GLOBALVAR __javaImportTool;

String getName(emf::EObject eObject,Boolean implementation):
JAVA org.openxma.dsl.generator.helper.NameExtension.getName(org.eclipse.emf.ecore.EObject,java.lang.Boolean);

String getName(QueryParameter queryParameter):
    Parameter.isInstance(queryParameter) ? ((Parameter)queryParameter).name : queryParameter.attribute.name;

String getImplementationType(QueryParameter parameter):"";
String getImplementationType(DelegateOperation delegateOperation):
let type = delegateOperation.view!=null ? delegateOperation.view : ((Operation)delegateOperation.operation).type:
getFullyQualifiedName(type,!Entity.isInstance(type));
String getImplementationType(QueryOperation queryOperation): getFullyQualifiedName(queryOperation.type,!Entity.isInstance(queryOperation.type));
String getImplementationType(Operation operation): getFullyQualifiedName(operation.type,!Entity.isInstance(operation.type));
String getImplementationType(Parameter parameter): getFullyQualifiedName(parameter.type,!Entity.isInstance(parameter.type));
String getImplementationType(Attribute feature): getFullyQualifiedName(feature.dataType,!Entity.isInstance(feature.dataType));

cached String getJavaType(SimpleType simpleType):
JAVA org.openxma.dsl.generator.helper.SimpleTypeExtension.getJavaType(org.openxma.dsl.core.model.SimpleType);

String getFullyQualifiedName(emf::EObject eObject,Boolean implementation) :
    eObject.getFullyQualifiedNameAndRegister(implementation);

String getFullyQualifiedNameAndRegister(emf::EObject eObject,Boolean implementation) :
JAVA org.openxma.dsl.generator.helper.NameExtension.getFullyQualifiedNameAndRegister(org.eclipse.emf.ecore.EObject,java.lang.Boolean);

cached String getCamelCasedModelNameSpaceName(String input):
JAVA org.openxma.dsl.generator.helper.NameExtension.getCamelCasedModelNameSpaceName(java.lang.String);

cached String getSubstringAfterLastDot(String input):
JAVA org.openxma.dsl.generator.helper.NameExtension.getSubstringAfterLastDot(java.lang.String);

cached String getModelNameSpaceNamePath(String input):
JAVA org.openxma.dsl.generator.helper.NameExtension.getModelNameSpaceNamePath(java.lang.String);

cached String getFullyQualifiedNameInternal(emf::EObject eObject,Boolean implementation) :
JAVA org.openxma.dsl.generator.helper.NameExtension.getFullyQualifiedName(org.eclipse.emf.ecore.EObject,java.lang.Boolean);

cached String getPackageName(emf::EObject eObject,Boolean implementation) :
JAVA org.openxma.dsl.generator.helper.NameExtension.getPackageName(org.eclipse.emf.ecore.EObject,java.lang.Boolean);

cached String getValidatorPackageName(Entity entity) :
    ((core::Model)entity.eContainer).name+".validation";

cached String getFullClassNameForDatamapping(ComplexType type):
JAVA org.openxma.dsl.generator.helper.NameExtension.getFullClassNameForDatamapping(org.openxma.dsl.dom.model.ComplexType);

cached String getClassFileName(Entity entity):
    classFileName(entity.getPackageName(true),getClassName(entity));
cached String getClassFileName(Service service):
    classFileName(service.getPackageName(true),getClassName(service));
cached String getClassFileName(Dao dao):
    classFileName(dao.getPackageName(true),getClassName(dao));
cached String getClassFileName(ApplicationSession applicationContext):
    classFileName(applicationContext.getPackageName(true),getClassName(applicationContext));
cached String getClassFileName(ModelElement modelElement):
    classFileName(modelElement.getPackageName(true),getName(modelElement,true));

cached String getCompositeIdentifierClassFileName(Entity entity):
    classFileName(entity.getPackageName(true),entity.getCompositeIdentifierName());

cached String getCompositeIdentifierName(Entity entity):
    entity.key.name;

cached String getIdentifierClassFileName(SimpleType simpleType):
    classFileName(simpleType.getPackageName(true),simpleType.getIdentifierClassName());

cached String getIdentifierClassName(SimpleType simpleType):
    simpleType.name;

String getFullyQualifiedCompositeIdentifierName(Entity entity): registerImport(entity.getPackageName(true)+"."+entity.getCompositeIdentifierName()) ;

cached String getInterfaceFileName(ModelElement modelElement):
    classFileName(modelElement.getPackageName(false),modelElement.name);

cached String getGenInterfaceFileName(ModelElement modelElement):
    classFileName(modelElement.getPackageName(false),getGenInterfaceName(modelElement));

cached String getGenInterfaceName(ModelElement modelElement):
    modelElement.name+"Gen";

cached String getGenClassFileName(ModelElement modelElement):
    classFileName(modelElement.getPackageName(true),getGenClassName(modelElement));

cached String getDtoAssemblerFactoryGenClassFileName(Model model):
    classFileName(model.name,"DtoAssemblerFactory"+getSubstringAfterLastDot(model.name).toFirstUpper()+"Gen");

cached String getDtoAssemblerFactoryClassFileName(Model model):
    classFileName(model.name,"DtoAssemblerFactory"+getSubstringAfterLastDot(model.name).toFirstUpper());

cached String getDtoAssemblerFactoryTestClassFileName(Model model):
    classFileName(model.name,"DtoAssemblerFactory"+getSubstringAfterLastDot(model.name).toFirstUpper()+"Test");

cached String getDtoAssemblerFactoryGenClassName(Model model):
    "DtoAssemblerFactory"+getSubstringAfterLastDot(model.name).toFirstUpper()+"Gen";

cached String getDtoAssemblerFactoryClassName(Model model):
    "DtoAssemblerFactory"+getSubstringAfterLastDot(model.name).toFirstUpper();

cached String getDtoAssemblerFactoryTestClassName(Model model):
    "DtoAssemblerFactory"+getSubstringAfterLastDot(model.name).toFirstUpper()+"Test";

cached String getGenXsdFileName(List modelElementList):
    xsdFileName(((Model)modelElementList.get(0)).name);

cached String getGenXsdIncludeFileName(List modelElementList):
    xsdIncludeFileName(((Model)modelElementList.get(0)).name);

cached String getGenXsdIncludeFileNameWithoutPath(List modelElementList):
    xsdIncludeFileNamewithoutPath(((Model)modelElementList.get(0)).name);

cached String getGenResourceBundleFileName(ModelElement modelElement):
    getPackagedFileName(modelElement.getPackageName(true),getGenClassName(modelElement),"properties");

cached String getGenValidatorClassFileName(Entity entity):
    classFileName(entity.getValidatorPackageName(),entity.getGenValidatorClassName());

cached String getValidatorClassFileName(Entity entity):
    classFileName(entity.getValidatorPackageName(),entity.getValidatorClassName());

cached String getGenResourceBundleName(EnumType enum):
    enum.name;

cached String getGenClassName(EnumType enum):
    enum.name;

cached String getGenValidatorClassName(Entity entity):
    entity.name+"GenValidator";

cached String getGenClassName(ValueObject valueObject):
    valueObject.name+"Gen";

cached String getGenClassName(ModelElement modelElement):
    modelElement.name+"GenImpl";

cached String getGenClassName(DataView dataView):
    dataView.name+"Gen";

cached String getClassName(ModelElement modelElement):
    modelElement.name+"Impl";

cached String getValidatorClassName(Entity entity):
    entity.name+"Validator";

cached String getQueryClassName(Entity entity):
    entity.name+"Query";

cached String getClassName(DataView dataView):
    dataView.name;

cached String getQualifiedPropertiesName(Entity entity):
    getClassFileName(entity) + ".property";

String getQualifiedClassName(ModelElement modelElement) :
    registerImport(modelElement.getPackageName(true)+"."+modelElement.getClassName());

String getQualifiedGenClassName(ModelElement modelElement) :
    registerImport(modelElement.getPackageName(true)+"."+modelElement.getGenClassName());

String getQualifiedInterfaceName(ModelElement modelElement) :
    registerImport(modelElement.getPackageName(false)+"."+modelElement.name);

String getQualifiedGenInterfaceName(ModelElement modelElement) :
    registerImport(modelElement.getPackageName(false)+"."+modelElement.getGenInterfaceName());

cached String getDisplayPropertiesFileName(Model model):
JAVA org.openxma.dsl.generator.helper.EntityExtension.getDisplayPropertiesFile(org.openxma.dsl.core.model.Model);

cached String getGeneratedHbmXmlFileName(Dao dao):
JAVA org.openxma.dsl.generator.helper.EntityExtension.getGeneratedHbmXmlFileName(org.openxma.dsl.dom.model.Dao);

cached String getFragmentHbmXmlFileName(Dao dao):
JAVA org.openxma.dsl.generator.helper.EntityExtension.getFragmentHbmXmlFileName(org.openxma.dsl.dom.model.Dao);

cached String getHbmXmlFileName(Dao dao):
JAVA org.openxma.dsl.generator.helper.EntityExtension.getHbmXmlFileName(org.openxma.dsl.dom.model.Dao);

cached String getPropertyFileName(Entity entity):
JAVA org.openxma.dsl.generator.helper.EntityExtension.getPropertyFileName(org.openxma.dsl.dom.model.Entity);

cached String getMutatorMethodName(emf::EObject eObject):  "set"+getName(eObject,false).toFirstUpper() ;
cached String getAccessorMethodName(emf::EObject eObject): (isBooleanType(eObject)?"is":"get")+getName(eObject,false).toFirstUpper() ;
cached String getAccessorMethodName(Attribute feature): "get"+feature.name.toFirstUpper();
cached String getAccessorMethodName(AttributeGroup key): "get"+((Entity)key.eContainer).getCompositeIdentifierName();
cached String getMutatorMethodName(Attribute feature) : "set"+feature.name.toFirstUpper();
cached String getHasMethodName(Attribute feature)     : "has"+feature.name.toFirstUpper();
cached String getAddMethodName(Attribute feature)     : "add"+feature.name.toFirstUpper();
cached String getRemoveMethodName(Attribute feature)     : "remove"+feature.name.toFirstUpper();
cached String getRemoveAllMethodName(Attribute feature)     : "removeAll"+feature.name.toFirstUpper();

cached boolean isBooleanType(emf::EObject eObject): false;
cached boolean isBooleanType(Property property): isBooleanType(property.type);
cached boolean isBooleanType(Function function): isBooleanType(function.resultType);
cached boolean isBooleanType(Attribute attribute):  SimpleType.isInstance(attribute.type.dataType)  && isBooleanType(attribute.type.dataType);
cached boolean isBooleanType(SimpleType simpleType): getJavaType(simpleType)=="boolean";
cached boolean isComplexType(Attribute attribute): ValueObject.isInstance(attribute.type.dataType);

cached String getMethodName(DataBaseConstraint dataBaseConstraint):
    switch (dataBaseConstraint.type) {
        case DataBaseConstraintType::NATURAL :
            "loadBy"+dataBaseConstraint.name
        case DataBaseConstraintType::UNIQUE :
            "loadBy"+dataBaseConstraint.name
        case DataBaseConstraintType::INDEX :
            "findBy"+dataBaseConstraint.name
        default : "NOT IMPLEMENTED"
    }
;


/**
 * return the column name for the given Entity and Attribute
 */
cached String getColumnName(Entity entity, Attribute attribute):
    JAVA org.openxma.dsl.generator.helper.EntityExtension.getColumnName(org.openxma.dsl.dom.model.Entity,org.openxma.dsl.dom.model.Attribute);
/**
 * return the package name for the given DomainModel
 */
cached String getPackageName(Model model):
    JAVA org.openxma.dsl.generator.helper.EntityExtension.getPackageName(org.openxma.dsl.core.model.Model);

cached String getPackageName(ModelElement modelElement):
    JAVA org.openxma.dsl.generator.helper.EntityExtension.getPackageName(org.openxma.dsl.core.model.ModelElement);

cached String getJoinColumnName(ManyToMany manyToMany):
    JAVA org.openxma.dsl.generator.helper.EntityExtension.getJoinColumnName(org.openxma.dsl.dom.model.ManyToMany);

String toSimpleName(String fqName) :
   lastToken(fqName,'.');

String toPackageName(String fqName) :
   skipLastToken(fqName,'.');
   
String toUnicode(AttributeTextProperty attributeText) :
    JAVA org.openxma.dsl.generator.helper.EntityExtension.toUnicode(org.openxma.dsl.dom.model.AttributeTextProperty);
    




© 2015 - 2024 Weber Informatics LLC | Privacy Policy