Exemple #1
0
        /// <summary>
        /// Moves information from PxsObject.Query.SubTable to mPxsObject.Query.Variables[XXX].SelectedValueset.
        /// So that we do not need to look both places in the rest of the code.
        /// </summary>
        /// <param name="mPxsObject"></param>
        /// <returns></returns>
        private PxsQuery rearrangePxsQuery(PxsQuery mPxsObject)
        {
            if (!String.IsNullOrEmpty(mPxsObject.Query.SubTable))
            {
                Dictionary <string, string> valuesetIdByVariableId = new Dictionary <string, string>();
                Dictionary <string, SubTableVariableRow> fromDB    = this.MetaQuery.GetSubTableVariableRowskeyVariable(this.mMainTableId, mPxsObject.Query.SubTable, false);
                foreach (string variableId in fromDB.Keys)
                {
                    if (String.IsNullOrEmpty(fromDB[variableId].ValueSet))
                    {
                        continue;  //assuming (I know :-) time
                    }
                    valuesetIdByVariableId.Add(variableId, fromDB[variableId].ValueSet);
                }
                mPxsObject.SetSelectedValuesetsAndNullSubtable(valuesetIdByVariableId);
            }
            else
            {
                foreach (var pxsVariable in mPxsObject.Query.Variables)
                {
                    if (String.IsNullOrEmpty(pxsVariable.SelectedValueset))
                    {
                        if (pxsVariable.Values.Items.Length > 0)
                        {
                            pxsVariable.SelectedValueset = PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS;
                        }
                    }
                }
            }

            return(mPxsObject);
        }
Exemple #2
0
        public PXSqlMeta_24(PxsQuery mPxsObject, string preferredLang, SqlDbConfig config, InfoForDbConnection selectedDbInfo, PCAxis.Sql.Parser.Instancemodus aModus, bool useTempTables)
            : base(config, selectedDbInfo, aModus, true)

        {
            log.Debug("PXSqlMeta(PxsQuery mPxsObject, SqlDbConfig config, Instancemodus aModus");


            //disse er trukket hit for å kunne kjøre med String hovedtabellId.
            this.mMainTableId = mPxsObject.Query.TableSource;

            //TODO; denne burde kunne fjernes
            this.mPxsSubTableId = mPxsObject.Query.SubTable;
            this.mConfig        = (SqlDbConfig_24)config;

            mMetaQuery = new MetaQuery(this.mConfig, this.SelectedDbInfo, useTempTables);

            this.mPxsFile = this.rearrangePxsQuery(mPxsObject);

            SetLanguageCodesFromPxs(preferredLang);
            BuildMeta(); //
        }
Exemple #3
0
        public PXSqlSubTables(Dictionary <string, SubTableRow> altIBasen, PxsQuery pPxsQuery, PXSqlMeta_24 pxsqlMeta)
            : base()
        {
            this.mPxsQuery = pPxsQuery;
            PXSqlSubTable mSubTable;

            foreach (SubTableRow subTableRow in altIBasen.Values)
            {
                mSubTable = new PXSqlSubTable(subTableRow);
                this.Add(mSubTable.SubTable, mSubTable);
            }
            // set selected subtables.
            if (pPxsQuery == null)
            {
                foreach (PXSqlSubTable subTable in this.Values)
                {
                    subTable.IsSelected = true;
                }
            }
            else
            {
                SetSelectedSubTable(pxsqlMeta);
            }
        }
