| package org.eclipse.osbp.xtext.reportdsl.common |
| |
| import org.eclipse.osbp.xtext.datamartdsl.DatamartAttribute |
| import org.eclipse.osbp.utils.entityhelper.DataType |
| import org.eclipse.osbp.dsl.semantic.common.types.LDataType |
| import org.eclipse.osbp.dsl.semantic.common.types.LDateType |
| import org.eclipse.birt.report.model.api.elements.DesignChoiceConstants |
| import org.eclipse.osbp.ui.api.datamart.IDataMart |
| import org.eclipse.osbp.ui.api.datamart.IDataMart.EType |
| |
| class DatatypeUtilities { |
| def static getDatatypeName(DatamartAttribute datamartAttribute){ |
| var scalartype = datamartAttribute.attributeRef.type |
| var dataTypes = DataTypes.typeFor(scalartype); |
| return datamartAttribute.getDatatypeName(dataTypes) |
| } |
| |
| def static getDatatypeName(DatamartAttribute datamartAttribute, DataType dtType){ |
| val dataTypes = datamartAttribute.getDatatype(dtType) |
| return datamartAttribute.getDatatypeName(dataTypes) |
| } |
| |
| def static getDatatypeName(IDataMart datamart, DatamartAttribute datamartAttribute){ |
| val eType = datamart.typesMap.get('''«datamartAttribute.attributeRef.entity.name».«datamartAttribute.aliasName»''') |
| val dataTypes = datamartAttribute.getDatatype(eType) |
| return datamartAttribute.getDatatypeName(dataTypes) |
| } |
| |
| def static getDatatypeName(DatamartAttribute datamartAttribute, DataTypes dtTypes){ |
| var typeName = "" |
| var scalartype = datamartAttribute.attributeRef.type |
| if (scalartype instanceof LDataType){ |
| var dType = scalartype as LDataType |
| if (dType.isDate()){ |
| if (scalartype.getDateType() == LDateType.DATE) { |
| typeName = DesignChoiceConstants.COLUMN_DATA_TYPE_DATE |
| } else if (dType.getDateType() == LDateType.TIME) { |
| typeName = DesignChoiceConstants.COLUMN_DATA_TYPE_TIME |
| } else if (dType.getDateType() == LDateType.TIMESTAMP) { |
| typeName = DesignChoiceConstants.COLUMN_DATA_TYPE_DATETIME |
| } |
| } else { |
| typeName = dtTypes.getNativeOdaDataTypeName() |
| } |
| } |
| return typeName |
| } |
| |
| def static getDatatype(DatamartAttribute datamartAttribute, DataType dtType){ |
| var attribute = datamartAttribute.attributeRef |
| var eType = dtType.getBasicType(attribute) |
| return datamartAttribute.getDatatype(eType) |
| } |
| |
| def static getDatatype(DatamartAttribute datamartAttribute, EType eType){ |
| var attribute = datamartAttribute.attributeRef |
| var dataType = DataTypes.typeFor(eType) |
| if (dataType == DataTypes.ANY) { |
| dataType = DataTypes.typeFor(attribute.type) |
| } |
| return dataType |
| } |
| } |