Created
October 9, 2016 09:53
-
-
Save JRuumis/b8a263912d3a2d16b784f4e715ee0968 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package rpd.load | |
| /** | |
| * Created by janis on 01/10/2016. | |
| */ | |
| // todo: create type for id references. perhaps separate for primary and foreign keys | |
| trait AddDataStore { | |
| var dataStore: DataStore = null | |
| } | |
| abstract sealed class TargetEntity extends Ordered[TargetEntity] with AddDataStore { | |
| val mdsid: String | |
| val name: String | |
| override def compare(that: TargetEntity) = this.name.compare(that.name) | |
| } | |
| // Helper classes | |
| case class ColumnReference(tableReference: String, columnReference: String) | |
| // Logical Layer | |
| case class BusinessModel(mdsid: String, name: String, description: String) extends TargetEntity { | |
| def logicalTables: List[LogicalTable] = dataStore.logicalTablesParentIndex(mdsid) | |
| } | |
| case class LogicalTable(mdsid: String, name: String, parentId: String, tableType: String) extends TargetEntity { | |
| def businessModel: BusinessModel = dataStore.businessModelsIndex(parentId) | |
| def columns = dataStore.logicalTableColumnsParentIndex(mdsid) | |
| } | |
| case class LogicalColumn(mdsid: String, name: String, parentId: String, columnType: String, aggregate: String, attributeExpression: String) extends TargetEntity { | |
| def logicalTable = dataStore.logicalTablesIndex(parentId) | |
| def businessModel = logicalTable.businessModel | |
| } | |
| case class LogicalTableSource(mdsid: String, name: String, parentId: String, filterValue: String, levels: String, fragmentationContent: String) extends TargetEntity { | |
| def logicalTable = dataStore.logicalTablesIndex(parentId) | |
| def columns = dataStore.logicalTableSourceColumnsParentIndex(mdsid) | |
| } | |
| case class LogicalTableSourceColumn(mdsid: String, name: String, parentId: String, physicalTableReferences: List[ColumnReference], logicalTableReferences: List[ColumnReference]) extends TargetEntity { | |
| def logicalTableSource = dataStore.logicalTableSourcesIndex(parentId) | |
| // todo: | |
| //def physicalTables = physicalTableReferences map (reference => dataStore.physicalTablesIndex(reference.tableReference) ) | |
| //def logicalTables = logicalTableReferences map (dataStore.logicalTablesIndex(_)) | |
| } | |
| case class LogicalJoin(mdsid: String, name: String, joinType: String, logicalTableId1: String, logicalColumnId1: String, multiplicity1: String, logicalTableId2: String, logicalColumnId2: String, multiplicity2: String) extends TargetEntity { | |
| def logicalTable1 = dataStore.logicalTablesIndex(logicalTableId1) | |
| def logicalTable2 = dataStore.logicalTablesIndex(logicalTableId2) | |
| def logicalColumn1 = dataStore.logicalTableColumnsIndex(logicalColumnId1) | |
| def logicalColumn2 = dataStore.logicalTableColumnsIndex(logicalColumnId2) | |
| } | |
| case class DimensionLevel(mdsid: String, name: String, parentId: String, isGrandTotal: String, childLevelIds: List[String]) extends TargetEntity { | |
| def childLevels = childLevelIds map (dataStore.dimensionLevelsIndex(_)) | |
| // todo: implement isGrandTotal as boolean! | |
| def dimension = dataStore.dimensionsIndex(parentId) | |
| } | |
| case class Dimension(mdsid: String, name: String, isValueBased: String, isRagged: String, isSkipped: String, parentId: String, rootLevelId: String) extends TargetEntity { | |
| def businessModel = dataStore.businessModelsIndex(parentId) | |
| def levels = dataStore.dimensionLevelsParentIndex(mdsid) | |
| def rootLevel = dataStore.dimensionLevelsIndex(rootLevelId) | |
| } | |
| // Physical Layer | |
| case class Database(mdsid: String, name: String, dbType: String) extends TargetEntity | |
| case class Schema(mdsid: String, name: String, parentId: String) extends TargetEntity | |
| case class PhysicalTable(mdsid: String, name: String, parentId: String, sourceTableId: String) extends TargetEntity // tables with sourceTableId are Aliases | |
| case class PhysicalColumn(mdsid: String, name: String, parentId: String, dataType: String, precision: String, description: String) extends TargetEntity | |
| case class ForeignKeyTarget(mdsid: String, name: String, parentId: String, referenceTableId: String, referenceColumnId: String) extends TargetEntity // todo: use ColumnReference | |
| // Presentation Layer | |
| case class PresentationCatalog(mdsid: String, name: String, businessModelId: String, description: String) extends TargetEntity | |
| case class PresentationTable(mdsid: String, name: String, parentId: String) extends TargetEntity | |
| case class PresentationTableColumn(mdsid: String, name: String, parentId: String, logicalTableId: String, logicalColumnId: String) extends TargetEntity // todo: use ColumnReference |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment