public GetMetadata ( ) : |
||
return |
internal List<WmsLayerViewModel> CreateMetadataForLayers(string uuid, List<WmsLayerViewModel> layers, string[] keywords, string username) { SimpleMetadata parentMetadata = new SimpleMetadata(_geoNorge.GetRecordByUuid(uuid)); List<SimpleKeyword> selectedKeywordsFromParent = CreateListOfKeywords(keywords); List<string> layerIdentifiers = new List<string>(); foreach (WmsLayerViewModel layer in layers) { try { SimpleMetadata simpleLayer = createMetadataForLayer(parentMetadata, selectedKeywordsFromParent, layer); MetadataTransaction transaction = _geoNorge.MetadataInsert(simpleLayer.GetMetadata(), CreateAdditionalHeadersWithUsername(username)); if (transaction.Identifiers != null && transaction.Identifiers.Count > 0) { layer.Uuid = transaction.Identifiers[0]; layerIdentifiers.Add(layer.Uuid); } } catch (Exception e) { layer.ErrorMessage = e.Message; Log.Error("Error while creating metadata for layer: " + layer.Title, e); } } parentMetadata.OperatesOn = layerIdentifiers; _geoNorge.MetadataUpdate(parentMetadata.GetMetadata()); return layers; }
private SimpleMetadata createMetadataForLayer(SimpleMetadata parentMetadata, List<SimpleKeyword> selectedKeywordsFromParent, WmsLayerViewModel layerModel) { MD_Metadata_Type parent = parentMetadata.GetMetadata(); MD_Metadata_Type layer = parent.Copy(); layer.parentIdentifier = new CharacterString_PropertyType { CharacterString = parent.fileIdentifier.CharacterString }; layer.fileIdentifier = new CharacterString_PropertyType { CharacterString = Guid.NewGuid().ToString() }; SimpleMetadata simpleLayer = new SimpleMetadata(layer); string title = layerModel.Title; if (string.IsNullOrWhiteSpace(title)) { title = layerModel.Name; } simpleLayer.Title = title; if (!string.IsNullOrWhiteSpace(layerModel.Abstract)) { simpleLayer.Abstract = layerModel.Abstract; } simpleLayer.Keywords = selectedKeywordsFromParent; if (layerModel.Keywords.Count > 0) { var existingKeywords = simpleLayer.Keywords; foreach (var keyword in layerModel.Keywords) { existingKeywords.Add(new SimpleKeyword { Keyword = keyword }); } simpleLayer.Keywords = existingKeywords; } simpleLayer.DistributionDetails = new SimpleDistributionDetails { Name = layerModel.Name, Protocol = parentMetadata.DistributionDetails.Protocol, URL = parentMetadata.DistributionDetails.URL }; if (!string.IsNullOrWhiteSpace(layerModel.BoundingBoxEast)) { string defaultWestBoundLongitude = "-20"; string defaultEastBoundLongitude = "38"; string defaultSouthBoundLatitude = "56"; string defaultNorthBoundLatitude = "90"; string parentWestBoundLongitude = defaultWestBoundLongitude; string parentEastBoundLongitude = defaultEastBoundLongitude; string parentSouthBoundLatitude = defaultSouthBoundLatitude; string parentNorthBoundLatitude = defaultNorthBoundLatitude; if (parentMetadata.BoundingBox != null) { parentWestBoundLongitude = parentMetadata.BoundingBox.WestBoundLongitude; parentEastBoundLongitude = parentMetadata.BoundingBox.EastBoundLongitude; parentSouthBoundLatitude = parentMetadata.BoundingBox.SouthBoundLatitude; parentNorthBoundLatitude = parentMetadata.BoundingBox.NorthBoundLatitude; } string WestBoundLongitude = layerModel.BoundingBoxWest; string EastBoundLongitude = layerModel.BoundingBoxEast; string SouthBoundLatitude = layerModel.BoundingBoxSouth; string NorthBoundLatitude = layerModel.BoundingBoxNorth; decimal number; if ( !Decimal.TryParse(WestBoundLongitude, out number) || !Decimal.TryParse(EastBoundLongitude, out number) || !Decimal.TryParse(SouthBoundLatitude, out number) || !Decimal.TryParse(NorthBoundLatitude, out number) ) { WestBoundLongitude = parentWestBoundLongitude; EastBoundLongitude = parentEastBoundLongitude; SouthBoundLatitude = parentSouthBoundLatitude; NorthBoundLatitude = parentNorthBoundLatitude; if ( !Decimal.TryParse(WestBoundLongitude, out number) || !Decimal.TryParse(EastBoundLongitude, out number) || !Decimal.TryParse(SouthBoundLatitude, out number) || !Decimal.TryParse(NorthBoundLatitude, out number) ) { WestBoundLongitude = defaultWestBoundLongitude; EastBoundLongitude = defaultEastBoundLongitude; SouthBoundLatitude = defaultSouthBoundLatitude; NorthBoundLatitude = defaultNorthBoundLatitude; } } simpleLayer.BoundingBox = new SimpleBoundingBox { EastBoundLongitude = EastBoundLongitude, WestBoundLongitude = WestBoundLongitude, NorthBoundLatitude = NorthBoundLatitude, SouthBoundLatitude = SouthBoundLatitude }; } if (!string.IsNullOrWhiteSpace(layerModel.EnglishTitle)) { simpleLayer.EnglishTitle = layerModel.EnglishTitle; } if (!string.IsNullOrWhiteSpace(layerModel.EnglishAbstract)) { simpleLayer.EnglishAbstract = layerModel.EnglishAbstract; } return simpleLayer; }
public void SaveMetadataModel(MetadataViewModel model, string username) { SimpleMetadata metadata = new SimpleMetadata(_geoNorge.GetRecordByUuid(model.Uuid)); UpdateMetadataFromModel(model, metadata); var transaction = _geoNorge.MetadataUpdate(metadata.GetMetadata(), CreateAdditionalHeadersWithUsername(username, model.Published)); if (transaction.TotalUpdated == "0") throw new Exception("Kunne ikke lagre endringene - kontakt systemansvarlig"); Task.Run(() => ReIndexOperatesOn(model)); Task.Run(() => RemoveCache(model)); }
public Stream SaveMetadataAsXml(MetadataViewModel model) { var simpleMetadata = new SimpleMetadata(_geoNorge.GetRecordByUuid(model.Uuid)); UpdateMetadataFromModel(model, simpleMetadata); return SerializeUtil.SerializeToStream(simpleMetadata.GetMetadata()); }
private SimpleMetadata createDuplicateOfMetadata(SimpleMetadata parentMetadata, WmsLayerViewModel layerModel) { MD_Metadata_Type parent = parentMetadata.GetMetadata(); MD_Metadata_Type layer = parent.Copy(); layer.parentIdentifier = new CharacterString_PropertyType { CharacterString = parent.fileIdentifier.CharacterString }; layer.fileIdentifier = new CharacterString_PropertyType { CharacterString = Guid.NewGuid().ToString() }; SimpleMetadata simpleLayer = new SimpleMetadata(layer); string title = layerModel.Title; if (string.IsNullOrWhiteSpace(title)) { title = layerModel.Name; } simpleLayer.Title = title; if (!string.IsNullOrWhiteSpace(layerModel.Abstract)) { simpleLayer.Abstract = layerModel.Abstract; } if (layerModel.Keywords.Count > 0) { var existingKeywords = simpleLayer.Keywords; foreach (var keyword in layerModel.Keywords) { existingKeywords.Add(new SimpleKeyword { Keyword = keyword }); } simpleLayer.Keywords = existingKeywords; } simpleLayer.DistributionDetails = new SimpleDistributionDetails { Name = layerModel.Name, Protocol = parentMetadata.DistributionDetails.Protocol, URL = parentMetadata.DistributionDetails.URL }; if (!string.IsNullOrWhiteSpace(layerModel.BoundingBoxEast)) { simpleLayer.BoundingBox = new SimpleBoundingBox { EastBoundLongitude = layerModel.BoundingBoxEast, WestBoundLongitude = layerModel.BoundingBoxWest, NorthBoundLatitude = layerModel.BoundingBoxNorth, SouthBoundLatitude = layerModel.BoundingBoxSouth }; } if (!string.IsNullOrWhiteSpace(layerModel.EnglishTitle)) { simpleLayer.EnglishTitle = layerModel.EnglishTitle; } if (!string.IsNullOrWhiteSpace(layerModel.EnglishAbstract)) { simpleLayer.EnglishAbstract = layerModel.EnglishAbstract; } return simpleLayer; }
public void SaveMetadataModel(MetadataViewModel model, string username) { SimpleMetadata metadata = new SimpleMetadata(_geoNorge.GetRecordByUuid(model.Uuid)); metadata.Title = model.Title; metadata.Abstract = model.Abstract; if (!string.IsNullOrWhiteSpace(model.Purpose)) metadata.Purpose = model.Purpose; if (!string.IsNullOrWhiteSpace(model.TopicCategory)) metadata.TopicCategory = model.TopicCategory; if (!string.IsNullOrWhiteSpace(model.SupplementalDescription)) metadata.SupplementalDescription = model.SupplementalDescription; if (!string.IsNullOrWhiteSpace(model.SpecificUsage)) metadata.SpecificUsage = model.SpecificUsage; var contactMetadata = model.ContactMetadata.ToSimpleContact(); if (!string.IsNullOrWhiteSpace(model.EnglishContactMetadataOrganization)) { contactMetadata.OrganizationEnglish = model.EnglishContactMetadataOrganization; } metadata.ContactMetadata = contactMetadata; var contactPublisher = model.ContactPublisher.ToSimpleContact(); if (!string.IsNullOrWhiteSpace(model.EnglishContactPublisherOrganization)) { contactPublisher.OrganizationEnglish = model.EnglishContactPublisherOrganization; } metadata.ContactPublisher = contactPublisher; var contactOwner = model.ContactOwner.ToSimpleContact(); if (!string.IsNullOrWhiteSpace(model.EnglishContactOwnerOrganization)) { contactOwner.OrganizationEnglish = model.EnglishContactOwnerOrganization; } metadata.ContactOwner = contactOwner; // documents if (!string.IsNullOrWhiteSpace(model.ProductSpecificationUrl)) metadata.ProductSpecificationUrl = model.ProductSpecificationUrl; if (!string.IsNullOrWhiteSpace(model.ProductSheetUrl)) metadata.ProductSheetUrl = model.ProductSheetUrl; if (!string.IsNullOrWhiteSpace(model.ProductPageUrl)) metadata.ProductPageUrl = model.ProductPageUrl; if (!string.IsNullOrWhiteSpace(model.LegendDescriptionUrl)) metadata.LegendDescriptionUrl = model.LegendDescriptionUrl; metadata.Thumbnails = Thumbnail.ToSimpleThumbnailList(model.Thumbnails); // distribution if (!string.IsNullOrWhiteSpace(model.SpatialRepresentation)) metadata.SpatialRepresentation = model.SpatialRepresentation; if (!string.IsNullOrWhiteSpace(model.ReferenceSystemCoordinateSystem)) { metadata.ReferenceSystem = new SimpleReferenceSystem { CoordinateSystem = model.ReferenceSystemCoordinateSystem, Namespace = model.ReferenceSystemNamespace }; } if (!string.IsNullOrWhiteSpace(model.DistributionFormatName) || !string.IsNullOrWhiteSpace(model.DistributionFormatVersion)) { metadata.DistributionFormat = new SimpleDistributionFormat { Name = model.DistributionFormatName, Version = model.DistributionFormatVersion }; } if (!string.IsNullOrWhiteSpace(model.DistributionUrl) || !string.IsNullOrWhiteSpace(model.DistributionProtocol) || !string.IsNullOrWhiteSpace(model.DistributionName)) { metadata.DistributionDetails = new SimpleDistributionDetails { URL = model.DistributionUrl, Protocol = model.DistributionProtocol, Name = model.DistributionName }; } // quality if (!string.IsNullOrWhiteSpace(model.QualitySpecificationTitle)) { metadata.QualitySpecification = new SimpleQualitySpecification { Title = model.QualitySpecificationTitle, Date = model.QualitySpecificationDate, DateType = model.QualitySpecificationDateType, Explanation = model.QualitySpecificationExplanation, Result = model.QualitySpecificationResult }; } if (!string.IsNullOrWhiteSpace(model.ProcessHistory)) metadata.ProcessHistory = model.ProcessHistory; if (!string.IsNullOrWhiteSpace(model.MaintenanceFrequency)) metadata.MaintenanceFrequency = model.MaintenanceFrequency; if (!string.IsNullOrWhiteSpace(model.ResolutionScale)) metadata.ResolutionScale = model.ResolutionScale; if (!string.IsNullOrWhiteSpace(model.Status)) metadata.Status = model.Status; metadata.DateCreated = model.DateCreated; metadata.DatePublished = model.DatePublished; metadata.DateUpdated = model.DateUpdated; if (!string.IsNullOrWhiteSpace(model.BoundingBoxEast)) { metadata.BoundingBox = new SimpleBoundingBox { EastBoundLongitude = model.BoundingBoxEast, WestBoundLongitude = model.BoundingBoxWest, NorthBoundLatitude = model.BoundingBoxNorth, SouthBoundLatitude = model.BoundingBoxSouth }; } if (!string.IsNullOrWhiteSpace(model.AccessConstraints) || !string.IsNullOrWhiteSpace(model.OtherConstraints) || !string.IsNullOrWhiteSpace(model.SecurityConstraints) || !string.IsNullOrWhiteSpace(model.UseConstraints) || !string.IsNullOrWhiteSpace(model.UseLimitations)) { metadata.Constraints = new SimpleConstraints { AccessConstraints = model.AccessConstraints, OtherConstraints = model.OtherConstraints, SecurityConstraints = model.SecurityConstraints, UseConstraints = model.UseConstraints, UseLimitations = model.UseLimitations }; } metadata.Keywords = model.GetAllKeywords(); bool hasEnglishFields = false; // don't create PT_FreeText fields if it isn't necessary if (!string.IsNullOrWhiteSpace(model.EnglishTitle)) { metadata.EnglishTitle = model.EnglishTitle; hasEnglishFields = true; } if (!string.IsNullOrWhiteSpace(model.EnglishAbstract)) { metadata.EnglishAbstract = model.EnglishAbstract; hasEnglishFields = true; } if (hasEnglishFields) metadata.SetLocale(SimpleMetadata.LOCALE_ENG); SetDefaultValuesOnMetadata(metadata); _geoNorge.MetadataUpdate(metadata.GetMetadata(), CreateAdditionalHeadersWithUsername(username)); }
public void SaveMetadataModel(SimpleMetadataViewModel model, string username) { SimpleMetadata metadata = new SimpleMetadata(_geoNorge.GetRecordByUuid(model.Uuid)); UpdateMetadataFromModel(model, metadata); _geoNorge.MetadataUpdate(metadata.GetMetadata(), CreateAdditionalHeadersWithUsername(username, model.Published)); }