GetDatasetVersionEffectiveTupleCount() public method

Returns the number of the effective tuples of the dataset version requested. See GetDatasetVersionEffectiveTuples for more details about the effective tuples of a dataset.
public GetDatasetVersionEffectiveTupleCount ( DatasetVersion datasetVersion ) : System.Int64
datasetVersion BExIS.Dlm.Entities.Data.DatasetVersion The object representing the data set version requested
return System.Int64
        private void addSelectedDatasetToBus(long datasetId)
        {
            TaskManager = (TaskManager)Session["TaskManager"];
            DatasetManager datasetManager = new DatasetManager();

            if (datasetManager.GetDatasetVersionEffectiveTupleCount(datasetManager.GetDatasetLatestVersion(datasetId)) > 0)
            {
                TaskManager.AddToBus("DatasetStatus", "edit");
            }
            else
                TaskManager.AddToBus("DatasetStatus", "new");

            DatasetVersion datasetVersion = datasetManager.GetDatasetLatestVersion(datasetId);

            TaskManager.AddToBus(TaskManager.DATASET_ID, datasetId);

            //Add Metadata to Bus
            //TITLE
            TaskManager.AddToBus(TaskManager.DATASET_TITLE, XmlDatasetHelper.GetInformation(datasetVersion, NameAttributeValues.title));

            ResearchPlanManager rpm = new ResearchPlanManager();
            ResearchPlan rp = rpm.Repo.Get(datasetVersion.Dataset.ResearchPlan.Id);
            TaskManager.AddToBus(TaskManager.RESEARCHPLAN_ID, rp.Id);
            TaskManager.AddToBus(TaskManager.RESEARCHPLAN_TITLE, rp.Title);
        }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="id"></param>
        /// <param name="metadataDoc"></param>
        /// <return></return>
        private void writeBexisIndex(long id, XmlDocument metadataDoc)
        {
            String docId = id.ToString();//metadataDoc.GetElementsByTagName("bgc:id")[0].InnerText;

            var dataset = new Document();
            List<XmlNode> facetNodes = facetXmlNodeList;
            dataset.Add(new Field("doc_id", docId, Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.NOT_ANALYZED));

            foreach (XmlNode facet in facetNodes)
            {
                String multivalued = facet.Attributes.GetNamedItem("multivalued").Value;
                string[] metadataElementNames = facet.Attributes.GetNamedItem("metadata_name").Value.Split(',');
                String lucene_name = facet.Attributes.GetNamedItem("lucene_name").Value;

                foreach (string metadataElementName in metadataElementNames)
                {
                    XmlNodeList elemList = metadataDoc.SelectNodes(metadataElementName);
                    if (elemList != null)
                    {
                        for (int i = 0; i < elemList.Count; i++)
                        {
                            string eleme = elemList[i].InnerText;
                            if (!elemList[i].InnerText.Trim().Equals(""))
                            {
                                dataset.Add(new Field("facet_" + lucene_name, elemList[i].InnerText,
                                    Lucene.Net.Documents.Field.Store.YES, Field.Index.NOT_ANALYZED));
                                dataset.Add(new Field("ng_all", elemList[i].InnerText,
                                    Lucene.Net.Documents.Field.Store.YES, Field.Index.ANALYZED));
                                writeAutoCompleteIndex(docId, lucene_name, elemList[i].InnerText);
                                writeAutoCompleteIndex(docId, "ng_all", elemList[i].InnerText);
                            }
                        }
                    }
                }
            }

            List<XmlNode> propertyNodes = propertyXmlNodeList;
            foreach (XmlNode property in propertyNodes)
            {
                String multivalued = property.Attributes.GetNamedItem("multivalued").Value;
                String lucene_name = property.Attributes.GetNamedItem("lucene_name").Value;
                string[] metadataElementNames = property.Attributes.GetNamedItem("metadata_name").Value.Split(',');

                foreach (string metadataElementName in metadataElementNames)
                {
                    XmlNodeList elemList = metadataDoc.SelectNodes(metadataElementName);
                    if (elemList != null)
                    {
                        String primitiveType = property.Attributes.GetNamedItem("primitive_type").Value;
                        if (elemList[0] != null)
                        {
                            if (primitiveType.ToLower().Equals("string"))
                            {
                                dataset.Add(new Field("property_" + lucene_name, elemList[0].InnerText,
                                    Lucene.Net.Documents.Field.Store.YES, Field.Index.NOT_ANALYZED));
                                dataset.Add(new Field("ng_all", elemList[0].InnerText,
                                    Lucene.Net.Documents.Field.Store.YES, Field.Index.ANALYZED));
                                writeAutoCompleteIndex(docId, lucene_name, elemList[0].InnerText);
                                writeAutoCompleteIndex(docId, "ng_all", elemList[0].InnerText);
                            }
                            else if (primitiveType.ToLower().Equals("date"))
                            {
                                //DateTime MyDateTime = DateTime.Now;
                                DateTime MyDateTime = new DateTime();
                                /*String dTFormatElementName = property.Attributes.GetNamedItem("date_format").Value;
                            XmlNodeList dtFormatElements = metadataDoc.GetElementsByTagName(dTFormatElementName);
                            String dateTimeFormat = dtFormatElements[0].InnerText;*/

                                if (DateTime.TryParse(elemList[0].InnerText, out MyDateTime))
                                {
                                    //MyDateTime = DateTime.ParseExact(elemList[0].InnerText, dateTimeFormat,
                                    //            CultureInfo.InvariantCulture);
                                    long t = MyDateTime.Ticks;

                                    NumericField xyz =
                                        new NumericField("property_numeric_" + lucene_name).SetLongValue(
                                            MyDateTime.Ticks);
                                    String dateToString = MyDateTime.Date.ToString("d",
                                        CultureInfo.CreateSpecificCulture("en-US"));
                                    dataset.Add(xyz);
                                    dataset.Add(new Field("property_" + lucene_name, dateToString,
                                        Lucene.Net.Documents.Field.Store.NO, Field.Index.NOT_ANALYZED));

                                    writeAutoCompleteIndex(docId, lucene_name, MyDateTime.Date.ToString());
                                    writeAutoCompleteIndex(docId, "ng_all", MyDateTime.Date.ToString());
                                }
                            }
                            else if (primitiveType.ToLower().Equals("integer"))
                            {
                                dataset.Add(
                                    new NumericField("property_numeric" + lucene_name).SetIntValue(
                                        Convert.ToInt32(elemList[0].InnerText)));
                                dataset.Add(new Field("property_" + lucene_name, elemList[0].InnerText,
                                    Lucene.Net.Documents.Field.Store.NO, Field.Index.NOT_ANALYZED));
                                //  writeAutoCompleteIndex(lucene_name, elemList[0].InnerText);
                            }
                            else if (primitiveType.ToLower().Equals("double"))
                            {
                                dataset.Add(
                                    new NumericField("property_numeric" + lucene_name).SetDoubleValue(
                                        Convert.ToDouble(elemList[0].InnerText)));
                                dataset.Add(new Field("property_" + lucene_name, elemList[0].InnerText,
                                    Lucene.Net.Documents.Field.Store.NO, Field.Index.NOT_ANALYZED));
                                writeAutoCompleteIndex(docId, lucene_name, elemList[0].InnerText);
                                writeAutoCompleteIndex(docId, "ng_all", elemList[0].InnerText);
                            }
                        }
                    }
                }
            }
            List<XmlNode> categoryNodes = categoryXmlNodeList;
            foreach (XmlNode category in categoryNodes)
            {
                if (category.Attributes.GetNamedItem("type").Value.Equals("primary_data_field"))
                {
                    String primitiveType = category.Attributes.GetNamedItem("primitive_type").Value;
                    String lucene_name = category.Attributes.GetNamedItem("lucene_name").Value;
                    String analysing = category.Attributes.GetNamedItem("analysed").Value;
                    float boosting = Convert.ToSingle(category.Attributes.GetNamedItem("boost").Value);
                    var toAnalyse = Lucene.Net.Documents.Field.Index.NOT_ANALYZED;
                    if (analysing.ToLower().Equals("yes"))
                    {
                        toAnalyse = Lucene.Net.Documents.Field.Index.ANALYZED;
                    }

                    DatasetManager dm = new DatasetManager();
                    if (dm.IsDatasetCheckedIn(id))
                    {
                        DatasetVersion dsv = dm.GetDatasetLatestVersion(id);
                        DataStructureManager dsm = new DataStructureManager();
                        StructuredDataStructure sds = dsm.StructuredDataStructureRepo.Get(dsv.Dataset.DataStructure.Id);
                        // Javad: check if the dataset is "checked-in". If yes, then use the paging version of the GetDatasetVersionEffectiveTuples method
                        // number of tuples for the for loop is also available via GetDatasetVersionEffectiveTupleCount
                        // a proper fetch (page) size can be obtained by calling dm.PreferedBatchSize
                        int fetchSize = dm.PreferedBatchSize;
                        long tupleSize = dm.GetDatasetVersionEffectiveTupleCount(dsv);
                        long noOfFetchs = tupleSize/fetchSize + 1;
                        for (int round = 0; round < noOfFetchs; round++)
                        {
                            List<AbstractTuple> dsVersionTuples = dm.GetDatasetVersionEffectiveTuples(dsv, round,
                                fetchSize);
                            List<string> primaryDataStringToindex = generateStringFromTuples(dsVersionTuples, sds);
                            if (primaryDataStringToindex != null)
                            {
                                foreach (string pDataValue in primaryDataStringToindex)
                                    // Loop through List with foreach
                                {
                                    Field a = new Field("category_" + lucene_name, pDataValue,
                                        Lucene.Net.Documents.Field.Store.NO, toAnalyse);
                                    a.Boost = boosting;
                                    dataset.Add(a);
                                    dataset.Add(new Field("ng_" + lucene_name, pDataValue,
                                        Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.ANALYZED));
                                    dataset.Add(new Field("ng_all", pDataValue, Lucene.Net.Documents.Field.Store.YES,
                                        Lucene.Net.Documents.Field.Index.ANALYZED));
                                    writeAutoCompleteIndex(docId, lucene_name, pDataValue);
                                    writeAutoCompleteIndex(docId, "ng_all", pDataValue);
                                }
                            }
                            GC.Collect();
                        }
                    }
                }
                else
                {
                    String multivalued = category.Attributes.GetNamedItem("multivalued").Value;
                    String primitiveType = category.Attributes.GetNamedItem("primitive_type").Value;
                    String lucene_name = category.Attributes.GetNamedItem("lucene_name").Value;
                    String storing = category.Attributes.GetNamedItem("store").Value;
                    String analysing = category.Attributes.GetNamedItem("analysed").Value;
                    float boosting = Convert.ToSingle(category.Attributes.GetNamedItem("boost").Value);
                    var toStore = Lucene.Net.Documents.Field.Store.NO;
                    var toAnalyse = Lucene.Net.Documents.Field.Index.NOT_ANALYZED;

                    if (storing.ToLower().Equals("yes"))
                    {
                        toStore = Lucene.Net.Documents.Field.Store.YES;
                    }
                    if (analysing.ToLower().Equals("yes"))
                    {
                        toAnalyse = Lucene.Net.Documents.Field.Index.ANALYZED;
                    }

                    string[] metadataElementNames = category.Attributes.GetNamedItem("metadata_name").Value.Split(',');

                    foreach (string metadataElementName in metadataElementNames)
                    {
                        XmlNodeList elemList = metadataDoc.SelectNodes(metadataElementName);
                        if (elemList != null)
                        {
                            for (int i = 0; i < elemList.Count; i++)
                            {
                                Field a = new Field("category_" + lucene_name, elemList[i].InnerText, toStore, toAnalyse);
                                a.Boost = boosting;
                                dataset.Add(a);
                                dataset.Add(new Field("ng_" + lucene_name, elemList[i].InnerText,
                                    Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.ANALYZED));
                                dataset.Add(new Field("ng_all", elemList[i].InnerText,
                                    Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.ANALYZED));
                                writeAutoCompleteIndex(docId, lucene_name, elemList[i].InnerText);
                                writeAutoCompleteIndex(docId, "ng_all", elemList[i].InnerText);
                            }
                        }
                    }

                }
            }

            List<XmlNode> generalNodes = generalXmlNodeList;

            foreach (XmlNode general in generalNodes)
            {

                String multivalued = general.Attributes.GetNamedItem("multivalued").Value;
                String primitiveType = general.Attributes.GetNamedItem("primitive_type").Value;
                String lucene_name = general.Attributes.GetNamedItem("lucene_name").Value;

                String storing = general.Attributes.GetNamedItem("store").Value;
                String analysing = general.Attributes.GetNamedItem("analysed").Value;

                var toStore = Lucene.Net.Documents.Field.Store.NO;
                var toAnalyse = Lucene.Net.Documents.Field.Index.NOT_ANALYZED;

                if (storing.ToLower().Equals("yes"))
                {
                    toStore = Lucene.Net.Documents.Field.Store.YES;
                }
                if (analysing.ToLower().Equals("yes"))
                {
                    toAnalyse = Lucene.Net.Documents.Field.Index.ANALYZED;
                }
                float boosting = Convert.ToSingle(general.Attributes.GetNamedItem("boost").Value);

                string[] metadataElementNames = general.Attributes.GetNamedItem("metadata_name").Value.Split(',');

                foreach (string metadataElementName in metadataElementNames)
                {

                    XmlNodeList elemList = metadataDoc.SelectNodes(metadataElementName);
                    for (int i = 0; i < elemList.Count; i++)
                    {
                        Field a = new Field(lucene_name, elemList[i].InnerText, toStore, toAnalyse);
                        a.Boost = boosting;
                        dataset.Add(a);
                        dataset.Add(new Field("ng_all", elemList[i].InnerText, Lucene.Net.Documents.Field.Store.NO, Field.Index.ANALYZED));
                        writeAutoCompleteIndex(docId, lucene_name, elemList[i].InnerText);
                        writeAutoCompleteIndex(docId, "ng_all", elemList[i].InnerText);
                    }
                }

            }

            indexWriter.AddDocument(dataset);
        }