public SimpleMetadataViewModel GetMetadataModel(string uuid) { SimpleMetadata metadata = new SimpleMetadata(_geoNorge.GetRecordByUuid(uuid)); var model = new SimpleMetadataViewModel() { Uuid = metadata.Uuid, Title = metadata.Title, HierarchyLevel = metadata.HierarchyLevel, ParentIdentifier = metadata.ParentIdentifier, MetadataStandard = metadata.MetadataStandard, Abstract = metadata.Abstract != null?metadata.Abstract.Replace("...", "") : "", ContactMetadata = new Contact(metadata.ContactMetadata, "pointOfContact"), ContactPublisher = new Contact(metadata.ContactPublisher, "publisher"), ContactOwner = new Contact(metadata.ContactOwner, "owner"), SupplementalDescription = metadata.SupplementalDescription, SpecificUsage = metadata.SpecificUsage, ProcessHistory = metadata.ProcessHistory, ProductPageUrl = metadata.ProductPageUrl, DistributionUrl = metadata.DistributionDetails != null ? metadata.DistributionDetails.URL : null, DistributionProtocol = metadata.DistributionDetails != null ? metadata.DistributionDetails.Protocol : null, MaintenanceFrequency = metadata.MaintenanceFrequency, DateUpdated = metadata.DateUpdated, DateMetadataUpdated = metadata.DateMetadataUpdated, KeywordsPlace = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, SimpleKeyword.TYPE_PLACE, null)), KeywordsNationalInitiative = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, null, SimpleKeyword.THESAURUS_NATIONAL_INITIATIVE)), KeywordsNationalTheme = CreateListOfKeywords(SimpleKeyword.Filter(metadata.Keywords, null, SimpleKeyword.THESAURUS_NATIONAL_THEME)), KeywordsEnglish = CreateDictionaryOfEnglishKeywords(metadata.Keywords), UseConstraints = metadata.Constraints != null ? metadata.Constraints.UseConstraints : null, OtherConstraintsLink = metadata.Constraints != null ? metadata.Constraints.OtherConstraintsLink : null, OtherConstraintsLinkText = metadata.Constraints != null ? metadata.Constraints.OtherConstraintsLinkText : null, OtherConstraintsAccess = metadata.Constraints != null ? metadata.Constraints.OtherConstraintsAccess : null, EnglishTitle = metadata.EnglishTitle, EnglishAbstract = metadata.EnglishAbstract, EnglishContactMetadataOrganization = metadata.ContactMetadata != null ? metadata.ContactMetadata.OrganizationEnglish : null, EnglishContactPublisherOrganization = metadata.ContactPublisher != null ? metadata.ContactPublisher.OrganizationEnglish : null, EnglishContactOwnerOrganization = metadata.ContactOwner != null ? metadata.ContactOwner.OrganizationEnglish : null }; if (metadata.BoundingBox != null) { model.BoundingBoxEast = ConvertCoordinateWithCommaToPoint(metadata.BoundingBox.EastBoundLongitude); model.BoundingBoxWest = ConvertCoordinateWithCommaToPoint(metadata.BoundingBox.WestBoundLongitude); model.BoundingBoxNorth = ConvertCoordinateWithCommaToPoint(metadata.BoundingBox.NorthBoundLatitude); model.BoundingBoxSouth = ConvertCoordinateWithCommaToPoint(metadata.BoundingBox.SouthBoundLatitude); } // Translations model.TitleFromSelectedLanguage = model.TitleTranslated(); return(model); }
static void Main(string[] args) { Console.Title = "GatewayHost"; ShieldingCloseButton(); SetConsoleCtrlHandler(cancelHandler, true); Console.WriteLine(DateTime.Now.ToString() + " Starting the server ..."); GatewayName = System.Configuration.ConfigurationManager.AppSettings["GatewayName"]; Console.Title = "GatewayHost - " + GatewayName; Console.WriteLine(DateTime.Now.ToString() + " Loading the keyword ..."); IKeywordLoad kl = new KeywordLoad(GatewayName); Keyword keyword = new Keyword(kl); processKeyword = new SimpleKeyword(keyword); Console.WriteLine(DateTime.Now.ToString() + " Loading the keyword ok."); Console.WriteLine(DateTime.Now.ToString() + " Initialize the server ..."); string gatewayType = System.Configuration.ConfigurationManager.AppSettings["GatewayType"]; if (gatewayType.ToLower() == "http") //普通http接口 { Gateway = new HttpGateway(GatewayName); } else if (gatewayType.ToLower() == "httppush") //推送状态报告和上行 { Gateway = new HttpPushGateway(GatewayName); } else if (gatewayType.ToLower() == "httpsdl") //四大类 { Gateway = new HttpSDLGateway(GatewayName); } Gateway.SMSEvent += Gateway_SMSEvent; Gateway.SendEvent += Gateway_SendEvent; Gateway.ReportEvent += Gateway_ReportEvent; Gateway.DeliverEvent += Gateway_DeliverEvent; Gateway.Connect(); Thread.Sleep(1000); frSMS = new RabbitMQHelper(AppConfig.MQHost, AppConfig.MQVHost, AppConfig.MQUserName, AppConfig.MQPassword); frSMS.OnSubsribeMessageRecieve += frSMS_ReceiveMessage; frSMS.SubsribeMessage(GatewayName, AppConfig.MaxPriority); Console.WriteLine(DateTime.Now.ToString() + " Initialize the server ok."); Console.WriteLine(DateTime.Now.ToString() + " Started the server ok."); Console.WriteLine(); Console.WriteLine("Press input 'quit' to stop it!"); do { } while (Console.ReadLine() != "quit"); frSMS.Close(); Gateway.Close(); Console.WriteLine("The server was stopped,press any key to exit!"); Console.ReadKey(); Environment.Exit(0); }
private List <SimpleKeyword> CreateListOfKeywords(string[] selectedKeywords) { List <SimpleKeyword> keywords = new List <SimpleKeyword>(); if (selectedKeywords != null) { foreach (var keyword in selectedKeywords) { SimpleKeyword simpleKeyword = null; if (keyword.StartsWith("Theme_")) { simpleKeyword = new SimpleKeyword { Keyword = stripPrefixFromKeyword(keyword), Type = SimpleKeyword.TYPE_THEME }; } else if (keyword.StartsWith("Place_")) { simpleKeyword = new SimpleKeyword { Keyword = stripPrefixFromKeyword(keyword), Type = SimpleKeyword.TYPE_PLACE }; } else if (keyword.StartsWith("Concept_")) { simpleKeyword = new SimpleKeyword { Keyword = stripPrefixFromKeyword(keyword), Type = SimpleKeyword.THESAURUS_CONCEPT }; } else if (keyword.StartsWith("NationalInitiative_")) { simpleKeyword = new SimpleKeyword { Keyword = stripPrefixFromKeyword(keyword), Thesaurus = SimpleKeyword.THESAURUS_NATIONAL_INITIATIVE }; } else if (keyword.StartsWith("Inspire_")) { simpleKeyword = new SimpleKeyword { Keyword = stripPrefixFromKeyword(keyword), Thesaurus = SimpleKeyword.THESAURUS_GEMET_INSPIRE_V1 }; } else if (keyword.StartsWith("Other_")) { simpleKeyword = new SimpleKeyword { Keyword = stripPrefixFromKeyword(keyword) }; } if (simpleKeyword != null) { keywords.Add(simpleKeyword); } } } return(keywords); }
private string ResolveThemeFromInspireKeywords(SimpleMetadata metadata) { var inspireKeywords = SimpleKeyword.Filter(metadata.Keywords, null, SimpleKeyword.THESAURUS_GEMET_INSPIRE_V1); if (inspireKeywords != null && inspireKeywords.Any()) { foreach (var simpleKeyword in inspireKeywords) { string lowerCaseKeyword = simpleKeyword.Keyword.ToLower(); string theme; if (_inspireKeywordToTheme.TryGetValue(lowerCaseKeyword, out theme)) { if (!string.IsNullOrWhiteSpace(theme)) { return(theme); } } } } return(null); }
private string ResolveThemeFromDokKeywords(SimpleMetadata metadata, string culture) { List <SimpleKeyword> keywordsDok = SimpleKeyword.Filter(metadata.Keywords, null, SimpleKeyword.THESAURUS_NATIONAL_THEME); foreach (var keyword in keywordsDok) { //string lowerCaseKeyword = keyword.Keyword.ToLower(); //string theme; //if (_dokCategoryToTheme.TryGetValue(lowerCaseKeyword, out theme)) //{ //return theme; //} if (culture == Culture.EnglishCode && !string.IsNullOrEmpty(keyword.EnglishKeyword)) { return(keyword.EnglishKeyword); } else { return(keyword.Keyword); } } return(null); }
public ProductSheet UpdateProductSheetFromMetadata(string uuid, ProductSheet productSheet) { register = new RegisterFetcher(); MD_Metadata_Type metadata = _geonorge.GetRecordByUuid(uuid); if (metadata == null) { throw new InvalidOperationException("Metadata not found for uuid: " + uuid); } var simpleMetadata = new SimpleMetadata(metadata); dynamic metedataExtended = register.GetMetadataExtended(simpleMetadata.Uuid); productSheet.Uuid = simpleMetadata.Uuid; productSheet.Title = simpleMetadata.Title; productSheet.Description = simpleMetadata.Abstract; productSheet.SupplementalDescription = simpleMetadata.SupplementalDescription; productSheet.Purpose = simpleMetadata.Purpose; productSheet.SpecificUsage = simpleMetadata.SpecificUsage; productSheet.UseLimitations = simpleMetadata.Constraints != null ? simpleMetadata.Constraints.UseLimitations : null; productSheet.UseConstraintsLicenseLink = simpleMetadata.Constraints != null ? simpleMetadata.Constraints.UseConstraintsLicenseLink : null; productSheet.UseConstraintsLicenseLinkText = simpleMetadata.Constraints != null ? simpleMetadata.Constraints.UseConstraintsLicenseLinkText : null; productSheet.ContactMetadata = simpleMetadata.ContactMetadata != null?CreateContact(simpleMetadata.ContactMetadata) : new Contact(); productSheet.ContactPublisher = simpleMetadata.ContactPublisher != null?CreateContact(simpleMetadata.ContactPublisher) : new Contact(); productSheet.ContactOwner = simpleMetadata.ContactOwner != null?CreateContact(simpleMetadata.ContactOwner) : new Contact(); productSheet.ResolutionScale = simpleMetadata.ResolutionScale; productSheet.KeywordsPlace = CreateKeywords(SimpleKeyword.Filter(simpleMetadata.Keywords, SimpleKeyword.TYPE_PLACE, null)); productSheet.ProcessHistory = simpleMetadata.ProcessHistory; productSheet.MaintenanceFrequency = simpleMetadata.MaintenanceFrequency; productSheet.Status = simpleMetadata.Status; productSheet.DistributionFormatName = simpleMetadata.DistributionFormat != null ? simpleMetadata.DistributionFormat.Name : null; productSheet.DistributionFormatVersion = simpleMetadata.DistributionFormat != null ? simpleMetadata.DistributionFormat.Version : null; productSheet.DistributionFormats = GetDistributionFormats(simpleMetadata.DistributionFormats); productSheet.AccessConstraints = simpleMetadata.Constraints != null?register.GetRestriction(simpleMetadata.Constraints.AccessConstraints, simpleMetadata.Constraints.OtherConstraintsAccess) : null; productSheet.LegendDescriptionUrl = simpleMetadata.LegendDescriptionUrl; productSheet.ProductPageUrl = simpleMetadata.ProductPageUrl; productSheet.ProductSpecificationUrl = simpleMetadata.ProductSpecificationUrl; foreach (var thumbnail in simpleMetadata.Thumbnails) { productSheet.Thumbnail = thumbnail.URL; if (!thumbnail.URL.StartsWith("http")) { productSheet.Thumbnail = "https://www.geonorge.no/geonetwork/srv/nor/resources.get?uuid=" + simpleMetadata.Uuid + "&access=public&fname=" + thumbnail.URL; } if (thumbnail.Type == "large_thumbnail") { break; } } //productSheet.CoverageArea = !string.IsNullOrWhiteSpace(simpleMetadata.CoverageUrl) ? GetCoverageLink(simpleMetadata.CoverageUrl, uuid) : ""; productSheet.CoverageArea = metedataExtended.CoverageUrl; productSheet.Projections = simpleMetadata.ReferenceSystems != null?getProjections(simpleMetadata.ReferenceSystems) : ""; return(productSheet); }
private void SetFAIR(ref MareanoDataset mareanoDataset) { mareanoDataset.I1_c_Criteria = null; mareanoDataset.I3_a_Criteria = null; mareanoDataset.I3_b_Criteria = null; int findableWeight = 0; if (_metadata?.SimpleMetadata == null) { return; } mareanoDataset.F2_a_Criteria = SimpleKeyword.Filter(_metadata.SimpleMetadata.Keywords, SimpleKeyword.TYPE_THEME, null).ToList().Count() >= 3; mareanoDataset.F2_b_Criteria = _metadata.SimpleMetadata.Title.Count() <= 100; mareanoDataset.F2_c_Criteria = _metadata.SimpleMetadata.Abstract?.Count() >= 200 && _metadata.SimpleMetadata.Abstract?.Count() <= 600; mareanoDataset.F3_a_Criteria = _metadata.SimpleMetadata.ResourceReference != null ?_metadata.SimpleMetadata.ResourceReference?.Code != null && _metadata.SimpleMetadata.ResourceReference?.Codespace != null : false; if (mareanoDataset.F1_a_Criteria) { findableWeight += 25; } if (mareanoDataset.F2_a_Criteria) { findableWeight += 10; } if (mareanoDataset.F2_b_Criteria) { findableWeight += 5; } if (mareanoDataset.F2_c_Criteria) { findableWeight += 10; } if (mareanoDataset.F3_a_Criteria) { findableWeight += 25; } if (mareanoDataset.F4_a_Criteria) { findableWeight += 25; } mareanoDataset.FindableStatusPerCent = findableWeight; mareanoDataset.FindableStatusId = CreateFairDelivery(findableWeight); int accesibleWeight = 0; mareanoDataset.A1_a_Criteria = CheckWfs(mareanoDataset.Uuid, mareanoDataset.WfsStatus); mareanoDataset.A1_b_Criteria = CheckWms(mareanoDataset.Uuid, mareanoDataset.WmsStatus); mareanoDataset.A1_c_Criteria = _metadata.SimpleMetadata?.DistributionsFormats != null?_metadata.SimpleMetadata.DistributionsFormats.Where(p => !string.IsNullOrEmpty(p.Protocol) && p.Protocol.Contains("GEONORGE:DOWNLOAD")).Any() : false; mareanoDataset.A1_d_Criteria = mareanoDataset.AtomFeedStatus != null?mareanoDataset.AtomFeedStatus.IsGood() : false; mareanoDataset.A1_e_Criteria = CheckDistributionUrl(mareanoDataset.Uuid, _metadata.SimpleMetadata.DistributionsFormats.Where(f => !string.IsNullOrEmpty(f.Protocol) && f.Protocol.Contains("GEONORGE:DOWNLOAD") || !string.IsNullOrEmpty(f.Protocol) && f.Protocol.Contains("WWW:DOWNLOAD") || !string.IsNullOrEmpty(f.Protocol) && f.Protocol.Contains("GEONORGE:FILEDOWNLOAD"))); mareanoDataset.A1_f_Criteria = true; if (mareanoDataset.A1_a_Criteria) { accesibleWeight += 15; } if (mareanoDataset.A1_b_Criteria) { accesibleWeight += 15; } if (mareanoDataset.A1_c_Criteria) { accesibleWeight += 15; } if (mareanoDataset.A1_d_Criteria) { accesibleWeight += 5; } if (mareanoDataset.A1_e_Criteria) { accesibleWeight += 40; } if (mareanoDataset.A1_f_Criteria) { accesibleWeight += 10; } if (mareanoDataset.A2_a_Criteria) { accesibleWeight += 0; } mareanoDataset.AccesibleStatusPerCent = accesibleWeight; mareanoDataset.AccesibleStatusId = CreateFairDelivery(accesibleWeight); int interoperableWeight = 0; var spatialRepresentation = _metadata.SimpleMetadata.SpatialRepresentation; if (spatialRepresentation == "vector") { mareanoDataset.I1_b_Criteria = _metadata.SimpleMetadata.DistributionsFormats.Where(p => p.FormatName == "GML").Any(); } else if (spatialRepresentation == "grid") { mareanoDataset.I1_b_Criteria = _metadata.SimpleMetadata.DistributionsFormats.Where(p => p.FormatName == "GeoTIFF" || p.FormatName == "TIFF" || p.FormatName == "JPEG" || p.FormatName == "JPEG2000").Any(); } if (spatialRepresentation != "grid") { mareanoDataset.I1_c_Criteria = _metadata.SimpleMetadata.QualitySpecifications != null && _metadata.SimpleMetadata.QualitySpecifications.Count > 0 ? _metadata.SimpleMetadata.QualitySpecifications.Where(r => !string.IsNullOrEmpty(r.Explanation) && r.Explanation.StartsWith("GML-filer er i henhold")).Any() : false; } mareanoDataset.I2_a_Criteria = !string.IsNullOrEmpty(_metadata.SimpleMetadata.TopicCategory); mareanoDataset.I2_b_Criteria = SimpleKeyword.Filter(_metadata.SimpleMetadata.Keywords, null, SimpleKeyword.THESAURUS_NATIONAL_THEME).ToList().Count() >= 1; if (spatialRepresentation != "grid") { mareanoDataset.I3_a_Criteria = SimpleKeyword.Filter(_metadata.SimpleMetadata.Keywords, null, SimpleKeyword.THESAURUS_CONCEPT).ToList().Count() >= 1; mareanoDataset.I3_b_Criteria = !string.IsNullOrEmpty(_metadata.SimpleMetadata.ApplicationSchema); } if (mareanoDataset.I1_a_Criteria) { interoperableWeight += 20; } if (mareanoDataset.I1_b_Criteria) { interoperableWeight += 10; } if (!mareanoDataset.I1_c_Criteria.HasValue || (mareanoDataset.I1_c_Criteria.HasValue && mareanoDataset.I1_c_Criteria.Value)) { interoperableWeight += 20; } if (mareanoDataset.I2_a_Criteria) { interoperableWeight += 10; } if (mareanoDataset.I2_b_Criteria) { interoperableWeight += 10; } if (!mareanoDataset.I3_a_Criteria.HasValue || (mareanoDataset.I3_a_Criteria.HasValue && mareanoDataset.I3_a_Criteria.Value)) { interoperableWeight += 10; } if (!mareanoDataset.I3_b_Criteria.HasValue || (mareanoDataset.I3_b_Criteria.HasValue && mareanoDataset.I3_b_Criteria.Value)) { interoperableWeight += 20; } mareanoDataset.InteroperableStatusPerCent = interoperableWeight; mareanoDataset.InteroperableStatusId = CreateFairDelivery(interoperableWeight); int reusableWeight = 0; mareanoDataset.R1_a_Criteria = !string.IsNullOrEmpty(_metadata.SimpleMetadata.Constraints?.UseConstraintsLicenseLink); mareanoDataset.R2_a_Criteria = _metadata.SimpleMetadata?.ProcessHistory.Count() > 200; mareanoDataset.R2_b_Criteria = !string.IsNullOrEmpty(_metadata.SimpleMetadata?.MaintenanceFrequency); mareanoDataset.R2_c_Criteria = !string.IsNullOrEmpty(_metadata.SimpleMetadata?.ProductSpecificationUrl); mareanoDataset.R2_d_Criteria = !string.IsNullOrEmpty(_metadata.SimpleMetadata?.ResolutionScale); mareanoDataset.R2_e_Criteria = !string.IsNullOrEmpty(_metadata.SimpleMetadata?.CoverageUrl) || !string.IsNullOrEmpty(_metadata.SimpleMetadata?.CoverageGridUrl) || !string.IsNullOrEmpty(_metadata.SimpleMetadata?.CoverageCellUrl); mareanoDataset.R2_f_Criteria = !string.IsNullOrEmpty(_metadata.SimpleMetadata?.Purpose); mareanoDataset.R3_b_Criteria = _metadata.SimpleMetadata.DistributionsFormats.Where(p => p.FormatName == "GML" || p.FormatName == "GeoTIFF" || p.FormatName == "TIFF" || p.FormatName == "JPEG" || p.FormatName == "JPEG2000" || p.FormatName == "NetCDF" || p.FormatName == "NetCDF-CF").Any(); if (mareanoDataset.R1_a_Criteria) { reusableWeight += 30; } if (mareanoDataset.R2_a_Criteria) { reusableWeight += 10; } if (mareanoDataset.R2_b_Criteria) { reusableWeight += 5; } if (mareanoDataset.R2_c_Criteria) { reusableWeight += 10; } if (mareanoDataset.R2_d_Criteria) { reusableWeight += 5; } if (mareanoDataset.R2_e_Criteria) { reusableWeight += 5; } if (mareanoDataset.R2_f_Criteria) { reusableWeight += 5; } if (mareanoDataset.R3_a_Criteria) { reusableWeight += 15; } if (mareanoDataset.R3_b_Criteria) { reusableWeight += 15; } mareanoDataset.ReUseableStatusPerCent = reusableWeight; mareanoDataset.ReUseableStatusId = CreateFairDelivery(reusableWeight); int fairWeight = (findableWeight + accesibleWeight + interoperableWeight + reusableWeight) / 4; mareanoDataset.FAIRStatusPerCent = fairWeight; mareanoDataset.FAIRStatusId = CreateFairDelivery(fairWeight); }
public Keyword(SimpleKeyword simple) { Value = simple.Keyword; Thesaurus = simple.Thesaurus; Type = simple.Type; }
private void CreateDatasets(XmlElement root, XmlElement catalog) { Dictionary <string, XmlNode> foafAgents = new Dictionary <string, XmlNode>(); Dictionary <string, XmlNode> vcardKinds = new Dictionary <string, XmlNode>(); Dictionary <string, XmlNode> services = new Dictionary <string, XmlNode>(); for (int d = 0; d < metadataSets.Items.Length; d++) { string uuid = ((www.opengis.net.DCMIRecordType)(metadataSets.Items[d])).Items[0].Text[0]; MD_Metadata_Type md = geoNorge.GetRecordByUuid(uuid); var data = new SimpleMetadata(md); if (data.DistributionFormats != null && data.DistributionFormats.Count > 0 && !string.IsNullOrEmpty(data.DistributionFormats[0].Name) && data.DistributionDetails != null && !string.IsNullOrEmpty(data.DistributionDetails.Protocol)) { Log.Info($"Processing dataset: [title={data.Title}], [uuid={uuid}]"); //Map dataset to catalog XmlElement catalogDataset = doc.CreateElement("dcat", "dataset", xmlnsDcat); catalogDataset.SetAttribute("resource", xmlnsRdf, kartkatalogenUrl + "Metadata/uuid/" + data.Uuid); catalog.AppendChild(catalogDataset); XmlElement dataset = doc.CreateElement("dcat", "Dataset", xmlnsDcat); dataset.SetAttribute("about", xmlnsRdf, kartkatalogenUrl + "Metadata/uuid/" + data.Uuid); root.AppendChild(dataset); XmlElement datasetIdentifier = doc.CreateElement("dct", "identifier", xmlnsDct); datasetIdentifier.InnerText = data.Uuid.ToString(); dataset.AppendChild(datasetIdentifier); XmlElement datasetTitle = doc.CreateElement("dct", "title", xmlnsDct); datasetTitle.SetAttribute("xml:lang", "no"); datasetTitle.InnerText = data.Title; dataset.AppendChild(datasetTitle); XmlElement datasetDescription = doc.CreateElement("dct", "description", xmlnsDct); datasetDescription.SetAttribute("xml:lang", "no"); if (!string.IsNullOrEmpty(data.Abstract)) { datasetDescription.InnerText = data.Abstract; } dataset.AppendChild(datasetDescription); foreach (var keyword in data.Keywords) { XmlElement datasetKeyword = doc.CreateElement("dcat", "keyword", xmlnsDcat); datasetKeyword.SetAttribute("xml:lang", "no"); datasetKeyword.InnerText = keyword.Keyword; dataset.AppendChild(datasetKeyword); } //Place // URI for the geographic identifier var places = SimpleKeyword.Filter(data.Keywords, null, SimpleKeyword.THESAURUS_ADMIN_UNITS); foreach (var place in places) { var aboutPlace = place.KeywordLink; if (!string.IsNullOrEmpty(aboutPlace)) { XmlElement datasetLocation = doc.CreateElement("dct", "spatial", xmlnsDct); datasetLocation.InnerText = aboutPlace; dataset.AppendChild(datasetLocation); } } //Resource metadata in GeoDCAT - AP using a geographic bounding box if (data.BoundingBox != null) { XmlElement datasetSpatial = doc.CreateElement("dct", "spatial", xmlnsDct); datasetSpatial.SetAttribute("rdf:parseType", "Resource"); XmlElement spatialLocn = doc.CreateElement("locn", "geometry", xmlnsLocn); spatialLocn.SetAttribute("rdf:datatype", "http://www.opengis.net/ont/geosparql#gmlLiteral"); var cdata = doc.CreateCDataSection("<gml:Envelope srsName=\"http://www.opengis.net/def/crs/OGC/1.3/CRS84\"><gml:lowerCorner>" + data.BoundingBox.WestBoundLongitude + " " + data.BoundingBox.SouthBoundLatitude + "</gml:lowerCorner><gml:upperCorner>" + data.BoundingBox.EastBoundLongitude + " " + data.BoundingBox.NorthBoundLatitude + "</gml:upperCorner></gml:Envelope>"); spatialLocn.AppendChild(cdata); datasetSpatial.AppendChild(spatialLocn); dataset.AppendChild(datasetSpatial); } List <string> themes = new List <string>(); string euLink = "http://publications.europa.eu/resource/authority/data-theme/"; //National theme var nationalThemes = SimpleKeyword.Filter(data.Keywords, null, SimpleKeyword.THESAURUS_NATIONAL_THEME); foreach (var theme in nationalThemes) { var aboutConcept = GetConcept(theme.Keyword); if (!string.IsNullOrEmpty(aboutConcept)) { themes.Add(aboutConcept); } if (Mappings.ThemeNationalToEU.ContainsKey(theme.Keyword)) { themes.Add(euLink + Mappings.ThemeNationalToEU[theme.Keyword]); } } //Inspire thene var themeInspires = SimpleKeyword.Filter(data.Keywords, null, SimpleKeyword.THESAURUS_GEMET_INSPIRE_V1); foreach (var themeInspire in themeInspires) { if (Mappings.ThemeInspireToEU.ContainsKey(themeInspire.Keyword)) { if (!themes.Contains(euLink + Mappings.ThemeInspireToEU[themeInspire.Keyword])) { themes.Add(euLink + Mappings.ThemeInspireToEU[themeInspire.Keyword]); } } } //Concepts var conceptThemes = SimpleKeyword.Filter(data.Keywords, null, SimpleKeyword.THESAURUS_CONCEPT); foreach (var theme in conceptThemes) { var aboutConcept = theme.KeywordLink; if (!string.IsNullOrEmpty(aboutConcept)) { if (!ConceptObjects.ContainsKey(aboutConcept)) { ConceptObjects.Add(aboutConcept, aboutConcept); themes.Add(aboutConcept); } } } foreach (var theme in themes) { XmlElement datasetTheme; if (theme.Contains("objektkatalog.geonorge.no")) { datasetTheme = doc.CreateElement("dct", "subject", xmlnsDct); } else { datasetTheme = doc.CreateElement("dcat", "theme", xmlnsDcat); } datasetTheme.SetAttribute("resource", xmlnsRdf, theme); dataset.AppendChild(datasetTheme); } if (data.Thumbnails != null && data.Thumbnails.Count > 0) { XmlElement datasetThumbnail = doc.CreateElement("foaf", "thumbnail", xmlnsFoaf); datasetThumbnail.SetAttribute("resource", xmlnsRdf, EncodeUrl(data.Thumbnails[0].URL)); dataset.AppendChild(datasetThumbnail); } XmlElement datasetUpdated = doc.CreateElement("dct", "updated", xmlnsDct); datasetUpdated.SetAttribute("datatype", xmlnsRdf, "http://www.w3.org/2001/XMLSchema#date"); if (data.DateUpdated.HasValue) { datasetUpdated.InnerText = data.DateUpdated.Value.ToString("yyyy-MM-dd"); if (!catalogLastModified.HasValue || data.DateUpdated > catalogLastModified) { catalogLastModified = data.DateUpdated; } } dataset.AppendChild(datasetUpdated); XmlElement datasetPublisher = doc.CreateElement("dct", "publisher", xmlnsDct); if (data.ContactOwner != null && !string.IsNullOrEmpty(data.ContactOwner.Organization) && OrganizationsLink.ContainsKey(data.ContactOwner.Organization) && OrganizationsLink[data.ContactOwner.Organization] != null) { datasetPublisher.SetAttribute("resource", xmlnsRdf, OrganizationsLink[data.ContactOwner.Organization]); } dataset.AppendChild(datasetPublisher); Organization organization = null; if (data.ContactOwner != null) { Log.Info("Looking up organization: " + data.ContactOwner.Organization); Task <Organization> getOrganizationTask = _organizationService.GetOrganizationByName(data.ContactOwner.Organization); organization = getOrganizationTask.Result; } XmlElement datasetContactPoint = doc.CreateElement("dcat", "contactPoint", xmlnsDcat); if (data.ContactOwner != null && !string.IsNullOrEmpty(data.ContactOwner.Organization) && OrganizationsLink.ContainsKey(data.ContactOwner.Organization) && OrganizationsLink[data.ContactOwner.Organization] != null) { datasetContactPoint.SetAttribute("resource", xmlnsRdf, OrganizationsLink[data.ContactOwner.Organization].Replace("organisasjoner/kartverket/", "organisasjoner/")); } dataset.AppendChild(datasetContactPoint); XmlElement datasetKind = doc.CreateElement("vcard", "Organization", xmlnsVcard); if (data.ContactOwner != null && !string.IsNullOrEmpty(data.ContactOwner.Organization) && OrganizationsLink.ContainsKey(data.ContactOwner.Organization) && OrganizationsLink[data.ContactOwner.Organization] != null) { datasetKind.SetAttribute("about", xmlnsRdf, OrganizationsLink[data.ContactOwner.Organization].Replace("organisasjoner/kartverket/", "organisasjoner/")); } XmlElement datasetOrganizationName = doc.CreateElement("vcard", "organization-unit", xmlnsVcard); datasetOrganizationName.SetAttribute("xml:lang", ""); if (organization != null) { datasetOrganizationName.InnerText = organization.Name; } datasetKind.AppendChild(datasetOrganizationName); if (data.ContactOwner != null && !string.IsNullOrEmpty(data.ContactOwner.Email)) { XmlElement datasetHasEmail = doc.CreateElement("vcard", "hasEmail", xmlnsVcard); datasetHasEmail.SetAttribute("resource", xmlnsRdf, "mailto:" + data.ContactOwner.Email); datasetKind.AppendChild(datasetHasEmail); } if (data.ContactOwner != null && !string.IsNullOrEmpty(data.ContactOwner.Organization) && OrganizationsLink.ContainsKey(data.ContactOwner.Organization) && OrganizationsLink[data.ContactOwner.Organization] != null) { if (!vcardKinds.ContainsKey(OrganizationsLink[data.ContactOwner.Organization].Replace("organisasjoner/kartverket/", "organisasjoner/"))) { vcardKinds.Add(OrganizationsLink[data.ContactOwner.Organization].Replace("organisasjoner/kartverket/", "organisasjoner/"), datasetKind); } } XmlElement datasetAccrualPeriodicity = doc.CreateElement("dct", "accrualPeriodicity", xmlnsDct); if (!string.IsNullOrEmpty(data.MaintenanceFrequency)) { datasetAccrualPeriodicity.InnerText = data.MaintenanceFrequency; } dataset.AppendChild(datasetAccrualPeriodicity); XmlElement datasetGranularity = doc.CreateElement("dcat", "granularity", xmlnsDcat); if (!string.IsNullOrEmpty(data.ResolutionScale)) { datasetGranularity.InnerText = data.ResolutionScale; } dataset.AppendChild(datasetGranularity); XmlElement datasetLicense = doc.CreateElement("dct", "license", xmlnsDct); if (data.Constraints != null && !string.IsNullOrEmpty(data.Constraints.OtherConstraintsLink)) { datasetLicense.SetAttribute("resource", xmlnsRdf, data.Constraints.OtherConstraintsLink); } dataset.AppendChild(datasetLicense); var accessConstraint = "PUBLIC"; XmlElement datasetAccess = doc.CreateElement("dct", "accessRights", xmlnsDct); if (data.Constraints != null && !string.IsNullOrEmpty(data.Constraints.AccessConstraints)) { if (data.Constraints.AccessConstraints.ToLower() == "restricted") { accessConstraint = "NON-PUBLIC"; } else if (data.Constraints.AccessConstraints == "norway digital restricted" || (data.Constraints.AccessConstraints == "otherRestrictions" && !string.IsNullOrEmpty(data.Constraints.OtherConstraintsAccess) && data.Constraints.OtherConstraintsAccess.ToLower() == "norway digital restricted")) { accessConstraint = "RESTRICTED"; } } datasetAccess.SetAttribute("resource", xmlnsRdf, "http://publications.europa.eu/resource/authority/access-right/" + accessConstraint); dataset.AppendChild(datasetAccess); XmlElement datasetDataQuality = doc.CreateElement("dcat", "dataQuality", xmlnsDcat); if (!string.IsNullOrEmpty(data.ProcessHistory)) { datasetDataQuality.InnerText = data.ProcessHistory; } dataset.AppendChild(datasetDataQuality); //Distribution if (data.DistributionFormats != null) { foreach (var distro in data.DistributionFormats) { if (!string.IsNullOrEmpty(distro.Name)) { //Map distribution to dataset XmlElement distributionDataset = doc.CreateElement("dcat", "distribution", xmlnsDcat); distributionDataset.SetAttribute("resource", xmlnsRdf, kartkatalogenUrl + "Metadata/uuid/" + data.Uuid + "/" + HttpUtility.UrlEncode(distro.Name)); dataset.AppendChild(distributionDataset); XmlElement distribution = doc.CreateElement("dcat", "Distribution", xmlnsDcat); distribution.SetAttribute("about", xmlnsRdf, kartkatalogenUrl + "Metadata/uuid/" + data.Uuid + "/" + HttpUtility.UrlEncode(distro.Name)); root.AppendChild(distribution); XmlElement distributionTitle = doc.CreateElement("dct", "title", xmlnsDct); distributionTitle.SetAttribute("xml:lang", "no"); if (data.DistributionDetails != null && !string.IsNullOrEmpty(data.DistributionDetails.Protocol)) { distributionTitle.InnerText = GetDistributionTitle(data.DistributionDetails.Protocol); } distribution.AppendChild(distributionTitle); XmlElement distributionDescription = doc.CreateElement("dct", "description", xmlnsDct); if (data.DistributionDetails != null && !string.IsNullOrEmpty(data.DistributionDetails.Protocol)) { distributionDescription.InnerText = GetDistributionDescription(data.DistributionDetails.Protocol); } distribution.AppendChild(distributionDescription); XmlElement distributionFormat = doc.CreateElement("dct", "format", xmlnsDct); if (MediaTypes.ContainsKey(distro.Name)) { distributionFormat.SetAttribute("resource", xmlnsRdf, MediaTypes[distro.Name]); } else { distributionFormat.InnerText = distro.Name; } distribution.AppendChild(distributionFormat); XmlElement distributionAccessURL = doc.CreateElement("dcat", "accessURL", xmlnsDcat); distributionAccessURL.SetAttribute("resource", xmlnsRdf, kartkatalogenUrl + "metadata/uuid/" + uuid); distribution.AppendChild(distributionAccessURL); XmlElement distributionLicense = doc.CreateElement("dct", "license", xmlnsDct); if (data.Constraints != null && !string.IsNullOrEmpty(data.Constraints.OtherConstraintsLink)) { distributionLicense.SetAttribute("resource", xmlnsRdf, data.Constraints.OtherConstraintsLink); } distribution.AppendChild(distributionLicense); XmlElement distributionStatus = doc.CreateElement("adms", "status", xmlnsAdms); if (!string.IsNullOrEmpty(data.Status)) { distributionStatus.SetAttribute("resource", xmlnsRdf, "http://purl.org/adms/status/" + data.Status); } distribution.AppendChild(distributionStatus); } } } // Dataset distributions AddDistributions(uuid, dataset, data, services); //Agent/publisher XmlElement agent = doc.CreateElement("foaf", "Agent", xmlnsFoaf); if (data.ContactOwner != null && !string.IsNullOrEmpty(data.ContactOwner.Organization) && OrganizationsLink.ContainsKey(data.ContactOwner.Organization) && OrganizationsLink[data.ContactOwner.Organization] != null) { agent.SetAttribute("about", xmlnsRdf, OrganizationsLink[data.ContactOwner.Organization]); } XmlElement agentType = doc.CreateElement("dct", "type", xmlnsDct); agentType.SetAttribute("resource", xmlnsRdf, "http://purl.org/adms/publishertype/NationalAuthority"); agent.AppendChild(agentType); if (organization != null && !string.IsNullOrEmpty(organization.Number)) { XmlElement agentIdentifier = doc.CreateElement("dct", "identifier", xmlnsDct); agentIdentifier.InnerText = organization.Number; agent.AppendChild(agentIdentifier); } XmlElement agentName = doc.CreateElement("foaf", "name", xmlnsFoaf); if (organization != null) { agentName.InnerText = organization.Name; } agent.AppendChild(agentName); if (data.ContactOwner != null && !string.IsNullOrEmpty(data.ContactOwner.Email)) { XmlElement agentMbox = doc.CreateElement("foaf", "mbox", xmlnsFoaf); agentMbox.InnerText = data.ContactOwner.Email; agent.AppendChild(agentMbox); } if (organization != null && !string.IsNullOrEmpty(organization.Number)) { XmlElement agentSameAs = doc.CreateElement("owl", "sameAs", xmlnsOwl); agentSameAs.InnerText = "http://data.brreg.no/enhetsregisteret/enhet/" + organization.Number; agent.AppendChild(agentSameAs); } if (data.ContactOwner != null && !string.IsNullOrEmpty(data.ContactOwner.Organization) && OrganizationsLink.ContainsKey(data.ContactOwner.Organization) && OrganizationsLink[data.ContactOwner.Organization] != null) { if (!foafAgents.ContainsKey(OrganizationsLink[data.ContactOwner.Organization])) { foafAgents.Add(OrganizationsLink[data.ContactOwner.Organization], agent); } } } } foreach (var foafAgent in foafAgents) { root.AppendChild(foafAgent.Value); } foreach (var vcardKind in vcardKinds) { root.AppendChild(vcardKind.Value); } foreach (var service in services) { root.AppendChild(service.Value); } AppendConcepts(root); }