public SearchResultsType GetDatasets() { GeoNorge _geoNorge = new GeoNorge("", "", WebConfigurationManager.AppSettings["GeoNetworkUrl"] + geoNetworkendPoint); _geoNorge.OnLogEventDebug += new GeoNorgeAPI.LogEventHandlerDebug(LogEventsDebug); _geoNorge.OnLogEventError += new GeoNorgeAPI.LogEventHandlerError(LogEventsError); var filters = new object[] { new PropertyIsLikeType { escapeChar = "\\", singleChar = "_", wildCard = "%", PropertyName = new PropertyNameType { Text = new[] { "protocol" } }, Literal = new LiteralType { Text = new[] { "GEONORGE:DOWNLOAD" } } } }; var filterNames = new ItemsChoiceType23[] { ItemsChoiceType23.PropertyIsLike, }; var result = _geoNorge.SearchWithFilters(filters, filterNames, 1, 1000, false); return(result); }
public SearchResultsType SearchMetadata(string searchString) { GeoNorge g = new GeoNorge("", "", WebConfigurationManager.AppSettings["GeoNetworkUrl"]); var filters = new object[] { new PropertyIsLikeType { escapeChar = "\\", singleChar = "_", wildCard = "%", PropertyName = new PropertyNameType { Text = new[] { "srv:title" } }, Literal = new LiteralType { Text = new[] { searchString } } } }; var filterNames = new ItemsChoiceType23[] { ItemsChoiceType23.PropertyIsLike, }; var result = g.SearchWithFilters(filters, filterNames, 1, 200, true); return(result); }
public SimpleMetadataService() { System.Collections.Specialized.NameValueCollection settings = System.Web.Configuration.WebConfigurationManager.AppSettings; string server = settings["GeoNetworkUrl"]; string username = settings["GeoNetworkUsername"]; string password = settings["GeoNetworkPassword"]; _geoNorge = new GeoNorgeAPI.GeoNorge(username, password, server); _geoNorge.OnLogEventDebug += new GeoNorgeAPI.LogEventHandlerDebug(LogEventsDebug); _geoNorge.OnLogEventError += new GeoNorgeAPI.LogEventHandlerError(LogEventsError); }
public MainWindow() { InitializeComponent(); MetadataViewModel model = Resources["MetadataModel"] as MetadataViewModel; if (model != null) { model.Metadata = new ObservableCollection <Metadata>(new List <Metadata>()); } _geonorgeApi = new GeoNorge(); }
public static SimpleMetadata FetchMetadata(string uuid) { try { GeoNorge g = new GeoNorge("", "", WebConfigurationManager.AppSettings["GeoNetworkUrl"]); MD_Metadata_Type metadata = g.GetRecordByUuid(uuid); return(metadata != null ? new SimpleMetadata(metadata) : null); } catch (Exception e) { return(null); } }
public SearchResultsType GetDatasets() { GeoNorge _geoNorge = new GeoNorge("", "", WebConfigurationManager.AppSettings["GeoNetworkUrl"] + geoNetworkendPoint); _geoNorge.OnLogEventDebug += new GeoNorgeAPI.LogEventHandlerDebug(LogEventsDebug); _geoNorge.OnLogEventError += new GeoNorgeAPI.LogEventHandlerError(LogEventsError); var filters = new object[] { new PropertyIsLikeType { escapeChar = "\\", singleChar = "_", wildCard = "%", PropertyName = new PropertyNameType { Text = new[] { "keyword" } }, Literal = new LiteralType { Text = new[] { "fellesDatakatalog" } } } }; var filterNames = new ItemsChoiceType23[] { ItemsChoiceType23.PropertyIsLike, }; var stopwatch = new Stopwatch(); stopwatch.Start(); var result = _geoNorge.SearchWithFilters(filters, filterNames, 1, 1000, false); stopwatch.Stop(); Log.Debug($"Looking up metadata from GeonorgeApi [timespent={stopwatch.ElapsedMilliseconds}ms]"); return(result); }
public ProductSheetService(GeoNorge geoNorge, ProductSheetContext dbContext, IOrganizationService organizationService) { _geonorge = geoNorge; _dbContext = dbContext; _organizationService = organizationService; }
public SimpleMetadataService(GeoNorge geonorge) { _geoNorge = geonorge; }
public void Init() { _geonorge = new GeoNorge(); }
public Task UpdateMetadata() { var datasetList = GetDatasets(); var datasets = datasetList.OrderBy(x => x.Uuid) .GroupBy(x => x.Uuid) .Select(g => new { Uuid = g.Key, Datasets = g.Select(dataset => new { dataset.Url, dataset.Organization, dataset.LastUpdated, dataset.DistributionsFormats, dataset.ReferenceSystems }) }).ToList(); foreach (var dataset in datasets) { try { var metadataInfo = new UpdateMetadataInformation(); metadataInfo.Uuid = dataset.Uuid.Trim(); metadataInfo.Distributions = new List <SimpleDistribution>(); foreach (var item in dataset.Datasets) { try { metadataInfo.DatasetDateUpdated = DateTime.Parse(item.LastUpdated, System.Globalization.CultureInfo.InvariantCulture); } catch (Exception e) { Log.Error("Error with LastUpdated: " + item.LastUpdated, e); } foreach (var distribution in item.DistributionsFormats) { SimpleDistribution simpleDistribution = new SimpleDistribution(); simpleDistribution.Organization = distribution.Organization; simpleDistribution.Protocol = "W3C:AtomFeed"; simpleDistribution.URL = item.Url; simpleDistribution.FormatName = distribution.FormatName; metadataInfo.Distributions.Add(simpleDistribution); } metadataInfo.Projections = new List <SimpleReferenceSystem>(); foreach (var projection in item.ReferenceSystems) { SimpleReferenceSystem simpleReferenceSystem = new SimpleReferenceSystem(); simpleReferenceSystem.CoordinateSystem = projection.CoordinateSystem; metadataInfo.Projections.Add(simpleReferenceSystem); } } System.Collections.Specialized.NameValueCollection settings = System.Web.Configuration.WebConfigurationManager.AppSettings; string server = settings["GeoNetworkUrl"]; string usernameGeonetwork = settings["GeoNetworkUsername"]; string password = settings["GeoNetworkPassword"]; string geonorgeUsername = settings["GeonorgeUsername"]; GeoNorge api = new GeoNorge(usernameGeonetwork, password, server); api.OnLogEventDebug += new GeoNorgeAPI.LogEventHandlerDebug(LogEventsDebug); api.OnLogEventError += new GeoNorgeAPI.LogEventHandlerError(LogEventsError); var metadata = api.GetRecordByUuid(metadataInfo.Uuid); SimpleMetadata simpleMetadata = new SimpleMetadata(metadata); List <SimpleDistribution> distributionFormats = simpleMetadata.DistributionsFormats; List <SimpleDistribution> distributionFormatsUpdated = new List <SimpleDistribution>(); if (HasAtomFeed(metadataInfo.Distributions)) { foreach (var distribution in distributionFormats) { if (distribution.Protocol != "W3C:AtomFeed") { distributionFormatsUpdated.Add(distribution); } } } else { distributionFormatsUpdated = distributionFormats; } distributionFormatsUpdated.AddRange(metadataInfo.Distributions); simpleMetadata.DistributionsFormats = distributionFormatsUpdated; simpleMetadata.DistributionDetails = new SimpleDistributionDetails { URL = distributionFormatsUpdated[0].URL, Protocol = distributionFormatsUpdated[0].Protocol, UnitsOfDistribution = distributionFormatsUpdated[0].UnitsOfDistribution }; List <SimpleReferenceSystem> simpleReferenceSystems = new List <SimpleReferenceSystem>(); foreach (var projection in metadataInfo.Projections) { SimpleReferenceSystem refsys = new SimpleReferenceSystem(); refsys.CoordinateSystem = projection.CoordinateSystem; simpleReferenceSystems.Add(refsys); } if (simpleMetadata.ReferenceSystems == null || (simpleMetadata.ReferenceSystems != null && simpleMetadata.ReferenceSystems.Count == 0)) { simpleMetadata.ReferenceSystems = simpleReferenceSystems; } simpleMetadata.DateMetadataUpdated = DateTime.Now; if (metadataInfo.DatasetDateUpdated.HasValue) { simpleMetadata.DateUpdated = metadataInfo.DatasetDateUpdated; } api.MetadataUpdate(simpleMetadata.GetMetadata(), CreateAdditionalHeadersWithUsername(geonorgeUsername, "true")); Log.Info($"Metadata updated for uuid: {metadataInfo.Uuid}"); } catch (Exception ex) { Log.Error("Error updating metadata uuid: " + dataset.Uuid + ", error: " + ex); } } return(Task.CompletedTask); }