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

extensions.EntityExtension.ext Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
import core;
import dom;
extension extensions::File;
extension extensions::Names;
extension extensions::Properties;
extension extensions::SimpleTypeExtension;
extension org::eclipse::xtend::util::stdlib::io;
extension org::eclipse::xtend::util::stdlib::cloning;

cached List[Entity] getEntities(Model model):
    model.eAllContents.typeSelect(Entity)
;

cached List[Dao] getDaos(Model model):
    model.eAllContents.typeSelect(Dao)
;

 String getIdClassName(Dao dao):
    dao.primaryKey!=null ?
        dao.primaryKeyColumn.attribute.getImplementationType() :
        dao.entity.getFullyQualifiedCompositeIdentifierName()
;

cached String getIdParameterName(Dao dao):
    dao.primaryKey!=null ?
        dao.primaryKeyColumn.attribute.name :
        dao.entity.getCompositeIdentifierName().toFirstLower()
;

cached boolean isPSM(Attribute attribute):
    attribute.getProperty("psm")!=null  || attribute.identifier || attribute.version
;
cached boolean isIdOrVersion(Attribute attribute):
    attribute.identifier || attribute.version
;

cached String getResolvedName(PresentableFeature presentableFeature): "";
cached String getResolvedName(Attribute attribute):
	attribute.getFQNProperty()!=null ? attribute.getFQNProperty().toString().toFirstLower()+attribute.name.toFirstUpper():attribute.name
;

String getQualifiedName(Attribute attribute):
	attribute.getFQNProperty()!=null ? attribute.getFQNProperty().toString().toFirstLower()+"."+attribute.name.toFirstLower():attribute.name
;

cached Entity getEntity(Column column): Column.isInstance(column.eContainer) ? ((Dao)column.eContainer.eContainer).entity : ((Dao)column.eContainer).entity;
cached Entity getEntity(AttributeGroup featureGroup): featureGroup.eContainer;
cached Entity getEntity(DataBaseConstraint dataBaseConstraint): ((Dao)dataBaseConstraint.eContainer).entity;
cached Entity getEntity(Attribute attribute):  attribute.eContainer;

cached List[Dao] getDaosForSubClasses(Model model,Entity entity):
	model.eAllContents.typeSelect(Dao).select(e|e.entity.superType==entity).sortBy(e|e.name)
;

String getType(dom::Attribute attribute): attribute.many ? registerImport("java.util.Collection")+"<"+attribute.getImplementationType()+">" : attribute.getImplementationType();
String getType(dom::Parameter parameter): parameter.many ? registerImport("java.util.Collection")+"<"+parameter.getImplementationType()+">" : parameter.getImplementationType();
String getType(dom::DaoOperation attribute): "";
String getType(dom::Operation operation): operation.type==null ? "void" :( operation.many ? registerImport("java.util.Collection")+"<"+operation.getImplementationType()+">" : operation.getImplementationType());
String getType(dom::QueryOperation operation): operation.type==null ? "void" :( operation.many ? registerImport("java.util.Collection")+"<"+operation.getImplementationType()+">" : operation.getImplementationType());
String getType(dom::DelegateOperation delegateOperation):
((Operation)delegateOperation.operation).type==null ? "void" :( ((Operation)delegateOperation.operation).many ? registerImport("java.util.Collection")+"<"+delegateOperation.getImplementationType()+">" : delegateOperation.getImplementationType());
core::Type getParameterType(QueryParameter queryParameter):
	dom::Parameter.isInstance(queryParameter) ? ((dom::Parameter)queryParameter).type : queryParameter.attribute.dataType;

boolean isMany(QueryParameter queryParameter):
	dom::Parameter.isInstance(queryParameter) ? ((dom::Parameter)queryParameter).many : queryParameter.attribute.many;

cached boolean isMany(DataBaseConstraint dataBaseConstraint): dataBaseConstraint.type != "unique-key";

cached String getConstantName(AttributeGroup sortOrder) :
    sortOrder.name.toUnderScoreString().toUpperCase()
;

cached String getDaoConstantName(QueryOperation queryOperation) :
	((Dao)queryOperation.eContainer).name+"."+queryOperation.getQueryName().toUnderScoreString().toUpperCase()
;

cached String getQualifiedQueryName(QueryOperation queryOperation) :
	((Dao)queryOperation.eContainer).entity.name+"."+queryOperation.getQueryName()
;

cached String getQueryName(QueryOperation queryOperation) :
	let queryOperationsWithSameName = ((Dao)queryOperation.eContainer).queryOperation.select(e|e.name == queryOperation.name):
	 queryOperationsWithSameName.size>1 ?  queryOperation.name.toFirstUpper() + queryOperationsWithSameName.toList().indexOf(queryOperation) : queryOperation.name.toFirstUpper()
