/// <summary> /// Creates a list of event-table-columns, i.e. "EVENT.event_id", "Event.case_id", ... /// </summary> /// <param name="withAggregation">Whether an aggregation on the event-table was selected</param> /// <returns>A list of strings that can be used for the select statement</returns> /// <author>Jannik Arndt, Roman Bauer</author> private IEnumerable <string> CreateEventSelectStatements(bool withAggregation) { List <string> result = new List <string>(); //aggregation selected --> build select clause with database functions because we will use group by clause if (withAggregation) { AbstractAggregationConfigurator aggConfigurator = new DefaultAggregationConfigurator(); foreach (string columnName in DBWorker.MetaData.ListOfEventsTableColumnNames) { string aggFunction = aggConfigurator.GetAggregationFunction(columnName); string projectionOnAttribute = aggFunction + "(" + TableColumnFormatter(EventTableName, columnName) + ")" + columnName; result.Add(projectionOnAttribute); } } //no aggregation selected --> build select clause in absence of group by clause else { foreach (string columnName in DBWorker.MetaData.ListOfEventsTableColumnNames) { result.Add(TableColumnFormatter(EventTableName, columnName)); } } return(result); }
/// <summary> /// Creates a list of dimension-table-columns /// </summary> /// <param name="withAggregation">Whether an aggregation on the event-table was selected</param> /// <returns>A list of strings that can be used for the select statement</returns> private IEnumerable <string> GetAllDimensionColumns(bool withAggregation) { if (withAggregation) { var result = new List <string>(); AbstractAggregationConfigurator aggConfigurator = new DefaultAggregationConfigurator(); foreach (var dimension in DBWorker.MetaData.ListOfFactDimensions) { if (!dimension.IsEmptyDimension) { result.Add(embedAttributeInFunction(aggConfigurator.GetDefaultAggregationFunction(), dimension.ToTable, dimension.DimensionColumnNames.Col_Content)); } } return(result); } else { var result = new List <string>(); foreach (var dimension in DBWorker.MetaData.ListOfFactDimensions) { if (!dimension.IsEmptyDimension) { result.Add(TableColumnFormatter(dimension.ToTable, dimension.DimensionColumnNames.Col_Content) + " AS " + dimension.ToTable); } } return(result); } }
/// <summary> /// Creates a fact-table-column for select clause, i.e. "FACT.fact_id". /// </summary> /// <param name="withAggregation">Wether an aggregation on the event-table was selected</param> /// <returns>String that can be used for the select statement</returns> /// <author>Jannik Arndt, Roman Bauer</author> private string CreateFactSelectStatement(bool withAggregation) { if (withAggregation) { AbstractAggregationConfigurator aggConfigurator = new DefaultAggregationConfigurator(); return(embedAttributeInFunction(aggConfigurator.GetDefaultAggregationFunction(), FactTableName, FactColumnName)); } else { return(TableColumnFormatter(FactTableName, FactColumnName)); } }
/// <summary> /// Embed the given attribute in the given function, for example "MIN(FACT.fact_id)fact_id" ... /// </summary> /// <param name="function">Function to use</param> /// <param name="tableName">Name of the table</param> /// <param name="columnName">Name of the column</param> /// <returns>String that can be used for select clause</returns> /// <author>Jannik Arndt, Roman Bauer</author> private string embedAttributeInFunction(string function, string tableName, string columnName) { AbstractAggregationConfigurator aggConfigurator = new DefaultAggregationConfigurator(); if (aggConfigurator.GetDefaultAggregationFunction().Equals(function)) { if (tableName.Equals(FactTableName)) { return(function + "(" + TableColumnFormatter(tableName, columnName) + ")" + columnName); } else { return(function + "(" + TableColumnFormatter(tableName, columnName) + ")" + tableName); } } else { //here you can implement another functions return(null); } }