def applyLogFile(self, metaXML): # TODO: make more safe if self.leLogFile.text() == "": return logFile = codecs.open(self.leLogFile.text(), "r", encoding="utf-8") logFileContent = logFile.read() logFile.close() root = metaXML.documentElement() mdDataQualityInfo = utils.getOrIsertAfterChild(root, "dataQualityInfo", ["distributionInfo", "contentInfo", "identificationInfo"]) mdDQData = utils.getOrCreateChild(mdDataQualityInfo, "DQ_DataQuality") # check requirements (not need for log file) if mdDQData.firstChildElement("scope").isNull(): mdScope = utils.getOrIsertTopChild(mdDQData, "scope") mdDQScope = utils.getOrCreateChild(mdScope, "DQ_Scope") mdLevel = utils.getOrIsertTopChild(mdDQScope, "level") mdScopeCode = utils.getOrCreateChild(mdLevel, "MD_ScopeCode") mdScopeCode.setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode") mdScopeCode.setAttribute("codeListValue", "dataset") textNode = utils.getOrCreateTextChild(mdScopeCode) textNode.setNodeValue("dataset") mdLineage = utils.getOrCreateChild(mdDQData, "lineage") mdLiLineage = utils.getOrCreateChild(mdLineage, "LI_Lineage") mdProcessStep = utils.getOrCreateChild(mdLiLineage, "processStep") mdLIProcessStep = utils.getOrCreateChild(mdProcessStep, "LI_ProcessStep") mdDescription = utils.getOrIsertTopChild(mdLIProcessStep, "description") mdCharStringElement = utils.getOrCreateChild(mdDescription, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(logFileContent)
def applyWorkflowTemplate(self, metaXML): # TODO: make more safe #if self.cmbWorkflow.currentIndex() == -1: if self.cmbWorkflow.currentText() == self.translatedNoneLabel: return workflowTemplate = self.workflowTemplateManager.loadTemplate(self.cmbWorkflow.currentText()) root = metaXML.documentElement() mdDataQualityInfo = utils.getOrIsertAfterChild(root, "dataQualityInfo", ["distributionInfo", "contentInfo", "identificationInfo"]) mdDQData = utils.getOrCreateChild(mdDataQualityInfo, "DQ_DataQuality") # check requirements (not need for workflow) if mdDQData.firstChildElement("scope").isNull(): mdScope = utils.getOrIsertTopChild(mdDQData, "scope") mdDQScope = utils.getOrCreateChild(mdScope, "DQ_Scope") mdLevel = utils.getOrIsertTopChild(mdDQScope, "level") mdScopeCode = utils.getOrCreateChild(mdLevel, "MD_ScopeCode") mdScopeCode.setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_ScopeCode") mdScopeCode.setAttribute("codeListValue", "dataset") textNode = utils.getOrCreateTextChild(mdScopeCode) textNode.setNodeValue("dataset") mdLineage = utils.getOrCreateChild(mdDQData, "lineage") mdLiLineage = utils.getOrCreateChild(mdLineage, "LI_Lineage") mdStatement = utils.getOrIsertTopChild(mdLiLineage, "statement") mdCharStringElement = utils.getOrCreateChild(mdStatement, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(workflowTemplate.stringRepresentation())
def applyLicenseTemplate(self, metaXML): # TODO: make more safe #if self.cmbLicense.currentIndex() == -1: if self.cmbLicense.currentText() == self.translatedNoneLabel: return licenseTemplate = self.licenseTemplateManager.loadTemplate(self.cmbLicense.currentText()) root = metaXML.documentElement() mdIdentificationInfo = utils.getOrCreateChild(root, "identificationInfo") mdDataIdentification = utils.getOrCreateChild(mdIdentificationInfo, "MD_DataIdentification") mdResourceConstraints = utils.getOrIsertAfterChild(mdDataIdentification, "resourceConstraints", ["resourceSpecificUsage", "descriptiveKeywords", "resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract"]) mdLegalConstraintsElement = utils.getOrCreateChild(mdResourceConstraints, "MD_LegalConstraints") # useLimitation mdUseLimitationElement = utils.getOrCreateChild(mdLegalConstraintsElement, "useLimitation") mdCharStringElement = utils.getOrCreateChild(mdUseLimitationElement, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(licenseTemplate.stringRepresentation()) # useConstraints mdUseConstraintsElement = utils.getOrCreateChild(mdLegalConstraintsElement, "useConstraints") mdRestrictionCodeElement = utils.getOrCreateChild(mdUseConstraintsElement, "MD_RestrictionCode") mdRestrictionCodeElement.setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode") mdRestrictionCodeElement.setAttribute("codeListValue", "license") textNode = utils.getOrCreateTextChild(mdRestrictionCodeElement) textNode.setNodeValue("license")
def applyLicenseTemplate(self, metaXML): # TODO: make more safe #if self.cmbLicense.currentIndex() == -1: if self.cmbLicense.currentText() == self.translatedNoneLabel: return licenseTemplate = self.licenseTemplateManager.loadTemplate( self.cmbLicense.currentText()) root = metaXML.documentElement() mdIdentificationInfo = utils.getOrCreateChild(root, "identificationInfo") mdDataIdentification = utils.getOrCreateChild(mdIdentificationInfo, "MD_DataIdentification") mdResourceConstraints = utils.getOrIsertAfterChild( mdDataIdentification, "resourceConstraints", [ "resourceSpecificUsage", "descriptiveKeywords", "resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract" ]) mdLegalConstraintsElement = utils.getOrCreateChild( mdResourceConstraints, "MD_LegalConstraints") # useLimitation mdUseLimitationElement = utils.getOrCreateChild( mdLegalConstraintsElement, "useLimitation") mdCharStringElement = utils.getOrCreateChild(mdUseLimitationElement, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(licenseTemplate.stringRepresentation()) # useConstraints mdUseConstraintsElement = utils.getOrCreateChild( mdLegalConstraintsElement, "useConstraints") mdRestrictionCodeElement = utils.getOrCreateChild( mdUseConstraintsElement, "MD_RestrictionCode") mdRestrictionCodeElement.setAttribute( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode" ) mdRestrictionCodeElement.setAttribute("codeListValue", "license") textNode = utils.getOrCreateTextChild(mdRestrictionCodeElement) textNode.setNodeValue("license")
def applyLogFile(self, metaXML): # TODO: make more safe if self.leLogFile.text() == "": return logFile = codecs.open(self.leLogFile.text(), "r", encoding="utf-8") logFileContent = logFile.read() logFile.close() root = metaXML.documentElement() mdDataQualityInfo = utils.getOrIsertAfterChild( root, "dataQualityInfo", ["distributionInfo", "contentInfo", "identificationInfo"]) mdDQData = utils.getOrCreateChild(mdDataQualityInfo, "DQ_DataQuality") # check requirements (not need for log file) if mdDQData.firstChildElement("scope").isNull(): mdScope = utils.getOrIsertTopChild(mdDQData, "scope") mdDQScope = utils.getOrCreateChild(mdScope, "DQ_Scope") mdLevel = utils.getOrIsertTopChild(mdDQScope, "level") mdScopeCode = utils.getOrCreateChild(mdLevel, "MD_ScopeCode") mdScopeCode.setAttribute( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode" ) mdScopeCode.setAttribute("codeListValue", "dataset") textNode = utils.getOrCreateTextChild(mdScopeCode) textNode.setNodeValue("dataset") mdLineage = utils.getOrCreateChild(mdDQData, "lineage") mdLiLineage = utils.getOrCreateChild(mdLineage, "LI_Lineage") mdProcessStep = utils.getOrCreateChild(mdLiLineage, "processStep") mdLIProcessStep = utils.getOrCreateChild(mdProcessStep, "LI_ProcessStep") mdDescription = utils.getOrIsertTopChild(mdLIProcessStep, "description") mdCharStringElement = utils.getOrCreateChild(mdDescription, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(logFileContent)
def applyWorkflowTemplate(self, metaXML): # TODO: make more safe #if self.cmbWorkflow.currentIndex() == -1: if self.cmbWorkflow.currentText() == self.translatedNoneLabel: return workflowTemplate = self.workflowTemplateManager.loadTemplate( self.cmbWorkflow.currentText()) root = metaXML.documentElement() mdDataQualityInfo = utils.getOrIsertAfterChild( root, "dataQualityInfo", ["distributionInfo", "contentInfo", "identificationInfo"]) mdDQData = utils.getOrCreateChild(mdDataQualityInfo, "DQ_DataQuality") # check requirements (not need for workflow) if mdDQData.firstChildElement("scope").isNull(): mdScope = utils.getOrIsertTopChild(mdDQData, "scope") mdDQScope = utils.getOrCreateChild(mdScope, "DQ_Scope") mdLevel = utils.getOrIsertTopChild(mdDQScope, "level") mdScopeCode = utils.getOrCreateChild(mdLevel, "MD_ScopeCode") mdScopeCode.setAttribute( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" ) mdScopeCode.setAttribute("codeListValue", "dataset") textNode = utils.getOrCreateTextChild(mdScopeCode) textNode.setNodeValue("dataset") mdLineage = utils.getOrCreateChild(mdDQData, "lineage") mdLiLineage = utils.getOrCreateChild(mdLineage, "LI_Lineage") mdStatement = utils.getOrIsertTopChild(mdLiLineage, "statement") mdCharStringElement = utils.getOrCreateChild(mdStatement, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(workflowTemplate.stringRepresentation())
def applyDatatypeTemplate(self, metaXML): # TODO: make more safe if self.cmbDatatype.currentText() == self.translatedNoneLabel: return datatypeTemplate = self.datatypeTemplateManager.loadTemplate( self.cmbDatatype.currentText()) root = metaXML.documentElement() mdIdentificationInfo = utils.getOrCreateChild(root, "identificationInfo") mdDataIdentification = utils.getOrCreateChild(mdIdentificationInfo, "MD_DataIdentification") #insert type of data mdSpatialRep = utils.getOrIsertAfterChild( mdDataIdentification, "spatialRepresentationType", [ "aggregationInfo", "resourceConstraints", "resourceSpecificUsage", "descriptiveKeywords", "resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract" ]) mdSpatialRepTypeCode = utils.getOrCreateChild( mdSpatialRep, "MD_SpatialRepresentationTypeCode") mdSpatialRepTypeCode.setAttribute( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_SpatialRepresentationTypeCode" ) textNode = utils.getOrCreateTextChild(mdSpatialRepTypeCode) if datatypeTemplate.type == "vector": mdSpatialRepTypeCode.setAttribute("codeListValue", "vector") textNode.setNodeValue("vector") else: mdSpatialRepTypeCode.setAttribute("codeListValue", "grid") textNode.setNodeValue("grid") #adding raster type mdContentInfo = utils.getOrCreateChild(root, "contentInfo") mdImageDescription = utils.getOrCreateChild( mdContentInfo, "MD_ImageDescription") mdContentType = utils.getOrIsertAfterChild( mdImageDescription, "contentType", ["attributeDescription"]) mdContentTypeCode = utils.getOrCreateChild( mdContentType, "MD_CoverageContentTypeCode") mdContentTypeCode.setAttribute( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_CoverageContentTypeCode" ) mdContentTypeCode.setAttribute("codeListValue", datatypeTemplate.type) textNode = utils.getOrCreateTextChild(mdContentTypeCode) textNode.setNodeValue(datatypeTemplate.type) #insert keywords mdDescKeywords = utils.getOrIsertAfterChild( mdDataIdentification, "descriptiveKeywords", [ "resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract" ]) mdKeywords = utils.getOrCreateChild(mdDescKeywords, "MD_Keywords") for keyword in datatypeTemplate.keywords: mdKeyword = utils.insertAfterChild(mdKeywords, "keyword", [ "keyword", ]) mdString = utils.getOrCreateChild(mdKeyword, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdString) textNode.setNodeValue(keyword) mdType = utils.getOrIsertAfterChild(mdKeywords, "type", [ "keyword", ]) mdTypeCode = utils.getOrCreateChild(mdType, "MD_KeywordTypeCode") mdTypeCode.setAttribute( "codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_KeywordTypeCode" ) mdTypeCode.setAttribute("codeListValue", "theme") textNode = utils.getOrCreateTextChild(mdTypeCode) textNode.setNodeValue("theme") #drop all spatial scale/accuracy while not mdDataIdentification.firstChildElement( "spatialResolution").isNull(): mdDataIdentification.removeChild( mdDataIdentification.firstChildElement("spatialResolution")) #insert spatial scale mdSpatialResolution = utils.insertAfterChild( mdDataIdentification, "spatialResolution", [ "spatialRepresentationType", "aggregationInfo", "resourceConstraints", "resourceSpecificUsage", "descriptiveKeywords", "resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract" ]) mdResolution = utils.getOrCreateChild(mdSpatialResolution, "MD_Resolution") mdEqScale = utils.getOrIsertTopChild(mdResolution, "equivalentScale") mdFraction = utils.getOrCreateChild(mdEqScale, "MD_RepresentativeFraction") mdDenominator = utils.getOrCreateChild(mdFraction, "denominator") mdInteger = utils.getOrCreateChild(mdDenominator, "gco:Integer") textNode = utils.getOrCreateTextChild(mdInteger) textNode.setNodeValue(datatypeTemplate.scale) #insert spatial accuracy mdSpatialResolution = utils.insertAfterChild( mdDataIdentification, "spatialResolution", [ "spatialResolution", "spatialRepresentationType", "aggregationInfo", "resourceConstraints", "resourceSpecificUsage", "descriptiveKeywords", "resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract" ]) mdResolution = utils.getOrCreateChild(mdSpatialResolution, "MD_Resolution") mdDistance = utils.getOrCreateChild(mdResolution, "distance") mdGcoDistance = utils.getOrCreateChild(mdDistance, "gco:Distance") textNode = utils.getOrCreateTextChild(mdGcoDistance) textNode.setNodeValue(datatypeTemplate.accuracy) mdGcoDistance.setAttribute("uom", "M") #insert thematic accurancy?????? return
def applyInstitutionTemplate(self, metaXML): # TODO: make more safe #if self.cmbOrganization.currentIndex() == -1: if self.cmbOrganization.currentText() == self.translatedNoneLabel: return template = self.orgsTemplateManager.organizations[ self.cmbOrganization.currentText()] root = metaXML.documentElement() mdContact = utils.getOrCreateChild(root, "contact") mdResponsibleParty = utils.getOrCreateChild(mdContact, "CI_ResponsibleParty") # individualName mdIndividualName = utils.getOrCreateChild(mdResponsibleParty, "individualName") mdCharStringElement = utils.getOrCreateChild(mdIndividualName, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.person) # organisationName mdOrganisationName = utils.getOrCreateChild(mdResponsibleParty, "organisationName") mdCharStringElement = utils.getOrCreateChild(mdOrganisationName, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.name) # positionName mdPositionName = utils.getOrCreateChild(mdResponsibleParty, "positionName") mdCharStringElement = utils.getOrCreateChild(mdPositionName, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.position) # go deeper... fill contactInfo mdContactInfo = utils.getOrCreateChild(mdResponsibleParty, "contactInfo") mdCIContact = utils.getOrCreateChild(mdContactInfo, "CI_Contact") # hours of service mdHours = utils.getOrCreateChild(mdCIContact, "hoursOfService") mdCharStringElement = utils.getOrCreateChild(mdHours, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.hours) # fill phones mdPhone = utils.getOrCreateChild(mdCIContact, "phone") mdCIPhone = utils.getOrCreateChild(mdPhone, "CI_Telephone") mdVoice = utils.getOrCreateChild(mdCIPhone, "voice") mdCharStringElement = utils.getOrCreateChild(mdVoice, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.phone) mdFacsimile = utils.getOrCreateChild(mdCIPhone, "facsimile") mdCharStringElement = utils.getOrCreateChild(mdFacsimile, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.phone) # fill address mdAddress = utils.getOrCreateChild(mdCIContact, "address") mdCIAddress = utils.getOrCreateChild(mdAddress, "CI_Address") # deliveryPoint mdDeliveryPoint = utils.getOrCreateChild(mdCIAddress, "deliveryPoint") mdCharStringElement = utils.getOrCreateChild(mdDeliveryPoint, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.deliveryPoint) # city mdCity = utils.getOrCreateChild(mdCIAddress, "city") mdCharStringElement = utils.getOrCreateChild(mdCity, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.city) # administrativeArea mdAdminArea = utils.getOrCreateChild(mdCIAddress, "administrativeArea") mdCharStringElement = utils.getOrCreateChild(mdAdminArea, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.adminArea) # postalCode mdPostalCode = utils.getOrCreateChild(mdCIAddress, "postalCode") mdCharStringElement = utils.getOrCreateChild(mdPostalCode, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.postalCode) # country mdCountry = utils.getOrCreateChild(mdCIAddress, "country") mdCharStringElement = utils.getOrCreateChild(mdCountry, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.country) # email mdEmail = utils.getOrCreateChild(mdCIAddress, "electronicMailAddress") mdCharStringElement = utils.getOrCreateChild(mdEmail, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.email)
def applyDatatypeTemplate(self, metaXML): # TODO: make more safe if self.cmbDatatype.currentText() == self.translatedNoneLabel: return datatypeTemplate = self.datatypeTemplateManager.loadTemplate(self.cmbDatatype.currentText()) root = metaXML.documentElement() mdIdentificationInfo = utils.getOrCreateChild(root, "identificationInfo") mdDataIdentification = utils.getOrCreateChild(mdIdentificationInfo, "MD_DataIdentification") #insert type of data mdSpatialRep = utils.getOrIsertAfterChild(mdDataIdentification, "spatialRepresentationType", ["aggregationInfo", "resourceConstraints", "resourceSpecificUsage", "descriptiveKeywords", "resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract"]) mdSpatialRepTypeCode = utils.getOrCreateChild(mdSpatialRep, "MD_SpatialRepresentationTypeCode") mdSpatialRepTypeCode.setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_SpatialRepresentationTypeCode") textNode = utils.getOrCreateTextChild(mdSpatialRepTypeCode) if datatypeTemplate.type == "vector": mdSpatialRepTypeCode.setAttribute("codeListValue", "vector") textNode.setNodeValue("vector") else: mdSpatialRepTypeCode.setAttribute("codeListValue", "grid") textNode.setNodeValue("grid") #adding raster type mdContentInfo = utils.getOrCreateChild(root, "contentInfo") mdImageDescription = utils.getOrCreateChild(mdContentInfo, "MD_ImageDescription") mdContentType = utils.getOrIsertAfterChild(mdImageDescription, "contentType", ["attributeDescription"]) mdContentTypeCode = utils.getOrCreateChild(mdContentType, "MD_CoverageContentTypeCode") mdContentTypeCode.setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_CoverageContentTypeCode") mdContentTypeCode.setAttribute("codeListValue", datatypeTemplate.type) textNode = utils.getOrCreateTextChild(mdContentTypeCode) textNode.setNodeValue(datatypeTemplate.type) #insert keywords mdDescKeywords = utils.getOrIsertAfterChild(mdDataIdentification, "descriptiveKeywords", ["resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract"]) mdKeywords = utils.getOrCreateChild(mdDescKeywords, "MD_Keywords") for keyword in datatypeTemplate.keywords: mdKeyword = utils.insertAfterChild(mdKeywords, "keyword", ["keyword",]) mdString = utils.getOrCreateChild(mdKeyword, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdString) textNode.setNodeValue(keyword) mdType = utils.getOrIsertAfterChild(mdKeywords, "type", ["keyword",]) mdTypeCode = utils.getOrCreateChild(mdType, "MD_KeywordTypeCode") mdTypeCode.setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_KeywordTypeCode") mdTypeCode.setAttribute("codeListValue", "theme") textNode = utils.getOrCreateTextChild(mdTypeCode) textNode.setNodeValue("theme") #drop all spatial scale/accuracy while not mdDataIdentification.firstChildElement("spatialResolution").isNull(): mdDataIdentification.removeChild(mdDataIdentification.firstChildElement("spatialResolution")) #insert spatial scale mdSpatialResolution = utils.insertAfterChild(mdDataIdentification, "spatialResolution", ["spatialRepresentationType", "aggregationInfo", "resourceConstraints", "resourceSpecificUsage", "descriptiveKeywords", "resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract"]) mdResolution = utils.getOrCreateChild(mdSpatialResolution, "MD_Resolution") mdEqScale = utils.getOrIsertTopChild(mdResolution, "equivalentScale") mdFraction = utils.getOrCreateChild(mdEqScale, "MD_RepresentativeFraction") mdDenominator = utils.getOrCreateChild(mdFraction, "denominator") mdInteger = utils.getOrCreateChild(mdDenominator, "gco:Integer") textNode = utils.getOrCreateTextChild(mdInteger) textNode.setNodeValue(datatypeTemplate.scale) #insert spatial accuracy mdSpatialResolution = utils.insertAfterChild(mdDataIdentification, "spatialResolution", ["spatialResolution", "spatialRepresentationType", "aggregationInfo", "resourceConstraints", "resourceSpecificUsage", "descriptiveKeywords", "resourceFormat", "graphicOverview", "resourceMaintenance", "pointOfContact", "status", "credit", "purpose", "abstract"]) mdResolution = utils.getOrCreateChild(mdSpatialResolution, "MD_Resolution") mdDistance = utils.getOrCreateChild(mdResolution, "distance") mdGcoDistance = utils.getOrCreateChild(mdDistance, "gco:Distance") textNode = utils.getOrCreateTextChild(mdGcoDistance) textNode.setNodeValue(datatypeTemplate.accuracy) mdGcoDistance.setAttribute("uom", "M") #insert thematic accurancy?????? return
def applyInstitutionTemplate(self, metaXML): # TODO: make more safe #if self.cmbOrganization.currentIndex() == -1: if self.cmbOrganization.currentText() == self.translatedNoneLabel: return template = self.orgsTemplateManager.organizations[self.cmbOrganization.currentText()] root = metaXML.documentElement() mdContact = utils.getOrCreateChild(root, "contact") mdResponsibleParty = utils.getOrCreateChild(mdContact, "CI_ResponsibleParty") # individualName mdIndividualName = utils.getOrCreateChild(mdResponsibleParty, "individualName") mdCharStringElement = utils.getOrCreateChild(mdIndividualName, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.person) # organisationName mdOrganisationName = utils.getOrCreateChild(mdResponsibleParty, "organisationName") mdCharStringElement = utils.getOrCreateChild(mdOrganisationName, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.name) # positionName mdPositionName = utils.getOrCreateChild(mdResponsibleParty, "positionName") mdCharStringElement = utils.getOrCreateChild(mdPositionName, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.position) # go deeper... fill contactInfo mdContactInfo = utils.getOrCreateChild(mdResponsibleParty, "contactInfo") mdCIContact = utils.getOrCreateChild(mdContactInfo, "CI_Contact") # hours of service mdHours = utils.getOrCreateChild(mdCIContact, "hoursOfService") mdCharStringElement = utils.getOrCreateChild(mdHours, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.hours) # fill phones mdPhone = utils.getOrCreateChild(mdCIContact, "phone") mdCIPhone = utils.getOrCreateChild(mdPhone, "CI_Telephone") mdVoice = utils.getOrCreateChild(mdCIPhone, "voice") mdCharStringElement = utils.getOrCreateChild(mdVoice, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.phone) mdFacsimile = utils.getOrCreateChild(mdCIPhone, "facsimile") mdCharStringElement = utils.getOrCreateChild(mdFacsimile, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.phone) # fill address mdAddress = utils.getOrCreateChild(mdCIContact, "address") mdCIAddress = utils.getOrCreateChild(mdAddress, "CI_Address") # deliveryPoint mdDeliveryPoint = utils.getOrCreateChild(mdCIAddress, "deliveryPoint") mdCharStringElement = utils.getOrCreateChild(mdDeliveryPoint, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.deliveryPoint) # city mdCity = utils.getOrCreateChild(mdCIAddress, "city") mdCharStringElement = utils.getOrCreateChild(mdCity, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.city) # administrativeArea mdAdminArea = utils.getOrCreateChild(mdCIAddress, "administrativeArea") mdCharStringElement = utils.getOrCreateChild(mdAdminArea, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.adminArea) # postalCode mdPostalCode = utils.getOrCreateChild(mdCIAddress, "postalCode") mdCharStringElement = utils.getOrCreateChild(mdPostalCode, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.postalCode) # country mdCountry = utils.getOrCreateChild(mdCIAddress, "country") mdCharStringElement = utils.getOrCreateChild(mdCountry, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.country) # email mdEmail = utils.getOrCreateChild(mdCIAddress, "electronicMailAddress") mdCharStringElement = utils.getOrCreateChild(mdEmail, "gco:CharacterString") textNode = utils.getOrCreateTextChild(mdCharStringElement) textNode.setNodeValue(template.email)