예제 #1
0
        public async Task <ActionResult> GetStatus(long id)
        {
            PublicationManager publicationManager = new PublicationManager();

            Broker broker =
                publicationManager.GetBroker()
                .Where(b => b.Name.ToLower().Equals("gfbio dev1"))
                .FirstOrDefault();


            if (broker != null)
            {
                //create a gfbio api webservice manager
                GFBIOWebserviceManager gfbioWebserviceManager = new GFBIOWebserviceManager(broker);

                string roStatusJsonResult = await gfbioWebserviceManager.GetStatusByResearchObjectById(id);

                //get status and store ro
                List <GFBIOResearchObjectStatus> gfbioRoStatusList =
                    new JavaScriptSerializer().Deserialize <List <GFBIOResearchObjectStatus> >(
                        roStatusJsonResult);
                GFBIOResearchObjectStatus gfbioRoStatus = gfbioRoStatusList.LastOrDefault();
                return(Content(gfbioRoStatus.status));
            }

            return(Content("no status"));
        }
예제 #2
0
        public string Convert(long datasetVersionId)
        {
            MetadataStructureManager metadataStructureManager = new MetadataStructureManager();
            DatasetManager           datasetManager           = new DatasetManager();


            SubmissionManager  submissionManager  = new SubmissionManager();
            PublicationManager publicationManager = new PublicationManager();


            try
            {
                DatasetVersion datasetVersion = datasetManager.GetDatasetVersion(datasetVersionId);

                _broker   = publicationManager.GetBroker(_broker.Id);
                _dataRepo = publicationManager.GetRepository(_dataRepo.Id);


                long   datasetId = datasetVersion.Dataset.Id;
                string name      = datasetManager.GetDatasetVersion(datasetVersionId).Dataset.MetadataStructure.Name;

                XmlDocument metadata = OutputMetadataManager.GetConvertedMetadata(datasetId,
                                                                                  TransmissionType.mappingFileExport, name, false);

                // create links to the api calls of the primary data?



                //add all to a zip


                //save document  and return filepath for download


                string path     = submissionManager.GetDirectoryPath(datasetId, _broker.Name);
                string filename = submissionManager.GetFileNameForDataRepo(datasetId, datasetVersionId, _dataRepo.Name, "xml");

                string filepath = Path.Combine(path, filename);

                FileHelper.CreateDicrectoriesIfNotExist(path);

                metadata.Save(filepath);


                return(filepath);
            }
            finally
            {
                datasetManager.Dispose();
                metadataStructureManager.Dispose();
                publicationManager.Dispose();
            }
        }
예제 #3
0
        //ToDO -> David <- do not store the files on the server
        public string Convert(long datasetVersionId)
        {
            DatasetManager datasetManager = new DatasetManager();

            PublicationManager publicationManager = new PublicationManager();

            try
            {
                _broker   = publicationManager.GetBroker(_broker.Id);
                _dataRepo = publicationManager.GetRepository(_dataRepo.Id);

                /***
                 *  Generate a txt file for pangaea
                 *  1. json metadata
                 *  2. tabseperated primary Data
                 *
                 *
                 * if data only unstructred, then only metadata
                 */

                string primaryDataFilePath = "";

                #region create primary Data


                primaryDataFilePath = generatePrimaryData(datasetVersionId);


                #endregion


                DatasetVersion datasetVersion      = datasetManager.GetDatasetVersion(datasetVersionId);
                long           datasetId           = datasetVersion.Dataset.Id;
                long           metadataStructureId = datasetVersion.Dataset.MetadataStructure.Id;

                DataStructureDataList datastructureDataList = OutputDataStructureManager.GetVariableList(datasetId);

                PanageaMetadata metadata = getMetadata(datasetVersion.Metadata, metadataStructureId);
                metadata.ParameterIDs = datastructureDataList.Variables;

                string json = JsonConvert.SerializeObject(metadata, Formatting.Indented);


                SubmissionManager submissionManager = new SubmissionManager();



                string path     = submissionManager.GetDirectoryPath(datasetId, _broker.Name);
                string filename = submissionManager.GetFileNameForDataRepo(datasetVersionId, datasetId, _dataRepo.Name, "txt");

                string filepath = Path.Combine(path, filename);

                try
                {
                    if (File.Exists(filepath))
                    {
                        File.Delete(filepath);
                    }

                    FileHelper.Create(filepath).Close();
                    File.WriteAllText(filepath, json + Environment.NewLine + Environment.NewLine);

                    if (!string.IsNullOrEmpty(primaryDataFilePath))
                    {
                        File.AppendAllText(filepath, File.ReadAllText(primaryDataFilePath));
                    }

                    return(filepath);
                }
                catch (Exception exception)
                {
                    throw exception;
                }



                return("");
            }
            finally
            {
                datasetManager.Dispose();
                publicationManager.Dispose();
            }
        }
