Ejemplo n.º 1
0
        /// <summary>
        /// Builds the Paxiom model used for selection
        /// </summary>
        /// <returns></returns>
        public override bool BuildForSelection()
        {
            #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 BuildForSelection");

            if (!_hasCalledSetPath)
            {
                throw new ApplicationException("BUG: SetPath must be called before BuildForSelection()");
            }

            try
            {
                setDbConfig();
                //log.Debug("Database: id = " + dbConf.Database.id + " Description = " + dbConf.Database.Description);
                log.Debug("Database: id = " + dbConf.Database.id + " Description preferred language = " + dbConf.GetDescription(m_preferredLanguage));

                log.Debug("_preferredLanguage:" + m_preferredLanguage + " _readAllLanguages:" + m_readAllLanguages.ToString());
                if (String.IsNullOrEmpty(maintableId))
                {
                    mPXSqlMeta = PXSqlMeta.GetPXSqlMeta(pxs, m_preferredLanguage, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.selection, false);
                }
                else
                {
                    mPXSqlMeta = PXSqlMeta.GetPXSqlMeta(maintableId, m_preferredLanguage, m_readAllLanguages, dbConf, GetInfoForDbConnection(), PCAxis.Sql.Parser.Instancemodus.selection, false);
                }
                m_parser = PXSqlParser.GetPXSqlParser(mPXSqlMeta);

                // this.m_model.Meta.CreateTitle();
                base.BuildForSelection();

                if (!DoNotApplyCurrentValueSet)
                {
                    ((PXSqlParser)m_parser).SetCurrentValueSets(this.Model.Meta);
                }

                _haveDoneBuildForSelection = true;
                Model.Meta.SetPreferredLanguage(m_preferredLanguage);
            }

            catch (Exception e)
            {
                errorHandler(e, "Error in BuildForSelection");
                throw;
            }
            log.Debug("Done BuildForSelection");

            #if DEBUG
            stopWatch.Stop();
            logTime.DebugFormat(System.Reflection.MethodBase.GetCurrentMethod().Name + " Done in ms = {0}", stopWatch.ElapsedMilliseconds);
            #endif

            return(true);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Factorymethod returning the subclass with the CNMM-version of the PXSqlMeta.
 /// </summary>
 /// <param name="inPXSqlMeta"></param>
 /// <param name="variableCode"></param>
 /// <returns></returns>
 public static PXSqlParserForCodelists GetPXSqlParserForCodelists(PXSqlMeta inPXSqlMeta, String variableCode)
 {
     if (inPXSqlMeta.CNMMVersion.Equals("2.2"))
     {
         return(new PCAxis.Sql.Parser_22.PXSqlParserForCodelists_22((PCAxis.Sql.Parser_22.PXSqlMeta_22)inPXSqlMeta, variableCode));
     }
     else if (inPXSqlMeta.CNMMVersion.Equals("2.3"))
     {
         return(new PCAxis.Sql.Parser_23.PXSqlParserForCodelists_23((PCAxis.Sql.Parser_23.PXSqlMeta_23)inPXSqlMeta, variableCode));
     }
     else if (inPXSqlMeta.CNMMVersion.Equals("2.4"))
     {
         return(new PCAxis.Sql.Parser_24.PXSqlParserForCodelists_24((PCAxis.Sql.Parser_24.PXSqlMeta_24)inPXSqlMeta, variableCode));
     }
     else
     {
         return(new PCAxis.Sql.Parser_21.PXSqlParserForCodelists_21((PCAxis.Sql.Parser_21.PXSqlMeta_21)inPXSqlMeta, variableCode));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Factory method returning a PXSqlParser of the same CMMM-version as that of the PXSqlMeta
        /// </summary>
        /// <param name="inPXSqlMeta"></param>
        /// <returns></returns>

        public static PXSqlParser GetPXSqlParser(PXSqlMeta inPXSqlMeta)
        {
            if (inPXSqlMeta.CNMMVersion.Equals("2.2"))
            {
                return(new PCAxis.Sql.Parser_22.PXSqlParser_22((PCAxis.Sql.Parser_22.PXSqlMeta_22)inPXSqlMeta));
            }
            else if (inPXSqlMeta.CNMMVersion.Equals("2.3"))
            {
                return(new PCAxis.Sql.Parser_23.PXSqlParser_23((PCAxis.Sql.Parser_23.PXSqlMeta_23)inPXSqlMeta));
            }
            else if (inPXSqlMeta.CNMMVersion.Equals("2.4"))
            {
                return(new PCAxis.Sql.Parser_24.PXSqlParser_24((PCAxis.Sql.Parser_24.PXSqlMeta_24)inPXSqlMeta));
            }
            else
            {
                return(new PCAxis.Sql.Parser_21.PXSqlParser_21((PCAxis.Sql.Parser_21.PXSqlMeta_21)inPXSqlMeta));
            }
        }
Ejemplo n.º 4
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);
        }