Exemplo n.º 1
0
        internal override List <PXSqlValue> GetValuesForParsing()
        {
            if (currentGrouping != null)
            {
                return(currentGrouping.GetValuesForParsing());
            }

            if (selectedValueset == null)
            {
                return(new List <PXSqlValue>());
            }

            if ((meta.inPresentationModus) && meta.ConstructedFromPxs)
            {
                return(mValues.GetValuesSortedByPxs(mValues.GetValuesForSelectedValueset(selectedValueset)));
                //return GetValuesSortedDefault(GetValuesForSelectedValueset()); // old sorting Thomas say its how Old Pcaxis does
            }
            else
            {
                PXSqlValueSet     tmpValueSet = mValueSets[selectedValueset];
                List <PXSqlValue> myOut       = new List <PXSqlValue>(tmpValueSet.NumberOfValues);
                foreach (string code in tmpValueSet.SortedListOfCodes)
                {
                    myOut.Add(mValues[code]);
                }
                return(myOut);
            }
        }
Exemplo n.º 2
0
        protected override void SetElimForPresentation()
        {
            string     tmpElim;
            PXSqlValue mValue;

            this.IsEliminatedByValue = false;

            List <decimal> NumberOfValuesInValuesets = new List <decimal>();


            if (pxsQueryVariable != null)
            {
                if (!string.IsNullOrEmpty(this.pxsQueryVariable.StructureId))
                {
                    int valueSetCount = this.ValueSets.Count();

                    if (valueSetCount > 1)
                    {
                        var           valuesetsWithEliminationValue = this.ValueSets.Where(x => x.Value.Elimination != meta.Config.Codes.EliminationN && x.Value.Elimination != meta.Config.Codes.EliminationA);
                        PXSqlValueSet onlyVsWithEliminationValue    = valuesetsWithEliminationValue.Count() == 1 ? valuesetsWithEliminationValue.First().Value : null;

                        if (this.ValueSets.Keys.Any(x => x == PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS))
                        {
                            selectedValueset = PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS;
                            PXSqlValueSet vs = this.ValueSets[PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS];
                            NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                            tmpElim = vs.Elimination;
                        }
                        else if (onlyVsWithEliminationValue != null)
                        {
                            NumberOfValuesInValuesets.Add(onlyVsWithEliminationValue.NumberOfValues);
                            tmpElim = onlyVsWithEliminationValue.Elimination;
                        }
                        else
                        {
                            tmpElim = meta.Config.Codes.EliminationN;
                        }
                    }
                    else if (valueSetCount == 1 && this.ValueSets.First().Value.Elimination != meta.Config.Codes.EliminationN)
                    {
                        PXSqlValueSet vs = this.ValueSets.First().Value;
                        NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                        tmpElim = vs.Elimination;
                    }
                    else
                    {
                        tmpElim = meta.Config.Codes.EliminationN;
                    }
                }
                else
                {
                    PXSqlValueSet vs = this.ValueSets[selectedValueset];
                    NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                    tmpElim = vs.Elimination;
                }
            }
            else
            {
                PXSqlValueSet vs = this.ValueSets[selectedValueset];
                NumberOfValuesInValuesets.Add(vs.NumberOfValues);
                tmpElim = vs.Elimination;
            }

            if (tmpElim == meta.Config.Codes.EliminationN || tmpElim.Length == 0)
            {
                if (!this.isSelected)
                {
                    throw new PCAxis.Sql.Exceptions.PxsException(11, this.Name);
                }
                else
                {
                    this.PaxiomElimination = PXConstant.NO;
                }
            }
            else if (tmpElim == meta.Config.Codes.EliminationA)
            {
                if (this.isSelected)
                {
                    // We have to compare values in the valuepool(s) with the values selected in the PxsFile

                    if (this.Values.Count == NumberOfValuesInValuesets[0])
                    {
                        this.PaxiomElimination = PXConstant.YES;
                    }
                    else
                    {
                        this.PaxiomElimination = PXConstant.NO;
                    }
                }
            }
            else
            { // An elimination value exist for the variable.
                if (this.isSelected)
                {
                    if (this.Values.TryGetValue(tmpElim, out mValue))
                    { // the elimination value is selected
                        this.PaxiomElimination = mValue.ValueCode;
                    }



                    else
                    { // The Elimination value is not selected.  Elimination in Paxiom should be NO.
                        this.PaxiomElimination = PXConstant.NO;
                    }
                }
                // If an elimiantion value exists and no values are selected for the variable, the elimination
                // value should be used when selecting data, and metadata should be marked as eliminated by value.
                else
                {
                    mValue           = new PXSqlValue();
                    mValue.ValueCode = tmpElim;

                    this.Values.Add(mValue.ValueCode, mValue);
                    this.IsEliminatedByValue = true;
                }
            }
        }