예제 #4
0
        public async Task <ActionResult> SendDataToDataRepo(long datasetId, string datarepo)
        {
            PublicationManager publicationManager = new PublicationManager();
            DatasetManager     datasetManager     = new DatasetManager();

            try
            {
                string zipfilepath = "";
                if (Session["ZipFilePath"] != null)
                {
                    zipfilepath = Session["ZipFilePath"].ToString();
                }

                DatasetVersion datasetVersion = datasetManager.GetDatasetLatestVersion(datasetId);

                Publication publication =
                    publicationManager.GetPublication()
                    .Where(
                        p =>
                        p.DatasetVersion.Id.Equals(datasetVersion.Id) &&
                        p.Broker.Name.ToLower().Equals(datarepo.ToLower()))
                    .FirstOrDefault();

                if (publication == null)
                {
                    //ToDo [SUBMISSION] -> create broker specfic function
                    // check case for gfbio
                    if (datarepo.ToLower().Contains("gfbio"))
                    {
                        #region GFBIO

                        //SubmissionManager publishingManager = new SubmissionManager();
                        //publishingManager.Load();
                        //DataRepository dataRepository = publishingManager.DataRepositories.Where(d => d.Name.Equals(datarepo)).FirstOrDefault();

                        Broker broker =
                            publicationManager.GetBroker()
                            .Where(b => b.Name.ToLower().Equals(datarepo.ToLower()))
                            .FirstOrDefault();


                        if (broker != null)
                        {
                            //Store ro in db
                            string title = xmlDatasetHelper.GetInformationFromVersion(datasetVersion.Id,
                                                                                      NameAttributeValues.title);
                            publicationManager.CreatePublication(datasetVersion, broker, title, 0, zipfilepath, "", "no status available");

                            //sendToGFBIO(broker, datasetId, datasetVersion, zipfilepath);
                        }

                        #endregion
                    }

                    if (datarepo.ToLower().Contains("pensoft"))
                    {
                        #region pensoft
                        Broker broker =
                            publicationManager.BrokerRepo.Get()
                            .Where(b => b.Name.ToLower().Equals(datarepo.ToLower()))
                            .FirstOrDefault();

                        Repository repository =
                            publicationManager.RepositoryRepo.Get()
                            .Where(b => b.Name.ToLower().Equals(datarepo.ToLower()))
                            .FirstOrDefault();

                        string title = xmlDatasetHelper.GetInformationFromVersion(datasetVersion.Id, NameAttributeValues.title);
                        publicationManager.CreatePublication(datasetVersion, broker, repository, title, 0, zipfilepath, "",
                                                             "no status available");
                        #endregion
                    }

                    if (datarepo.ToLower().Equals("generic"))
                    {
                        #region GENERIC

                        Broker broker =
                            publicationManager.BrokerRepo.Get()
                            .Where(b => b.Name.ToLower().Equals(datarepo.ToLower()))
                            .FirstOrDefault();
                        string title = xmlDatasetHelper.GetInformationFromVersion(datasetVersion.Id, NameAttributeValues.title);
                        publicationManager.CreatePublication(datasetVersion, broker, title, 0, zipfilepath, "",
                                                             "created");

                        #endregion
                    }
                }
                else
                {
                    Json("Publication exist.");
                }
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
            finally
            {
                publicationManager.Dispose();
                datasetManager.Dispose();
            }

            return(Json(true));
        }