public void TransformDatatupleToJson() { //Arrange DatasetManager datasetManager = new DatasetManager(); try { //Act DatasetVersion datasetversion = datasetManager.GetDatasetLatestVersion(datasetId); var result = datasetManager.GetDatasetVersionEffectiveTuples(datasetversion); foreach (var dt in result) { dt.Materialize(); dt.Dematerialize(); } var newDts = result.Cast <DataTuple>(); foreach (var dt in newDts) { //dt.Materialize2(); //dt.Dematerialize2(); // convert variablevalues 1 to json } //Assert Assert.That(result.Count(), Is.EqualTo(numberOfTuples)); foreach (var dt in newDts) { for (int i = 0; i < dt.VariableValues.Count; i++) { var vv1 = dt.VariableValues.ElementAt(i); //var vv2 = dt.VariableValues2.ElementAt(i); //Assert.That(vv1.DataAttribute.Id , Is.EqualTo(vv2.DataAttribute.Id)); //Assert.That(vv1.Note, Is.EqualTo(vv2.Note)); //Assert.That(vv1.ObtainingMethod, Is.EqualTo(vv2.ObtainingMethod)); //Assert.That(vv1.ParameterValues, Is.EqualTo(vv2.ParameterValues)); //Assert.That(vv1.ResultTime, Is.EqualTo(vv2.ResultTime)); //Assert.That(vv1.SamplingTime, Is.EqualTo(vv2.SamplingTime)); //Assert.That(vv1.Tuple.Id, Is.EqualTo(vv2.Tuple.Id)); //Assert.That(vv1.Value, Is.EqualTo(vv2.Value)); //Assert.That(vv1.Variable.Id, Is.EqualTo(vv2.Variable.Id)); //Assert.That(vv1.VariableId, Is.EqualTo(vv2.VariableId)); } } } catch (Exception ex) { throw (ex); } finally { datasetManager.Dispose(); } }
public bool HasTransmission(long datasetid, TransmissionType type) { Dataset dataset = this.GetUnitOfWork().GetReadOnlyRepository <Dataset>().Get(datasetid); DatasetManager dm = new DatasetManager(); try { DatasetVersion datasetVersion = dm.GetDatasetLatestVersion(dataset); // get MetadataStructure if (datasetVersion != null && datasetVersion.Dataset != null && datasetVersion.Dataset.MetadataStructure != null && datasetVersion.Dataset.MetadataStructure.Extra != null && datasetVersion.Metadata != null) { MetadataStructure metadataStructure = datasetVersion.Dataset.MetadataStructure; XDocument xDoc = XmlUtility.ToXDocument((XmlDocument)datasetVersion.Dataset.MetadataStructure.Extra); IEnumerable <XElement> temp = XmlUtility.GetXElementsByAttribute(nodeNames.convertRef.ToString(), AttributeNames.type.ToString(), type.ToString(), xDoc); if (temp != null && temp.Any()) { return(true); } } return(false); } finally { dm.Dispose(); } }
/// <summary> /// Add Datatuples to a Excel Template file /// </summary> /// <remarks></remarks> /// <seealso cref=""/> /// <param name="dataTuples"> Datatuples to add</param> /// <param name="filePath">Path of the excel template file</param> /// <param name="dataStructureId">Id of datastructure</param> /// <returns>List of Errors or null</returns> public List <Error> AddDataTuples(DatasetManager datasetManager, List <long> dataTuplesIds, string filePath, long dataStructureId) { if (File.Exists(filePath)) { using (DataStructureManager dataStructureManager = new DataStructureManager()) { dataStructure = dataStructureManager.StructuredDataStructureRepo.Get(dataStructureId); // setup file Init(filePath, dataStructureId); // add header StructuredDataStructure sds = GetDataStructure(dataStructureId); AddHeader(sds); // iterate over all input rows DataTupleIterator tupleIterator = new DataTupleIterator(dataTuplesIds, datasetManager); foreach (var tuple in tupleIterator) { // add row and increment current index if (AddRow(tuple, rowIndex) && !tuple.Id.Equals(dataTuplesIds.Last())) { rowIndex += 1; } } // close the excel file Close(); } } return(ErrorMessages); }
public DataTable ConvertDatasetVersion(DatasetManager datasetManager, DatasetVersion datasetVersion, string tableName = "") { DataTable dt = new DataTable(); if (string.IsNullOrEmpty(tableName)) { dt.TableName = "Primary data table"; } else { dt.TableName = tableName; } using (DataStructureManager dsm = new DataStructureManager()) { StructuredDataStructure sds = dsm.StructuredDataStructureRepo.Get(datasetVersion.Dataset.DataStructure.Id); var tupleIds = datasetManager.GetDatasetVersionEffectiveTupleIds(datasetVersion); if (tupleIds != null && tupleIds.Count > 0 && sds != null) { buildTheHeader(sds, dt); buildTheBody(datasetManager, tupleIds, dt, sds); } } return(dt); }
/// <summary> /// Return a value of the attribute from the incoming metadata /// </summary> /// <param name="datasetid"></param> /// <param name="metadata"></param> /// <param name="name"></param> /// <returns></returns> public string GetInformation(long datasetid, XmlDocument metadata, NameAttributeValues name) { using (var unitOfWork = this.GetUnitOfWork()) using (DatasetManager dm = new DatasetManager()) using (MetadataStructureManager msm = new MetadataStructureManager()) { if (datasetid <= 0) { return(String.Empty); } var dataset = dm.GetDataset(datasetid); MetadataStructure metadataStructure = msm.Repo.Get(dataset.MetadataStructure.Id); if ((XmlDocument)metadataStructure.Extra == null) { return(string.Empty); } XDocument xDoc = XmlUtility.ToXDocument((XmlDocument)metadataStructure.Extra); XElement temp = XmlUtility.GetXElementByAttribute(nodeNames.nodeRef.ToString(), "name", name.ToString(), xDoc); string xpath = temp.Attribute("value").Value.ToString(); string value = metadata.SelectSingleNode(xpath).InnerText; return(string.IsNullOrWhiteSpace(value) ? "not available" : value); } }
// GET: api/Metadata public IEnumerable <MetadataViewObject> Get() { DatasetManager dm = new DatasetManager(); try { var datasetIds = dm.GetDatasetLatestIds(); List <MetadataViewObject> tmp = new List <MetadataViewObject>(); foreach (var id in datasetIds) { MetadataViewObject mvo = new MetadataViewObject(); mvo.DatasetId = id; List <string> t = xmlDatasetHelper.GetAllTransmissionInformation(id, TransmissionType.mappingFileExport, AttributeNames.name).ToList(); mvo.Format = t.ToArray(); tmp.Add(mvo); } return(tmp); } finally { dm.Dispose(); } }
public void DatasetManager_GetData_Measurements() { DatasetManager dm = new DatasetManager(connectionKey, "TESTSESSION"); List <DataPoint> series = dm.GetData("MeasurementLog", "Measure", null); Assert.IsTrue(series.Count > 0); }
/// <summary> /// /// </summary> /// <remarks></remarks> /// <seealso cref=""/> public void updateIndex(Dictionary <long, IndexingAction> datasetsToIndex) { using (DatasetManager dm = new DatasetManager()) { try { if (!isIndexConfigured) { this.configureBexisIndexing(false); } foreach (KeyValuePair <long, IndexingAction> pair in datasetsToIndex) { if (pair.Value == IndexingAction.CREATE) { Query query = new TermQuery(new Term("doc_id", pair.Key.ToString())); TopDocs tds = BexisIndexSearcher.getIndexSearcher().Search(query, 1); if (tds.TotalHits < 1) { writeBexisIndex(pair.Key, dm.GetDatasetLatestMetadataVersion(pair.Key)); } else { indexWriter.DeleteDocuments(new Term("doc_id", pair.Key.ToString())); autoCompleteIndexWriter.DeleteDocuments(new Term("id", pair.Key.ToString())); writeBexisIndex(pair.Key, dm.GetDatasetLatestMetadataVersion(pair.Key)); } } else if (pair.Value == IndexingAction.DELETE) { indexWriter.DeleteDocuments(new Term("doc_id", pair.Key.ToString())); autoCompleteIndexWriter.DeleteDocuments(new Term("id", pair.Key.ToString())); } else if (pair.Value == IndexingAction.UPDATE) { indexWriter.DeleteDocuments(new Term("doc_id", pair.Key.ToString())); autoCompleteIndexWriter.DeleteDocuments(new Term("id", pair.Key.ToString())); writeBexisIndex(pair.Key, dm.GetDatasetLatestMetadataVersion(pair.Key)); } } indexWriter.Commit(); autoCompleteIndexWriter.Commit(); BexisIndexSearcher.searcher = new IndexSearcher(indexWriter.GetReader()); BexisIndexSearcher._Reader = indexWriter.GetReader(); BexisIndexSearcher.autoCompleteSearcher = new IndexSearcher(autoCompleteIndexWriter.GetReader()); } catch (Exception ex) { throw ex; } finally { autoCompleteIndexWriter.Dispose(); indexWriter.Dispose(); BexisIndexSearcher.searcher = new IndexSearcher(indexWriter.GetReader()); BexisIndexSearcher.autoCompleteSearcher = new IndexSearcher(autoCompleteIndexWriter.GetReader()); } } }
private string generatePrimaryData(long datasetVersionId) { try { DatasetManager datasetManager = new DatasetManager(); DatasetVersion datasetVersion = datasetManager.GetDatasetVersion(datasetVersionId); if (datasetVersion.Dataset.DataStructure.Self is StructuredDataStructure) { OutputDataManager outputDataManager = new OutputDataManager(); SubmissionManager submissionManager = new SubmissionManager(); long datasetId = datasetVersion.Dataset.Id; string fileName = submissionManager.GetFileNameForDataRepo(datasetId, datasetVersionId, _dataRepo.Name, "csv"); string filepath = outputDataManager.GenerateAsciiFile( datasetId, datasetVersionId, fileName, "text/txt"); return(filepath); } } catch (Exception) { throw; } return(""); }
// GET: DQManager public ActionResult Index() { DatasetManager dm = new DatasetManager(); //dataset manager ManageDQ manageModel = new ManageDQ(); //DatasetVersion dsv = new DatasetVersion(); //dataset version manager List <long> datasetIds = dm.GetDatasetLatestIds(); //get latest //List<List<long>> matrixId = new List<List<long>>(); List <dataset> datasets = new List <dataset>(); foreach (long Id in datasetIds) //for each dataset { dataset ds = new dataset(); ds.Id = Id; ds.title = dm.GetDatasetLatestVersion(Id).Title; //List<DatasetVersion> datasetVersions = dm.GetDatasetVersions(Id); //List<long> versionIds = new List<long>(); //for (int i = 0; i < datasetVersions.Count; ++i) //{ // long versionId = datasetVersions[i].Id; // versionIds.Add(versionId); //} ////matrixId.Add(versions); //ds.versionIds = versionIds; datasets.Add(ds); } //manageModel.matrixId = matrixId; manageModel.datasets = datasets; return(View(manageModel)); }
private void addSelectedDatasetToBus(long datasetId) { DatasetManager datasetManager = new DatasetManager(); try { TaskManager = (TaskManager)Session["TaskManager"]; 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.GetInformationFromVersion(datasetVersion.Id, 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); } finally { datasetManager.Dispose(); } }
public static string GenerateDataStructure(long datasetId) { string path = ""; try { DatasetManager datasetManager = null; try { datasetManager = new DatasetManager(); DatasetVersion datasetVersion = datasetManager.GetDatasetLatestVersion(datasetId); DataStructureDataTable dataStructureDataTable = new DataStructureDataTable(datasetId); // store in content descriptor path = storeGeneratedFilePathToContentDiscriptor(datasetId, datasetVersion, "datastructure", ".txt"); } finally { datasetManager.Dispose(); } } catch (Exception ex) { throw ex; } return(path); }
/// <summary> /// Return a metadata as html file from a datasetversion /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult GetMetadataAsHtmlFile(long id) { DatasetManager dm = new DatasetManager(); try { using (var uow = this.GetUnitOfWork()) { long dsId = dm.GetDatasetLatestVersion(id).Id; DatasetVersion ds = uow.GetUnitOfWork().GetReadOnlyRepository <DatasetVersion>().Get(dsId); XmlDocument document = OutputMetadataManager.GetConvertedMetadata(id, TransmissionType.mappingFileExport, ds.Dataset.MetadataStructure.Name); string htmlPage = PartialView("SimpleMetadata", document).RenderToString(); byte[] content = Encoding.ASCII.GetBytes(htmlPage); return(File(content, "text/html", "metadata.html")); } } catch (Exception ex) { throw ex; } finally { dm.Dispose(); } }
public static string GetSchemaDirectoryPath(long datasetId) { using (DatasetManager datasetManager = new DatasetManager()) using (MetadataStructureManager metadataStructureManager = new MetadataStructureManager()) { try { DatasetVersion datasetVersion = datasetManager.GetDatasetLatestVersion(datasetId); MetadataStructure metadataStructure = metadataStructureManager.Repo.Get(datasetVersion.Dataset.MetadataStructure.Id); string path = Path.Combine(AppConfiguration.GetModuleWorkspacePath("DCM"), "Metadata", metadataStructure.Name); if (!String.IsNullOrEmpty(path) && Directory.Exists(path)) { return(path); } } catch (Exception ex) { throw ex; } } return(String.Empty); }
// get header public Header GetHeader(long id) { if (id <= 0) { return(null); } DatasetManager datasetManager = new DatasetManager(); try { DatasetVersion datasetVersion = datasetManager.GetDatasetLatestVersion(id); DateTime lastModified = datasetVersion.Timestamp; Header header = new Header(); header.OAI_Identifier = ConvertToOaiId(id); header.OAI_Set = AppConfiguration.ApplicationName; // ToDo what is a oai_set? header.Datestamp = lastModified; //Date Last Modified; header.Deleted = false; header.OAIDataProviderId = -1; return(header); } finally { datasetManager.Dispose(); } }
private string getStorePath(long datasetVersionId, string exportTo) { using (DatasetManager datasetManager = new DatasetManager()) using (MetadataStructureManager metadataStructureManager = new MetadataStructureManager()) { DatasetVersion datasetVersion = datasetManager.GetDatasetVersion(datasetVersionId); Dataset dataset = datasetManager.GetDataset(datasetVersionId); string md_title = metadataStructureManager.Repo.Get(datasetVersion.Dataset.MetadataStructure.Id).Name; string path; int versionNr = datasetManager.GetDatasetVersionNr(datasetVersion); if (string.IsNullOrEmpty(exportTo) || exportTo.ToLower().Equals("generic")) { path = IOHelper.GetDynamicStorePath(datasetVersion.Dataset.Id, versionNr, "metadata", ".xml"); } else { path = IOHelper.GetDynamicStorePath(datasetVersion.Dataset.Id, versionNr, "metadata_" + exportTo, ".xml"); } return(path); } }
private List <string> getVariableNames(long datasetId) { List <string> vars = new List <string>(); DatasetManager datasetManager = new DatasetManager(); try { var dataset = datasetManager.GetDataset(datasetId); if (dataset != null && dataset.DataStructure != null && dataset.DataStructure.Self is StructuredDataStructure) { StructuredDataStructure sds = (StructuredDataStructure)dataset.DataStructure.Self; if (sds != null) { sds.Variables.ToList().ForEach(v => vars.Add(v.Label)); } } return(vars); } catch (Exception ex) { return(new List <string>()); } finally { } }
public ActionResult ShowPreviewDataStructure(long datasetID) { DatasetManager dm = new DatasetManager(); DataStructureManager dsm = new DataStructureManager(); try { using (var uow = this.GetUnitOfWork()) { long dsId = dm.GetDatasetLatestVersion(datasetID).Id; DatasetVersion ds = uow.GetUnitOfWork().GetReadOnlyRepository <DatasetVersion>().Get(dsId); DataStructure dataStructure = uow.GetReadOnlyRepository <DataStructure>().Get(ds.Dataset.DataStructure.Id); long id = (long)datasetID; Tuple <DataStructure, long> m = new Tuple <DataStructure, long>( dataStructure, id ); return(PartialView("_previewDatastructure", m)); } } catch (Exception ex) { throw ex; } }
/// <summary> /// THE ACTIONRESULT FOR SHOW DATASET LIST VIEW /// </summary> /// <param name="datasetIds"></param> /// <param name="performerName"></param> /// <returns></returns> public ActionResult ShowDatasetList() { ExternalLink dsModel = new ExternalLink(); List <datasetInfo> datasetInfos = new List <datasetInfo>(); DatasetManager dm = new DatasetManager(); DataStructureManager dsm = new DataStructureManager(); List <long> datasetIds = dm.GetDatasetLatestIds(); foreach (long Id in datasetIds) { if (dm.IsDatasetCheckedIn(Id)) { DatasetVersion datasetVersion = dm.GetDatasetLatestVersion(Id); //get last dataset versions datasetInfo datasetInfo = new datasetInfo(); datasetInfo.title = datasetVersion.Title; DataStructure dataStr = dsm.AllTypesDataStructureRepo.Get(datasetVersion.Dataset.DataStructure.Id); string type = "file"; if (dataStr.Self.GetType() == typeof(StructuredDataStructure)) { type = "tabular"; } datasetInfo.type = type; datasetInfo.Id = Id; datasetInfos.Add(datasetInfo); } } dsModel.datasetInfos = datasetInfos; return(View(dsModel)); }
public JsonResult PrepareTxtData(long id) { if (hasUserRights(id, RightType.Read)) { string ext = ".txt"; DatasetManager datasetManager = new DatasetManager(); try { DatasetVersion datasetVersion = datasetManager.GetDatasetLatestVersion(id); AsciiWriter writer = new AsciiWriter(TextSeperator.comma); OutputDataManager ioOutputDataManager = new OutputDataManager(); string title = getTitle(writer.GetTitle(id)); string path = ""; string message = string.Format("dataset {0} version {1} was downloaded as txt.", id, datasetVersion.Id); // if filter selected if (filterInUse()) { #region generate a subset of a dataset String[] visibleColumns = null; if (Session["Columns"] != null) { visibleColumns = (String[])Session["Columns"]; } path = ioOutputDataManager.GenerateAsciiFile(id, title, "text/plain", visibleColumns); LoggerFactory.LogCustom(message); #endregion generate a subset of a dataset } else { path = ioOutputDataManager.GenerateAsciiFile(id, title, "text/plain"); LoggerFactory.LogCustom(message); } return(Json(true, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(ex.Message, JsonRequestBehavior.AllowGet)); } finally { datasetManager.Dispose(); } } else { return(Json("User has no rights.", JsonRequestBehavior.AllowGet)); } }
public List <FileInformation> getFilesByDatasetId(long datasetId, string entityType, long versionNo = 0) { EntityPermissionManager entityPermissionManager = null; DatasetManager datasetManager = null; try { entityPermissionManager = new EntityPermissionManager(); datasetManager = new DatasetManager(); bool access = entityPermissionManager.HasEffectiveRight(HttpContext.User.Identity.Name, typeof(Dataset), datasetId, RightType.Read); if (access) { Session["EntityType"] = entityType; return(getFilesByDataset(datasetManager.DatasetRepo.Get(datasetId), datasetManager, entityType, versionNo)); } else { return(null); } } catch { return(null); } finally { entityPermissionManager.Dispose(); datasetManager.Dispose(); } }
private DataTable getData(long id, long versionId = 0) { DatasetManager dm = new DatasetManager(); try { // if versionid = 0 - get latest Version // if version is not 0 // check if version is latest version if (id != 0 && (versionId == 0 || dm.GetDatasetLatestVersionId(id).Equals(versionId))) { DataTable data; data = dm.GetLatestDatasetVersionTuples(id); data.Strip(); return(data); } // if not return(getHistoryData(versionId)); } finally { dm.Dispose(); } }
public List <EntityStoreItem> GetVersionsById(long id) { DatasetManager dm = new DatasetManager(); List <EntityStoreItem> tmp = new List <EntityStoreItem>(); try { var datasetIds = dm.GetDatasetLatestIds(); var datasetHelper = new XmlDatasetHelper(); var versions = dm.GetDataset(id).Versions.OrderBy(v => v.Timestamp).ToList(); foreach (var v in versions) { tmp.Add(new EntityStoreItem() { Id = v.Id, Title = v.Title, Version = versions.IndexOf(v) + 1, CommitComment = "(" + v.Timestamp.ToString("dd.MM.yyyy HH:mm") + "): " + v.ChangeDescription }); } return(tmp); } catch (Exception ex) { return(tmp); } finally { dm.Dispose(); } }
/// <summary> /// Purges a dataset, which means the dataset and all its versions will be physically removed from the database. /// </summary> /// <param name="id">the identifier of the dataset to be purged.</param> /// <remarks>This operation is not revocerable.</remarks> /// <returns></returns> public ActionResult Purge(long id) { ViewBag.Title = PresentationModel.GetViewTitleForTenant("Purge", Session.GetTenant()); DatasetManager dm = new DatasetManager(); var entityPermissionManager = new EntityPermissionManager(); try { if (dm.PurgeDataset(id)) { entityPermissionManager.Delete(typeof(Dataset), id); if (this.IsAccessibale("DDM", "SearchIndex", "ReIndexUpdateSingle")) { var x = this.Run("DDM", "SearchIndex", "ReIndexUpdateSingle", new RouteValueDictionary() { { "id", id }, { "actionType", "DELETE" } }); } } } catch (Exception e) { ViewData.ModelState.AddModelError("", string.Format("Dataset {0} could not be purged.", id)); } return(View()); }
/// <summary> /// returns a value of a metadata node /// </summary> /// <param name="datasetVersion"></param> /// <param name="name"></param> /// <returns></returns> public IEnumerable <string> GetAllTransmissionInformation(long datasetid, TransmissionType type, AttributeNames returnType = AttributeNames.value) { Dataset dataset = this.GetUnitOfWork().GetReadOnlyRepository <Dataset>().Get(datasetid); DatasetManager dm = new DatasetManager(); try { DatasetVersion datasetVersion = dm.GetDatasetLatestVersion(dataset); // get MetadataStructure if (datasetVersion != null && datasetVersion.Dataset != null && datasetVersion.Dataset.MetadataStructure != null && datasetVersion.Dataset.MetadataStructure.Extra != null && datasetVersion.Metadata != null) { return(GetAllTransmissionInformationFromMetadataStructure(datasetVersion.Dataset.MetadataStructure.Id, type, returnType)); } return(null); } finally { dm.Dispose(); } }
/// <summary> /// Deletes a dataset, which means the dataset is marked as deleted, but is not physically removed from the database. /// </summary> /// <param name="id">the identifier of the dataset to be purged.</param> /// <remarks>When a dataset is deleted, it is consodered as non-exisiting, but for the sake or provenance, citation, history, etc, it is not removed froom the database. /// The function to recover a deleted dataset, will not be provided.</remarks> /// <returns></returns> public ActionResult Delete(long id) { var datasetManager = new DatasetManager(); var entityPermissionManager = new EntityPermissionManager(); try { if (datasetManager.DeleteDataset(id, ControllerContext.HttpContext.User.Identity.Name, true)) { //entityPermissionManager.Delete(typeof(Dataset), id); // This is not needed here. if (this.IsAccessibale("DDM", "SearchIndex", "ReIndexUpdateSingle")) { var x = this.Run("DDM", "SearchIndex", "ReIndexUpdateSingle", new RouteValueDictionary() { { "id", id }, { "actionType", "DELETE" } }); } } } catch (Exception e) { ViewData.ModelState.AddModelError("", $@"Dataset {id} could not be deleted."); } return(View()); //return RedirectToAction("List"); }
/// <summary> /// Information in metadata is stored as xml /// get back the vale of an attribute /// e.g. title = "dataset title" /// /// </summary> /// <param name="datasetVersion"></param> /// <param name="name"></param> /// <returns></returns> public string GetInformationFromVersion(long datasetVersionId, long metadataStructureId, NameAttributeValues name) { using (var unitOfWork = this.GetUnitOfWork()) using (DatasetManager dm = new DatasetManager()) using (MetadataStructureManager msm = new MetadataStructureManager()) { if (datasetVersionId <= 0) { return(String.Empty); } if (metadataStructureId <= 0) { return(String.Empty); } MetadataStructure metadataStructure = msm.Repo.Get(metadataStructureId); if ((XmlDocument)metadataStructure.Extra == null) { return(string.Empty); } XDocument xDoc = XmlUtility.ToXDocument((XmlDocument)metadataStructure.Extra); XElement temp = XmlUtility.GetXElementByAttribute(nodeNames.nodeRef.ToString(), "name", name.ToString(), xDoc); string xpath = temp.Attribute("value").Value.ToString(); return(dm.GetMetadataValueFromDatasetVersion(datasetVersionId, xpath)); } }
public ActionResult LoadMetadataStructureTab(long Id) { #region load Model DatasetManager datasetManager = new DatasetManager(); try { // retrieves all the dataset version IDs which are in the checked-in state datasetVersionIds = datasetManager.GetDatasetVersionLatestIds(); MetadataStructure metadataStructure = this.GetUnitOfWork().GetReadOnlyRepository <MetadataStructure>().Get(Id); MetadataStructureModel model = new MetadataStructureModel( metadataStructure.Id, metadataStructure.Name, metadataStructure.Description, getDatasetVersionsDic(metadataStructure, datasetVersionIds), IsExportAvailable(metadataStructure) ); #endregion return(PartialView("_metadataStructureView", model)); } finally { datasetManager.Dispose(); } }
private void addSelectedDatasetToBus(long datasetId) { using (DatasetManager datasetManager = new DatasetManager()) using (ResearchPlanManager rpm = new ResearchPlanManager()) { TaskManager = (TaskManager)Session["TaskManager"]; 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, datasetVersion.Title); ResearchPlan rp = rpm.Repo.Get(datasetVersion.Dataset.ResearchPlan.Id); TaskManager.AddToBus(TaskManager.RESEARCHPLAN_ID, rp.Id); TaskManager.AddToBus(TaskManager.RESEARCHPLAN_TITLE, rp.Title); } }
public List <ApiDatasetAttachmentsModel> Get() { DatasetManager dm = new DatasetManager(); List <ApiDatasetAttachmentsModel> tmp = new List <ApiDatasetAttachmentsModel>(); try { var datasetIds = dm.GetDatasetLatestIds(); foreach (long id in datasetIds) { var model = GetApiDatasetAttachmentsModel(id, dm); if (model != null) { tmp.Add(model); } } return(tmp); } finally { dm.Dispose(); } }