/// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            //Validation of parameters and user have been successful. We may now proceed to read from the database
            var adoKeywordRelease = new Keyword_Release_ADO();

            if (DTO.LngIsoCode != null)
            {
                Keyword_BSO_Extract bse = new Keyword_BSO_Extract(DTO.LngIsoCode);
                DTO.KrlValue = bse.Singularize(DTO.KrlValue);
            }

            //Create the Keyword_Subject - and retrieve the newly created Id
            int newId = adoKeywordRelease.Create(Ado, DTO);

            if (newId == 0)
            {
                Response.error = Label.Get("error.create");
                return(false);
            }
            else if (newId < 0)
            {
                Response.error = Label.Get("error.duplicate");
            }

            Response.data = JSONRPC.success;
            return(true);
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Keyword_Release_ADO adoKeywordRelease = new Keyword_Release_ADO();

            //You can't change the mandatory flag
            DTO.KrlMandatoryFlag = false;
            if (DTO.LngIsoCode != null)
            {
                Keyword_BSO_Extract bse = new Keyword_BSO_Extract(DTO.LngIsoCode);
                DTO.KrlValue = bse.Singularize(DTO.KrlValue);
            }
            int updated = adoKeywordRelease.Update(Ado, DTO);

            if (updated == 0)
            {
                Log.Instance.Debug("No record found for update request");
                Response.error = Label.Get("error.delete");
                return(false);
            }
            else if (updated < 0)
            {
                Response.error = Label.Get("error.duplicate");
            }

            Response.data = JSONRPC.success;
            return(true);
        }
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            var adoKeywordRelease = new Keyword_Release_ADO();

            var list = adoKeywordRelease.Read(Ado, DTO);

            Response.data = list.data;

            return(true);
        }
예제 #4
0
        /// <summary>
        /// Execute
        /// </summary>
        /// <returns></returns>
        protected override bool Execute()
        {
            Keyword_Release_ADO keyWordAdo = new Keyword_Release_ADO();

            int deleteCount = keyWordAdo.Delete(Ado, null, DTO.KrlCode, false);

            if (deleteCount == 0)
            {
                Log.Instance.Debug("No record found for delete request");
                Response.error = Label.Get("error.delete");
                return(false);
            }

            Response.data = JSONRPC.success;
            return(true);
        }
