Example #1
0
    def test_xtf_with_start_and_closing_tag(self):
        found_models = get_models_from_xtf(
            get_test_path("xtf/start_and_closing_tag.xtf"))
        # print(get_models_from_xtf("/docs/borrar/xtf/empty_element_tag.xtf"))
        expected_models = ['Datos_Gestor_Catastral_V2_9_6']

        self.assertEqual(expected_models, found_models)
Example #2
0
 def test_xtf_with_empty_element_tag(self):
     found_models = get_models_from_xtf(
         get_test_path("xtf/empty_element_tag.xtf"))
     expected_models = [
         'Datos_Gestor_Catastral_V2_9_6',
         'Datos_Integracion_Insumos_V2_9_6', 'Datos_SNR_V2_9_6',
         'ISO19107_PLANAS_V1', 'LADM_COL_V1_3'
     ]
     self.assertEqual(expected_models, found_models)
    def test_xtf_with_start_and_closing_tag(self):
        found_models = get_models_from_xtf(
            get_test_path("xtf/start_and_closing_tag.xtf"))
        # print(get_models_from_xtf("/docs/borrar/xtf/empty_element_tag.xtf"))
        expected_models = [
            LADMColModelRegistry().model(
                LADMNames.SUPPLIES_MODEL_KEY).full_name()
        ]

        self.assertEqual(expected_models, found_models)
 def test_xtf_with_empty_element_tag(self):
     found_models = get_models_from_xtf(
         get_test_path("xtf/empty_element_tag.xtf"))
     expected_models = [
         LADMColModelRegistry().model(
             LADMNames.SNR_DATA_SUPPLIES_MODEL_KEY).full_name(),
         LADMColModelRegistry().model(
             LADMNames.SUPPLIES_MODEL_KEY).full_name(),
         LADMColModelRegistry().model(
             LADMNames.SUPPLIES_INTEGRATION_MODEL_KEY).full_name()
     ]
     self.assertEqual(expected_models.sort(), found_models.sort())
Example #5
0
    def update_import_models(self):
        self.clear_messages()
        error_msg = None

        if not self.xtf_file_line_edit.text().strip():
            color = '#ffd356'  # Light orange
            self.import_models_qmodel = QStandardItemModel()
            self.import_models_list_view.setModel(self.import_models_qmodel)
        else:
            if os.path.isfile(self.xtf_file_line_edit.text().strip()):
                color = '#fff'  # White

                self.import_models_qmodel = QStandardItemModel()
                model_names = get_models_from_xtf(
                    self.xtf_file_line_edit.text().strip())

                for model in self.__ladmcol_models.supported_models():
                    if not model.hidden() and model.full_name() in model_names:
                        item = QStandardItem(model.full_alias())
                        item.setData(model.full_name(), Qt.UserRole)
                        item.setCheckable(False)
                        item.setEditable(False)
                        self.import_models_qmodel.appendRow(item)

                if self.import_models_qmodel.rowCount() > 0:
                    self.import_models_list_view.setModel(
                        self.import_models_qmodel)
                else:
                    error_msg = QCoreApplication.translate(
                        "DialogImportData",
                        "No models were found in the XTF. Is it a valid file?")
                    color = '#ffd356'  # Light orange
                    self.import_models_qmodel = QStandardItemModel()
                    self.import_models_list_view.setModel(
                        self.import_models_qmodel)
            else:
                error_msg = QCoreApplication.translate(
                    "DialogImportData", "Please set a valid XTF file")
                color = '#ffd356'  # Light orange
                self.import_models_qmodel = QStandardItemModel()
                self.import_models_list_view.setModel(
                    self.import_models_qmodel)
        self.xtf_file_line_edit.setStyleSheet(
            'QLineEdit {{ background-color: {} }}'.format(color))

        if error_msg:
            self.txtStdout.setText(error_msg)
            self.show_message(error_msg, Qgis.Warning)
            self.import_models_list_view.setFocus()
            return
Example #6
0
    def get_converters(self, source_xtf):
        converters = dict()  # {converter_key: name}

        if source_xtf:
            # Get models present in the source XTF
            models = get_models_from_xtf(source_xtf)
            self.logger.debug(__name__,
                              "Models found in source XTF: {}".format(models))

            # Ask the registry for converters that apply for those models
            if models:
                converters = self._converter_registry.get_converters_for_models(
                    models)
                self.logger.debug(
                    __name__,
                    "Converters found for source XTF models: {}".format(
                        list(converters.keys())))

        return converters
Example #7
0
    def apply_role_model_configuration(self, configuration):
        """
        Applies the configuration that the active role has set over models that are in both the DB and the XTF.

        Important:
        Note that this works better if the checked models are limited to one (e.g. Field Data Capture) or limited to
        a group of related models (e.g., the 3 supplies models). When the checked models are heterogeneous, results
        start to be unpredictable, as the configuration for a single model may affect the others.

        :param configuration: SchemaImportConfiguration object
        :return: configuration object updated
        """
        model_names = get_models_from_xtf(self.xtf_file_line_edit.text().strip())

        for model in self.__ladmcol_models.non_hidden_and_supported_models():
            if model.full_name() in model_names:  # We'll check models in the DB that are also in the XTF
                params = model.get_ili2db_params()
                if ILI2DB_IMPORT in params:
                    for param in params[ILI2DB_IMPORT]:  # List of tuples
                        if param[0] == ILI2DB_DATASET:  # param: (option, value)
                            configuration.dataset = param[1]
                            self.logger.debug(__name__, "Import XTF data into dataset '{}'! (taken from role config)".format(param[1]))

        return configuration