diff --git a/CHANGES.txt b/CHANGES.txt index 7ae1b6b66..0d83e39db 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,6 @@ === Release of PxWeb 2023 v1 === +- Dcat file uses the organizations.json file to map between organization names and existing organization uris +- Dcat admin tool and api-endpoint is now updated to allow for catalog titles and descriptions in multiple languages - Dcat admin tool settings are now saved separately for each database, in the corresponding database.config file - Dcat admin tool now uses the BackgroundWorker to run tasks as background processes - Upgraded versions of nuget-packages diff --git a/PXWeb/Admin/Settings-General-Language.aspx.designer.cs b/PXWeb/Admin/Settings-General-Language.aspx.designer.cs index 3d0e345db..ece17a99a 100644 --- a/PXWeb/Admin/Settings-General-Language.aspx.designer.cs +++ b/PXWeb/Admin/Settings-General-Language.aspx.designer.cs @@ -1,18 +1,19 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.3634 // // Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. +// the code is regenerated. // //------------------------------------------------------------------------------ -namespace PXWeb.Admin { - - - public partial class Settings_General_Language { - +namespace PXWeb.Admin +{ + + + public partial class Settings_General_Language + { + /// /// rptSiteLanguages control. /// @@ -21,7 +22,7 @@ public partial class Settings_General_Language { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.Repeater rptSiteLanguages; - + /// /// lblDefaultLanguage control. /// @@ -30,7 +31,7 @@ public partial class Settings_General_Language { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.Label lblDefaultLanguage; - + /// /// cboDefaultLanguage control. /// @@ -39,7 +40,7 @@ public partial class Settings_General_Language { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.DropDownList cboDefaultLanguage; - + /// /// imgDefaultLanguage control. /// @@ -48,15 +49,17 @@ public partial class Settings_General_Language { /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.ImageButton imgDefaultLanguage; - + /// /// Master property. /// /// /// Auto-generated property. /// - public new PXWeb.Admin.Admin Master { - get { + public new PXWeb.Admin.Admin Master + { + get + { return ((PXWeb.Admin.Admin)(base.Master)); } } diff --git a/PXWeb/Admin/Tools-XMLGenerator.aspx b/PXWeb/Admin/Tools-XMLGenerator.aspx index c76ab713e..6252d07cd 100644 --- a/PXWeb/Admin/Tools-XMLGenerator.aspx +++ b/PXWeb/Admin/Tools-XMLGenerator.aspx @@ -20,16 +20,6 @@ -
- "> - - -
-
- "> - - -
"> @@ -50,14 +40,46 @@
-
+ +
+ + +
+ + + > +
+
+ + > + +
+
+ + > + +
+
+<%-- +

+ + > + > + > +