Exemple #4
0
 public static PXSqlMeta GetPXSqlMeta(PxsQuery mPxsObject, string preferredLang, SqlDbConfig config, InfoForDbConnection selectedDbInfo, Instancemodus aModus, bool useTempTables)
 {
     if (config.MetaModel.Equals("2.1"))
     {
         return(new Parser_21.PXSqlMeta_21(mPxsObject, preferredLang, config, selectedDbInfo, aModus));
     }
     else if (config.MetaModel.Equals("2.2"))
     {
         return(new Parser_22.PXSqlMeta_22(mPxsObject, preferredLang, config, selectedDbInfo, aModus));
     }
     else if (config.MetaModel.Equals("2.3"))
     {
         return(new Parser_23.PXSqlMeta_23(mPxsObject, preferredLang, config, selectedDbInfo, aModus));
     }
     else if (config.MetaModel.Equals("2.4"))
     {
         return(new Parser_24.PXSqlMeta_24(mPxsObject, preferredLang, config, selectedDbInfo, aModus, useTempTables));
     }
     else
     {
         log.Debug("creating Parser_21.PXSqlMeta_21, but config.MetaModel is " + config.MetaModel);
         return(new Parser_21.PXSqlMeta_21(mPxsObject, preferredLang, config, selectedDbInfo, aModus));
     }
 }
Exemple #5
0
        public void SetPath(Dictionary <string, Object> argumentDictionary)
        {
            log.Debug("doing SetPath(Dictionary<string, Object> argumentDictionary)");

            if (!(argumentDictionary.ContainsKey(PXSqlKeywords.PXS_QUERY_OBJECT) || argumentDictionary.ContainsKey(PXSqlKeywords.PXS_FILEPATH) || argumentDictionary.ContainsKey(PXSqlKeywords.MAINTABLE_ID)))
            {
                throw new ApplicationException("BUG: argumentDictionary must contain key: PXSqlKeywords.PXS_QUERY_OBJECT, PXSqlKeywords.PXS_FILEPATH or PXSqlKeywords.MAINTABLE_ID");
            }

            bool dbIdPartOfMaintableId = false;

            if (argumentDictionary.ContainsKey(PXSqlKeywords.PXS_QUERY_OBJECT))
            {
                maintableId = null;
                pxs         = (PxsQuery)argumentDictionary[PXSqlKeywords.PXS_QUERY_OBJECT];
            }
            else if (argumentDictionary.ContainsKey(PXSqlKeywords.PXS_FILEPATH))
            {
                maintableId = null;
                string path = (string)argumentDictionary[PXSqlKeywords.PXS_FILEPATH];
                pxs = new PCAxis.Sql.Pxs.PxsQuery(path, m_preferredLanguage);
            }
            else
            { //maintableId
                pxs = null;

                string tmpMaintableId = (string)argumentDictionary[PXSqlKeywords.MAINTABLE_ID];
                log.Debug("tmpMaintableId = " + tmpMaintableId);
                if (tmpMaintableId.Contains(":"))
                {
                    _dbId = tmpMaintableId.Split(':')[0];
                    dbIdPartOfMaintableId = true;
                    if (_dbId != "")
                    {
                        hasSetDbId = true;
                    }
                    else
                    {
                        hasSetDbId = false;
                    }
                    maintableId = tmpMaintableId.Split(':')[1];
                }
                else
                {
                    hasSetDbId  = false;
                    maintableId = tmpMaintableId;
                }
            }

            if (!dbIdPartOfMaintableId)
            {
                if (argumentDictionary.ContainsKey(PXSqlKeywords.DATABASE_ID))
                {
                    _dbId      = (string)argumentDictionary[PXSqlKeywords.DATABASE_ID];
                    hasSetDbId = true;
                }
                else
                {
                    hasSetDbId = false;
                }
            }

            log.Debug("Leaving setPath: hasSetDbId =" + hasSetDbId.ToString());
            _hasCalledSetPath = true;
        }