;

cached boolean isIdentifiable(Entity entity): null!=entity.identifier || null!=entity.key;

cached boolean includesAllRequiredFeaturesFor(DataView dataView,Entity entity):
 JAVA org.openxma.dsl.generator.helper.EntityExtension.includesAllRequiredFeaturesFor(org.openxma.dsl.dom.model.DataView,org.openxma.dsl.dom.model.Entity)
;

cached String toUnderScoreString(String camcelCaseName) :
    JAVA org.openxma.dsl.common.Strings.toUnderScoreString(java.lang.String)
;

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

cached boolean includesVersion(DataView dataView,Entity entity):
 JAVA org.openxma.dsl.generator.helper.EntityExtension.includesVersionFor(org.openxma.dsl.dom.model.DataView,org.openxma.dsl.dom.model.Entity)
;

Attribute getAttributeOfAttributeHolder(PresentableFeature attrHolder):
JAVA org.openxma.xmadsl.XmadslModelExtension.getAttributeOfAttributeHolder(org.openxma.dsl.dom.model.PresentableFeature);

DataTypeAndTypeParameter getType(PresentableFeature attributeHolder):
JAVA org.openxma.xmadsl.XmadslModelExtension.getType(org.openxma.dsl.dom.model.PresentableFeature);

String getFQNProperty(PresentableFeature attr):
JAVA org.openxma.xmadsl.XmadslModelExtension.getFQNProperty(org.openxma.dsl.dom.model.PresentableFeature);


cached boolean isInverseSide(Attribute attribute):
 JAVA org.openxma.dsl.generator.helper.EntityExtension.isInverseSide(org.openxma.dsl.dom.model.Attribute)
;

cached String getSetParameterMethodName(QueryParameter queryParameter):
	dom::Parameter.isInstance(queryParameter) ? ((dom::Parameter)queryParameter).type.getSetParameterMethodName() : queryParameter.attribute.type.getSetParameterMethodName()
;

cached String getSetParameterMethodName(core::Type type):
	type.isDateType() ? "setDate" : (type.isTimeStampType() ? "setTimestamp" : "setParameter")
;

cached String getSetParameterMethodName(DataTypeAndTypeParameter type):
	type.isDateType() ? "setDate" : (type.isTimeStampType() ? "setTimestamp" : "setParameter")
;

String getComment(Column column):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.getComment(org.openxma.dsl.dom.model.Column)
;

boolean hasComment(Column column):
	column.getComment().length>0
;

cached String getStoredProcedureConstantName(QueryOperation queryOperation) :
	"SP_" + queryOperation.getQueryName().toUnderScoreString().toUpperCase()
;

List getAllNonRequiredReferenceNonManyAttributesRecursive(Entity entity):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.getAllNonRequiredReferenceNonManyAttributesRecursive(org.openxma.dsl.dom.model.Entity)
;

List getAllMatchingAttributes(Entity entity, DataView dataView):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.getAllMatchingAttributes(org.openxma.dsl.dom.model.Entity, org.openxma.dsl.dom.model.DataView)
;

Boolean isStringSimpleType(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isStringSimpleType(org.openxma.dsl.dom.model.Attribute)
;

Boolean isDateSimpleType(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isDateSimpleType(org.openxma.dsl.dom.model.Attribute)
;

Boolean isBigDecimalSimpleType(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isBigDecimalSimpleType(org.openxma.dsl.dom.model.Attribute)
;

Boolean isBooleanSimpleType(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isBooleanSimpleType(org.openxma.dsl.dom.model.Attribute)
;

Boolean isDoubleSimpleType(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isDoubleSimpleType(org.openxma.dsl.dom.model.Attribute)
;

Boolean isFloatSimpleType(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isFloatSimpleType(org.openxma.dsl.dom.model.Attribute)
;

Boolean isIntegerSimpleType(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isIntegerSimpleType(org.openxma.dsl.dom.model.Attribute)
;

Boolean isLongSimpleType(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isLongSimpleType(org.openxma.dsl.dom.model.Attribute)
;

Boolean isTimestampSimpleType(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isTimestampSimpleType(org.openxma.dsl.dom.model.Attribute)
;

Boolean isValueObject(Attribute attribute):
  JAVA org.openxma.dsl.generator.helper.EntityExtension.isValueObject(org.openxma.dsl.dom.model.Attribute)
;





© 2015 - 2024 Weber Informatics LLC | Privacy Policy