public ValidationResult Validate(MetadataEntry metadataEntry, MD_Metadata_Type metadata, string rawXmlProcessed) { ValidationResult validationResult = new ValidationResult(); if (metadataEntry.HasResourceType("software")) { validationResult = HasDistributionUrl(metadata, validationResult); } else { bool allowSpatialDataThemeError = true; bool allowConformityError = true; validationResult = new InspireValidator().Validate(rawXmlProcessed, allowSpatialDataThemeError, allowConformityError); } return validationResult; }
private static ValidationResult HasDistributionUrl(MD_Metadata_Type metadata, ValidationResult validationResult) { if (metadata.distributionInfo != null && metadata.distributionInfo.MD_Distribution != null && metadata.distributionInfo.MD_Distribution.transferOptions != null && metadata.distributionInfo.MD_Distribution.transferOptions[0] != null && metadata.distributionInfo.MD_Distribution.transferOptions[0].MD_DigitalTransferOptions != null && metadata.distributionInfo.MD_Distribution.transferOptions[0].MD_DigitalTransferOptions.onLine != null && metadata.distributionInfo.MD_Distribution.transferOptions[0].MD_DigitalTransferOptions.onLine[0] != null && metadata.distributionInfo.MD_Distribution.transferOptions[0].MD_DigitalTransferOptions.onLine[0] .CI_OnlineResource != null && metadata.distributionInfo.MD_Distribution.transferOptions[0].MD_DigitalTransferOptions.onLine[0] .CI_OnlineResource.linkage != null && metadata.distributionInfo.MD_Distribution.transferOptions[0].MD_DigitalTransferOptions.onLine[0] .CI_OnlineResource.linkage.URL != null) { string url = metadata.distributionInfo.MD_Distribution.transferOptions[0].MD_DigitalTransferOptions.onLine[0] .CI_OnlineResource.linkage.URL; if (url.Trim().Length > 1) { validationResult.Result = 1; } else { validationResult.Result = 0; validationResult.Messages = "Empty URL in distributionInfo."; } } else { validationResult.Result = 0; validationResult.Messages = "Missing URL in distributionInfo."; } return validationResult; }
private MetadataEntry ParseCswRecordResponse(string uuid, MD_Metadata_Type metadata) { var title = "unknown"; var resourceType = "unknown"; var organization = "unknown"; var inspireResource = false; string purpose = null; string abstractText = null; StringBuilder contactInformation = new StringBuilder(); List<string> keywords = new List<string>(); if (metadata != null) { if (metadata.hierarchyLevel != null && metadata.hierarchyLevel[0] != null) { resourceType = metadata.hierarchyLevel[0].MD_ScopeCode.codeListValue; } var dataIdentification = metadata.identificationInfo[0].AbstractMD_Identification; if (dataIdentification != null) { title = dataIdentification.citation.CI_Citation.title.CharacterString; if (dataIdentification.pointOfContact != null && dataIdentification.pointOfContact[0] != null && dataIdentification.pointOfContact[0].CI_ResponsibleParty != null) { CI_ResponsibleParty_Type responsibleParty = dataIdentification.pointOfContact[0].CI_ResponsibleParty; if (responsibleParty.organisationName != null && !string.IsNullOrWhiteSpace(responsibleParty.organisationName.CharacterString)) organization = responsibleParty.organisationName.CharacterString; if (responsibleParty.individualName != null && !string.IsNullOrWhiteSpace(responsibleParty.individualName.CharacterString)) { contactInformation.Append(responsibleParty.individualName.CharacterString); } if (responsibleParty.contactInfo != null && responsibleParty.contactInfo.CI_Contact != null) { var contact = responsibleParty.contactInfo.CI_Contact; if (contact.address != null && contact.address.CI_Address != null) { var address = contact.address.CI_Address; if (address.electronicMailAddress != null && address.electronicMailAddress[0] != null && !string.IsNullOrWhiteSpace(address.electronicMailAddress[0].CharacterString)) { contactInformation.Append(" - ").Append(address.electronicMailAddress[0].CharacterString).Append("\n"); } else { contactInformation.Append("\n"); } if (address.deliveryPoint != null && address.deliveryPoint[0] != null && !string.IsNullOrWhiteSpace(address.deliveryPoint[0].CharacterString)) { contactInformation.Append(address.deliveryPoint[0].CharacterString).Append(", "); } if (address.postalCode != null && !string.IsNullOrWhiteSpace(address.postalCode.CharacterString)) { contactInformation.Append(address.postalCode.CharacterString).Append(" "); } if (address.city != null && !string.IsNullOrWhiteSpace(address.city.CharacterString)) { contactInformation.Append(address.city.CharacterString); } } if (contact.phone != null && contact.phone.CI_Telephone != null && contact.phone.CI_Telephone.voice != null && contact.phone.CI_Telephone.voice[0] != null && !string.IsNullOrWhiteSpace(contact.phone.CI_Telephone.voice[0].CharacterString)) { contactInformation.Append("\nTlf: ").Append(contact.phone.CI_Telephone.voice[0].CharacterString); } } } // collect keywords if (dataIdentification.descriptiveKeywords != null) { foreach (var descriptiveKeyword in dataIdentification.descriptiveKeywords) { if (descriptiveKeyword.MD_Keywords != null && descriptiveKeyword.MD_Keywords.keyword != null) { foreach (var singleKeyword in descriptiveKeyword.MD_Keywords.keyword) { if (singleKeyword.CharacterString != null) { keywords.Add(singleKeyword.CharacterString); /** old way of determine inspire or norge digitalt if (singleKeyword.CharacterString.Equals("annet", StringComparison.InvariantCultureIgnoreCase)) { inspireResource = false; } **/ } } } } } inspireResource = IsInspireResource(metadata); // collect purpose if (dataIdentification.purpose != null && !string.IsNullOrWhiteSpace(dataIdentification.purpose.CharacterString)) { purpose = dataIdentification.purpose.CharacterString; } // collect abstract if (dataIdentification.@abstract != null && !string.IsNullOrWhiteSpace([email protected])) { abstractText = [email protected]; } } } if (inspireResource) { inspireResource = IsApplicableForInspireValidation(resourceType); } return new MetadataEntry() { Uuid = uuid, Title = title, ResourceType = resourceType, ResponsibleOrganization = organization, InspireResource = inspireResource, ValidationResults = new List<ValidationResult>(), ContactInformation = contactInformation.ToString(), Keywords = string.Join(", ", keywords), Purpose = purpose, Abstract = abstractText }; }
private bool IsInspireResource(MD_Metadata_Type metadata) { bool isInspireResource = false; if (metadata.dataQualityInfo != null && metadata.dataQualityInfo[0] != null && metadata.dataQualityInfo[0].DQ_DataQuality != null && metadata.dataQualityInfo[0].DQ_DataQuality.report != null && metadata.dataQualityInfo[0].DQ_DataQuality.report[0] != null && metadata.dataQualityInfo[0].DQ_DataQuality.report[0].AbstractDQ_Element != null && metadata.dataQualityInfo[0].DQ_DataQuality.report[0].AbstractDQ_Element.result != null && metadata.dataQualityInfo[0].DQ_DataQuality.report[0].AbstractDQ_Element.result[0] != null && metadata.dataQualityInfo[0].DQ_DataQuality.report[0].AbstractDQ_Element.result[0].AbstractDQ_Result != null) { var result = metadata.dataQualityInfo[0].DQ_DataQuality.report[0].AbstractDQ_Element.result[0].AbstractDQ_Result as DQ_ConformanceResult_Type; if (result != null && result.specification != null && result.specification.CI_Citation != null && result.specification.CI_Citation.title != null && result.specification.CI_Citation.title.CharacterString != null && result.specification.CI_Citation.title.CharacterString.ToUpper().Contains("COMMISSION REGULATION (EU)")) { isInspireResource = true; } } return isInspireResource; }
public void ShouldReturnParentIdentifier() { string identifier = "testIdentifier"; MD_Metadata_Type metadata = new MD_Metadata_Type(); metadata.parentIdentifier = new CharacterString_PropertyType{ CharacterString = identifier}; SimpleMetadata simpleMetadata = new SimpleMetadata(metadata); Assert.AreEqual(identifier, simpleMetadata.ParentIdentifier); }
public void ShouldReturnValidTimePeriod() { MD_Metadata_Type metadata = new MD_Metadata_Type(); metadata.hierarchyLevel = new MD_ScopeCode_PropertyType[] { new MD_ScopeCode_PropertyType() { MD_ScopeCode = new CodeListValue_Type() { codeListValue = "service" } } }; metadata.identificationInfo = new MD_Identification_PropertyType[] { new MD_Identification_PropertyType{ AbstractMD_Identification = new SV_ServiceIdentification_Type() { extent = new EX_Extent_PropertyType[] { new EX_Extent_PropertyType { EX_Extent = new EX_Extent_Type() { temporalElement= new EX_TemporalExtent_PropertyType[] { new EX_TemporalExtent_PropertyType() { EX_TemporalExtent = new EX_TemporalExtent_Type() { extent = new TM_Primitive_PropertyType() { AbstractTimePrimitive = new TimePeriodType() { Item= new TimePositionType() { Value = "2010-01-01T12:00:00" }, Item1= new TimePositionType() { Value = "2018-01-01T12:00:00" } } } } } } } } } } } }; SimpleMetadata simpleMetadata = new SimpleMetadata(metadata); Assert.NotNull(simpleMetadata.ValidTimePeriod); Assert.AreEqual("2010-01-01T12:00:00", simpleMetadata.ValidTimePeriod.ValidFrom); Assert.AreEqual("2018-01-01T12:00:00", simpleMetadata.ValidTimePeriod.ValidTo); }
public static MD_Metadata_Type CreateMetadataExample() { MD_Metadata_Type m = new MD_Metadata_Type(); m.fileIdentifier = CharString("12345-67890-aabbcc-ddeeff-ggffhhjj"); m.language = CharString("nor"); m.metadataStandardName = CharString("ISO19139"); m.metadataStandardVersion = CharString("1.0"); m.hierarchyLevel = new[] { new MD_ScopeCode_PropertyType { MD_ScopeCode = new CodeListValue_Type { codeList = "http://www.isotc211.org/2005/resources/codeList.xml#MD_ScopeCode", codeListValue = "dataset" } } }; var responsibleParty = new CI_ResponsibleParty_Type() { individualName = CharString("Hans Hansen"), role = new CI_RoleCode_PropertyType() { CI_RoleCode = new CodeListValue_Type { codeList = "http://www.isotc211.org/2005/resources/codeList.xml#CI_RoleCode", codeListValue = "resourceProvider" } }, organisationName = CharString("Statens Kartverk"), contactInfo = new CI_Contact_PropertyType() { CI_Contact = new CI_Contact_Type() { address = new CI_Address_PropertyType() { CI_Address = new CI_Address_Type() { electronicMailAddress = new[] { CharString("*****@*****.**") } } } } } }; m.contact = new CI_ResponsibleParty_PropertyType[] { new CI_ResponsibleParty_PropertyType() { CI_ResponsibleParty = responsibleParty } }; m.dateStamp = new Date_PropertyType() { Item = DateTime.Now }; var mdDataIdentificationType = new MD_DataIdentification_Type(); mdDataIdentificationType.pointOfContact = new[] { new CI_ResponsibleParty_PropertyType { CI_ResponsibleParty = responsibleParty } }; mdDataIdentificationType.citation = new CI_Citation_PropertyType { CI_Citation = new CI_Citation_Type { title = CharString("Eksempeldatasettet sin tittel."), date = new[] { new CI_Date_PropertyType { CI_Date = new CI_Date_Type { date = new Date_PropertyType { Item = DateTime.Now.Date.ToString("yyyy-MM-dd") }, dateType = new CI_DateTypeCode_PropertyType { CI_DateTypeCode = new CodeListValue_Type { codeList = "http://www.isotc211.org/2005/resources/codeList.xml#CI_DateTypeCode", codeListValue = "creation" } } } } }, alternateTitle = new[] { CharString("Dette er en den alternative tittelen til datasettet som tilbys.") }, identifier = new[] { new MD_Identifier_PropertyType { MD_Identifier = new MD_Identifier_Type { code = CharString("12345-abcdef-67890-ghijkl") } } } } }; mdDataIdentificationType.@abstract = CharString("Dette datasettet inneholder ditt og datt. Kan brukes til dette, men må ikke brukes til andre ting som for eksempel dette."); mdDataIdentificationType.purpose = CharString("Dette er formålet."); mdDataIdentificationType.resourceSpecificUsage = new[] { new MD_Usage_PropertyType() { MD_Usage = new MD_Usage_Type() { specificUsage = CharString("Skal bare brukes sånn og sånn"), usageDateTime = new DateTime_PropertyType() { DateTime = DateTime.Now }, userContactInfo = new [] { new CI_ResponsibleParty_PropertyType { CI_ResponsibleParty = responsibleParty } }, userDeterminedLimitations = CharString("Her kommer det begrensninger på bruk av dataene.") } } }; mdDataIdentificationType.spatialResolution = new MD_Resolution_PropertyType[] { new MD_Resolution_PropertyType() { MD_Resolution = new MD_Resolution_Type() { Item = new MD_RepresentativeFraction_PropertyType() { MD_RepresentativeFraction = new MD_RepresentativeFraction_Type() { denominator = new Integer_PropertyType() { Integer = "1000" } } } } } }; mdDataIdentificationType.language = new[] { CharString("nor") }; mdDataIdentificationType.descriptiveKeywords = new[] { new MD_Keywords_PropertyType { MD_Keywords = new MD_Keywords_Type { keyword = new MD_Keyword[] { new MD_Keyword { keyword = new PT_FreeText_PropertyType { CharacterString = "Adresser", PT_FreeText = new PT_FreeText_Type { id = "ENG", textGroup = new LocalisedCharacterString_PropertyType[] { new LocalisedCharacterString_PropertyType { LocalisedCharacterString = new LocalisedCharacterString_Type { locale = "#ENG", Value = "Addresses" } } } } } } }, thesaurusName = new CI_Citation_PropertyType { CI_Citation = new CI_Citation_Type { title = CharString("GEMET - INSPIRE themes, version 1.0"), date = new [] { new CI_Date_PropertyType { CI_Date = new CI_Date_Type { date = new Date_PropertyType { Item = DateTime.Now }, dateType = new CI_DateTypeCode_PropertyType { CI_DateTypeCode = new CodeListValue_Type() { codeList = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode", codeListValue = "publication" } } } } } } } } } }; mdDataIdentificationType.resourceConstraints = new[] { new MD_Constraints_PropertyType { MD_Constraints = new MD_Constraints_Type { useLimitation = new [] { new PT_FreeText_PropertyType { CharacterString = "Gratis å benytte til alle formål.", PT_FreeText = new PT_FreeText_Type { id = "ENG", textGroup = new LocalisedCharacterString_PropertyType[] { new LocalisedCharacterString_PropertyType { LocalisedCharacterString = new LocalisedCharacterString_Type { locale = "#ENG", Value = "Free of charge" } } } } } } } }, new MD_Constraints_PropertyType { MD_Constraints = new MD_LegalConstraints_Type { accessConstraints = new MD_RestrictionCode_PropertyType[] { new MD_RestrictionCode_PropertyType { MD_RestrictionCode = new CodeListValue_Type { codeListValue = "none" , codeList = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_RestrictionCode" } } }, useConstraints = new MD_RestrictionCode_PropertyType[] { new MD_RestrictionCode_PropertyType { MD_RestrictionCode = new CodeListValue_Type { codeListValue = "free" , codeList = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_RestrictionCode" } } }, otherConstraints = new MD_RestrictionOther_PropertyType [] { new MD_RestrictionOther_PropertyType { MD_RestrictionOther = new PT_FreeText_PropertyType { CharacterString = "Ingen begrensninger på bruk.", PT_FreeText = new PT_FreeText_Type { id = "ENG", textGroup = new LocalisedCharacterString_PropertyType[] { new LocalisedCharacterString_PropertyType { LocalisedCharacterString = new LocalisedCharacterString_Type { locale = "#ENG", Value = "No restrictions" } } } } } } , new MD_RestrictionOther_PropertyType { MD_RestrictionOther = new Anchor_Type{href="http://test.no",Value="Link"} }, new MD_RestrictionOther_PropertyType { MD_RestrictionOther = CharString("norway digital restricted") } } } }, new MD_Constraints_PropertyType { MD_Constraints = new MD_SecurityConstraints_Type { userNote = new CharacterString_PropertyType { CharacterString = "Text that describes why it is not freely open" }, classification = new MD_ClassificationCode_PropertyType { MD_ClassificationCode = new CodeListValue_Type { codeList = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_ClassificationCode", codeListValue = "unclassified" } } } } }; mdDataIdentificationType.topicCategory = new[] { new MD_TopicCategoryCode_PropertyType { MD_TopicCategoryCode = MD_TopicCategoryCode_Type.location } }; mdDataIdentificationType.extent = new[] { new EX_Extent_PropertyType { EX_Extent = new EX_Extent_Type { geographicElement = new [] { new EX_GeographicExtent_PropertyType { AbstractEX_GeographicExtent = new EX_GeographicBoundingBox_Type { westBoundLongitude = new Decimal_PropertyType { Decimal = 2 }, eastBoundLongitude = new Decimal_PropertyType { Decimal = 33 }, southBoundLatitude = new Decimal_PropertyType { Decimal = 57 }, northBoundLatitude = new Decimal_PropertyType { Decimal = 72 } } } }, temporalElement = new EX_TemporalExtent_PropertyType[] { new EX_TemporalExtent_PropertyType { EX_TemporalExtent = new EX_TemporalExtent_Type { extent = new TM_Primitive_PropertyType { AbstractTimePrimitive = new TimePeriodType() { id="id_1", Item = new TimePositionType() { Value = "2014-01-01" }, Item1 = new TimePositionType() { Value = "2020-01-01" } } } } } } } } }; mdDataIdentificationType.supplementalInformation = CharString("Dette er den utfyllende informasjonen."); m.identificationInfo = new[] { new MD_Identification_PropertyType { AbstractMD_Identification = mdDataIdentificationType } }; m.distributionInfo = new MD_Distribution_PropertyType { MD_Distribution = new MD_Distribution_Type { transferOptions = new[] { new MD_DigitalTransferOptions_PropertyType { MD_DigitalTransferOptions = new MD_DigitalTransferOptions_Type { onLine = new[] { new CI_OnlineResource_PropertyType { CI_OnlineResource = new CI_OnlineResource_Type { linkage = new URL_PropertyType { URL = "http://www.kartverket.no" } } } } } } } } }; var dqDataQualityType = new DQ_DataQuality_Type(); dqDataQualityType.scope = new DQ_Scope_PropertyType { DQ_Scope = new DQ_Scope_Type { level = new MD_ScopeCode_PropertyType { MD_ScopeCode = new CodeListValue_Type { codeList = "http://www.isotc211.org/2005/resources/codeList.xml#MD_ScopeCode", codeListValue = "dataset" } } } }; dqDataQualityType.lineage = new LI_Lineage_PropertyType { LI_Lineage = new LI_Lineage_Type { statement = CharString("Her kommer det en tekst om prosesshistorien.") } }; dqDataQualityType.report = new[] { new DQ_Element_PropertyType { AbstractDQ_Element = new DQ_DomainConsistency_Type { result = new [] { new DQ_Result_PropertyType { AbstractDQ_Result = new DQ_ConformanceResult_Type { specification = new CI_Citation_PropertyType { CI_Citation = new CI_Citation_Type { title = CharString("COMMISSION REGULATION (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services"), date = new CI_Date_PropertyType[] { new CI_Date_PropertyType { CI_Date = new CI_Date_Type { date = new Date_PropertyType { Item = "2010-12-08" }, dateType = new CI_DateTypeCode_PropertyType { CI_DateTypeCode = new CodeListValue_Type { codeList = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode", codeListValue = "publication" } } } } } } }, explanation = CharString("See the referenced specification"), pass = new Boolean_PropertyType { Boolean = true } } } } } } }; m.dataQualityInfo = new[] { new DQ_DataQuality_PropertyType { DQ_DataQuality = dqDataQualityType } }; m.referenceSystemInfo = new MD_ReferenceSystem_PropertyType[] { new MD_ReferenceSystem_PropertyType { MD_ReferenceSystem = new MD_ReferenceSystem_Type { referenceSystemIdentifier = new RS_Identifier_PropertyType { RS_Identifier = new RS_Identifier_Type { code = new CharacterString_PropertyType { CharacterString = "http://www.opengis.net/def/crs/EPSG/0/25831" }, codeSpace = new CharacterString_PropertyType { CharacterString = "EPSG" } } } } } }; return m; }
/// <summary> /// Update metadata record in GeoNorge. /// </summary> /// <param name="metadata"></param> /// <returns></returns> public MetadataTransaction MetadataUpdate(MD_Metadata_Type metadata, Dictionary<string, string> additionalRequestHeaders = null) { TransactionType request = _requestFactory.MetadataUpdate(metadata); return _requestRunner.RunCswTransaction(request, additionalRequestHeaders); }
/// <summary> /// Construct simple metadata object based on the opengis metadata. /// </summary> /// <param name="md">The original metadata object</param> public SimpleMetadata(MD_Metadata_Type md) { if (md == null) throw new ArgumentNullException("md", "Metadata cannot be null."); _md = md; }
private static SimpleMetadata CreateSimpleMetadata(string hierarchyLevel, AbstractMD_Identification_Type identification) { MD_Metadata_Type md = new MD_Metadata_Type { fileIdentifier = new CharacterString_PropertyType { CharacterString = Guid.NewGuid().ToString() }, identificationInfo = new MD_Identification_PropertyType[] { new MD_Identification_PropertyType { AbstractMD_Identification = identification } } }; SimpleMetadata simpleMetadata = new SimpleMetadata(md); simpleMetadata.HierarchyLevel = hierarchyLevel; return simpleMetadata; }