def _create_baskets(self):
        if self._valid_selection():
            db_connector = db_utils.get_db_connector(
                self._updated_configuration())
            if db_connector and db_connector.get_basket_handling:
                feedbacks = []
                for record in db_connector.get_topics_info():
                    dataset_tid = self.dataset_tableview.selectedIndexes(
                    )[0].data(int(DatasetModel.Roles.TID))
                    status, message = db_connector.create_basket(
                        dataset_tid,
                        ".".join([record["model"], record["topic"]]))
                    feedbacks.append((status, message))

                info_box = QMessageBox(self)
                info_box.setIcon(QMessageBox.Warning if len(
                    [feedback for feedback in feedbacks
                     if not feedback[0]]) else QMessageBox.Information)
                info_title = self.tr("Created baskets")
                info_box.setWindowTitle(info_title)
                info_box.setText("{}{}".format(
                    "\n".join([feedback[1] for feedback in feedbacks]),
                    "\n\nBe aware that the IDs of the baskets are created as UUIDs. To change that, edit the t_ili2db_basket table manually."
                    if len([feedback for feedback in feedbacks
                            if feedback[0]]) else "",
                ))
                info_box.exec_()
Ejemplo n.º 2
0
 def refresh_export_models(self):
     db_connector = db_utils.get_db_connector(
         self.export_data_configuration)
     self.current_models_model.refresh_model(db_connector)
     self.current_datasets_model.refresh_model(db_connector)
     self.current_baskets_model.refresh_model(db_connector)
     return
 def _add_dataset(self):
     db_connector = db_utils.get_db_connector(self._updated_configuration())
     if db_connector and db_connector.get_basket_handling:
         edit_dataset_dialog = EditDatasetDialog(self, db_connector)
         edit_dataset_dialog.exec_()
         self._refresh_datasets(self._updated_configuration())
         self._jump_to_entry(edit_dataset_dialog.dataset_line_edit.text())
 def _refresh_datasets(self, configuration):
     db_connector = db_utils.get_db_connector(configuration)
     if db_connector and db_connector.get_basket_handling:
         self._enable_dataset_handling(True)
         return self.dataset_model.refresh_model(db_connector)
     else:
         self._enable_dataset_handling(False)
         return self.dataset_model.clear()
Ejemplo n.º 5
0
 def _db_modelnames(self, configuration):
     db_connector = db_utils.get_db_connector(configuration)
     modelnames = list()
     if db_connector:
         if db_connector.db_or_schema_exists(
         ) and db_connector.metadata_exists():
             db_models = db_connector.get_models()
             regex = re.compile(r"(?:\{[^\}]*\}|\s)")
             for db_model in db_models:
                 for modelname in regex.split(db_model["modelname"]):
                     modelnames.append(modelname.strip())
     return modelnames
 def _refresh_schemadata_models(self):
     db_connector = db_utils.get_db_connector(self.current_configuration)
     self.schema_validations[
         self.current_schema_identificator
     ].models_model.refresh_model(db_connector)
     self.schema_validations[
         self.current_schema_identificator
     ].datasets_model.refresh_model(db_connector)
     self.schema_validations[
         self.current_schema_identificator
     ].baskets_model.refresh_model(db_connector)
     return
 def _edit_dataset(self):
     if self._valid_selection():
         db_connector = db_utils.get_db_connector(
             self._updated_configuration())
         if db_connector and db_connector.get_basket_handling:
             dataset = (
                 self.dataset_tableview.selectedIndexes()[0].data(
                     int(DatasetModel.Roles.TID)),
                 self.dataset_tableview.selectedIndexes()[0].data(
                     int(DatasetModel.Roles.DATASETNAME)),
             )
             edit_dataset_dialog = EditDatasetDialog(
                 self, db_connector, dataset)
             edit_dataset_dialog.exec_()
             self._refresh_datasets(self._updated_configuration())
             self._jump_to_entry(
                 edit_dataset_dialog.dataset_line_edit.text())
    def setup_dialog(self, basket_handling):
        self.db_connector = db_utils.get_db_connector(
            self.workflow_wizard.import_data_configuration
        )
        self.basket_handling = basket_handling

        if self.basket_handling:
            self._set_basket_defaults()
        else:
            self.file_table_view.setColumnHidden(
                gui_utils.SourceModel.Columns.IS_CATALOGUE, True
            )
            self.file_table_view.setColumnHidden(
                gui_utils.SourceModel.Columns.DATASET, True
            )
            self.datasetmanager_button.setHidden(True)
        self._update_referencedata_completer()
    def _create_default_dataset(self):
        self.print_info.emit(
            self.tr("Create the default dataset {}").format(
                DEFAULT_DATASETNAME),
            LogColor.COLOR_INFO,
        )
        db_connector = db_utils.get_db_connector(self.configuration)

        default_dataset_tid = None
        default_datasets_info_tids = [
            datasets_info["t_id"]
            for datasets_info in db_connector.get_datasets_info()
            if datasets_info["datasetname"] == DEFAULT_DATASETNAME
        ]
        if default_datasets_info_tids:
            default_dataset_tid = default_datasets_info_tids[0]
        else:
            status, message = db_connector.create_dataset(DEFAULT_DATASETNAME)
            self.print_info.emit(message, LogColor.COLOR_INFO)
            if status:
                default_datasets_info_tids = [
                    datasets_info["t_id"]
                    for datasets_info in db_connector.get_datasets_info()
                    if datasets_info["datasetname"] == DEFAULT_DATASETNAME
                ]
                if default_datasets_info_tids:
                    default_dataset_tid = default_datasets_info_tids[0]

        if default_dataset_tid is not None:
            for topic_record in db_connector.get_topics_info():
                status, message = db_connector.create_basket(
                    default_dataset_tid,
                    ".".join([topic_record["model"], topic_record["topic"]]),
                )
                self.print_info.emit(
                    self.tr("- {}").format(message), LogColor.COLOR_INFO)
        else:
            self.print_info.emit(
                self.
                tr("No default dataset created ({}) - do it manually in the dataset manager."
                   ).format(message),
                LogColor.COLOR_FAIL,
            )
Ejemplo n.º 10
0
 def refresh_import_models(self, silent=False):
     db_connector = db_utils.get_db_connector(
         self.import_schema_configuration)
     return self.import_models_model.refresh_model(self.source_model,
                                                   db_connector, silent)
Ejemplo n.º 11
0
 def _db_or_schema_exists(self, configuration):
     db_connector = db_utils.get_db_connector(configuration)
     if db_connector:
         return db_connector.db_or_schema_exists()
     return False
Ejemplo n.º 12
0
 def _basket_handling(self, configuration):
     db_connector = db_utils.get_db_connector(configuration)
     if db_connector:
         return db_connector.get_basket_handling()
     return False
 def _get_tid_handling(self):
     db_connector = db_utils.get_db_connector(self.configuration)
     return db_connector.get_tid_handling()