public JsonResult CheckExportPossibility(string datarepo, long datasetid) { bool isDataConvertable = false; bool isMetadataConvertable = false; string metadataValidMessage = ""; bool exist = false; //get broker PublicationManager publicationManager = new PublicationManager(); // datasetversion DatasetManager dm = new DatasetManager(); long version = dm.GetDatasetLatestVersion(datasetid).Id; if (publicationManager.BrokerRepo.Get().Any(d => d.Name.ToLower().Equals(datarepo.ToLower()))) { Broker broker = publicationManager.BrokerRepo.Get().Where(d => d.Name.ToLower().Equals(datarepo.ToLower())).FirstOrDefault(); Publication publication = publicationManager.PublicationRepo.Get() .Where(p => p.Broker != null && p.Broker.Id.Equals(broker.Id) && p.DatasetVersion != null && p.DatasetVersion.Id.Equals(version)) .FirstOrDefault(); if (publication != null && !String.IsNullOrEmpty(publication.FilePath) && FileHelper.FileExist(Path.Combine(AppConfiguration.DataPath, publication.FilePath))) { //model.Exist = true; exist = true; } else { #region metadata // if no conversion is needed if (String.IsNullOrEmpty(broker.MetadataFormat)) { //model.IsMetadataConvertable = true; isMetadataConvertable = true; // Validate metadataValidMessage = OutputMetadataManager.IsValideAgainstSchema(datasetid, TransmissionType.mappingFileExport, datarepo); } else { //if convertion check ist needed //get all export attr from metadata structure List <string> exportNames = xmlDatasetHelper.GetAllTransmissionInformation(datasetid, TransmissionType.mappingFileExport, AttributeNames.name).ToList(); if (exportNames.Contains(broker.MetadataFormat)) { isMetadataConvertable = true; } metadataValidMessage = OutputMetadataManager.IsValideAgainstSchema(datasetid, TransmissionType.mappingFileExport, datarepo); } #endregion #region primary Data //todo need a check if the primary data is structured or not, if its unstructured also export should be possible if (broker.PrimaryDataFormat.ToLower().Contains("text/plain") || broker.PrimaryDataFormat.ToLower().Contains("text/csv") || broker.PrimaryDataFormat.ToLower().Contains("application/excel") || String.IsNullOrEmpty(broker.PrimaryDataFormat)) { isDataConvertable = true; } #endregion } //check if reporequirements are fit //e.g. GFBIO } return(Json(new { isMetadataConvertable = isMetadataConvertable, isDataConvertable = isDataConvertable, metadataValidMessage = metadataValidMessage, Exist = exist })); }
public ActionResult LoadDataRepoRequirementView(string datarepo, long datasetid) { DataRepoRequirentModel model = new DataRepoRequirentModel(); model.DatasetId = datasetid; //get broker PublicationManager publicationManager = new PublicationManager(); // datasetversion DatasetManager dm = new DatasetManager(); try { long version = dm.GetDatasetLatestVersionId(datasetid); model.DatasetVersionId = version; if (publicationManager.BrokerRepo.Get().Any(d => d.Name.ToLower().Equals(datarepo.ToLower()))) { Broker broker = publicationManager.BrokerRepo.Get() .Where(d => d.Name.ToLower().Equals(datarepo.ToLower())) .FirstOrDefault(); Publication publication = publicationManager.PublicationRepo.Get() .Where(p => p.Broker.Id.Equals(broker.Id) && p.DatasetVersion.Id.Equals(version)) .FirstOrDefault(); if (publication != null && !String.IsNullOrEmpty(publication.FilePath) && FileHelper.FileExist(Path.Combine(AppConfiguration.DataPath, publication.FilePath))) { model.Exist = true; } else { //if convertion check ist needed //get all export attr from metadata structure List <string> exportNames = xmlDatasetHelper.GetAllTransmissionInformation(datasetid, TransmissionType.mappingFileExport, AttributeNames.name).ToList(); if (string.IsNullOrEmpty(broker.MetadataFormat) || exportNames.Contains(broker.MetadataFormat)) { model.IsMetadataConvertable = true; } // Validate model.metadataValidMessage = OutputMetadataManager.IsValideAgainstSchema(datasetid, TransmissionType.mappingFileExport, datarepo); #region primary Data if (broker.PrimaryDataFormat.ToLower().Contains("text/plain") || broker.PrimaryDataFormat.ToLower().Contains("text/csv") || broker.PrimaryDataFormat.ToLower().Contains("application/excel") || String.IsNullOrEmpty(broker.PrimaryDataFormat)) { model.IsDataConvertable = true; } #endregion } } return(PartialView("_dataRepositoryRequirementsView", model)); } catch (Exception ex) { throw ex; } finally { publicationManager.Dispose(); dm.Dispose(); } }