Esempio n. 1
0
        public DataStructureResultsModel fill(long[] previewIds, string saerchTerms)
        {
            DataStructureResultStruct dataStructureResult = new DataStructureResultStruct();

            DataStructureManager dataStructureManager = null;

            try
            {
                dataStructureManager = new DataStructureManager();
                foreach (DataStructure ds in getStucturedDataStructures(saerchTerms, dataStructureManager))
                {
                    dataStructureResult             = new DataStructureResultStruct();
                    dataStructureResult.Id          = ds.Id;
                    dataStructureResult.Title       = ds.Name;
                    dataStructureResult.Description = ds.Description;

                    if (ds.Datasets.Count > 0)
                    {
                        dataStructureResult.inUse = true;
                    }

                    dataStructureResult.Structured = true;

                    if (previewIds != null && previewIds.Contains(ds.Id))
                    {
                        dataStructureResult.Preview = true;
                    }

                    this.dataStructureResults.Add(dataStructureResult);
                }

                foreach (DataStructure ds in getUnStucturedDataStructures(saerchTerms, dataStructureManager))
                {
                    dataStructureResult             = new DataStructureResultStruct();
                    dataStructureResult.Id          = ds.Id;
                    dataStructureResult.Title       = ds.Name;
                    dataStructureResult.Description = ds.Description;

                    if (ds.Datasets.Count > 0)
                    {
                        dataStructureResult.inUse = true;
                    }

                    if (previewIds != null && previewIds.Contains(ds.Id))
                    {
                        dataStructureResult.Preview = true;
                    }

                    this.dataStructureResults.Add(dataStructureResult);
                }
                return(this);
            }
            finally
            {
                dataStructureManager.Dispose();
            }
        }
Esempio n. 2
0
        public Structure(long datasetId) : this()
        {
            using (DatasetManager datasetManager = new DatasetManager())
            {
                var dataset = datasetManager.DatasetRepo.Get(datasetId);
                if (dataset != null && dataset.DataStructure.Id != 0)
                {
                    DataStructureResultStruct dataStructureResultStruct = new DataStructureResultStruct(this.Id);
                    this.Id          = dataStructureResultStruct.Id;
                    this.Title       = dataStructureResultStruct.Title;
                    this.Description = dataStructureResultStruct.Description;
                    this.inUse       = dataStructureResultStruct.inUse;
                    this.Structured  = dataStructureResultStruct.Structured;
                    this.Variables   = new DataTable("Variables");

                    this.Variables.Columns.Add("Id");
                    this.Variables.Columns.Add("Label");
                    this.Variables.Columns.Add("Description");
                    this.Variables.Columns.Add("isOptional");
                    this.Variables.Columns.Add("Unit");
                    this.Variables.Columns.Add("DataType");
                    this.Variables.Columns.Add("SystemType");

                    if (this.Structured == true)
                    {
                        StructuredDataStructurePreviewModel structuredDataStructurePreviewModel = new StructuredDataStructurePreviewModel(this.Id);
                        DataRow dataRow;
                        foreach (VariablePreview vs in structuredDataStructurePreviewModel.VariablePreviews)
                        {
                            dataRow                = this.Variables.NewRow();
                            dataRow["Id"]          = vs.Id;
                            dataRow["Label"]       = vs.Label;
                            dataRow["Description"] = vs.Description;
                            dataRow["isOptional"]  = vs.isOptional;
                            dataRow["Unit"]        = vs.Unit;
                            dataRow["DataType"]    = vs.DataType;
                            dataRow["SystemType"]  = vs.SystemType;
                            this.Variables.Rows.Add(dataRow);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public Structure()
        {
            DataStructureResultStruct dataStructureResultStruct = new DataStructureResultStruct();

            this.Id          = 0;
            this.Title       = dataStructureResultStruct.Title;
            this.Description = dataStructureResultStruct.Description;
            this.inUse       = dataStructureResultStruct.inUse;
            this.Structured  = dataStructureResultStruct.Structured;
            this.Variables   = new DataTable("Variables");

            this.Variables.Columns.Add("Id");
            this.Variables.Columns.Add("Label");
            this.Variables.Columns.Add("Description");
            this.Variables.Columns.Add("isOptional");
            this.Variables.Columns.Add("Unit");
            this.Variables.Columns.Add("DataType");
            this.Variables.Columns.Add("SystemType");
        }
Esempio n. 4
0
        public DataStructureResultsModel fill(long[] previewIds, string saerchTerms, bool structured = true, bool unstructured = true)
        {
            DataStructureResultStruct dataStructureResult = new DataStructureResultStruct();

            DataStructureManager dataStructureManager = null;
            DatasetManager       datasetManager       = null;

            try
            {
                dataStructureManager = new DataStructureManager();
                datasetManager       = new DatasetManager();

                using (IUnitOfWork uow = this.GetBulkUnitOfWork())
                {
                    if (structured)
                    {
                        foreach (DataStructure ds in getStucturedDataStructures(saerchTerms, dataStructureManager))
                        {
                            dataStructureResult             = new DataStructureResultStruct();
                            dataStructureResult.Id          = ds.Id;
                            dataStructureResult.Title       = ds.Name;
                            dataStructureResult.Description = ds.Description;

                            foreach (Dataset d in ds.Datasets)
                            {
                                if (datasetManager.RowAny(d.Id, uow))
                                {
                                    dataStructureResult.inUse = true;
                                    break;
                                }

                                // currently not working

                                /* else
                                 * {
                                 *  foreach (DatasetVersion dv in d.Versions)
                                 *  {
                                 *      if (datasetManager.GetDatasetVersionEffectiveTuples(dv).Any())
                                 *      {
                                 *          dataStructureResult.inUse = true;
                                 *          break;
                                 *      }
                                 *  }
                                 * }*/
                            }

                            dataStructureResult.Structured = true;

                            if (previewIds != null && previewIds.Contains(ds.Id))
                            {
                                dataStructureResult.Preview = true;
                            }

                            this.dataStructureResults.Add(dataStructureResult);
                        }
                    }
                }
                if (unstructured)
                {
                    foreach (DataStructure ds in getUnStucturedDataStructures(saerchTerms, dataStructureManager))
                    {
                        dataStructureResult             = new DataStructureResultStruct();
                        dataStructureResult.Id          = ds.Id;
                        dataStructureResult.Title       = ds.Name;
                        dataStructureResult.Description = ds.Description;

                        if (ds.Datasets.Count > 1) // Allow to edit, if only one file is linked to it
                        {
                            dataStructureResult.inUse = true;
                        }

                        if (previewIds != null && previewIds.Contains(ds.Id))
                        {
                            dataStructureResult.Preview = true;
                        }

                        this.dataStructureResults.Add(dataStructureResult);
                    }
                }
                return(this);
            }
            finally
            {
                dataStructureManager.Dispose();
                datasetManager.Dispose();
            }
        }