コード例 #1
0
  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)
コード例 #2
0
  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())
コード例 #3
0
  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")
コード例 #4
0
    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")
コード例 #5
0
    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)
コード例 #6
0
    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())
コード例 #7
0
    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
コード例 #8
0
  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