Esempio n. 1
0
        private void SetVariableName(string variablecode, string variablename, PCAxis.Paxiom.PXMeta meta)
        {
            Variable v;

            v = FindVariable(meta, variablecode);
            if (v == null)
            {
                return;
            }
            v.Name = variablename;
        }
Esempio n. 2
0
 private void SetElimination(string variablename, string elimination, PCAxis.Paxiom.PXMeta meta)
 {
     PCAxis.Paxiom.Variable v;
     v = FindVariable(meta, variablename);
     if (v == null)
     {
         this.Warnings.Add(new BuilderMessage(ErrorCodes.ELIMINATION));
         return;
     }
     v.SetElimination(elimination);
     if (elimination != "YES")
     {
         v.SetEliminationValue(elimination);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// For creation after "build for selection GUI"
        /// </summary>
        /// <param name="pax"></param>
        /// <param name="langs"></param>
        /// <param name="selections"></param>
        /// <param name="pxsqlMeta"></param>
        public PxsQuery(PCAxis.Paxiom.PXMeta pax, StringCollection langs, PCAxis.Paxiom.Selection[] selections, InfoFromPxSqlMeta2PxsQuery pxsqlMeta)
        {
            init1();


            #region this.Information
            //this.Information.CreatedDate = DateTime.Now;
            //skal bruke pax.Meta.CreationDate men hva er formatet til denne stringen?
            #endregion this.Information


            #region this.Query

            List <string> theLangs = new List <string>();
            foreach (string aLang in langs)
            {
                theLangs.Add(aLang);
            }


            this.setLangs(theLangs);

            //this.Query.TableSource = pax.TableID; // eller Matrix
            this.Query.TableSource = pax.MainTable;// changed. reqtest bug 325/339



            List <PQVariable> tmpPxsVars = new List <PQVariable>();


            foreach (Variable var in pax.Variables)
            {
                Selection correspondingSelection = null;
                foreach (Selection sel in selections)
                {
                    if (sel.VariableCode.Equals(var.Code))
                    {
                        correspondingSelection = sel;
                    }
                }



                if (var.IsContentVariable || var.Code.Equals("CONTENTSCODE") || var.IsTime || var.Code.Equals("TID") || var.Code.Equals("Tid"))
                {
                    List <BasicValueType> tmpList = new List <BasicValueType>();

                    int sortOrder = 1;

                    foreach (string valCode in correspondingSelection.ValueCodes)
                    {
                        if (var.IsContentVariable || var.Code.Equals("CONTENTSCODE")) // new piv
                        {
                            string contents = var.Values.GetByCode(valCode).ContentInfo.RefrenceID;
                            tmpList.Add(new BasicValueType(contents, sortOrder++));
                        }
                        else
                        {
                            tmpList.Add(new BasicValueType(valCode, sortOrder++));
                        }
                    }

                    if (var.IsContentVariable || var.Code.Equals("CONTENTSCODE"))
                    {
                        this.Query.Contents.code = var.Code;
                        //

                        //
                        this.Query.Contents.Content = tmpList.ToArray();
                    }
                    else
                    {
                        //pax vet bare nok til å lage timeoption 0 :-<
                        #region this.Query.Time
                        this.Query.Time.code       = var.Code;
                        this.Query.Time.TimeOption = TimeTypeTimeOption.Item0;

                        TimeTypeTimeValues tttv = new TimeTypeTimeValues();
                        tttv.TimeValue       = tmpList.ToArray();
                        this.Query.Time.Item = tttv;

                        this.Query.Time.TimeVal = var.TimeValue;//??
                        #endregion this.Query.Time
                    }
                }
                else     //classification
                {
                    #region preparing for this.Query.Variables
                    PQVariable tmpPxsVar = new PQVariable();
                    tmpPxsVar.code = var.Code;

                    //på tynn is her:

                    tmpPxsVar.Aggregation = PQVariableAggregation.N;

                    string selectedValueset = pxsqlMeta.GetSelectedValuesetId(var.Code);


                    string currentGrouping = pxsqlMeta.GetCurrentGroupingId(var.Code);


                    //
                    // string currentGrouping = var.CurrentGrouping; will get trouble for pxs4selection
                    // with a grouping, since it is not an "applied grouping", but more of a "backgroud grouping"


                    if (!String.IsNullOrEmpty(currentGrouping))
                    {
                        tmpPxsVar.Aggregation = PQVariableAggregation.G;
                        tmpPxsVar.StructureId = currentGrouping;
                        log.Debug(currentGrouping);
                        //} else if ( (! String.IsNullOrEmpty(selectedValueset)) &&
                        //    selectedValueset != PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS) {
                        //        tmpPxsVar.StructureId = pxsqlMeta.Variables[var.Code].SelectedValueset;
                        //        tmpPxsVar.Aggregation = PQVariableAggregation.V;
                        //    // denne skulle vel bort?
                    }
                    //skip variables which does not have codes in Selection object
                    if (correspondingSelection == null || correspondingSelection.ValueCodes.Count == 0)
                    {
                        if (pxsqlMeta.GetSelectedValuesetId(var.Code) == null || (pxsqlMeta.GetSelectedValuesetId(var.Code) == PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS && String.IsNullOrEmpty(currentGrouping))) // added to save info about selected valueset.
                        {
                            continue;
                        }
                    }

                    //Hmm: hva skal gjelde: paxiom eller pxs?
                    //Hmm2: ved endring av kode/text i grensesntitt, bør det kjøres en applyCodeText noe som fører til at neste linje kan slettes og opsjon fra paxiom brukes
                    //tmpPxsVar.PresTextOption = "Both";


                    tmpPxsVar.Values       = new PQVariableValues();
                    tmpPxsVar.Values.Items = new ValueTypeWithGroup[correspondingSelection.ValueCodes.Count];

                    for (int n = 0; n < tmpPxsVar.Values.Items.Length; n++)
                    {
                        tmpPxsVar.Values.Items[n] = new ValueTypeWithGroup(correspondingSelection.ValueCodes[n], n + 1);
                    }

                    tmpPxsVar.SelectedValueset = pxsqlMeta.GetSelectedValuesetId(var.Code); // To fix problem with missing valueset info when more than two variabeles with multiple valuesets. e.g no subtable is set.
                    tmpPxsVars.Add(tmpPxsVar);
                    #endregion preparing for this.Query.Variables
                }
            }

            this.Query.Variables = tmpPxsVars.ToArray();
            #endregion this.Query

            #region this.Presentation
            this.Presentation = new PresentationType();
            if (pax.Stub.Count > 0)
            {
                this.Presentation.Stub = new AxisType[pax.Stub.Count];
                for (int n = 0; n < pax.Stub.Count; n++)
                {
                    this.Presentation.Stub[n] = new AxisType(pax.Stub[n].Code, n);
                }
            }

            if (pax.Heading.Count > 0)
            {
                this.Presentation.Heading = new AxisType[pax.Heading.Count];
                for (int n = 0; n < pax.Heading.Count; n++)
                {
                    this.Presentation.Heading[n] = new AxisType(pax.Heading[n].Code, n);
                }
            }

            #endregion this.Presentation
        }
Esempio n. 4
0
        /// <summary>
        /// Sets the groupinginfo names for a variable
        /// </summary>
        /// <param name="groupingInfoNames">names of the groupingInfo</param>
        /// <param name="variablecode">name of the variable that has the given grouping</param>
        /// <param name="meta"></param>
        /// <remarks></remarks>
        private void SetGroupingInfoNames(string variablecode, System.Collections.Specialized.StringCollection groupingInfoNames, PCAxis.Paxiom.PXMeta meta)
        {
            Variable paxiomVariable;

            paxiomVariable = FindVariable(meta, variablecode);
            if (paxiomVariable == null)
            {
                log.Debug("SetGroupingInfoNames: Can't find variablecode:\"" + variablecode + "\"");
                return;
            }
            log.Debug("SetGroupingInfoNames: for variablecode:\"" + variablecode + "\"");

            if (paxiomVariable.Groupings.Count != groupingInfoNames.Count)
            {
                throw new ApplicationException("Number of names differ from number of value sets");
            }
            for (int i = 0; i < groupingInfoNames.Count; i++)
            {
                log.Debug("groupingInfoNames[i]" + groupingInfoNames[i]);
                paxiomVariable.Groupings[i].Name = groupingInfoNames[i];
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Sets the groupinginfo GroupPres for a variable
        /// </summary>
        /// <param name="groupingInfoGroupPres">names of the groupingInfo</param>
        /// <param name="variablecode">name of the variable that has the given grouping</param>
        /// <param name="meta"></param>
        /// <remarks></remarks>
        private void SetGroupingInfoGroupPres(string variablecode, System.Collections.Specialized.StringCollection groupingInfoGroupPres, PCAxis.Paxiom.PXMeta meta)
        {
            Variable paxiomVariable;

            paxiomVariable = FindVariable(meta, variablecode);
            if (paxiomVariable == null)
            {
                log.Debug("SetGroupingInfoNames: Can't find variablecode:\"" + variablecode + "\"");
                return;
            }
            log.Debug("SetGroupingInfoNames: for variablecode:\"" + variablecode + "\"");

            if (paxiomVariable.Groupings.Count != groupingInfoGroupPres.Count)
            {
                throw new ApplicationException("Number of names differ from number of value sets");
            }

            PCAxis.Paxiom.GroupingIncludesType aggregationType;


            for (int i = 0; i < groupingInfoGroupPres.Count; i++)
            {
                log.Debug("groupingInfoGroupPres[i]" + groupingInfoGroupPres[i]);

                switch (groupingInfoGroupPres[i])
                {
                case "SingleValues":
                    aggregationType = GroupingIncludesType.SingleValues;
                    break;

                case "AggregatedValues":
                    aggregationType = GroupingIncludesType.AggregatedValues;
                    break;

                default:
                    aggregationType = GroupingIncludesType.All;
                    break;
                }

                paxiomVariable.Groupings[i].GroupPres = aggregationType;
            }
        }
Esempio n. 6
0
        ///<summary>
        /// Creates GroupingInfo's for the cube
        ///</summary>
        ///<param name="groupingInfoIds">id for the GroupingInfo</param>
        /// <param name="variablecode">name of the variable that has
        /// the given GropuingInfo</param>
        /// <param name="meta"></param>
        /// <remarks></remarks>
        private void CreateGroupingInfo(string variablecode, System.Collections.Specialized.StringCollection groupingInfoIds, PCAxis.Paxiom.PXMeta meta)
        {
            Variable v;

            v = FindVariable(meta, variablecode);
            if (v == null)
            {
                log.Debug("Can't find variablecode:\"" + variablecode + "\"");
                return;
            }


            GroupingInfo grInfo;

            for (int i = 0; i < groupingInfoIds.Count; i++)
            {
                grInfo = new GroupingInfo(groupingInfoIds[i]);

                v.AddGrouping(grInfo);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Hmm, some lucky keywords are given special tretment, accessing Paxiom.PXMeta directly. The others are just passed on to the normal set meta
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="subkey"></param>
        /// <param name="values"></param>
        /// <param name="meta"></param>
        /// <param name="isDefaultLanguage"></param>
        protected override void SetMeta(string keyword, string subkey, System.Collections.Specialized.StringCollection values, PCAxis.Paxiom.PXMeta meta, bool isDefaultLanguage)
        {
            switch (keyword)
            {
            //case PXKeywords.VARIABLE_NAME:
            case "VARIABLENAME":
                SetVariableName(subkey, values[0], meta);
                break;

            case PXKeywords.GROUPING_ID:
                CreateGroupingInfo(subkey, values, meta);

                break;

            case PXKeywords.GROUPING_GROUPPRES:
                SetGroupingInfoGroupPres(subkey, values, meta);
                break;

            case PXKeywords.GROUPING_NAME:
                SetGroupingInfoNames(subkey, values, meta);
                break;

            case PXKeywords.ELIMINATION:
                SetElimination(subkey, values[0], meta);
                break;

            default:
                base.SetMeta(keyword, subkey, values, meta, isDefaultLanguage);
                break;
            }
        }
Esempio n. 8
0
 protected override PCAxis.Paxiom.Variable FindVariable(PCAxis.Paxiom.PXMeta meta, string findId, int lang)
 {
     return(meta.Variables.GetByCode(findId));
 }