/// <summary> /// Constructor called when parser is in selectionmode and there are no grouping ids in pxs or no pxs at all. /// </summary> /// <returns></returns> public PXSqlGrouping(GroupingRow groupingRow, PXSqlMeta_22 meta, PXSqlVariableClassification var, GroupingIncludesType include) { Init(groupingRow, meta, var); //TODO overriding include from paxiom, have to discuss how paxion can override database default. this.mIncludeType = include; // DONE, is now passed to paxiom as part of GroupingInfo ... this.mIncludeType = this.mDefaultIncludeType; //TODO end tempValueList = new StringCollection(); StringCollection tempParentList = new StringCollection(); mGroups = new List <PXSqlGroup>(); PXSqlGroup tmpGroup = null; this.isHierarchy = this.mHierarchy != meta.Config.Codes.HierarchyNon; if (!isHierarchy) // Not hierarchical groups { this.mIncludeType = include; List <ValueGroupRow> myValuegroupRows = meta.MetaQuery.GetValueGroupRowsSorted(mGroupingId, null, true, meta.MainLanguageCode); foreach (ValueGroupRow myRow in myValuegroupRows) { if (!tempParentList.Contains(myRow.GroupCode)) { tmpGroup = new PXSqlGroup(myRow.GroupCode); mGroups.Add(tmpGroup); tempParentList.Add(myRow.GroupCode); } else { foreach (PXSqlGroup group in mGroups) { if (group.ParentCode == myRow.GroupCode) { tmpGroup = group; break; } } } tmpGroup.AddChildCode(myRow.ValueCode); } AddValues(mValuePoolId, tempParentList, valuePoolValueTextExists); } else //hierarchical groups { this.mIncludeType = GroupingIncludesType.All; createHierarchy(meta.MetaQuery.GetValueGroupRowsSorted(mGroupingId, levelOne, true, meta.MainLanguageCode)); setHierarchyLevelsOpen(); setHierarchyLevels(); setHierarchyNames(); variable.Values.Clear(); AddValues(mValuePoolId, tempValueList, valuePoolValueTextExists); } }
/// <summary> /// Get filter string for aggregation type /// </summary> /// <param name="aggType">Aggregation type</param> /// <returns>Filter string for the aggregation type</returns> public static string GetAggregationTypeFilterString(GroupingIncludesType aggType) { switch (aggType) { case GroupingIncludesType.AggregatedValues: return("agg:"); case GroupingIncludesType.SingleValues: return("agg_single:"); case GroupingIncludesType.All: return("agg_all:"); default: return("agg:"); } }
private void Init(GroupingRow groupingRow, PXSqlMeta_24 meta, PXSqlVariableClassification var) { this.meta = meta; this.variable = var; this.valuePoolValueTextExists = var.ValuePool.ValueTextExists; this.mValuePoolId = groupingRow.ValuePool; this.mValuesetIds = var.ValusetIds; this.mGroupingId = groupingRow.Grouping; this.mGroupPres = groupingRow.GroupPres; // throw new NotImplementedException("I init i PXSqlGrouping"); //TODO; tok bort this.mGeoAreaNo = groupingRow.GeoAreaNo; // this.mGeoAreaNo = groupingRow.GeoAreaNo; this.mHierarchy = groupingRow.Hierarchy; this.Description = groupingRow.Description; this.mIsDefault = !string.IsNullOrEmpty(groupingRow.DefaultInGui) && groupingRow.DefaultInGui == meta.Config.Codes.Yes; this.PresText = new Dictionary <string, string>(); foreach (string langCode in meta.LanguageCodes) { this.PresText[langCode] = groupingRow.texts[langCode].PresText; } this.SortCode = groupingRow.texts[meta.MainLanguageCode].SortCode; //TODO added databasedefault to override value from paxiom, should be possible to do both switch (this.mGroupPres.ToUpper()) { case "I": mDefaultIncludeType = GroupingIncludesType.SingleValues; break; case "A": mDefaultIncludeType = GroupingIncludesType.AggregatedValues; break; case "B": mDefaultIncludeType = GroupingIncludesType.All; break; default: mDefaultIncludeType = GroupingIncludesType.AggregatedValues; break; } }
//for Selection without grouping id in from pxs public PXSqlGrouping(GroupingRow groupingRow, PXSqlMeta_21 meta, PXSqlVariableClassification var, GroupingIncludesType include) { Init(groupingRow, meta, var); //TODO overriding include from paxiom, have to discuss how paxion can override database default. this.mIncludeType = include; // DONE, is now passed to paxiom as part of GroupingInfo ... this.mIncludeType = this.mDefaultIncludeType; //TODO end StringCollection tempParentList = new StringCollection(); mGroups = new List <PXSqlGroup>(); PXSqlGroup tmpGroup = null; foreach (VSGroupRow myRow in meta.MetaQuery.GetVSGroupRowsSorted(mValuePoolId, mValuesetIds, mGroupingId, meta.MainLanguageCode)) { if (!tempParentList.Contains(myRow.GroupCode)) { tmpGroup = new PXSqlGroup(myRow.GroupCode); mGroups.Add(tmpGroup); tempParentList.Add(myRow.GroupCode); } else { foreach (PXSqlGroup group in mGroups) { if (group.ParentCode == myRow.GroupCode) { tmpGroup = group; break; } } } tmpGroup.AddChildCode(myRow.ValueCode); } // Add the values to valuecollection of this variable AddValues(mValuePoolId, tempParentList, valuePoolValueTextExists); //PXSqlValue tempValue; // foreach (ValueRow row in meta.MetaQuery.GetValueRowsByValuePool(mValuePoolId, tempParentList, valuePoolValueTextExists)) //{ // tempValue = new PXSqlValue(row, meta.LanguageCodes, meta.MainLanguageCode); // var.Values.Add(tempValue.ValueCode,tempValue); //} }
/// <summary>Started from GUI via builder, a grouping is applied.</summary> /// <param name="paxiomVariable">the paxiom Variable </param> /// <param name="groupingId">The id of the grouping</param> /// <param name="include">Emun value inducating what the new codelist should include:parents,childern or both </param> internal void ApplyGrouping(Variable paxiomVariable, string groupingId, GroupingIncludesType include) { paxiomVariable.RecreateValues();// per inge values for variable must be deleted before created for new valueset. this.currentGrouping = new PXSqlGrouping(this.metaQuery.GetGroupingRow(ValuePool.ValuePool, groupingId), meta, this, include); this.selectedValueset = PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS; //todo; or should it be valuset for vsgroup? //was SetElimForSelection(); //TODO How should elimination for groups be? // SetDefaultPresTextOption(); this.PaxiomElimination = PXConstant.NO; this.PresTextOption = this.ValuePool.ValuePres; //send new state to paxiom: paxiomVariable.CurrentGrouping = this.currentGrouping.GetPaxiomGrouping(); }
private void Init(GroupingRow groupingRow, PXSqlMeta_21 meta, PXSqlVariableClassification var) { this.meta = meta; this.variable = var; this.valuePoolValueTextExists = var.ValuePool.ValueTextExists; this.mValuePoolId = groupingRow.ValuePool; this.mValuesetIds = var.ValusetIds; this.mGroupingId = groupingRow.Grouping; this.mGroupPres = groupingRow.GroupPres; this.mGeoAreaNo = groupingRow.GeoAreaNo; this.PresText = new Dictionary <string, string>(); this.Description = groupingRow.Description; foreach (string langCode in meta.LanguageCodes) { this.PresText[langCode] = groupingRow.texts[langCode].PresText; } this.SortCode = groupingRow.texts[meta.MainLanguageCode].SortCode; //TODO added databasedefault to override value from paxiom, should be possible to do both switch (this.mGroupPres.ToUpper()) { case "I": mDefaultIncludeType = GroupingIncludesType.SingleValues; break; case "A": mDefaultIncludeType = GroupingIncludesType.AggregatedValues; break; case "B": mDefaultIncludeType = GroupingIncludesType.All; break; default: mDefaultIncludeType = GroupingIncludesType.AggregatedValues; break; } }
/// <summary> /// Tries to parse the aggregation name and type from the filter string /// </summary> /// <param name="filter">Filter string</param> /// <param name="aggregation">Aggregation name</param> /// <param name="aggregationType">Aggregation type</param> /// <returns>True if aggregation name and type could be parsed, else false</returns> public static bool TryParseAggregationAndType(string filter, out string aggregation, out GroupingIncludesType aggregationType) { int startIndex; if (filter.StartsWith("agg:")) { aggregationType = GroupingIncludesType.AggregatedValues; startIndex = 4; } else if (filter.StartsWith("agg_single:")) { aggregationType = GroupingIncludesType.SingleValues; startIndex = 11; } else if (filter.StartsWith("agg_all:")) { aggregationType = GroupingIncludesType.All; startIndex = 8; } else { aggregation = ""; aggregationType = GroupingIncludesType.AggregatedValues; return(false); //Not an aggregation } aggregation = filter.Substring(startIndex); return(true); }
/// <summary>Finds the variable and passes to call on to it</summary> /// <param name="paxiomVariable">The paxiom Varable, but both this and the name?? </param> /// <param name="variableCode">The variable to which the new Grouping should be applied</param> /// <param name="groupingId">The id of the new grouping</param> /// <param name="include">Emun value inducating what the new codelist should include:parents,childern or both </param> override internal void ApplyGrouping(Variable paxiomVariable, string variableCode, string groupingId, GroupingIncludesType include) { if (mVariablesClassification.ContainsKey(variableCode)) { mVariablesClassification[variableCode].ApplyGrouping(paxiomVariable, groupingId, include); } else { throw new ApplicationException("BUG"); } }
/// <summary>Finds the variable and passes to call on to it</summary> /// <param name="paxiomVariable">The paxiom Varable, but both this and the name?? </param> /// <param name="variableCode">The variable to which the new Grouping should be applied</param> /// <param name="groupingId">The id of the new grouping</param> /// <param name="include">Emun value inducating what the new codelist should include:parents,childern or both </param> internal abstract void ApplyGrouping(Variable paxiomVariable, string variableCode, string groupingId, GroupingIncludesType include);
public override void ApplyGrouping(string variableCode, GroupingInfo groupInfo, GroupingIncludesType include) { //JFI: ingen recreateValues? Variable paxiomVariable = base.Model.Meta.Variables.GetByCode(variableCode); //alter state of mPXSqlMeta, and change paxiomVariable (except sendeing codelists): mPXSqlMeta.ApplyGrouping(paxiomVariable, variableCode, groupInfo.ID, include); paxiomVariable.CurrentGrouping.GroupPres = include; //send the codelist: m_parser = PXSqlParserForCodelists.GetPXSqlParserForCodelists(mPXSqlMeta, variableCode); base.BuildForSelection(); //JFI: Ingen .CurrentValueSet= ? }