diff --git a/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql b/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql index 041f55be50..f606244fe4 100644 --- a/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql +++ b/Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql @@ -916,6 +916,9 @@ CREATE TABLE [dbo].Dataset( [Folder] [nvarchar](1000) NOT NULL, [DigitalObjectIdentifier] [varchar](256) NULL, [Source] [varchar](256) NULL, + [Type] [varchar](256) NULL, + [Url] [varchar](256) NULL, + [Provider_ID] [int] NULL, CONSTRAINT [PK_Dataset] PRIMARY KEY CLUSTERED ( [ID] ASC @@ -1420,6 +1423,7 @@ GO + EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Table ID' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Catalogue', @level2type=N'COLUMN',@level2name=N'ID' GO EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'‘SMR01’ for example' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'Catalogue', @level2type=N'COLUMN',@level2name=N'Acronym' diff --git a/Rdmp.Core/Datasets/HDRDataset.cs b/Rdmp.Core/Datasets/HDRDataset.cs new file mode 100644 index 0000000000..5ed09c3406 --- /dev/null +++ b/Rdmp.Core/Datasets/HDRDataset.cs @@ -0,0 +1,423 @@ +using Rdmp.Core.Datasets.HDRItems; +using Rdmp.Core.Repositories; +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Rdmp.Core.Datasets +{ + public class HDRDataset: PluginDataset + { + //public List Versions { get; set; } + //public string Id { get; set; } + //public string mongo_object_id { get; set; } + + public string message { get; set; } + public Data data { get; set; } + + public HDRDataset() { } + public HDRDataset(ICatalogueRepository catalogueRepository, string name) : base(catalogueRepository, name) { } + public HDRDataset(ICatalogueRepository repository, DbDataReader r) : base(repository, r) { } + + } + + // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); + public class Access + { + public string accessRights { get; set; } + public string jurisdiction { get; set; } + public string accessService { get; set; } + public object dataProcessor { get; set; } + public string dataController { get; set; } + public string deliveryLeadTime { get; set; } + public object accessRequestCost { get; set; } + public string accessServiceCategory { get; set; } + } + + public class Accessibility + { + public Usage usage { get; set; } + public Access access { get; set; } + public FormatAndStandards formatAndStandards { get; set; } + } + + public class Collection + { + public int id { get; set; } + public string name { get; set; } + public string description { get; set; } + public string image_link { get; set; } + public bool enabled { get; set; } + public int @public { get; set; } + public int counter { get; set; } + public DateTime created_at { get; set; } + public DateTime updated_at { get; set; } + public object deleted_at { get; set; } + public string mongo_object_id { get; set; } + public string mongo_id { get; set; } + public object updated_on { get; set; } + public int team_id { get; set; } + public string status { get; set; } + public List dataset_version_ids { get; set; } + } + + public class Column + { + public string name { get; set; } + public object values { get; set; } + public string dataType { get; set; } + public bool sensitive { get; set; } + public string description { get; set; } + } + + public class Coverage + { + public object pathway { get; set; } + public string spatial { get; set; } + public string followUp { get; set; } + public string typicalAgeRange { get; set; } + public object datasetCompleteness { get; set; } + public List materialType { get; set; } + public int typicalAgeRangeMax { get; set; } + public int typicalAgeRangeMin { get; set; } + } + + public class Data + { + public int id { get; set; } + public string mongo_object_id { get; set; } + public string mongo_id { get; set; } + public string mongo_pid { get; set; } + public string datasetid { get; set; } + public string pid { get; set; } + public object source { get; set; } + public int discourse_topic_id { get; set; } + public bool is_cohort_discovery { get; set; } + public int commercial_use { get; set; } + public int state_id { get; set; } + public int uploader_id { get; set; } + public int metadataquality_id { get; set; } + public int user_id { get; set; } + public int team_id { get; set; } + public int views_count { get; set; } + public int views_prev_count { get; set; } + public int has_technical_details { get; set; } + public string created { get; set; } + public string updated { get; set; } + public string submitted { get; set; } + public object published { get; set; } + public DateTime created_at { get; set; } + public DateTime updated_at { get; set; } + public object deleted_at { get; set; } + public string create_origin { get; set; } + public string status { get; set; } + public int durs_count { get; set; } + public int publications_count { get; set; } + public int tools_count { get; set; } + public int collections_count { get; set; } + public List spatialCoverage { get; set; } + public List durs { get; set; } + public List publications { get; set; } + public List named_entities { get; set; } + public List collections { get; set; } + public List versions { get; set; } + public Team team { get; set; } + } + + public class DataCustodian + { + public object logo { get; set; } + public string name { get; set; } + public string memberOf { get; set; } + public string identifier { get; set; } + public object description { get; set; } + public object contactPoint { get; set; } + } + + public class DatasetLinkage + { + public object isPartOf { get; set; } + public object isMemberOf { get; set; } + public object isDerivedFrom { get; set; } + public object linkedDatasets { get; set; } + } + + public class Documentation + { + public string inPipeline { get; set; } + public string description { get; set; } + public object associatedMedia { get; set; } + } + + public class EnrichmentAndLinkage + { + public object tools { get; set; } + public object isPartOf { get; set; } + public object derivedFrom { get; set; } + public object investigations { get; set; } + public object linkableDatasets { get; set; } + public object similarToDatasets { get; set; } + public object publicationAboutDataset { get; set; } + public object publicationUsingDataset { get; set; } + } + + public class FormatAndStandards + { + public string formats { get; set; } + public string languages { get; set; } + public object conformsTo { get; set; } + public string vocabularyEncodingSchemes { get; set; } + public List format { get; set; } + public List language { get; set; } + public List vocabularyEncodingScheme { get; set; } + } + + public class Linkage + { + public object tools { get; set; } + public object dataUses { get; set; } + public object isReferenceIn { get; set; } + public DatasetLinkage datasetLinkage { get; set; } + public object investigations { get; set; } + public object associatedMedia { get; set; } + public object isGeneratedUsing { get; set; } + public object syntheticDataWebLink { get; set; } + public object publicationAboutDataset { get; set; } + public object publicationUsingDataset { get; set; } + } + + public class Metadata + { + public Metadata metadata { get; set; } + public string gwdmVersion { get; set; } + //public OriginalMetadata original_metadata { get; set; } + public object omics { get; set; } + public Linkage linkage { get; set; } + public Summary summary { get; set; } + public Coverage coverage { get; set; } + public Required required { get; set; } + public Provenance provenance { get; set; } + public List observations { get; set; } + public Accessibility accessibility { get; set; } + public List structuralMetadata { get; set; } + public object demographicFrequency { get; set; } + public List tissuesSampleCollection { get; set; } + } + + public class NamedEntity + { + public int id { get; set; } + public string name { get; set; } + public DateTime created_at { get; set; } + public DateTime updated_at { get; set; } + public object deleted_at { get; set; } + public List dataset_version_ids { get; set; } + } + + public class Observation + { + public string observedNode { get; set; } + public int measuredValue { get; set; } + public string observationDate { get; set; } + public string measuredProperty { get; set; } + public string disambiguatingDescription { get; set; } + } + + public class Origin + { + public string source { get; set; } + public string purpose { get; set; } + public string imageContrast { get; set; } + public string collectionSituation { get; set; } + public List datasetType { get; set; } + public List datasetSubType { get; set; } + public List collectionSource { get; set; } + } + + public class OriginalMetadata + { + public object omics { get; set; } + public DateTime issued { get; set; } + public Summary summary { get; set; } + public string version { get; set; } + public Coverage coverage { get; set; } + public DateTime modified { get; set; } + public List revisions { get; set; } + public string identifier { get; set; } + public Provenance provenance { get; set; } + public List observations { get; set; } + public Accessibility accessibility { get; set; } + public Documentation documentation { get; set; } + public StructuralMetadata structuralMetadata { get; set; } + public object demographicFrequency { get; set; } + public EnrichmentAndLinkage enrichmentAndLinkage { get; set; } + } + + public class Provenance + { + public Origin origin { get; set; } + public Temporal temporal { get; set; } + } + + public class Publisher + { + public string name { get; set; } + public string gatewayId { get; set; } + } + + public class Required + { + public DateTime issued { get; set; } + public string version { get; set; } + public DateTime modified { get; set; } + public string gatewayId { get; set; } + public List revisions { get; set; } + public string gatewayPid { get; set; } + } + + public class ResourceCreator + { + public string name { get; set; } + public object rorId { get; set; } + public object gatewayId { get; set; } + } + + public class Revision + { + public string url { get; set; } + public string version { get; set; } + } + + public class Root + { + public string message { get; set; } + public Data data { get; set; } + } + + public class SpatialCoverage + { + public int id { get; set; } + public DateTime created_at { get; set; } + public DateTime updated_at { get; set; } + public string region { get; set; } + public bool enabled { get; set; } + public List dataset_version_ids { get; set; } + } + + public class StructuralMetadata + { + public List tables { get; set; } + public object syntheticDataWebLink { get; set; } + public string name { get; set; } + public List columns { get; set; } + public string description { get; set; } + } + + public class Summary + { + public string title { get; set; } + public object doiName { get; set; } + public string @abstract { get; set; } + //public string keywords { get; set; } + public Publisher publisher { get; set; } + public string inPipeline { get; set; } + public string shortTitle { get; set; } + public string datasetType { get; set; } + public string description { get; set; } + public string contactPoint { get; set; } + public string datasetSubType { get; set; } + public int populationSize { get; set; } + public object controlledKeywords { get; set; } + public DataCustodian dataCustodian { get; set; } + public object alternateIdentifiers { get; set; } + } + + public class Table + { + public string name { get; set; } + public List columns { get; set; } + public string description { get; set; } + } + + public class Team + { + public int id { get; set; } + public string pid { get; set; } + public DateTime created_at { get; set; } + public DateTime updated_at { get; set; } + public object deleted_at { get; set; } + public string name { get; set; } + public bool enabled { get; set; } + public bool allows_messaging { get; set; } + public bool workflow_enabled { get; set; } + public bool access_requests_management { get; set; } + public bool uses_5_safes { get; set; } + public bool is_admin { get; set; } + public string team_logo { get; set; } + public string member_of { get; set; } + public object contact_point { get; set; } + public string application_form_updated_by { get; set; } + public string application_form_updated_on { get; set; } + public string mongo_object_id { get; set; } + public bool notification_status { get; set; } + public bool is_question_bank { get; set; } + public bool is_provider { get; set; } + public object url { get; set; } + public object introduction { get; set; } + public object dar_modal_header { get; set; } + public object dar_modal_content { get; set; } + public object dar_modal_footer { get; set; } + public bool is_dar { get; set; } + public object service { get; set; } + } + + public class Temporal + { + public string endDate { get; set; } + public string timeLag { get; set; } + public string startDate { get; set; } + public string accrualPeriodicity { get; set; } + public string distributionReleaseDate { get; set; } + public string publishingFrequency { get; set; } + } + + public class TissuesSampleCollection + { + public object id { get; set; } + public object disease { get; set; } + public string materialType { get; set; } + public object collectionType { get; set; } + public object dataCategories { get; set; } + public object sampleAgeRange { get; set; } + public object accessConditions { get; set; } + public object storageTemperature { get; set; } + public object tissueSampleMetadata { get; set; } + } + + public class Usage + { + public ResourceCreator resourceCreator { get; set; } + public string dataUseLimitation { get; set; } + public string dataUseRequirement { get; set; } + public List dataUseRequirements { get; set; } + } + + public class Version + { + public int id { get; set; } + public DateTime created_at { get; set; } + public DateTime updated_at { get; set; } + public object deleted_at { get; set; } + public int dataset_id { get; set; } + public Metadata metadata { get; set; } + public int version { get; set; } + public object provider_team_id { get; set; } + public object application_type { get; set; } + public List linked_dataset_versions { get; set; } + } + + +} diff --git a/Rdmp.Core/Datasets/HDRDatasetProvider.cs b/Rdmp.Core/Datasets/HDRDatasetProvider.cs new file mode 100644 index 0000000000..25f3d00dcd --- /dev/null +++ b/Rdmp.Core/Datasets/HDRDatasetProvider.cs @@ -0,0 +1,86 @@ +using Amazon.Runtime.Internal.Endpoints.StandardLibrary; +using Newtonsoft.Json; +using Rdmp.Core.CommandExecution; +using Rdmp.Core.Curation.Data; +using Rdmp.Core.Curation.Data.Datasets; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace Rdmp.Core.Datasets +{ + public class HDRDatasetProvider : PluginDatasetProvider + { + private HttpClient _client; + public HDRDatasetProvider(IBasicActivateItems activator, DatasetProviderConfiguration configuration) : base(activator, configuration) + { + _client = new HttpClient(); + var credentials = Repository.GetAllObjectsWhere("ID", Configuration.DataAccessCredentials_ID).First(); + var apiKey = credentials.GetDecryptedPassword(); + _client.DefaultRequestHeaders.Add("x-application-id", credentials.Username); + _client.DefaultRequestHeaders.Add("x-client-id", apiKey); + } + public override void AddExistingDataset(string name, string url) + { + //var uri = $"{Configuration.Url}/data-sets/{UrltoUUID(url)}"; + var response = Task.Run(async () => await _client.GetAsync(url)).Result; + if (response.StatusCode == HttpStatusCode.OK) + { + var detailsString = Task.Run(async () => await response.Content.ReadAsStringAsync()).Result; + HDRDataset hdrDataset = JsonConvert.DeserializeObject(detailsString); + var datasetName = string.IsNullOrWhiteSpace(name) ? hdrDataset?.data.versions?.First().metadata.metadata.summary.title : name; + var dataset = new Curation.Data.Datasets.Dataset(Repository, datasetName) + { + Url = url, + Type = this.ToString(), + Provider_ID = Configuration.ID, + //DigitalObjectIdentifier = hdrDataset.data.versions.First().metadata.metadata.summary.doiName.ToString(), + Folder = $"\\{Configuration.Name}", + }; + dataset.SaveToDatabase(); + Activator.Publish(dataset); + } + else + { + throw new Exception("Cannot access dataset at provided url"); + } + } + + public override Dataset Create() + { + throw new NotImplementedException(); + } + + public HDRDataset FetchHDRDataset(Dataset dataset) + { + var response = Task.Run(async () => await _client.GetAsync(dataset.Url)).Result; + if (response.StatusCode == HttpStatusCode.OK) + { + var detailsString = Task.Run(async () => await response.Content.ReadAsStringAsync()).Result; + Console.WriteLine(detailsString); + HDRDataset hdrDataset = JsonConvert.DeserializeObject(detailsString); + return hdrDataset; + } + throw new Exception("Unable to fetch HDR dataset"); + } + + public override Dataset FetchDatasetByID(int id) + { + throw new NotImplementedException(); + } + + public override List FetchDatasets() + { + throw new NotImplementedException(); + } + + public override void Update(string uuid, PluginDataset datasetUpdates) + { + throw new NotImplementedException(); + } + } +} diff --git a/Rdmp.Core/Datasets/HDRItems/HDRSummary.cs b/Rdmp.Core/Datasets/HDRItems/HDRSummary.cs new file mode 100644 index 0000000000..ce379aee0d --- /dev/null +++ b/Rdmp.Core/Datasets/HDRItems/HDRSummary.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Rdmp.Core.Datasets.HDRItems +{ + public class HDRSummary + { + public HDRSummary(string title) { + Title = title; + } + + public string Title { get; set; } + } +} diff --git a/Rdmp.UI/Collections/ConfigurationsCollectionUI.cs b/Rdmp.UI/Collections/ConfigurationsCollectionUI.cs index c894f08133..684d5261ab 100644 --- a/Rdmp.UI/Collections/ConfigurationsCollectionUI.cs +++ b/Rdmp.UI/Collections/ConfigurationsCollectionUI.cs @@ -35,6 +35,13 @@ private IAtomicCommand[] GetWhitespaceRightClickMenu() new ExecuteCommandCreateNewPureConfigurationUI(_activator){ OverrideCommandName="Create New Pure Configuration", SuggestedCategory="Pure Datasets" }, + new ExecuteCommandCreateNewHDRConfigurationUI(_activator){ + OverrideCommandName="Create New HDR Configuration", SuggestedCategory="HDR Integration" + }, + new ExecuteCommandImportExistingHDRDatasetUI(_activator) + { + OverrideCommandName="Import Existing HDR Dataset", SuggestedCategory="HDR Integration" + }, new ExecuteCommandAddNewRegexRedactionConfigurationUI(_activator) { OverrideCommandName="Add New Regex Redaction Configuration", SuggestedCategory="Regex" diff --git a/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandCreateNewHDRConfigurationUI.cs b/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandCreateNewHDRConfigurationUI.cs new file mode 100644 index 0000000000..7babda78f6 --- /dev/null +++ b/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandCreateNewHDRConfigurationUI.cs @@ -0,0 +1,28 @@ +using Rdmp.Core.CommandExecution; +using Rdmp.Core.CommandExecution.AtomicCommands; +using Rdmp.UI.ItemActivation; +using Rdmp.UI.SimpleDialogs.Datasets; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Rdmp.UI.CommandExecution.AtomicCommands; + +public class ExecuteCommandCreateNewHDRConfigurationUI : BasicCommandExecution, IAtomicCommand +{ + private readonly IActivateItems _activator; + + public ExecuteCommandCreateNewHDRConfigurationUI(IActivateItems activator) : base(activator) + { + _activator = activator; + } + + public override void Execute() + { + base.Execute(); + var ui = new CreateNewHDRConfigurationUI(_activator); + ui.ShowDialog(); + } +} diff --git a/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandImportExistingHDRDatasetUI.cs b/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandImportExistingHDRDatasetUI.cs new file mode 100644 index 0000000000..11c984e5a4 --- /dev/null +++ b/Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandImportExistingHDRDatasetUI.cs @@ -0,0 +1,30 @@ +// Copyright (c) The University of Dundee 2018-2019 +// This file is part of the Research Data Management Platform (RDMP). +// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// You should have received a copy of the GNU General Public License along with RDMP. If not, see . + +using Rdmp.Core.CommandExecution.AtomicCommands; +using Rdmp.UI.ItemActivation; +using Rdmp.UI.SimpleDialogs.Datasets; +using System; + + +namespace Rdmp.UI.CommandExecution.AtomicCommands; + +public class ExecuteCommandImportExistingHDRDatasetUI : ExecuteCommandCreateDataset +{ + private readonly IActivateItems _activator; + + public ExecuteCommandImportExistingHDRDatasetUI(IActivateItems activator) : base( + activator, "New Dataset") + { + _activator = activator; + } + + public override void Execute() + { + var ui = new ImportExistingHDRDatasetUI(_activator, this); + ui.ShowDialog(); + } +} diff --git a/Rdmp.UI/CommandExecution/Proposals/ProposeExecutionWhenTargetIsDataset.cs b/Rdmp.UI/CommandExecution/Proposals/ProposeExecutionWhenTargetIsDataset.cs index 4dd1e01798..de0631353e 100644 --- a/Rdmp.UI/CommandExecution/Proposals/ProposeExecutionWhenTargetIsDataset.cs +++ b/Rdmp.UI/CommandExecution/Proposals/ProposeExecutionWhenTargetIsDataset.cs @@ -28,12 +28,18 @@ public ProposeExecutionWhenTargetIsDataset(IActivateItems itemActivator) : base( public override void Activate(Dataset target) { string PureAssembly = typeof(PureDatasetProvider).ToString(); - - if(target.Type == PureAssembly) + string HDRAssembly = typeof(HDRDatasetProvider).ToString(); + if (target.Type == PureAssembly) { ItemActivator.Activate(target); return; } + if (target.Type == HDRAssembly) + { + ItemActivator.Activate(target); + return; + } + ItemActivator.Activate(target); } diff --git a/Rdmp.UI/Rdmp.UI.csproj b/Rdmp.UI/Rdmp.UI.csproj index ccdc7a485c..054d4212f8 100644 --- a/Rdmp.UI/Rdmp.UI.csproj +++ b/Rdmp.UI/Rdmp.UI.csproj @@ -137,6 +137,12 @@ DatabaseTypeUI.cs + + Form + + + Form + Form @@ -247,6 +253,9 @@ WideMessageBox.cs + + UserControl + Component diff --git a/Rdmp.UI/SimpleDialogs/Datasets/CreateNewHDRConfigurationUI.Designer.cs b/Rdmp.UI/SimpleDialogs/Datasets/CreateNewHDRConfigurationUI.Designer.cs new file mode 100644 index 0000000000..62fce2e0bd --- /dev/null +++ b/Rdmp.UI/SimpleDialogs/Datasets/CreateNewHDRConfigurationUI.Designer.cs @@ -0,0 +1,154 @@ +namespace Rdmp.UI.SimpleDialogs.Datasets +{ + partial class CreateNewHDRConfigurationUI + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + label1 = new System.Windows.Forms.Label(); + label2 = new System.Windows.Forms.Label(); + label3 = new System.Windows.Forms.Label(); + label4 = new System.Windows.Forms.Label(); + tbName = new System.Windows.Forms.TextBox(); + tbUrl = new System.Windows.Forms.TextBox(); + tbOrganisationId = new System.Windows.Forms.TextBox(); + cbCredentials = new System.Windows.Forms.ComboBox(); + btnSave = new System.Windows.Forms.Button(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new System.Drawing.Point(136, 76); + label1.Name = "label1"; + label1.Size = new System.Drawing.Size(25, 15); + label1.TabIndex = 0; + label1.Text = "Url:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new System.Drawing.Point(119, 37); + label2.Name = "label2"; + label2.Size = new System.Drawing.Size(42, 15); + label2.TabIndex = 1; + label2.Text = "Name:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new System.Drawing.Point(26, 116); + label3.Name = "label3"; + label3.Size = new System.Drawing.Size(135, 15); + label3.TabIndex = 2; + label3.Text = "Data Access Credentials:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new System.Drawing.Point(69, 152); + label4.Name = "label4"; + label4.Size = new System.Drawing.Size(92, 15); + label4.TabIndex = 3; + label4.Text = "Organisation ID:"; + // + // tbName + // + tbName.Location = new System.Drawing.Point(169, 34); + tbName.Name = "tbName"; + tbName.Size = new System.Drawing.Size(370, 23); + tbName.TabIndex = 4; + tbName.TextChanged += ValidateForm; + // + // tbUrl + // + tbUrl.Location = new System.Drawing.Point(169, 73); + tbUrl.Name = "tbUrl"; + tbUrl.Size = new System.Drawing.Size(370, 23); + tbUrl.TabIndex = 5; + tbUrl.TextChanged += ValidateForm; + // + // tbOrganisationId + // + tbOrganisationId.Location = new System.Drawing.Point(169, 149); + tbOrganisationId.Name = "tbOrganisationId"; + tbOrganisationId.Size = new System.Drawing.Size(370, 23); + tbOrganisationId.TabIndex = 6; + tbOrganisationId.TextChanged += ValidateForm; + // + // cbCredentials + // + cbCredentials.FormattingEnabled = true; + cbCredentials.Location = new System.Drawing.Point(169, 108); + cbCredentials.Name = "cbCredentials"; + cbCredentials.Size = new System.Drawing.Size(208, 23); + cbCredentials.TabIndex = 7; + cbCredentials.SelectedIndexChanged += ValidateForm; + // + // btnSave + // + btnSave.Enabled = false; + btnSave.Location = new System.Drawing.Point(464, 192); + btnSave.Name = "btnSave"; + btnSave.Size = new System.Drawing.Size(75, 23); + btnSave.TabIndex = 8; + btnSave.Text = "Save"; + btnSave.UseVisualStyleBackColor = true; + btnSave.Click += Save; + // + // CreateNewPureConfigurationUI + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(800, 450); + Controls.Add(btnSave); + Controls.Add(cbCredentials); + Controls.Add(tbOrganisationId); + Controls.Add(tbUrl); + Controls.Add(tbName); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "CreateNewPureConfigurationUI"; + Text = "Create Pure Configuration"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox tbName; + private System.Windows.Forms.TextBox tbUrl; + private System.Windows.Forms.TextBox tbOrganisationId; + private System.Windows.Forms.ComboBox cbCredentials; + private System.Windows.Forms.Button btnSave; + } +} \ No newline at end of file diff --git a/Rdmp.UI/SimpleDialogs/Datasets/CreateNewHDRConfigurationUI.cs b/Rdmp.UI/SimpleDialogs/Datasets/CreateNewHDRConfigurationUI.cs new file mode 100644 index 0000000000..3b299f5aa0 --- /dev/null +++ b/Rdmp.UI/SimpleDialogs/Datasets/CreateNewHDRConfigurationUI.cs @@ -0,0 +1,71 @@ +using Rdmp.Core.Curation.Data; +using Rdmp.Core.Curation.Data.Datasets; +using Rdmp.Core.Datasets; +using Rdmp.UI.ItemActivation; +using Rdmp.UI.TestsAndSetup.ServicePropogation; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Rdmp.UI.SimpleDialogs.Datasets +{ + public partial class CreateNewHDRConfigurationUI : RDMPForm + { + + private readonly IActivateItems _activator; + public CreateNewHDRConfigurationUI(IActivateItems activator) + { + InitializeComponent(); + _activator = activator; + var dataAccessCredentials = _activator.RepositoryLocator.CatalogueRepository.GetAllObjects(); + cbCredentials.Items.Clear(); + cbCredentials.Items.AddRange(dataAccessCredentials); + } + + private void DisableSave() + { + btnSave.Enabled = false; + } + + private void ValidateForm(object sender, EventArgs e) + { + + if (cbCredentials.SelectedItem is null) + { + DisableSave(); + return; + } + if (string.IsNullOrWhiteSpace(tbName.Text)) + { + DisableSave(); + return; + } + if (string.IsNullOrWhiteSpace(tbUrl.Text)) + { + DisableSave(); + return; + } + if (string.IsNullOrWhiteSpace(tbOrganisationId.Text)) + { + DisableSave(); + return; + } + btnSave.Enabled = true; + } + + private void Save(object sender, EventArgs e) + { + var config = new DatasetProviderConfiguration(_activator.RepositoryLocator.CatalogueRepository, tbName.Text, typeof(HDRDatasetProvider).ToString(), tbUrl.Text, ((DataAccessCredentials)cbCredentials.SelectedItem).ID, tbOrganisationId.Text); + config.SaveToDatabase(); + _activator.Publish(config); + Close(); + _activator.Show($"Dataset Provider '{tbName.Text}' has successfully been created"); + } + } +} diff --git a/Rdmp.UI/SimpleDialogs/Datasets/CreateNewHDRConfigurationUI.resx b/Rdmp.UI/SimpleDialogs/Datasets/CreateNewHDRConfigurationUI.resx new file mode 100644 index 0000000000..af32865ec1 --- /dev/null +++ b/Rdmp.UI/SimpleDialogs/Datasets/CreateNewHDRConfigurationUI.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Rdmp.UI/SimpleDialogs/Datasets/ImportExistingHDRDatasetUI.Designer.cs b/Rdmp.UI/SimpleDialogs/Datasets/ImportExistingHDRDatasetUI.Designer.cs new file mode 100644 index 0000000000..5543655006 --- /dev/null +++ b/Rdmp.UI/SimpleDialogs/Datasets/ImportExistingHDRDatasetUI.Designer.cs @@ -0,0 +1,131 @@ +namespace Rdmp.UI.SimpleDialogs.Datasets +{ + partial class ImportExistingHDRDatasetUI + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + btnCreate = new System.Windows.Forms.Button(); + btnCancel = new System.Windows.Forms.Button(); + tbUrl = new System.Windows.Forms.TextBox(); + lblError = new System.Windows.Forms.Label(); + label2 = new System.Windows.Forms.Label(); + cbProviders = new System.Windows.Forms.ComboBox(); + label1 = new System.Windows.Forms.Label(); + SuspendLayout(); + // + // btnCreate + // + btnCreate.Location = new System.Drawing.Point(550, 108); + btnCreate.Name = "btnCreate"; + btnCreate.Size = new System.Drawing.Size(75, 23); + btnCreate.TabIndex = 14; + btnCreate.Text = "Create"; + btnCreate.UseVisualStyleBackColor = true; + btnCreate.Click += btnCreate_Click; + // + // btnCancel + // + btnCancel.Location = new System.Drawing.Point(459, 108); + btnCancel.Name = "btnCancel"; + btnCancel.Size = new System.Drawing.Size(75, 23); + btnCancel.TabIndex = 15; + btnCancel.Text = "Cancel"; + btnCancel.UseVisualStyleBackColor = true; + btnCancel.Click += btnCancel_Click; + // + // tbUrl + // + tbUrl.Location = new System.Drawing.Point(74, 56); + tbUrl.Name = "tbUrl"; + tbUrl.Size = new System.Drawing.Size(551, 23); + tbUrl.TabIndex = 17; + // + // lblError + // + lblError.AutoSize = true; + lblError.ForeColor = System.Drawing.Color.Red; + lblError.Location = new System.Drawing.Point(23, 95); + lblError.Name = "lblError"; + lblError.Size = new System.Drawing.Size(0, 15); + lblError.TabIndex = 18; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new System.Drawing.Point(14, 20); + label2.Name = "label2"; + label2.Size = new System.Drawing.Size(54, 15); + label2.TabIndex = 19; + label2.Text = "Provider:"; + // + // cbProviders + // + cbProviders.FormattingEnabled = true; + cbProviders.Location = new System.Drawing.Point(74, 17); + cbProviders.Name = "cbProviders"; + cbProviders.Size = new System.Drawing.Size(345, 23); + cbProviders.TabIndex = 20; + cbProviders.SelectedIndexChanged += cbProviders_SelectedIndexChanged; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new System.Drawing.Point(37, 59); + label1.Name = "label1"; + label1.Size = new System.Drawing.Size(37, 15); + label1.TabIndex = 16; + label1.Text = "UUID:"; + // + // ImportExistingPureDatasetUI + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + ClientSize = new System.Drawing.Size(667, 158); + Controls.Add(cbProviders); + Controls.Add(label2); + Controls.Add(lblError); + Controls.Add(tbUrl); + Controls.Add(label1); + Controls.Add(btnCancel); + Controls.Add(btnCreate); + Name = "ImportExistingPureDatasetUI"; + Text = "Import Existing HDR Dataset"; + Load += ImportExistingPureDatasetUI_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private System.Windows.Forms.Button btnCreate; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.TextBox tbUrl; + private System.Windows.Forms.Label lblError; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.ComboBox cbProviders; + private System.Windows.Forms.Label label1; + } +} \ No newline at end of file diff --git a/Rdmp.UI/SimpleDialogs/Datasets/ImportExistingHDRDatasetUI.cs b/Rdmp.UI/SimpleDialogs/Datasets/ImportExistingHDRDatasetUI.cs new file mode 100644 index 0000000000..a20214bbbb --- /dev/null +++ b/Rdmp.UI/SimpleDialogs/Datasets/ImportExistingHDRDatasetUI.cs @@ -0,0 +1,77 @@ +using Amazon.Auth.AccessControlPolicy; +using Rdmp.Core.CommandExecution.AtomicCommands; +using Rdmp.Core.Curation.Data.Aggregation; +using Rdmp.Core.Curation.Data.Datasets; +using Rdmp.Core.Datasets; +using Rdmp.UI.CommandExecution.AtomicCommands; +using Rdmp.UI.ItemActivation; +using Rdmp.UI.TestsAndSetup.ServicePropogation; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Rdmp.UI.SimpleDialogs.Datasets; + +public partial class ImportExistingHDRDatasetUI : RDMPForm +{ + private readonly IActivateItems _activator; + + private readonly string[] _visibilities = { "FREE", "CAMPUS", "BACKEND", "CONFIDENTIAL" }; + + private DatasetProviderConfiguration _providerConfiguration; + private HDRDatasetProvider _datasetProvider; + + public ImportExistingHDRDatasetUI(IActivateItems activator, ExecuteCommandImportExistingHDRDatasetUI command) : base(activator) + { + _activator = activator; + InitializeComponent(); + var configs = _activator.RepositoryLocator.CatalogueRepository.GetAllObjectsWhere("Type", typeof(HDRDatasetProvider).ToString()); + cbProviders.Items.AddRange(configs); + } + + private void ImportExistingPureDatasetUI_Load(object sender, EventArgs e) + { + + } + + private void btnCancel_Click(object sender, EventArgs e) + { + Dispose(); + } + + private void btnCreate_Click(object sender, EventArgs e) + { + if (_activator.YesNo("Please confirm you wish to import this Dataset", "Import Dataset")) + { + var url = _providerConfiguration.Url + "/v1/datasets/" + tbUrl.Text;//todo strip trailing / if it exists i.e. /api//v1/ + try + { + _datasetProvider.AddExistingDataset(null, url); + Close(); + Dispose(); + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + lblError.Text = "Unable to locate dataset. Ensure UUID is correct."; + lblError.Visible = true; + return; + } + } + } + + private void cbProviders_SelectedIndexChanged(object sender, EventArgs e) + { + if (cbProviders.SelectedItem is DatasetProviderConfiguration config) + { + _providerConfiguration = config; + _datasetProvider = new HDRDatasetProvider(_activator, _providerConfiguration); + } + } +} diff --git a/Rdmp.UI/SimpleDialogs/Datasets/ImportExistingHDRDatasetUI.resx b/Rdmp.UI/SimpleDialogs/Datasets/ImportExistingHDRDatasetUI.resx new file mode 100644 index 0000000000..af32865ec1 --- /dev/null +++ b/Rdmp.UI/SimpleDialogs/Datasets/ImportExistingHDRDatasetUI.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Rdmp.UI/SubComponents/HDRDatasetConfigurationUI.Designer.cs b/Rdmp.UI/SubComponents/HDRDatasetConfigurationUI.Designer.cs new file mode 100644 index 0000000000..b42b034356 --- /dev/null +++ b/Rdmp.UI/SubComponents/HDRDatasetConfigurationUI.Designer.cs @@ -0,0 +1,258 @@ +namespace Rdmp.UI.SubComponents +{ + partial class HDRDatasetConfigurationUI + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + columnButtonRenderer1 = new BrightIdeasSoftware.ColumnButtonRenderer(); + btnViewOnHDR = new System.Windows.Forms.Button(); + label1 = new System.Windows.Forms.Label(); + tbName = new System.Windows.Forms.TextBox(); + tbDescription = new System.Windows.Forms.TextBox(); + label2 = new System.Windows.Forms.Label(); + label3 = new System.Windows.Forms.Label(); + tbStartDate = new System.Windows.Forms.TextBox(); + btnSave = new System.Windows.Forms.Button(); + tbAbstract = new System.Windows.Forms.TextBox(); + label5 = new System.Windows.Forms.Label(); + tbKeywords = new System.Windows.Forms.TextBox(); + label6 = new System.Windows.Forms.Label(); + tbDOI = new System.Windows.Forms.TextBox(); + label7 = new System.Windows.Forms.Label(); + label8 = new System.Windows.Forms.Label(); + tbContactPoint = new System.Windows.Forms.TextBox(); + tbEndDate = new System.Windows.Forms.TextBox(); + label4 = new System.Windows.Forms.Label(); + SuspendLayout(); + // + // columnButtonRenderer1 + // + columnButtonRenderer1.ButtonPadding = new System.Drawing.Size(10, 10); + // + // btnViewOnHDR + // + btnViewOnHDR.Enabled = false; + btnViewOnHDR.Location = new System.Drawing.Point(29, 26); + btnViewOnHDR.Name = "btnViewOnHDR"; + btnViewOnHDR.Size = new System.Drawing.Size(121, 23); + btnViewOnHDR.TabIndex = 1; + btnViewOnHDR.Text = "View on HDR"; + btnViewOnHDR.UseVisualStyleBackColor = true; + btnViewOnHDR.Click += btnViewOnPure_Click; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new System.Drawing.Point(122, 72); + label1.Name = "label1"; + label1.Size = new System.Drawing.Size(42, 15); + label1.TabIndex = 2; + label1.Text = "Name:"; + // + // tbName + // + tbName.Location = new System.Drawing.Point(170, 69); + tbName.Name = "tbName"; + tbName.Size = new System.Drawing.Size(712, 23); + tbName.TabIndex = 3; + // + // tbDescription + // + tbDescription.Location = new System.Drawing.Point(170, 293); + tbDescription.Multiline = true; + tbDescription.Name = "tbDescription"; + tbDescription.Size = new System.Drawing.Size(712, 92); + tbDescription.TabIndex = 5; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new System.Drawing.Point(94, 296); + label2.Name = "label2"; + label2.Size = new System.Drawing.Size(70, 15); + label2.TabIndex = 4; + label2.Text = "Description:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new System.Drawing.Point(106, 395); + label3.Name = "label3"; + label3.Size = new System.Drawing.Size(61, 15); + label3.TabIndex = 6; + label3.Text = "Start Date:"; + // + // tbStartDate + // + tbStartDate.Location = new System.Drawing.Point(170, 395); + tbStartDate.Name = "tbStartDate"; + tbStartDate.Size = new System.Drawing.Size(181, 23); + tbStartDate.TabIndex = 7; + // + // btnSave + // + btnSave.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right; + btnSave.Location = new System.Drawing.Point(807, 427); + btnSave.Name = "btnSave"; + btnSave.Size = new System.Drawing.Size(75, 23); + btnSave.TabIndex = 14; + btnSave.Text = "Save"; + btnSave.UseVisualStyleBackColor = true; + btnSave.Click += btnSave_Click; + // + // tbAbstract + // + tbAbstract.Location = new System.Drawing.Point(170, 108); + tbAbstract.Multiline = true; + tbAbstract.Name = "tbAbstract"; + tbAbstract.Size = new System.Drawing.Size(712, 92); + tbAbstract.TabIndex = 17; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new System.Drawing.Point(110, 108); + label5.Name = "label5"; + label5.Size = new System.Drawing.Size(54, 15); + label5.TabIndex = 18; + label5.Text = "Abstract:"; + // + // tbKeywords + // + tbKeywords.Location = new System.Drawing.Point(170, 206); + tbKeywords.Name = "tbKeywords"; + tbKeywords.Size = new System.Drawing.Size(712, 23); + tbKeywords.TabIndex = 19; + // + // label6 + // + label6.AutoSize = true; + label6.Location = new System.Drawing.Point(103, 209); + label6.Name = "label6"; + label6.Size = new System.Drawing.Size(61, 15); + label6.TabIndex = 20; + label6.Text = "Keywords:"; + // + // tbDOI + // + tbDOI.Location = new System.Drawing.Point(170, 235); + tbDOI.Name = "tbDOI"; + tbDOI.Size = new System.Drawing.Size(181, 23); + tbDOI.TabIndex = 21; + // + // label7 + // + label7.AutoSize = true; + label7.Location = new System.Drawing.Point(134, 238); + label7.Name = "label7"; + label7.Size = new System.Drawing.Size(30, 15); + label7.TabIndex = 22; + label7.Text = "DOI:"; + // + // label8 + // + label8.AutoSize = true; + label8.Location = new System.Drawing.Point(81, 264); + label8.Name = "label8"; + label8.Size = new System.Drawing.Size(83, 15); + label8.TabIndex = 24; + label8.Text = "Contact Point:"; + // + // tbContactPoint + // + tbContactPoint.Location = new System.Drawing.Point(170, 264); + tbContactPoint.Name = "tbContactPoint"; + tbContactPoint.Size = new System.Drawing.Size(181, 23); + tbContactPoint.TabIndex = 23; + // + // tbEndDate + // + tbEndDate.Location = new System.Drawing.Point(170, 424); + tbEndDate.Name = "tbEndDate"; + tbEndDate.Size = new System.Drawing.Size(181, 23); + tbEndDate.TabIndex = 28; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new System.Drawing.Point(106, 427); + label4.Name = "label4"; + label4.Size = new System.Drawing.Size(57, 15); + label4.TabIndex = 27; + label4.Text = "End Date:"; + // + // HDRDatasetConfigurationUI + // + AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + Controls.Add(tbEndDate); + Controls.Add(label4); + Controls.Add(btnSave); + Controls.Add(label8); + Controls.Add(tbContactPoint); + Controls.Add(label7); + Controls.Add(tbDOI); + Controls.Add(label6); + Controls.Add(tbKeywords); + Controls.Add(label5); + Controls.Add(tbAbstract); + Controls.Add(tbStartDate); + Controls.Add(label3); + Controls.Add(tbDescription); + Controls.Add(label2); + Controls.Add(tbName); + Controls.Add(label1); + Controls.Add(btnViewOnHDR); + Name = "HDRDatasetConfigurationUI"; + Size = new System.Drawing.Size(955, 648); + Load += PureDatasetConfigurationUI_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private BrightIdeasSoftware.ColumnButtonRenderer columnButtonRenderer1; + private System.Windows.Forms.Button btnViewOnHDR; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox tbName; + private System.Windows.Forms.TextBox tbDescription; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.TextBox tbStartDate; + private System.Windows.Forms.Button btnSave; + private System.Windows.Forms.TextBox tbAbstract; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox tbKeywords; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox tbDOI; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TextBox tbContactPoint; + private System.Windows.Forms.TextBox tbEndDate; + private System.Windows.Forms.Label label4; + } +} diff --git a/Rdmp.UI/SubComponents/HDRDatasetConfigurationUI.cs b/Rdmp.UI/SubComponents/HDRDatasetConfigurationUI.cs new file mode 100644 index 0000000000..bd552deb20 --- /dev/null +++ b/Rdmp.UI/SubComponents/HDRDatasetConfigurationUI.cs @@ -0,0 +1,135 @@ +using NPOI.HSSF.Record.Aggregates.Chart; +using Rdmp.Core.Curation.Data.Datasets; +using Rdmp.Core.Datasets; +using Rdmp.Core.Datasets.PureItems; +using Rdmp.Core.ReusableLibraryCode; +using Rdmp.UI.ItemActivation; +using Rdmp.UI.Refreshing; +using Rdmp.UI.TestsAndSetup.ServicePropogation; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Rdmp.UI.SubComponents; + +public partial class HDRDatasetConfigurationUI : DatsetConfigurationUI_Design, IRefreshBusSubscriber +{ + + private HDRDataset _dataset; + private IActivateItems _activator; + private HDRDatasetProvider _provider; + private Dataset _dbObject; + public HDRDatasetConfigurationUI() + { + InitializeComponent(); + } + + public override void SetDatabaseObject(IActivateItems activator, Dataset databaseObject) + { + _activator = activator; + _dbObject = databaseObject; + base.SetDatabaseObject(activator, databaseObject); + _provider = new HDRDatasetProvider(activator, activator.RepositoryLocator.CatalogueRepository.GetAllObjectsWhere("ID", databaseObject.Provider_ID).First()); + _dataset = _provider.FetchHDRDataset(databaseObject); + var summary= _dataset.data.versions.First().metadata.metadata.summary; + //if (_dataset.PortalURL is not null) + //{ + // btnViewOnHDR.Enabled = true; + //} + tbName.Text = summary.title; + tbAbstract.Text = summary.@abstract; + tbContactPoint.Text = summary.contactPoint.ToString(); + tbDOI.Text = summary.doiName.ToString(); + tbDescription.Text = summary.description; + tbStartDate.Text = _dataset.data.versions.First().metadata.metadata.provenance.temporal.startDate; + tbEndDate.Text = _dataset.data.versions.First().metadata.metadata.provenance.temporal.endDate; + } + + public void RefreshBus_RefreshObject(object sender, RefreshObjectEventArgs e) + { + throw new NotImplementedException(); + } + + private void label1_Click(object sender, EventArgs e) + { + + } + + private void btnViewOnPure_Click(object sender, EventArgs e) + { + //UsefulStuff.OpenUrl(_dataset.PortalURL); + } + + private void PureDatasetConfigurationUI_Load(object sender, EventArgs e) + { + + } + + private void btnSave_Click(object sender, EventArgs e) + { + //if (_activator.YesNo("Are you sure?", "Save Changes")) + //{ + // var datasetUpdate = new PureDataset(); + // _dataset.Title.En_GB = tbName.Text; + // datasetUpdate.Title = _dataset.Title; + // var datasetDescriptionTerm = "/dk/atira/pure/dataset/descriptions/datasetdescription"; + // var description = _dataset.Descriptions.Where(d => d.Term.URI == datasetDescriptionTerm).FirstOrDefault(); + // if (description is null) + // { + // //error + // Console.WriteLine("No known description!"); + // } + // else + // { + // description.Value = new ENGBWrapper(tbDescription.Text); + // datasetUpdate.Descriptions = new List { description }; + // } + // if (!string.IsNullOrWhiteSpace(tbStartDate.Text)) + // { + // _dataset.TemporalCoveragePeriod.StartDate = new PureDate(DateTime.Parse(tbStartDate.Text)); + // } + // if (!string.IsNullOrWhiteSpace(tbTemporalEnd.Text)) + // { + // _dataset.TemporalCoveragePeriod.EndDate = new PureDate(DateTime.Parse(tbTemporalEnd.Text)); + // } + // if (!string.IsNullOrWhiteSpace(tbStartDate.Text) || !string.IsNullOrWhiteSpace(tbTemporalEnd.Text)) + // datasetUpdate.TemporalCoveragePeriod = _dataset.TemporalCoveragePeriod; + + // datasetUpdate.Links = new(); + // foreach (var link in links) + // { + // var original = _dataset.Links.Where(l => l.PureID == link.Link.PureID).First(); + // if (original.Url == link.LinkUrl && link.LinkDescription == original.Description.En_GB) + // { + // continue; + // } + // var pl = new PureLink(link.Link.PureID, link.LinkUrl, link.Link.Alias, new ENGBWrapper(link.LinkDescription), link.Link.LinkType); + // datasetUpdate.Links.Add(pl); + // } + // if (!datasetUpdate.Links.Any()) datasetUpdate.Links = null; + // _provider.Update(_dataset.UUID, datasetUpdate); + // SetDatabaseObject(_activator, _dbObject); + // _activator.Show("Successfully updated Pure dataset"); + //} + } + + private void label4_Click(object sender, EventArgs e) + { + + } + +} + +[TypeDescriptionProvider( + typeof(AbstractControlDescriptionProvider))] +public abstract class + HDRDatsetConfigurationUI_Design : RDMPSingleDatabaseObjectControl +{ +} \ No newline at end of file diff --git a/Rdmp.UI/SubComponents/HDRDatasetConfigurationUI.resx b/Rdmp.UI/SubComponents/HDRDatasetConfigurationUI.resx new file mode 100644 index 0000000000..55e408cef0 --- /dev/null +++ b/Rdmp.UI/SubComponents/HDRDatasetConfigurationUI.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file