Beispiel #1
0
        private List <PXSqlGroup> GetListOfGroupFromPxs()
        {
            if (this.pxsQueryVariable.Values.Items.Length == 0)
            {
                throw new ApplicationException("GetListOfGroupFromPxs(): No entries found");
            }
            List <PXSqlGroup> myOut = new List <PXSqlGroup>();

            foreach (PCAxis.Sql.Pxs.ValueTypeWithGroup val in this.pxsQueryVariable.Values.Items)
            {
                if (val.code.Contains("*") || val.code.Contains("?"))
                {
                    throw new ApplicationException("GetListOfGroupFromPxs(): Groups cannot contain wildcards");
                }
                PXSqlGroup group = new PXSqlGroup(val.code);

                if (val.Group == null || val.Group.GroupValue == null || val.Group.GroupValue.Length < 1)
                {
                    throw new ApplicationException("GetListOfGroupFromPxs(): Expected group children");
                }
                foreach (GroupValueType child in val.Group.GroupValue)
                {
                    group.AddChildCode(child.code);
                }
                myOut.Add(group);
            }
            return(myOut);
        }
Beispiel #2
0
        /// <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_24 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);
            }
        }
Beispiel #3
0
        //for selection or presentation with grouping id in from pxs
        public PXSqlGrouping(GroupingRow groupingRow, PXSqlMeta_24 meta, PXSqlVariableClassification var, StringCollection outputCodes)
        {
            Init(groupingRow, meta, var);


            StringCollection tempParentList = new StringCollection();

            mGroups = new List <PXSqlGroup>();
            PXSqlGroup tmpGroup = null;

            this.isHierarchy = this.mHierarchy != meta.Config.Codes.HierarchyNon;
            foreach (string code in outputCodes)
            {
                tmpGroup = new PXSqlGroup(code);
                mGroups.Add(tmpGroup);
            }

            var parentGroupCodes = mGroups.Select(x => x.ParentCode).ToArray();
            Dictionary <string, ValueGroupRow>  templist = meta.MetaQuery.GetValueGroupRowskeyValueCode(mGroupingId, parentGroupCodes, true);
            Dictionary <string, List <string> > childCodesByParentCode = new Dictionary <string, List <string> >();

            foreach (var listItem in templist)
            {
                string parentCode = listItem.Value.GroupCode;

                if (!childCodesByParentCode.ContainsKey(parentCode))
                {
                    childCodesByParentCode[parentCode] = new List <string>();
                }

                childCodesByParentCode[parentCode].Add(listItem.Key);
            }

            foreach (PXSqlGroup group in mGroups)
            {
                if (childCodesByParentCode.ContainsKey(group.ParentCode))
                {
                    foreach (var childCode in childCodesByParentCode[group.ParentCode])
                    {
                        group.AddChildCode(childCode);
                    }
                }
                else
                {
                    group.AddChildCode(group.ParentCode);
                }
            }

            // Add the values to valuecollection of this variable
            AddValues(mValuePoolId, outputCodes, valuePoolValueTextExists);
        }
Beispiel #4
0
 public void CreateHierarchyForParsing(PXSqlGroup group)
 {
     foreach (string childCode in group.ChildCodes)
     {
         //hierarchiesKeywordValue  += "\"" + group.ParentCode + "\"" + ":" + "\"" + childCode + "\"," ;
         hierarchiesKeywordValue.Add("\"" + group.ParentCode + "\"" + ":" + "\"" + childCode + "\"");
         foreach (PXSqlGroup childGroup in mGroups)
         {
             if (childGroup.ParentCode == childCode)
             {
                 CreateHierarchyForParsing(childGroup);
             }
         }
     }
     return;
 }
Beispiel #5
0
        /// <summary>
        /// Recursive method drilling down to the leafs
        /// </summary>
        /// <param name="toGroup">Add the leaf IDs to this</param>
        /// <param name="parentCode">Check if this has children</param>
        private void addLeafChildIds(PXSqlGroup toGroup, String parentCode)
        {
            Dictionary <string, ValueGroupRow> templist = meta.MetaQuery.GetValueGroupRowskeyValueCode(mGroupingId, parentCode, true);

            if (templist.Count < 1)
            {
                //Has no children
                toGroup.AddChildCode(parentCode);
            }
            else
            {
                foreach (KeyValuePair <string, ValueGroupRow> childOfparent in templist)
                {
                    addLeafChildIds(toGroup, childOfparent.Key);
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// Recursive method to receive all values for all groups in a grouping.
 /// </summary>
 /// <param name="group"></param>
 /// <param name="childrenlist"></param>
 /// <returns></returns>
 public List <PXSqlValue> GetHierarchicalValues(PXSqlGroup group, List <PXSqlValue> childrenlist)
 {
     if (group.GroupLevel == 1)
     {
         childrenlist.Add(variable.Values[group.ParentCode]);
     }
     foreach (string childCode in group.ChildCodes)
     {
         childrenlist.Add(variable.Values[childCode]);
         foreach (PXSqlGroup childGroup in mGroups)
         {
             if (childGroup.ParentCode == childCode)
             {
                 GetHierarchicalValues(childGroup, childrenlist);
             }
         }
     }
     return(childrenlist);
 }
Beispiel #7
0
        /// <summary>
        /// Creates Hierarchical groups
        /// </summary>
        /// <returns></returns>
        private void createHierarchy(List <ValueGroupRow> mGroupRows)
        {
            int        counter;
            PXSqlGroup myGoup = null;

            if (mGroupRows.Count < 1)
            {
            }
            else
            {
                counter = 0;
                foreach (ValueGroupRow row in mGroupRows)
                {
                    if (counter == 0)
                    {
                        myGoup            = new PXSqlGroup(row.GroupCode);
                        myGoup.GroupLevel = int.Parse(row.GroupLevel);
                        mGroups.Add(myGoup);
                        if (row.GroupLevel == "1")
                        {
                            tempValueList.Add(row.GroupCode);
                            rootGroup = myGoup;
                        }
                    }
                    myGoup.AddChildCode(row.ValueCode);
                    tempValueList.Add(row.ValueCode);
                    List <ValueGroupRow> templist = new List <ValueGroupRow>();
                    foreach (KeyValuePair <string, ValueGroupRow> tempdict in meta.MetaQuery.GetValueGroupRowskeyValueCode(mGroupingId, row.ValueCode, true))
                    {
                        templist.Add(tempdict.Value);
                    }
                    if (templist.Count > 0)
                    {
                        createHierarchy(templist);
                    }
                    counter++;
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Returns a List of PXSqlGroup with one PXSqlGroup for each output "row"
        /// ( if children is to be displayed, they must be included as their own parent)
        /// The Group must be "expanded" in the sense that the children codes must "point" to rows in the datadata-table.
        /// This is used only when a Sum is used to calculate values.
        /// </summary>
        internal List <PXSqlGroup> GetGroupsForDataParsing()
        {
            if (!this.isOnNonstoredData())
            {
                throw new ApplicationException("Grouping BUG");
            }

            if (this.isHierarchy)
            {
                List <PXSqlGroup> myOut = new List <PXSqlGroup>();
                foreach (PXSqlGroup unExpanded in mGroups)
                {
                    PXSqlGroup tmpGroup = new PXSqlGroup(unExpanded.ParentCode);
                    this.addLeafChildIds(tmpGroup, unExpanded.ParentCode);
                    myOut.Add(tmpGroup);
                }
                return(myOut);
            }
            else
            {
                //The non-hierarchy has no levels to expand
                return(mGroups);
            }
        }