Exemplo n.º 3
0
        private void SetValueset()
        {
            valusetIds = new StringCollection();

            List <PXSqlValueSet> sortedValuesets = new List <PXSqlValueSet>();

            string defaultInGuiValueset = metaQuery.GetValuesetIdDefaultInGui(meta.MainTable.MainTable, this.Name);

            if (this.pxsQueryVariable == null || this.pxsQueryVariable.SelectedValueset == PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS)
            {
                var  valueSetsByPresText = new Dictionary <string, PXSqlValueSet>();
                bool shouldSubTableVarablesBeSortedAlphabetical = meta.MetaQuery.ShouldSubTableVarablesBeSortedAlphabetical(meta.MainTable.MainTable, this.Name);

                List <string> valuesetIds = meta.MetaQuery.GetValuesetIdsFromSubTableVariableOrderedBySortcode(meta.MainTable.MainTable, this.Name);

                foreach (string valuesetId in valuesetIds)
                {
                    bool isDefault = valuesetId.Equals(defaultInGuiValueset);

                    if (shouldSubTableVarablesBeSortedAlphabetical)
                    {
                        var valueSet = new PXSqlValueSet(meta.MetaQuery.GetValueSetRow(valuesetId), meta, isDefault);
                        valueSetsByPresText[valueSet.PresText[this.meta.MainLanguageCode]] = valueSet;
                    }
                    else
                    {
                        sortedValuesets.Add(new PXSqlValueSet(meta.MetaQuery.GetValueSetRow(valuesetId), meta, isDefault));
                    }
                }

                if (shouldSubTableVarablesBeSortedAlphabetical)
                {
                    var sortedValuesetPresTexts = valueSetsByPresText.Keys.OrderBy(x => x).ToArray();

                    foreach (var presText in sortedValuesetPresTexts)
                    {
                        sortedValuesets.Add(valueSetsByPresText[presText]);
                    }
                }
            }
            else
            {
                // for selected valueset without subtable stored in pxs.
                bool isDefault = this.pxsQueryVariable.SelectedValueset.Equals(defaultInGuiValueset);
                sortedValuesets.Add(new PXSqlValueSet(meta.MetaQuery.GetValueSetRow(this.pxsQueryVariable.SelectedValueset), meta, isDefault));
            }



            int NumberOfSelectedValueSets = sortedValuesets.Count;

            mValueSets = new Dictionary <string, PXSqlValueSet>();
            int totalNumberOfValues = 0;

            List <EliminationAux> elimValues = new List <EliminationAux>(); // For the magicAll valueSet

            StringCollection tmpValuePres = new StringCollection();         // For the magicAll valueSet
            List <string>    metaIdValues = new List <string>();            // For all the magicAll ValueSet MetaId

            foreach (PXSqlValueSet valueSetItem in sortedValuesets)
            {
                mValueSet = valueSetItem;
                mValueSet.NumberOfValues = meta.MetaQuery.GetNumberOfValuesInValueSetById(mValueSet.ValueSet);

                totalNumberOfValues += mValueSet.NumberOfValues;

                mValueSets.Add(mValueSet.ValueSet, mValueSet);
                valusetIds.Add(mValueSet.ValueSet);
                metaIdValues.Add(mValueSet.MetaId);

                // helpers for the magicAll
                elimValues.Add(mValueSet.GetEliminationAux());
                if (!tmpValuePres.Contains(mValueSet.ValuePres))
                {
                    tmpValuePres.Add(mValueSet.ValuePres);
                }
            }

            // Add the collection to the variable.
            //this.ValueSets = mValueSets;  a = a !

            this.TotalNumberOfValuesInDB = totalNumberOfValues;

            if (NumberOfSelectedValueSets == 1)
            {
                selectedValueset = mValueSet.ValueSet;
                addMetaId(mValueSet.MetaId);
            }
            else
            {
                string allValuePres;
                if (tmpValuePres.Count == 1)
                {
                    allValuePres = tmpValuePres[0];
                }
                else
                {
                    allValuePres = "V"; //For valuepool TODO her må det endres slik at codes V legges i config fila
                }
                PXSqlValueSet magicAll = new PXSqlValueSet(this.PresText, sortedValuesets[0].ValuePoolId, elimValues, metaQuery.DB.Codes.No, allValuePres);
                magicAll.NumberOfValues = totalNumberOfValues;
                this.ValueSets.Add(magicAll.ValueSet, magicAll);
                foreach (var metaId in metaIdValues)
                {
                    addMetaId(metaId);
                }
            }
        }