예제 #5
0
        /// <summary>
        /// Create a keyword release
        /// </summary>
        /// <param name="Ado"></param>
        /// <param name="releaseId"></param>
        /// <param name="userName"></param>
        internal void Create(ADO Ado, int releaseId, string userName)
        {
            Release_ADO rAdo = new Data.Release_ADO(Ado);

            var latestRelease = Release_ADO.GetReleaseDTO(rAdo.ReadID(releaseId, userName));

            if (latestRelease == null) return;

            rAdo.DeleteKeywords(latestRelease.RlsCode, userName);

            //Create the table that will be bulk inserted
            DataTable dt = new DataTable();
            dt.Columns.Add("KRL_VALUE", typeof(string));
            dt.Columns.Add("KRL_RLS_ID", typeof(int));
            dt.Columns.Add("KRL_MANDATORY_FLAG", typeof(bool));
            dt.Columns.Add("KRL_SINGULARISED_FLAG", typeof(bool));

            Keyword_Release_ADO adoKeywordCreate = new Keyword_Release_ADO();

            //Get the matrices for the RlsCode - There may be more than one e.g. if multiple languages are used in the same release
            Matrix_ADO mAdo = new Matrix_ADO(Ado);
            IList<dynamic> matrixList;

            matrixList = mAdo.ReadAllForRelease(latestRelease.RlsCode, userName);

            //Create the table rows
            foreach (dynamic item in matrixList)
            {
                //Get a Keyword Extractor - the particular version returned will depend on the language
                Keyword_BSO_Extract kbe = new Keyword_BSO_Extract(item.LngIsoCode);
                // IKeywordExtractor ext = kbe.GetExtractor();

                //Add the keywords and other data to the output table
                AddToTable(ref dt, kbe.ExtractSplitSingular(item.MtrTitle), item.RlsID);

                //Add the MtrCode to the keyword list without any transformations
                AddToTable(ref dt, new List<string>() { item.MtrCode }, item.RlsID, false);

                //Add the Copyright Code
                AddToTable(ref dt, kbe.ExtractSplit(item.CprCode), item.RlsID, false);

                //Add the Copyright Value
                AddToTable(ref dt, kbe.ExtractSplit(item.CprValue), item.RlsID, false);

                //Add the Language
                AddToTable(ref dt, kbe.ExtractSplit(item.LngIsoName), item.RlsID, false);

                //Add the Frequency Code
                //AddToTable(ref dt, ext.ExtractSplit(item.FrqCode), item.RlsID);

                //Add the Frequency Value
                AddToTable(ref dt, kbe.ExtractSplitSingular(item.FrqValue), item.RlsID);

                //Get the keywords from Statistic
                IList<dynamic> statList = mAdo.ReadStatisticByRelease(latestRelease.RlsCode, item.LngIsoCode);
                foreach (dynamic statItem in statList)
                {
                    AddToTable(ref dt, kbe.ExtractSplit(statItem.SttCode), item.RlsID, false);
                    AddToTable(ref dt, kbe.ExtractSplitSingular(statItem.SttValue), item.RlsID);
                    AddToTable(ref dt, kbe.ExtractSplitSingular(statItem.SttUnit), item.RlsID);
                }

                //Get the keywords from Classification
                IList<dynamic> classificationList = mAdo.ReadClassificationByRelease(latestRelease.RlsCode, item.LngIsoCode);
                foreach (dynamic classItem in classificationList)
                {
                    AddToTable(ref dt, kbe.ExtractSplit(classItem.ClsCode), item.RlsID, false);
                    AddToTable(ref dt, kbe.ExtractSplitSingular(classItem.ClsValue), item.RlsID);

                    //Get the keywords from Variables
                    IList<dynamic> variableList = mAdo.ReadVariableByRelease(latestRelease.RlsCode, item.LngIsoCode, classItem.ClsCode);
                    foreach (dynamic variableItem in variableList)
                    {
                        AddToTable(ref dt, kbe.ExtractSplit(variableItem.VrbCode), item.RlsID, false);
                        AddToTable(ref dt, kbe.ExtractSplitSingular(variableItem.VrbValue), item.RlsID);
                    }
                }

                //Get the keywords from Period
                IList<dynamic> periodList = mAdo.ReadPeriodByRelease(latestRelease.RlsCode, item.LngIsoCode, item.FrqCode);
                foreach (dynamic periodItem in periodList)
                {
                    AddToTable(ref dt, kbe.ExtractSplit(periodItem.PrdCode), item.RlsID, false);
                    AddToTable(ref dt, kbe.ExtractSplitSingular(periodItem.PrdValue), item.RlsID);
                }

            }
            //Final check to make sure there are no duplicates
            adoKeywordCreate.Create(Ado, dt.DefaultView.ToTable(true, new string[4] { "KRL_VALUE", "KRL_RLS_ID", "KRL_MANDATORY_FLAG", "KRL_SINGULARISED_FLAG" }));
        }
        internal void Create(ADO Ado, int releaseId, string userName, Matrix matrix)
        {
            Release_ADO rAdo = new Data.Release_ADO(Ado);

            var latestRelease = Release_ADO.GetReleaseDTO(rAdo.ReadID(releaseId, userName));

            if (latestRelease == null)
            {
                return;
            }


            //Create the table that will be bulk inserted
            DataTable dt = new DataTable();

            dt.Columns.Add("KRL_VALUE", typeof(string));
            dt.Columns.Add("KRL_RLS_ID", typeof(int));
            dt.Columns.Add("KRL_MANDATORY_FLAG", typeof(bool));
            dt.Columns.Add("KRL_SINGULARISED_FLAG", typeof(bool));

            Keyword_Release_ADO adoKeywordCreate = new Keyword_Release_ADO();



            List <Matrix.Specification> specList = new List <Matrix.Specification>()
            {
                matrix.MainSpec
            };

            if (matrix.OtherLanguageSpec != null)
            {
                foreach (Matrix.Specification lspec in matrix.OtherLanguageSpec)
                {
                    specList.Add(lspec);
                }
            }

            //Create the table rows
            foreach (var spec in specList)
            {
                //spec = matrix.GetSpecFromLanguage(item.LngIsoCode);
                //Get a Keyword Extractor - the particular version returned will depend on the language
                Keyword_BSO_Extract kbe = new Keyword_BSO_Extract(spec.Language);


                //Add the keywords and other data to the output table
                AddToTable(ref dt, kbe.ExtractSplitSingular(spec.Title), releaseId);

                //Add the MtrCode to the keyword list without any transformations
                AddToTable(ref dt, new List <string>()
                {
                    spec.MatrixCode
                }, releaseId, false);

                //Add the Copyright Code
                AddToTable(ref dt, kbe.ExtractSplit(matrix.Copyright.CprCode, false), releaseId, false);

                //Add the Copyright Value
                AddToTable(ref dt, kbe.ExtractSplit(matrix.Copyright.CprValue), releaseId, false);

                //Add the Language
                //AddToTable(ref dt, kbe.ExtractSplit(item.LngIsoName), item.RlsID, false);

                //Add the Frequency Code
                AddToTable(ref dt, kbe.ExtractSplit(spec.Frequency.Code, false), releaseId);

                //Add the Frequency Value
                AddToTable(ref dt, kbe.ExtractSplitSingular(spec.Frequency.Value), releaseId);

                //Get the keywords from Statistic
                foreach (dynamic statItem in spec.Statistic)
                {
                    AddToTable(ref dt, kbe.ExtractSplit(statItem.Code, false), releaseId, false);
                    AddToTable(ref dt, kbe.ExtractSplitSingular(statItem.Value), releaseId);
                    AddToTable(ref dt, kbe.ExtractSplitSingular(statItem.Unit), releaseId);
                }



                //Get the keywords from Classification
                foreach (dynamic classItem in spec.Classification)
                {
                    AddToTable(ref dt, kbe.ExtractSplit(classItem.Code, false), releaseId, false);
                    AddToTable(ref dt, kbe.ExtractSplitSingular(classItem.Value), releaseId);

                    //Get the keywords from Variables

                    foreach (dynamic variableItem in classItem.Variable)
                    {
                        AddToTable(ref dt, kbe.ExtractSplit(variableItem.Code, false), releaseId, false);
                        AddToTable(ref dt, kbe.ExtractSplitSingular(variableItem.Value), releaseId);
                    }
                }

                //Get the keywords from Period
                foreach (dynamic periodItem in spec.Frequency.Period)
                {
                    AddToTable(ref dt, kbe.ExtractSplit(periodItem.Code, false), releaseId, false);
                    AddToTable(ref dt, kbe.ExtractSplitSingular(periodItem.Value), releaseId);
                }
            }
            var distinctRows = dt.DefaultView.ToTable(true, new string[4] {
                "KRL_VALUE", "KRL_RLS_ID", "KRL_MANDATORY_FLAG", "KRL_SINGULARISED_FLAG"
            });

            //Final check to make sure there are no duplicates
            adoKeywordCreate.Create(Ado, distinctRows);
        }