Exemple #6
0
        /// <summary>
        /// Builds the Paxiom model used for presentation
        /// </summary>
        /// <param name="selections">Selections of parameters used to specify what data that should be presented</param>
        /// <returns></returns>
        public override bool BuildForPresentation(PCAxis.Paxiom.Selection[] selections)
        {
            #if DEBUG
            System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
            logTime.DebugFormat("Start " + System.Reflection.MethodBase.GetCurrentMethod().Name + ". Maintable={0}", maintableId);
            #endif

            log.Debug("Start BuildForPresentation");
            if (!_hasCalledSetPath)
            {
                throw new ApplicationException("BUG: SetPath must be called before BuildForPresentation.");
            }

            if (_haveDoneBuildForPresentation)
            {
                throw new ApplicationException("Hmm  BuildForPresentation has allready been called, what is the policy on this?");
            }
            try
            {
                setDbConfig();
                //m_parser = PXSqlParser.GetPXSqlParser(mPXSqlMeta);

                if (!_haveDoneBuildForSelection)
                {
                    // a WS or batch. selection is irrelevat and should be null.

                    if (String.IsNullOrEmpty(maintableId))
                    {
                        mPXSqlMeta = PXSqlMeta.GetPXSqlMeta(pxs, m_preferredLanguage, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.presentation, true);
                    }
                    else
                    {
                        mPXSqlMeta = PXSqlMeta.GetPXSqlMeta(maintableId, m_preferredLanguage, m_readAllLanguages, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.presentation, true);
                    }
                }
                else
                {
                    //Not in use
                    //PxSQLEliniationProvider.ApplyEliminationIfSupported(selections, dbConf, GetInfoForDbConnection(), this.Model.Meta);

                    // a GUI: need to create a new pxs with the selections made in GUI
                    // and ajust the _parser and reread meta


                    PxsQuery tmpPxs = new PxsQuery(base.m_model.Meta, getLanguagesPxsQueryCreation(), selections, mPXSqlMeta.GetInfoFromPxSqlMeta2PxsQuery());

                    //for debugging: TODO Kun for test.
                    //tmpPxs.WriteToFile("aaapxs.xml");

                    mPXSqlMeta        = PXSqlMeta.GetPXSqlMeta(tmpPxs, m_preferredLanguage, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.presentation, true);
                    base.m_model.Meta = new PCAxis.Paxiom.PXMeta();
                }
                m_parser = PXSqlParser.GetPXSqlParser(mPXSqlMeta);
                //   this.m_model.Meta.CreateTitle();
                base.BuildForSelection();

                this.SetMatrixSize();

                if (!mPXSqlMeta.MainTableContainsOnlyMetaData())
                {
                    using (PXSqlData mPXSqlData = PXSqlData.GetPXSqlData(mPXSqlMeta, dbConf))
                    {
#if DEBUG
                        logTime.DebugFormat(System.Reflection.MethodBase.GetCurrentMethod().Name + " before CreateMatrix in ms = {0}", stopWatch.ElapsedMilliseconds);
#endif
                        m_model.Data.Write(mPXSqlData.CreateMatrix(), 0, mPXSqlData.MatrixSize - 1);

                        if (mPXSqlData.DataNoteCellEntries.Count > 0)
                        {
                            m_model.Data.WriteDataNoteCells(mPXSqlData.DataCellNotes, 0, mPXSqlData.MatrixSize - 1);
                            m_model.Data.UseDataCellMatrix = true;
                        }

                        m_parser = PXSqlParseMetaPostData.GetPXSqlParseMetaPostData(mPXSqlMeta, mPXSqlData);

                        base.BuildForSelection();
                    }
                }
                else
                {
                    //lager juksedata
                    m_model.Data.Write(new double[m_model.Data.MatrixSize], 0, m_model.Data.MatrixSize - 1);
                    m_parser = new PXSqlParserForDataCellNote(new Dictionary <string, string>());
                    base.BuildForSelection();
                }
                m_model.Meta.Prune();
                _haveDoneBuildForSelection    = true;
                _haveDoneBuildForPresentation = true;
                m_model.Meta.SetPreferredLanguage(m_preferredLanguage);

                this.m_model.IsComplete = true;
            }
            catch (Exception e)
            {
                errorHandler(e, "Error in BuildForPresentation");
                throw;
            }
            log.Debug("Done BuildForPresentation");
            #if DEBUG
            stopWatch.Stop();
            logTime.DebugFormat(System.Reflection.MethodBase.GetCurrentMethod().Name + " Done in ms = {0}", stopWatch.ElapsedMilliseconds);
            #endif
            return(true);
        }