private static CharacterString_PropertyType CharString(string s) { var sp = new CharacterString_PropertyType(); sp.CharacterString = s; return(sp); }
private string GetStringOrNull(MD_Keyword keywordElement) { string keywordValue = null; var keyword = keywordElement.keyword; if (keyword.GetType() == typeof(PT_FreeText_PropertyType)) { CharacterString_PropertyType charString = keyword as CharacterString_PropertyType; if (charString != null) { keywordValue = charString.CharacterString; } } else if (keyword.GetType() == typeof(CharacterString_PropertyType)) { CharacterString_PropertyType charString = keyword as CharacterString_PropertyType; if (charString != null) { keywordValue = charString.CharacterString; } } else if (keyword.GetType() == typeof(Anchor_Type)) { Anchor_Type anchor = keyword as Anchor_Type; if (anchor != null) { keywordValue = anchor.Value; } } return(keywordValue); }
private string GetStringFromObject(object o) { Anchor_Type titleObject = o as Anchor_Type; CI_Citation_Title citation = o as CI_Citation_Title; if (titleObject != null) { return(titleObject.Value); } else if (citation != null) { CharacterString_PropertyType title = citation.item as CharacterString_PropertyType; return(title.CharacterString); } else { CharacterString_PropertyType title = o as CharacterString_PropertyType; return(title.CharacterString); } }
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) { CharacterString_PropertyType titleString = null; Anchor_Type titleObject = dataIdentification.citation.CI_Citation.title.item as Anchor_Type; if (titleObject != null) { titleString = toCharString(titleObject.Value); } else { titleString = dataIdentification.citation.CI_Citation.title.item as CharacterString_PropertyType; } title = titleString.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.keyword != null) { string keywordValue = GetStringOrNull(singleKeyword); keywords.Add(keywordValue); /** 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 }); }