public void AddDimensionLevelTest() { Dimension target = new Dimension(); Dimension d = new Dimension(); target.AddDimensionLevel(d); Assert.AreEqual(d, target.GetCoarserDimensionLevel()[0]); }
public void AddDimensionLevelTest1() { Dimension target = new Dimension(); List<Dimension> l = new List<Dimension>() { new Dimension() }; target.AddDimensionLevel(l); Assert.AreEqual(l[0], target.GetCoarserDimensionLevel()[0]); }
public SelectedDimension(int axis = 0, Dimension dimension = null, int levelDepth = 0, int aggregationDepth = 0, bool areFiltersSelected = false, List<DimensionContent> selectedFilters = null, bool isAllLevel = false) { IsAllLevelSelected = isAllLevel; Axis = axis; Dimension = dimension ?? new Dimension(); LevelDepth = levelDepth; AggregationDepth = aggregationDepth; AreFiltersSelected = areFiltersSelected; SelectedFilters = selectedFilters ?? new List<DimensionContent>(); }
/// <summary> /// Creates a Join-statement for a given dimension. /// </summary> /// <param name="dimension"></param> /// <returns></returns> /// <author>Jannik Arndt, Bernhard Bruns, Bernd Nottbeck</author> public virtual string CreateJoinStatementFromDimension(Dimension dimension) { StringBuilder joinStatement = new StringBuilder(); joinStatement.Append("JOIN ") .Append(TableNameFormatter(dimension.ToTable)) .Append(" ON ") .Append(TableColumnFormatter(dimension.FromTable, dimension.FromColumn)) .Append(" = ") .Append(TableColumnFormatter(dimension.ToTable, dimension.ToColumn)) .Append(" "); return joinStatement.ToString(); }
public void CompareDimensionTest() { Dimension d1 = new Dimension(); Dimension d2 = new Dimension(); d1.DimensionLevelsList = new List<Dimension> {new Dimension()}; d2.DimensionLevelsList = new List<Dimension>(); PrivateType pt = new PrivateType(typeof(XMLHelper)); bool result = (bool)pt.InvokeStatic("CompareDimensions", new Object[] { d1, d2 }); Assert.IsFalse(result); }
/// <summary> /// Recursively go through all level steps and return a list of all necessary join-statements. /// </summary> /// <param name="list">The list that needs to be filled</param> /// <param name="dimension"></param> /// <param name="grain"></param> /// <returns></returns> /// <author>Jannik Arndt, Bernd Nottbeck</author> public virtual List<string> CollectAllJoinStatements(List<string> list, Dimension dimension, int grain) { if (grain < 0) { return list; } if (grain > 0 && dimension != null && dimension.GetCoarserDimensionLevel() != null) CollectAllJoinStatements(list, dimension.GetCoarserDimensionLevel()[0], --grain); if (dimension != null && dimension.ToTable != "") list.Add(CreateJoinStatementFromDimension(dimension)); return list; }
/// <summary> /// Method to Add the logical dimension ALL to every dimension "axis" /// </summary> /// <param name="dimensionList">dimension "axis" list</param> public void AddAllLevel(List<Dimension> dimensionList) { foreach (var dimension in dimensionList) { if (dimension.IsEmptyDimension) continue; var temp = dimension; while (temp.DimensionLevelsList.Count != 0) temp = temp.DimensionLevelsList[0]; var allDimension = new Dimension("ALL", "MPMALLAGGREGATION", "", "", "MPMALLAGGREGATION", "ALL"); allDimension.DimensionContentsList.Add(new DimensionContent("0", "ALL", "ALL")); temp.AddDimensionLevel(allDimension); } }
/// <summary> /// Adds a single Dimension (usually for coarser level). /// </summary> /// <param Name="dimension">A Dimension-Object</param> /// <author>Jannik Arndt</author> public void AddDimensionLevel(Dimension dimension) { DimensionLevelsList.Add(dimension); }
private bool allLevelSelected(Dimension dimension, int levelDepth) { if (levelDepth > 1) { return allLevelSelected(dimension.DimensionLevelsList[0], levelDepth - 1); } return dimension.FromConstraint == "MPMALLAGGREGATION"; }
public void to_tableTest() { Dimension target = new Dimension(); string expected = "Teststring"; string actual; target.ToTable = expected; actual = target.ToTable; Assert.AreEqual(expected, actual); }
public void to_constraintTest() { Dimension target = new Dimension(); string expected = "Teststring"; string actual; target.ToConstraint = expected; actual = target.ToConstraint; Assert.AreEqual(expected, actual); }
public void GetLevelTest() { Dimension target = new Dimension(); Dimension d1 = new Dimension(); Dimension d2 = new Dimension(); d1.AddDimensionLevel(d2); target.AddDimensionLevel(d1); List<Dimension> actual = target.GetLevel(); Assert.AreEqual(actual.Count, 3); }
/// <summary> /// Go through all Axis-Selector-ComboBoxes except the given one and check, if the dimension is already displayed somewhere /// </summary> /// <param name="dimension">The dimension that this method looks for</param> /// <param name="except">If this ComboBox displays the dimension, it is being ignored</param> /// <returns></returns> /// <author>Jannik Arndt</author> public ComboBox CheckIfDimensionIsAlreadySelected(Dimension dimension, ComboBox except) { return _listOfAxisComboBoxes.FirstOrDefault(comboBox => comboBox.SelectedItem == dimension && !comboBox.Equals(except)); }
/// <summary> /// Update internal event selection model. /// </summary> /// <param Name="axis"></param> /// /// <param Name="dim"></param> /// /// <param Name="levelDepth"></param> /// /// <param Name="dimContent"></param> /// <param name="aggregationDepth"></param> public void Update(int axis, Dimension dim, int levelDepth, int aggregationDepth, List<DimensionContent> dimContent) { SelectedDimension showEmptyDimension = null; foreach (SelectedDimension selectedDimension in _instance.SelectedDimensions) { if (selectedDimension.Axis == axis) { if (dim.IsEmptyDimension) { showEmptyDimension = selectedDimension; } else { selectedDimension.Dimension = dim; selectedDimension.LevelDepth = levelDepth; selectedDimension.AggregationDepth = aggregationDepth - 1; //-1 exclude the logical no aggregation dimension selectedDimension.SelectedFilters = dimContent; if (allLevelSelected(selectedDimension.Dimension, selectedDimension.LevelDepth)) { selectedDimension.IsAllLevelSelected = true; } else { selectedDimension.IsAllLevelSelected = false; } } break; } } if (showEmptyDimension != null) { _instance.SelectedDimensions.Remove(showEmptyDimension); } _instance.SelectionHasChangedSinceLastLoading = true; }
/// <summary> /// Looks if the given dimension is also selected by another selector as the given one. /// <param name="showingDimensionSelector">Selector which currently show the dimension.</param> /// <param name="dimension">Dimension to look for.</param> /// </summary> private bool IsAlreadySelected(EventDimensionSelector showingDimensionSelector, Dimension dimension) { foreach (EventDimensionSelector dimSelector in _listOfDimensionSelectors) { if (dimSelector.DimensionComboBox.SelectedItem == dimension && dimSelector != showingDimensionSelector) { return true; } } return false; }
public void from_columnTest() { Dimension target = new Dimension(); string expected = "Teststring"; string actual; target.FromColumn = expected; actual = target.FromColumn; Assert.AreEqual(expected, actual); }
public void DimensionConstructorTest() { Dimension target = new Dimension(); Assert.IsNotNull(target); }
/// <summary> /// This takes a tablename (most likely "FACT") and loads all foreign keys, which should point to a dimension (Table + column). /// It creates a List of Dimensions and adds a dimension for each row the Database returns. It then goes on recursively /// and grabs the Table + Column of the "next" Table, meaning the one you end up at, if you roll up the cube. /// Note that in this piece of code a dimension may have MULTIPLE sub-ListOfDimensions, which should not exist in the model, /// but IF they do, it's not a problem at this point (but rather a GUI-problem) /// </summary> /// <param name="tablename">The Name of the Table whose ListOfDimensions are to be found.</param> /// <returns>A list of ListOfDimensions which, most likely, contain even more ListOfDimensions themselves.</returns> /// <author>Jannik Arndt, Bernd Nottbeck</author> public List<Dimension> GetDimensionsOf(String tablename) { DataTable referencedTables; DataTable dimensionContentDataTable; List<Dimension> resultingListOfDimensions = new List<Dimension>(); try { Open(); // every table row is a dimension referencedTables = GetReferencingDataTable(tablename); foreach (DataRow referencedTableRow in referencedTables.Rows) { // create a dimension-object (see MetaWorker.Dimension) Dimension newDimension = new Dimension(referencedTableRow["FromColumn"].ToString(), referencedTableRow["FromConstraint"].ToString(), referencedTableRow["FromTable"].ToString(), referencedTableRow["FromColumn"].ToString(), referencedTableRow["ToConstraint"].ToString(), referencedTableRow["ToTable"].ToString(), referencedTableRow["ToColumn"].ToString()); // Load the content of this table dimensionContentDataTable = GetTableContent(referencedTableRow["ToTable"].ToString()); // create DimensionContent-Objects and add them to the current dimension foreach (DataRow dimensionContentRow in dimensionContentDataTable.Rows) { string description = ""; if (dimensionContentRow.ItemArray.Count() > 2) description = dimensionContentRow[2].ToString(); newDimension.DimensionContentsList.Add(new DimensionContent(dimensionContentRow[0].ToString(), dimensionContentRow[1].ToString(), description)); } // save the DimensionColumnNames for generated DB-querys newDimension.DimensionColumnNames = new DimensionColumnNames(dimensionContentDataTable.Columns[0].ColumnName, dimensionContentDataTable.Columns[1].ColumnName, dimensionContentDataTable.Columns[2].ColumnName); dimensionContentDataTable.Reset(); // now recursively find all sub-ListOfDimensions of this Table and add them to the current dimension newDimension.AddDimensionLevel(GetDimensionsOf(referencedTableRow["ToTable"].ToString())); // add the current dimension to the list that will be returned eventually resultingListOfDimensions.Add(newDimension); } return resultingListOfDimensions; } finally { Close(); } }
/// <summary> /// Returns the dimension table for the given level /// </summary> /// <param name="dimension"></param> /// /// <param name="levelDepth"></param> /// <author>Roman Bauer</author> private Dimension getDimensionByLevelDepth(Dimension dimension, int levelDepth) { if (levelDepth > 1) return getDimensionByLevelDepth(dimension.DimensionLevelsList[0], levelDepth - 1); return dimension; }
public void DimensionConstructorTest1() { string setname = "Teststring"; string setfrom_constraint = "Teststring"; string setfrom_table = "Teststring"; string setfrom_column = "Teststring"; string setto_constraint = "Teststring"; string setto_table = "Teststring"; string setto_column = "Teststring"; Dimension target = new Dimension(setname, setfrom_constraint, setfrom_table, setfrom_column, setto_constraint, setto_table, setto_column); Assert.IsNotNull(target); }
/// <summary> /// Private method to build the list of sub-ListOfDimensions (=level) recursively. /// </summary> /// <param Name="dimension">Start with "this".</param> /// <author>Jannik Arndt</author> private void BuildLevelList(Dimension dimension) { LevelList.Add(dimension); if (dimension.DimensionLevelsList.Count > 0) BuildLevelList(dimension.DimensionLevelsList[0]); }
private List<EventDimensionSelector> GetShowingDimensionSelectors(Dimension dimension) { List<EventDimensionSelector> foundSelectors = new List<EventDimensionSelector>(); foreach (EventDimensionSelector dimSelector in _listOfDimensionSelectors) { if (dimSelector.DimensionComboBox.SelectedItem == dimension) { foundSelectors.Add(dimSelector); } } return foundSelectors; }
/// <summary> /// Init selector with the given dimensions. /// <param name="allDimensions">All dimensions which the selector could show.</param> /// <param name="dimensionToShow">Current dimension to show.</param> /// </summary> internal void Init(List<Dimension> allDimensions, Dimension dimensionToShow) { ShowedDimension = dimensionToShow; //set dimension List<Dimension> temp = new List<Dimension>(); Dimension emptyDimension = new Dimension("no selection", toTable: "no selection", isEmptyDimension: true); temp.Add(emptyDimension); temp.AddRange(allDimensions); DimensionComboBox.ItemsSource = temp; DimensionComboBox.DisplayMemberPath = "Dimensionname"; DimensionComboBox.SelectedItem = temp[temp.IndexOf(dimensionToShow)]; //set level DimensionLevelComboBox.ItemsSource = dimensionToShow.GetLevel(); DimensionLevelComboBox.DisplayMemberPath = "Level"; DimensionLevelComboBox.SelectedIndex = DimensionLevelComboBox.Items.Count - 1;//select highest level by default //set aggregation temp = new List<Dimension>(); Dimension emptyLevel = new Dimension("empty level", toTable: "no aggregation", isEmptyDimension: true); temp.Add(emptyLevel); temp.AddRange(dimensionToShow.GetLevel()); DimensionAggregationComboBox.Items.Clear(); //exclude the all level dimension for aggregation level combobox foreach (Dimension dim in temp) { if (dim != temp.Last()) { DimensionAggregationComboBox.Items.Add(dim); } } DimensionAggregationComboBox.DisplayMemberPath = "Level"; DimensionAggregationComboBox.SelectedIndex = 0; //set content var showedLevel = (Dimension)DimensionLevelComboBox.SelectedItem; DimensionContentFilter.ItemsSource = showedLevel.DimensionContentsList; DimensionContentFilter.DisplayMemberPath = "content"; DimensionContentFilter.SelectAll(); DimensionContentSearch.Clear(); }
private void updateInternalEventSelectionModel(int axis, Dimension dimension, int levelDepth, int aggregatioDepth, List<DimensionContent> dimensionContent) { EventSelectionModel.GetInstance().Update(axis, dimension, levelDepth, aggregatioDepth, dimensionContent); }
internal void UpdateByDimensionChange(Dimension newSelectedDimension) { ShowedDimension = newSelectedDimension; //update level DimensionLevelComboBox.ItemsSource = newSelectedDimension.GetLevel(); //update aggregation level List<Dimension> temp = new List<Dimension>(); Dimension emptyLevel = new Dimension("empty level", toTable: "no aggregation", isEmptyDimension: true); temp.Add(emptyLevel); temp.AddRange(newSelectedDimension.GetLevel()); DimensionAggregationComboBox.Items.Clear(); //exclude the all level for aggregation level combobox foreach (Dimension dim in temp) { if (dim != temp.Last()) { DimensionAggregationComboBox.Items.Add(dim); } } DimensionAggregationComboBox.DisplayMemberPath = "Level"; DimensionAggregationComboBox.SelectedIndex = 0; //update content DimensionContentSearch.Clear(); }