+
--%> +
+ +
+ +
">
- +
diff --git a/PXWeb/Admin/Tools-XMLGenerator.aspx.cs b/PXWeb/Admin/Tools-XMLGenerator.aspx.cs index d5b8af6dd..e4990a42f 100644 --- a/PXWeb/Admin/Tools-XMLGenerator.aspx.cs +++ b/PXWeb/Admin/Tools-XMLGenerator.aspx.cs @@ -15,7 +15,7 @@ using System.Globalization; using System.Collections.Generic; using System.IO; -using Px.Rdf; +using Px.Dcat; namespace PXWeb.Admin { @@ -45,6 +45,7 @@ protected void fillCNMMDatabases(DropDownList ddl) ddl.Items.Add(new ListItem(db.Id, db.Id)); } } + protected void cboSelectDbType_SelectedIndexChanged(object sender, EventArgs e) { if (cboSelectDbType.SelectedItem.Value == "PX") fillPxDatabases(cboSelectDb); @@ -130,8 +131,8 @@ private void ReadSettings(string database) textBoxSelectApiURL.Text = dcatSettings.BaseApiUrl; textBoxSelectLandingPageURL.Text = dcatSettings.LandingPageUrl; textBoxSelectPublisher.Text = dcatSettings.Publisher; - textBoxSelectCatalogTitle.Text = dcatSettings.CatalogTitle; - textBoxSelectCatalogDesc.Text = dcatSettings.CatalogDescription; + // textBoxSelectCatalogTitle.Text = dcatSettings.CatalogTitle; + // textBoxSelectCatalogDesc.Text = dcatSettings.CatalogDescription; textBoxSelectLicense.Text = dcatSettings.License; updateStatusLabel(dcatSettings); @@ -142,8 +143,48 @@ private void ReadSettings(string database) { btnGenerateXML.Enabled = true; } + + var settingsLookup = new Dictionary(); + IEnumerable languageSpecificSettings = dcatSettings.LanguageSpecificSettings; + if (languageSpecificSettings != null) { + foreach (IDcatLanguageSpecificSettings l in dcatSettings.LanguageSpecificSettings) + { + settingsLookup.Add(l.Language, l); + } + } + + var langSettings = new List(); + foreach (ILanguageSettings l in Settings.Current.General.Language.SiteLanguages) { + string id = l.Name; + IDcatLanguageSpecificSettings settings; + string title; + string desc; + if (settingsLookup.TryGetValue(id, out settings)) + { + title = settings.CatalogTitle; + desc = settings.CatalogDescription; + } + else + { + title = "Catalog title"; + desc = "Catalog desc"; + } + langSettings.Add( + new + { + Id = id, + Name = new CultureInfo(id).EnglishName, + Title = title, + Description = desc, + } + ); + } + + dcatLanguageSpecificSettings.DataSource = langSettings; + dcatLanguageSpecificSettings.DataBind(); } + private void updateStatusLabel(DcatSettings dcatSettings) { lblStatusValue.Text = dcatSettings.FileStatus.ToString(); @@ -162,15 +203,38 @@ private void saveCurrentSettings() dcats.BaseApiUrl = textBoxSelectApiURL.Text; dcats.LandingPageUrl = textBoxSelectLandingPageURL.Text; dcats.Publisher = textBoxSelectPublisher.Text; - dcats.CatalogTitle = textBoxSelectCatalogTitle.Text; - dcats.CatalogDescription = textBoxSelectCatalogDesc.Text; + // dcats.CatalogTitle = textBoxSelectCatalogTitle.Text; + // dcats.CatalogDescription = textBoxSelectCatalogDesc.Text; dcats.License = textBoxSelectLicense.Text; dcats.Database = cboSelectDb.Text; dcats.DatabaseType = cboSelectDbType.Text; + var languageSpecificSettingsList = new List(); + + foreach (RepeaterItem itm in dcatLanguageSpecificSettings.Items) + { + IDcatLanguageSpecificSettings langSpecificSettings = GetLangSpecificSettings(itm); + languageSpecificSettingsList.Add(langSpecificSettings); + } + dcats.LanguageSpecificSettings = languageSpecificSettingsList; + db.Save(); } + private IDcatLanguageSpecificSettings GetLangSpecificSettings(RepeaterItem itm) + { + var hf = (HiddenField)itm.FindControl("hidSetting"); + string lang = hf.Value; + + var titleTextBox = (TextBox)itm.FindControl("textBoxSelectCatalogTitle"); + string title = titleTextBox.Text; + + var descTextBox = (TextBox)itm.FindControl("textBoxSelectCatalogDescription"); + var desc = descTextBox.Text; + + return new DcatLanguageSpecificSettings(lang, title, desc); + } + protected void MasterSave_Click(object sender, EventArgs e) { saveCurrentSettings(); } diff --git a/PXWeb/Admin/Tools-XMLGenerator.aspx.designer.cs b/PXWeb/Admin/Tools-XMLGenerator.aspx.designer.cs index 957671232..5eaef02a5 100644 --- a/PXWeb/Admin/Tools-XMLGenerator.aspx.designer.cs +++ b/PXWeb/Admin/Tools-XMLGenerator.aspx.designer.cs @@ -95,60 +95,6 @@ public partial class Tools_XMLGenerator /// protected global::System.Web.UI.WebControls.ImageButton imgSelectBaseURI; - /// - /// lblSelectCatalogTitle control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Label lblSelectCatalogTitle; - - /// - /// textBoxSelectCatalogTitle control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox textBoxSelectCatalogTitle; - - /// - /// imgSelectCatalogTitle control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.ImageButton imgSelectCatalogTitle; - - /// - /// lblSelectCatalogDesc control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Label lblSelectCatalogDesc; - - /// - /// textBoxSelectCatalogDesc control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.TextBox textBoxSelectCatalogDesc; - - /// - /// imgSelectCatalogDesc control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.ImageButton imgSelectCatalogDesc; - /// /// lblSelectLicense control. /// @@ -257,6 +203,15 @@ public partial class Tools_XMLGenerator /// protected global::System.Web.UI.WebControls.ImageButton imgSelectPublisher; + /// + /// dcatLanguageSpecificSettings control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Repeater dcatLanguageSpecificSettings; + /// /// lblStatus control. /// diff --git a/PXWeb/Code/API/Controllers/DcatController.cs b/PXWeb/Code/API/Controllers/DcatController.cs index 65831e3c6..b8a0d0fb4 100644 --- a/PXWeb/Code/API/Controllers/DcatController.cs +++ b/PXWeb/Code/API/Controllers/DcatController.cs @@ -5,51 +5,118 @@ using System.Net; using System.Net.Http; using System.Web.Http; -using Px.Rdf; +using Px.Dcat; using System.Web; using System.IO; namespace PXWeb.API { - [AuthenticationFilter] - public class DcatController : ApiController + [AuthenticationFilter] + public class DcatController : ApiController + { + public class Input { - [HttpPost] - public HttpResponseMessage buildXML(string databaseType, string database, string baseURI, string catalogTitle, string catalogDescription, string license, string baseApiUrl, string landingPageUrl, string publisher, [FromUri] List languages, string preferredLanguage) - { - string databaseTypeLower = databaseType.ToLower(); - RdfSettings settings = new RdfSettings() - { - BaseUri = baseURI, - CatalogTitle = catalogTitle, - CatalogDescription = catalogDescription, - License = license, - BaseApiUrl = baseApiUrl, - LandingPageUrl = landingPageUrl, - PublisherName = publisher, - Languages = languages, - PreferredLanguage = preferredLanguage, - ThemeMapping = HttpContext.Current.Server.MapPath("~/TMapping.json") - }; - if (databaseTypeLower == "cnmm") { - settings.Fetcher = new CNMMFetcher(); - settings.DBid = database; - } - else if(databaseTypeLower == "px") - { - settings.DBid = HttpContext.Current.Server.MapPath(PXWeb.Settings.Current.General.Paths.PxDatabasesPath) + database + "/Menu.xml"; - if (!File.Exists(settings.DBid)) return Request.CreateResponse(HttpStatusCode.BadRequest, $"Database does not exist: {database}"); - string localThemeMapping = HttpContext.Current.Server.MapPath(PXWeb.Settings.Current.General.Paths.PxDatabasesPath) + database + "/TMapping.json"; - if (File.Exists(localThemeMapping)) settings.ThemeMapping = localThemeMapping; - settings.Fetcher = new PXFetcher(HttpContext.Current.Server.MapPath(PXWeb.Settings.Current.General.Paths.PxDatabasesPath)); - } - else - { - return Request.CreateResponse(HttpStatusCode.BadRequest, $"Invalid database type"); - } - string savePath = HttpContext.Current.Server.MapPath(PXWeb.Settings.Current.General.Paths.PxDatabasesPath + database + "/dcat-ap.xml"); - XML.WriteToFile(savePath, settings); - return Request.CreateResponse(HttpStatusCode.OK, $"Xml file created successfully, {databaseType}"); + public string DatabaseType; + public string Database; + public string BaseUri; + public string License; + public string BaseApiUrl; + public string LandingPageUrl; + public string Publisher; + public List Languages; + public List LanguageSpecificSettings; + } + + [HttpPost] + public HttpResponseMessage buildXML([FromBody] Input input) + { + if (input is null) { return Request.CreateResponse(HttpStatusCode.BadRequest, $"Missing json body"); } + string databaseTypeLower = input.DatabaseType.ToLower(); + + List missingFields = new List(); + if (input.DatabaseType is null) + { + missingFields.Add("DatabaseType"); + } + if (input.Database is null) + { + missingFields.Add("Database"); + } + if (input.BaseUri is null) + { + missingFields.Add("BaseUri"); + } + if (input.License is null) + { + missingFields.Add("License"); + } + if (input.BaseApiUrl is null) + { + missingFields.Add("BaseApiUrl"); + } + if (input.LandingPageUrl is null) + { + missingFields.Add("LandingPageUrl"); + } + if (input.Publisher is null) + { + missingFields.Add("Publisher"); + } + if (input.Languages is null) + { + missingFields.Add("Languages"); + } + if (input.LanguageSpecificSettings is null) + { + missingFields.Add("LanguageSpecificSettings"); + } + + if (missingFields.Count > 0) + { + return Request.CreateResponse(HttpStatusCode.BadRequest, $"Missing following parameters in json body: {string.Join(", ", missingFields)}"); + } + + string mainLanguage = new string(Settings.Current.General.Language.DefaultLanguage.Take(2).ToArray()); + + string databasePath = HttpContext.Current.Server.MapPath(PXWeb.Settings.Current.General.Paths.PxDatabasesPath); + string themeMapping = HttpContext.Current.Server.MapPath("~/Themes.json"); + string organizationMapping = HttpContext.Current.Server.MapPath("~/Organizations.json"); + string localThemeMapping = databasePath + input.Database + "/Themes.json"; + string localOrganizationMapping = databasePath + input.Database + "/Organizations.json"; + + if (File.Exists(localThemeMapping)) themeMapping = localThemeMapping; + if (File.Exists(localOrganizationMapping)) organizationMapping = localOrganizationMapping; + + Px.Dcat.DcatSettings settings = new Px.Dcat.DcatSettings() + { + BaseUri = input.BaseUri, + CatalogTitles = input.LanguageSpecificSettings.Select(x => new KeyValuePair(x.Language, x.CatalogTitle)).ToList(), + CatalogDescriptions = input.LanguageSpecificSettings.Select(x => new KeyValuePair(x.Language, x.CatalogDescription)).ToList(), + License = input.License, + BaseApiUrl = input.BaseApiUrl, + LandingPageUrl = input.LandingPageUrl, + PublisherName = input.Publisher, + Languages = input.Languages, + ThemeMapping = themeMapping, + OrganizationMapping = organizationMapping, + MainLanguage = mainLanguage + }; + if (databaseTypeLower == "cnmm") { + settings.DatabaseType = Px.Dcat.Helpers.DatabaseType.CNMM; + settings.DatabaseId = input.Database; + } + else if(databaseTypeLower == "px") + { + settings.DatabaseType = Px.Dcat.Helpers.DatabaseType.PX; + settings.DatabaseId = HttpContext.Current.Server.MapPath(PXWeb.Settings.Current.General.Paths.PxDatabasesPath) + input.Database + "/Menu.xml"; + } + else + { + return Request.CreateResponse(HttpStatusCode.BadRequest, $"Invalid database type: {input.DatabaseType}"); } + string savePath = HttpContext.Current.Server.MapPath(PXWeb.Settings.Current.General.Paths.PxDatabasesPath + input.Database + "/dcat-ap.xml"); + DcatWriter.WriteToFile(savePath, settings); + return Request.CreateResponse(HttpStatusCode.OK, "Xml-file created successfully"); } + } } \ No newline at end of file diff --git a/PXWeb/Code/BackgroundWorker/PxWebBackgroundWorker.cs b/PXWeb/Code/BackgroundWorker/PxWebBackgroundWorker.cs index b3376ef6c..cdf1727d2 100644 --- a/PXWeb/Code/BackgroundWorker/PxWebBackgroundWorker.cs +++ b/PXWeb/Code/BackgroundWorker/PxWebBackgroundWorker.cs @@ -8,7 +8,9 @@ using PCAxis.Paxiom; using PCAxis.Search; using PCAxis.Paxiom.Extensions; -using Px.Rdf; +using Px.Dcat.Interfaces; +using Px.Dcat; +using Px.Dcat.Helpers; namespace PXWeb.BackgroundWorker { @@ -309,53 +311,70 @@ private static void CreateDcatFile(string database) DcatStatusType startStatus = dcat.FileStatus; List languages = new List(); - string preferredLanguage = firstTwo(Settings.Current.General.Language.DefaultLanguage); foreach (LanguageSettings ls in Settings.Current.General.Language.SiteLanguages) { languages.Add(firstTwo(ls.Name)); } - string themeMapping = System.Web.Hosting.HostingEnvironment.MapPath("~/TMapping.json"); - string dbType = dcat.DatabaseType; + string themeMapping = System.Web.Hosting.HostingEnvironment.MapPath("~/Themes.json"); + string organizationMapping = System.Web.Hosting.HostingEnvironment.MapPath("~/Organizations.json"); + + Px.Dcat.Helpers.DatabaseType dbType = dcat.DatabaseType == "PX" ? Px.Dcat.Helpers.DatabaseType.PX : Px.Dcat.Helpers.DatabaseType.CNMM; + string dbid; - IFetcher fetcher; string databasepath = GetDatabasePath(); string savePath = databasepath + dcat.Database + "/dcat-ap.xml"; + + string localThemeMapping = databasepath + dcat.Database + "/Themes.json"; + string localOrganizationMapping = databasepath + dcat.Database + "/Organizations.json"; + + if (File.Exists(localThemeMapping)) themeMapping = localThemeMapping; + if (File.Exists(localOrganizationMapping)) organizationMapping = localOrganizationMapping; + switch (dbType) { - case "PX": + case DatabaseType.PX: dbid = databasepath + dcat.Database + "/Menu.xml"; - string localThemeMapping = databasepath + dcat.Database + "/TMapping.json"; - if (File.Exists(localThemeMapping)) themeMapping = localThemeMapping; - fetcher = new PXFetcher(databasepath); break; - case "CNMM": + case DatabaseType.CNMM: dbid = dcat.Database; - fetcher = new CNMMFetcher(); break; default: return; } - RdfSettings settings = new RdfSettings + List> titles = new List>(); + List> descriptions = new List>(); + + foreach (IDcatLanguageSpecificSettings s in dcat.LanguageSpecificSettings) + { + string lang = s.Language; + string title = s.CatalogTitle; + string desc = s.CatalogDescription; + titles.Add(new KeyValuePair(lang, title)); + descriptions.Add(new KeyValuePair(lang, desc)); + } + + string mainLanguage = new string(Settings.Current.General.Language.DefaultLanguage.Take(2).ToArray()); + var settings = new Px.Dcat.DcatSettings { BaseUri = dcat.BaseURI, BaseApiUrl = dcat.BaseApiUrl, - PreferredLanguage = preferredLanguage, - Languages = languages, - CatalogTitle = dcat.CatalogTitle, - CatalogDescription = dcat.CatalogDescription, + CatalogTitles = titles, + CatalogDescriptions = descriptions, PublisherName = dcat.Publisher, - DBid = dbid, - Fetcher = fetcher, + DatabaseId = dbid, + DatabaseType = dbType, LandingPageUrl = dcat.LandingPageUrl, License = dcat.License, - ThemeMapping = themeMapping + ThemeMapping = themeMapping, + OrganizationMapping = organizationMapping, + MainLanguage = mainLanguage }; try @@ -363,7 +382,7 @@ private static void CreateDcatFile(string database) dcat.FileStatus = DcatStatusType.Creating; db.Save(); - XML.WriteToFile(savePath, settings); + DcatWriter.WriteToFile(savePath, settings); _logger.Info("Dcat-file for the '" + database + "' database was created successfully"); dcat.FileStatus = DcatStatusType.Created; diff --git a/PXWeb/Code/Settings/DcatLanguageSpecificSettings.cs b/PXWeb/Code/Settings/DcatLanguageSpecificSettings.cs new file mode 100644 index 000000000..1b67e1e64 --- /dev/null +++ b/PXWeb/Code/Settings/DcatLanguageSpecificSettings.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Xml; + +namespace PXWeb +{ + internal class DcatLanguageSpecificSettings : IDcatLanguageSpecificSettings + { + #region "Private fields" + + #endregion + + #region "public methods" + + /// + /// Constructor + /// + /// XML-node for the Dcat settings + public DcatLanguageSpecificSettings(XmlNode node) + { + string xpath; + + xpath = "./Language"; + Language = SettingsHelper.GetSettingValue(xpath, node, ""); + + xpath = "./CatalogTitle"; + CatalogTitle = SettingsHelper.GetSettingValue(xpath, node, "Catalog title"); + + xpath = "./CatalogDescription"; + CatalogDescription = SettingsHelper.GetSettingValue(xpath, node, "Catalog description"); + + } + /// + /// Constructor + /// + public DcatLanguageSpecificSettings(string language, string catalogTitle, string catalogDescription) + { + Language = language; + CatalogTitle = catalogTitle; + CatalogDescription = catalogDescription; + } + + /// + /// Save Dcat settings to the settings file + /// + /// XML-node for the Dcat settings + public void Save(XmlNode node) + { + string xpath; + + xpath = "./Language"; + SettingsHelper.SetSettingValue(xpath, node, Language); + + xpath = "./CatalogTitle"; + SettingsHelper.SetSettingValue(xpath, node, CatalogTitle); + + xpath = "./CatalogDescription"; + SettingsHelper.SetSettingValue(xpath, node, CatalogDescription); + + } + + public string Language { get; set; } + public string CatalogTitle { get; set; } + public string CatalogDescription { get; set; } + #endregion + } +} \ No newline at end of file diff --git a/PXWeb/Code/Settings/DcatSettings.cs b/PXWeb/Code/Settings/DcatSettings.cs index 933f7c811..bd56c88a0 100644 --- a/PXWeb/Code/Settings/DcatSettings.cs +++ b/PXWeb/Code/Settings/DcatSettings.cs @@ -43,12 +43,6 @@ public DcatSettings(XmlNode node) xpath = "./LandingPageUrl"; LandingPageUrl = SettingsHelper.GetSettingValue(xpath, node, "https://baseLandingPage.com/"); - xpath = "./CatalogTitle"; - CatalogTitle = SettingsHelper.GetSettingValue(xpath, node, "Catalog title"); - - xpath = "./CatalogDescription"; - CatalogDescription = SettingsHelper.GetSettingValue(xpath, node, "Catalog description"); - xpath = "./Publisher"; Publisher = SettingsHelper.GetSettingValue(xpath, node, "SCB"); @@ -66,6 +60,15 @@ public DcatSettings(XmlNode node) xpath = "./FileUpdated"; FileUpdated = SettingsHelper.GetSettingValue(xpath, node, ""); + + xpath = "./LanguageSpecific"; + var languageSpecificSettings = new List(); + foreach (XmlNode languageNode in node.SelectNodes(xpath)) + { + DcatLanguageSpecificSettings nodeSettings = new DcatLanguageSpecificSettings(languageNode); + languageSpecificSettings.Add(nodeSettings); + } + LanguageSpecificSettings = languageSpecificSettings; } /// @@ -85,12 +88,6 @@ public void Save(XmlNode node) xpath = "./LandingPageUrl"; SettingsHelper.SetSettingValue(xpath, node, LandingPageUrl); - xpath = "./CatalogTitle"; - SettingsHelper.SetSettingValue(xpath, node, CatalogTitle); - - xpath = "./CatalogDescription"; - SettingsHelper.SetSettingValue(xpath, node, CatalogDescription); - xpath = "./Publisher"; SettingsHelper.SetSettingValue(xpath, node, Publisher); @@ -108,19 +105,31 @@ public void Save(XmlNode node) xpath = "./FileUpdated"; SettingsHelper.SetSettingValue(xpath, node, FileUpdated); + + xpath = "./LanguageSpecific"; + var nodes = node.SelectNodes(xpath); + + // Remove all current nodes + foreach (XmlNode n in nodes) n.ParentNode.RemoveChild(n); + + foreach (DcatLanguageSpecificSettings s in LanguageSpecificSettings) + { + var newNode = node.OwnerDocument.CreateNode(XmlNodeType.Element, "LanguageSpecific", ""); + s.Save(newNode); + node.AppendChild(newNode); + } } public string BaseURI { get; set; } public string BaseApiUrl { get; set; } public string LandingPageUrl { get; set; } public string Publisher { get; set; } - public string CatalogTitle { get; set; } - public string CatalogDescription { get; set; } public string Database { get; set; } public string DatabaseType { get; set; } public string License { get; set; } public DcatStatusType FileStatus { get; set; } public string FileUpdated { get; set; } + public IEnumerable LanguageSpecificSettings { get; set; } #endregion } } diff --git a/PXWeb/Code/Settings/Interfaces/IDcatLanguageSpecificSettings.cs b/PXWeb/Code/Settings/Interfaces/IDcatLanguageSpecificSettings.cs new file mode 100644 index 000000000..90d43bb10 --- /dev/null +++ b/PXWeb/Code/Settings/Interfaces/IDcatLanguageSpecificSettings.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PXWeb +{ + public interface IDcatLanguageSpecificSettings + { + /// + /// Language for these settings + /// + string Language { get; } + + /// + /// Title of the catalog + /// + string CatalogTitle { get; } + + /// + /// Description of the catalog + /// + string CatalogDescription { get; } + + } +} diff --git a/PXWeb/Code/Settings/Interfaces/IDcatSettings.cs b/PXWeb/Code/Settings/Interfaces/IDcatSettings.cs index 54427844b..e285bddc0 100644 --- a/PXWeb/Code/Settings/Interfaces/IDcatSettings.cs +++ b/PXWeb/Code/Settings/Interfaces/IDcatSettings.cs @@ -27,14 +27,9 @@ public interface IDcatSettings string LandingPageUrl { get; } /// - /// Title of the catalog + /// Settings that are different for each language /// - string CatalogTitle { get; } - - /// - /// Description of the catalog - /// - string CatalogDescription { get; } + IEnumerable LanguageSpecificSettings { get; } /// /// Publisher of the catalog diff --git a/PXWeb/Organizations.json b/PXWeb/Organizations.json new file mode 100644 index 000000000..1389e2939 --- /dev/null +++ b/PXWeb/Organizations.json @@ -0,0 +1,3 @@ +{ +"Statistics Sweden": "http://id.kb.se/organisations/SE2021000837" +} diff --git a/PXWeb/PXWeb.csproj b/PXWeb/PXWeb.csproj index d367e0a3e..e561619e9 100644 --- a/PXWeb/PXWeb.csproj +++ b/PXWeb/PXWeb.csproj @@ -111,7 +111,7 @@ ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - ..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll ..\packages\Ninject.3.3.4\lib\net45\Ninject.dll @@ -155,8 +155,8 @@ ..\packages\PcAxis.Sql.1.2.1\lib\netstandard2.0\PCAxis.Sql.dll - - ..\packages\Px.Rdf.1.0.3\lib\netstandard2.0\Px.Rdf.dll + + ..\packages\Px.Dcat.2.0.0\lib\netstandard2.0\Px.Dcat.dll ..\packages\PXWeb.SavedQuery.MsSql.1.0.3\lib\netstandard2.0\PXWeb.SavedQuery.MsSql.dll @@ -724,6 +724,7 @@ + @@ -773,6 +774,7 @@ + diff --git a/PXWeb/Resources/Styles/Admin.css b/PXWeb/Resources/Styles/Admin.css index b2659b269..2654d8bfd 100644 --- a/PXWeb/Resources/Styles/Admin.css +++ b/PXWeb/Resources/Styles/Admin.css @@ -456,3 +456,28 @@ input.colorTextField { word-break: break-all; word-break: break-word; } + +.dcatLanguageSpecific { + width: 100%; + display: inline-block; + font-weight: bold; + padding: 2px 0; +} + +.dcatCatalogTitle { + width: 100%; + display: inline-block; + padding: 2px 0; +} + +.dcatCatalogDesc { + width: 100%; + display: inline-block; + padding: 2px 0; +} + +.dcatGenerateBtn { + display: inline-block; + margin-top: 20px; + margin-left: 200px; +} \ No newline at end of file diff --git a/PXWeb/TMapping.json b/PXWeb/Themes.json similarity index 100% rename from PXWeb/TMapping.json rename to PXWeb/Themes.json diff --git a/PXWeb/packages.config b/PXWeb/packages.config index fa0484d3d..a891cbd68 100644 --- a/PXWeb/packages.config +++ b/PXWeb/packages.config @@ -24,7 +24,7 @@ - + @@ -39,7 +39,7 @@ - +