Exemplo n.º 1
0
    def _fill_dataset_db_model(self, dataset: Dataset):
        """ Fills a Dataset db record from the ISOMetadata data

        Args:
            dataset (Dataset): The old/empty object
        Returns:
             dataset (Dataset): The dataset object
        """
        dataset.language_code = self.language
        dataset.character_set_code = self.character_set_code or "utf8"
        dataset.hierarchy_level_code = self.hierarchy_level
        dataset.update_frequency_code = self.update_frequency
        dataset.update_frequency_code = self.update_frequency
        dataset.legal_restriction_code = None
        dataset.date_stamp = self.date_stamp
        dataset.metadata_standard_name = self.md_standard_name
        dataset.metadata_standard_version = self.md_standard_version
        dataset.reference_system_code = self.ref_system
        dataset.reference_system_version = self.ref_system_version
        dataset.reference_system_authority_title = self.ref_system_authority
        dataset.md_identifier_code = self.file_identifier
        dataset.distribution_function_code = self.distribution_function or "dataset"
        dataset.lineage_statement = self.lineage
        dataset.legal_restriction_other_constraints = self.access_constraints
        dataset.use_limitation = self.use_limitation

        return dataset
Exemplo n.º 2
0
    def _fill_metadata_dataset_identification_form(data: dict, metadata: Metadata, dataset: Dataset, user: MrMapUser):
        """ Fills form data into Metadata/Dataset records

        Args:
            data (dict): Cleaned form data
            metadata (dict): The metadata record
            dataset (dict): The dataset record
            user: The performing user
        Returns:

        """
        metadata.title = data.get("title", None)
        metadata.abstract = data.get("abstract", None)
        metadata.created = data.get("date_stamp", None)
        metadata.created_by = data.get("created_by", None)

        dataset.language_code = data.get("language_code", None)
        dataset.character_set_code = data.get("character_set_code", None)
        dataset.date_stamp = data.get("date_stamp", None)

        ref_systems = data.get("reference_system", [])
        metadata.reference_system.clear()
        for ref_system in ref_systems:
            metadata.reference_system.add(ref_system)

        additional_related_objects = data.get("additional_related_objects", [])
        MetadataRelation.objects.filter(to_metadata=metadata, origin=ResourceOriginEnum.EDITOR.value).delete()
        for additional_object in additional_related_objects:
            additional_object.add_metadata_relation(to_metadata=metadata,
                                                    relation_type=MetadataRelationEnum.DESCRIBES.value,
                                                    internal=True,
                                                    origin=ResourceOriginEnum.EDITOR.value)
Exemplo n.º 3
0
 def _create_dataset_from_md_metadata(self, md_metadata: Element,
                                      metadata: Metadata) -> Dataset:
     """ Creates a Dataset record from xml data
     Args:
         md_metadata (Element): The xml element which holds the data
         metadata (Metadata): The related metadata element
     Returns:
         dataset (Dataset): The dataset record
     """
     dataset = Dataset()
     dataset.language_code = metadata.language_code
     dataset.language_code_list_url = xml_helper.try_get_attribute_from_xml_element(
         md_metadata, "codeList",
         ".//" + GENERIC_NAMESPACE_TEMPLATE.format("language") + "/" +
         GENERIC_NAMESPACE_TEMPLATE.format("LanguageCode"))
     dataset.character_set_code = xml_helper.try_get_text_from_xml_element(
         md_metadata,
         ".//" + GENERIC_NAMESPACE_TEMPLATE.format("characterSet") + "/" +
         GENERIC_NAMESPACE_TEMPLATE.format("MD_CharacterSetCode"))
     dataset.character_set_code_list_url = xml_helper.try_get_attribute_from_xml_element(
         md_metadata, "codeList",
         ".//" + GENERIC_NAMESPACE_TEMPLATE.format("characterSet") + "/" +
         GENERIC_NAMESPACE_TEMPLATE.format("MD_CharacterSetCode"))
     dataset.date_stamp = xml_helper.try_get_text_from_xml_element(
         md_metadata,
         ".//" + GENERIC_NAMESPACE_TEMPLATE.format("dateStamp") + "/" +
         GENERIC_NAMESPACE_TEMPLATE.format("Date"))
     dataset.metadata_standard_name = xml_helper.try_get_text_from_xml_element(
         md_metadata,
         ".//" + GENERIC_NAMESPACE_TEMPLATE.format("metadataStandardName") +
         "/" + GENERIC_NAMESPACE_TEMPLATE.format("CharacterString"))
     dataset.metadata_standard_version = xml_helper.try_get_text_from_xml_element(
         md_metadata, ".//" +
         GENERIC_NAMESPACE_TEMPLATE.format("metadataStandardVersion") +
         "/" + GENERIC_NAMESPACE_TEMPLATE.format("CharacterString"))
     dataset.update_frequency_code = xml_helper.try_get_text_from_xml_element(
         md_metadata, ".//" +
         GENERIC_NAMESPACE_TEMPLATE.format("MD_MaintenanceFrequencyCode"))
     dataset.update_frequency_code_list_url = xml_helper.try_get_attribute_from_xml_element(
         md_metadata, "codeList", ".//" +
         GENERIC_NAMESPACE_TEMPLATE.format("MD_MaintenanceFrequencyCode"))
     dataset.use_limitation = xml_helper.try_get_text_from_xml_element(
         md_metadata,
         ".//" + GENERIC_NAMESPACE_TEMPLATE.format("useLimitation") + "/" +
         GENERIC_NAMESPACE_TEMPLATE.format("CharacterString"))
     dataset.lineage_statement = xml_helper.try_get_text_from_xml_element(
         md_metadata,
         ".//" + GENERIC_NAMESPACE_TEMPLATE.format("statement") + "/" +
         GENERIC_NAMESPACE_TEMPLATE.format("CharacterString"))
     return dataset