Ejemplo n.º 1
0
    def __init__(self, iface):
        QDialog.__init__(self, iface.mainWindow())
        self.setupUi(self)
        self.iface = iface

        self.notif_bar = NotificationBar(self.vlNotification, 6000)
        self._apply_btn = self.buttonBox.button(QDialogButtonBox.Apply)
        self._reg_config = RegistryConfig()
        self._db_config = DatabaseConfig()

        # Connect signals
        self._apply_btn.clicked.connect(self.apply_settings)
        self.buttonBox.accepted.connect(self.on_accept)
        self.chk_pg_connections.toggled.connect(self._on_use_pg_connections)
        self.cbo_pg_connections.currentIndexChanged.connect(
            self._on_pg_profile_changed)
        self.btn_db_conn_clear.clicked.connect(self.clear_properties)
        self.btn_test_db_connection.clicked.connect(
            self._on_test_db_connection)
        self.btn_template_folder.clicked.connect(
            self._on_choose_doc_designer_template_path)
        self.btn_composer_out_folder.clicked.connect(
            self._on_choose_doc_generator_output_path)
        self.btn_test_docs_repo_conn.clicked.connect(
            self._on_test_cmis_connection)
        self.txt_atom_pub_url.textChanged.connect(self._on_cmis_url_changed)
        self.btn_holders_conf_file.clicked.connect(
            self._on_choose_holders_config_file)

        self._config = StdmConfiguration.instance()
        self.init_gui()
Ejemplo n.º 2
0
    def __init__(self, iface):
        QDialog.__init__(self, iface.mainWindow())
        self.setupUi(self)
        self.iface = iface

        self.notif_bar = NotificationBar(self.vlNotification, 6000)
        self._apply_btn = self.buttonBox.button(QDialogButtonBox.Apply)
        self._reg_config = RegistryConfig()
        self._db_config = DatabaseConfig()

        #Connect signals
        self._apply_btn.clicked.connect(self.apply_settings)
        self.buttonBox.accepted.connect(self.on_accept)
        self.chk_pg_connections.toggled.connect(self._on_use_pg_connections)
        self.cbo_pg_connections.currentIndexChanged.connect(
            self._on_pg_profile_changed)
        self.btn_db_conn_clear.clicked.connect(self.clear_properties)
        self.btn_test_db_connection.clicked.connect(self._on_test_connection)
        self.btn_supporting_docs.clicked.connect(
            self._on_choose_supporting_docs_path)
        self.btn_template_folder.clicked.connect(
            self._on_choose_doc_designer_template_path)
        self.btn_composer_out_folder.clicked.connect(
            self._on_choose_doc_generator_output_path)
        self.upgradeButton.toggled.connect(self.manage_upgrade)

        self._config = StdmConfiguration.instance()
        self._default_style_sheet = self.txtRepoLocation.styleSheet()

        self.manage_upgrade()

        self.init_gui()
Ejemplo n.º 3
0
    def __init__(self, iface):
        QDialog.__init__(self, iface.mainWindow())
        self.setupUi(self)

        QgsGui.enableAutoGeometryRestore(self)

        self.btn_composer_out_folder.setIcon(
            GuiUtils.get_icon('open_file.png'))
        self.btn_template_folder.setIcon(GuiUtils.get_icon('open_file.png'))
        self.btn_supporting_docs.setIcon(GuiUtils.get_icon('open_file.png'))

        self.iface = iface

        self.notif_bar = NotificationBar(self.vlNotification, 6000)
        self._apply_btn = self.buttonBox.button(QDialogButtonBox.Apply)
        self._reg_config = RegistryConfig()
        self._db_config = DatabaseConfig()

        version = version_from_metadata()
        #upgrade_label_text = self.label_9.text().replace(
        #'1.4', version.strip()
        #)
        #self.label_9.setText(upgrade_label_text)

        # Connect signals
        self._apply_btn.clicked.connect(self.apply_settings)
        self.buttonBox.accepted.connect(self.on_accept)
        self.chk_pg_connections.toggled.connect(self._on_use_pg_connections)
        self.cbo_pg_connections.currentIndexChanged.connect(
            self._on_pg_profile_changed)
        self.btn_db_conn_clear.clicked.connect(self.clear_properties)
        self.btn_test_db_connection.clicked.connect(self._on_test_connection)
        self.btn_supporting_docs.clicked.connect(
            self._on_choose_supporting_docs_path)
        self.btn_template_folder.clicked.connect(
            self._on_choose_doc_designer_template_path)
        self.btn_composer_out_folder.clicked.connect(
            self._on_choose_doc_generator_output_path)

        self._config = StdmConfiguration.instance()
        self._default_style_sheet = self.txtRepoLocation.styleSheet()

        #self.upgradeButton.toggled.connect(self.manage_upgrade)
        #self.manage_upgrade()

        self.init_gui()

        self.profile_entity_widget = None
        self.cache = None
        self.sort_record_widget = None

        self.tabWidget.setCurrentIndex(0)
        self.btnAdd.clicked.connect(self.add_sorting_column)
        self.init_sorting_widgets(self.cbo_profiles.currentText())
        self.cbo_profiles.currentIndexChanged.connect(self.profile_changed)
Ejemplo n.º 4
0
 def __init__(self, log_file, parent=None):
     """
     Database version updater that registers all database updaters.
     :param log_file: The log file object
     :type log_file: Object
     :param parent: The parent of the QObject
     :type parent: QWidget/NoneType
     """
     QObject.__init__(self, parent)
     self.config = StdmConfiguration.instance()
     self.log_file = log_file
Ejemplo n.º 5
0
 def load_config(self):
     """
     Load STDM configuration
     :return:
     """
     stdm_config = None
     if QFile.exists(HOME+"/stdm/configuration.stc"):
         stdm_config = QFile(CONFIG_FILE)
     ConfigurationFileSerializer(stdm_config)
     profiles = StdmConfiguration.instance().profiles
     return profiles
Ejemplo n.º 6
0
 def load_config(self):
     """
     Load STDM configuration
     :return:
     """
     stdm_config = None
     if QFile.exists(HOME + "/stdm/configuration.stc"):
         stdm_config = QFile(CONFIG_FILE)
     ConfigurationFileSerializer(stdm_config)
     profiles = StdmConfiguration.instance().profiles
     return profiles
Ejemplo n.º 7
0
 def __init__(self, log_file, parent=None):
     """
     Database version updater that registers all database updaters.
     :param log_file: The log file object
     :type log_file: Object
     :param parent: The parent of the QObject
     :type parent: QWidget/NoneType
     """
     QObject.__init__(self, parent)
     self.config = StdmConfiguration.instance()
     self.log_file = log_file
Ejemplo n.º 8
0
    def __init__(self, engine=None, parent=None):
        QObject.__init__(self, parent)

        self.config = StdmConfiguration.instance()
        self.engine = engine
        self.metadata = metadata

        #Use the default engine if None is specified.
        if self.engine is None:
            self.engine = STDMDb.instance().engine

        #Ensure there is a connectable set in the metadata
        if self.metadata.bind is None:
            self.metadata.bind = self.engine
Ejemplo n.º 9
0
def profile_and_user_views(profile, check_party=False):
    """
    Gets current profile and user views. If views has a valid profile prefix
    and not valid current profile entity, it will be excluded.
    :param profile: The profile object
    :type profile: Object
    :param check_party: A boolean to filter out party views based on multi_party
    If check party is True and multi_party is True, it excludes party views
    from the return
    :type check_party: Boolean
    :return: List of profile and user views
    :rtype: List
    """
    from stdm.data.pg_utils import (
        pg_views
    )
    from stdm.data.configuration.stdm_configuration import (
        StdmConfiguration
    )

    source_tables = []

    social_tenure = profile.social_tenure

    for view, entity in social_tenure.views.iteritems():

        # For party views, if check party is true, add party views.
        # If multi-party is false. Otherwise, add all party views - this is not
        # recommended for composer data source.
        if entity in social_tenure.parties:
            if check_party:
                if not social_tenure.multi_party:
                    source_tables.append(view)
            else:
                source_tables.append(view)

        else:
            source_tables.append(view)

    stdm_config = StdmConfiguration.instance()
    all_str_views = []
    for prof in stdm_config.profiles.values():
        all_str_views.extend(prof.social_tenure.views.keys())

    for value in pg_views():
        #if value not in all_str_views:  #and value not in source_tables:
        #if value[:2] == profile.prefix:
        if value not in source_tables:
            source_tables.append(value)
    return source_tables
Ejemplo n.º 10
0
def profile_and_user_views(profile, check_party=False):
    """
    Gets current profile and user views. If views has a valid profile prefix
    and not valid current profile entity, it will be excluded.
    :param profile: The profile object
    :type profile: Object
    :param check_party: A boolean to filter out party views based on multi_party
    If check party is True and multi_party is True, it excludes party views
    from the return
    :type check_party: Boolean
    :return: List of profile and user views
    :rtype: List
    """
    from stdm.data.pg_utils import (pg_views)
    from stdm.data.configuration.stdm_configuration import (StdmConfiguration)
    source_tables = []
    stdm_config = StdmConfiguration.instance()
    social_tenure = profile.social_tenure
    for value in pg_views():
        if 'vw_social_tenure_relationship' in value:
            # if a value exist on the left side of vw, assess further
            if len(value.split('_vw')) > 0:
                entity = value.split('_vw')[0]
                # we are more sure this could be entity
                if '_' in entity and len(entity.split('_')) > 0:
                    # if the prefix exist in the configuration
                    if entity.split('_')[0] in \
                            stdm_config.prefixes():
                        # Check if the entity is in the current profile
                        entity_obj = profile.entity_by_name(entity)
                        if entity_obj is not None:
                            if check_party and entity_obj in social_tenure.parties:
                                if not social_tenure.multi_party:
                                    source_tables.append(value)
                            else:
                                source_tables.append(value)
                    # it means this is not a valid entity so add it
                    else:
                        source_tables.append(value)
                # it is a user view; add it to the combo list.
                else:
                    source_tables.append(value)
            # it is a user view; add it to the combo list.
            else:
                source_tables.append(value)
        else:
            source_tables.append(value)

    return source_tables
Ejemplo n.º 11
0
 def __init__(self, document, log_file, parent=None):
     """
     Initializes ConfigurationVersionUpdater.
     :param document: The configuration to be updated.
     :type document: QDomDocument
     :param log_file: The log file object
     :type log_file: file
     :param parent: The parent of QObject
     :type parent: QWidget/NoneType
     """
     QObject.__init__(self, parent)
     self.document = document
     self.log_file = log_file
     self.config = StdmConfiguration.instance()
     self.config_utils = ConfigurationUtils(document)
     self.profiles_detail = OrderedDict()
Ejemplo n.º 12
0
 def __init__(self, document, log_file, parent=None):
     """
     Initializes ConfigurationVersionUpdater.
     :param document: The configuration to be updated.
     :type document: QDomDocument
     :param log_file: The log file object
     :type log_file: file
     :param parent: The parent of QObject
     :type parent: QWidget/NoneType
     """
     QObject.__init__(self, parent)
     self.document = document
     self.log_file = log_file
     self.config = StdmConfiguration.instance()
     self.config_utils = ConfigurationUtils(document)
     self.profiles_detail = OrderedDict()
Ejemplo n.º 13
0
def table_to_profile_name(table_name):
    """
    Get profile name from prefix.
    :param table_name: The name of the table.
    :type prefix: String
    :return: Profile name.
    :rtype: String
    """
    from stdm.data.configuration.stdm_configuration import (StdmConfiguration)
    prefix = table_name.split('_', 1)[0]

    config = StdmConfiguration.instance()
    profile_name = [
        p.name for p in config.profiles.values() if p.prefix == prefix
    ]

    return profile_name[0]
Ejemplo n.º 14
0
def user_non_profile_views():
    """
    Gets and return user based views excluding profile views in the configuration.
    :return: User views
    :rtype: List
    """
    from stdm.data.configuration.stdm_configuration import (StdmConfiguration)
    from stdm.data.pg_utils import (pg_views)
    source_tables = []
    stdm_config = StdmConfiguration.instance()
    all_str_views = []
    for prof in stdm_config.profiles.values():
        all_str_views.extend(prof.social_tenure.views.keys())

    for value in pg_views():
        if value not in all_str_views:
            source_tables.append(value)
    return source_tables
Ejemplo n.º 15
0
def current_profile():
    """
    :return: Returns text on current profile in the configuration currently
    being used.
    :rtype: Profile
    """
    from stdm.data.configuration.stdm_configuration import StdmConfiguration

    reg_config = RegistryConfig()
    profile_info = reg_config.read([CURRENT_PROFILE])
    profile_name = profile_info.get(CURRENT_PROFILE, '')

    # Return None if there is no current profile
    if not profile_name:
        return None

    profiles = StdmConfiguration.instance().profiles

    return profiles.get(unicode(profile_name), None)
Ejemplo n.º 16
0
def current_profile():
    """
    :return: Returns text on current profile in the configuration currently
    being used.
    :rtype: Profile
    """
    from stdm.data.configuration.stdm_configuration import StdmConfiguration

    reg_config = RegistryConfig()
    profile_info = reg_config.read([CURRENT_PROFILE])
    profile_name = profile_info.get(CURRENT_PROFILE, '')

    #Return None if there is no current profile
    if not profile_name:
        return None

    profiles = StdmConfiguration.instance().profiles

    return profiles.get(unicode(profile_name), None)
Ejemplo n.º 17
0
    def __init__(self, iface):
        QDialog.__init__(self, iface.mainWindow())
        self.setupUi(self)
        self.iface = iface

        self.notif_bar = NotificationBar(self.vlNotification, 6000)
        self._apply_btn = self.buttonBox.button(QDialogButtonBox.Apply)
        self._reg_config = RegistryConfig()
        self._db_config = DatabaseConfig()

        version = version_from_metadata()
        upgrade_label_text = self.label_9.text().replace('1.4', version)
        self.label_9.setText(upgrade_label_text)

        #Connect signals
        self._apply_btn.clicked.connect(self.apply_settings)
        self.buttonBox.accepted.connect(self.on_accept)
        self.chk_pg_connections.toggled.connect(self._on_use_pg_connections)
        self.cbo_pg_connections.currentIndexChanged.connect(
            self._on_pg_profile_changed)
        self.btn_db_conn_clear.clicked.connect(self.clear_properties)
        self.btn_test_db_connection.clicked.connect(self._on_test_connection)
        self.btn_supporting_docs.clicked.connect(
            self._on_choose_supporting_docs_path)
        self.btn_template_folder.clicked.connect(
            self._on_choose_doc_designer_template_path)
        self.btn_composer_out_folder.clicked.connect(
            self._on_choose_doc_generator_output_path)
        self.upgradeButton.toggled.connect(self.manage_upgrade)

        self._config = StdmConfiguration.instance()
        self._default_style_sheet = self.txtRepoLocation.styleSheet()

        self.manage_upgrade()

        self.sort_order = OrderedDict()
        self.sort_order['idasc'] = 'ID - Smallest to Biggest'
        self.sort_order['iddesc'] = 'ID - Biggest to Smallest'
        self.sort_order['asc'] = 'Smallest to Biggest'
        self.sort_order['desc'] = 'Biggest to Smallest'

        self.init_gui()
Ejemplo n.º 18
0
    def __init__(self, iface):
        QDialog.__init__(self, iface.mainWindow())
        self.setupUi(self)
        self.iface = iface

        self.notif_bar = NotificationBar(self.vlNotification, 6000)
        self._apply_btn = self.buttonBox.button(QDialogButtonBox.Apply)
        self._reg_config = RegistryConfig()
        self._db_config = DatabaseConfig()

        version = version_from_metadata()
        upgrade_label_text = self.label_9.text().replace('1.4', version)
        self.label_9.setText(upgrade_label_text)

        #Connect signals
        self._apply_btn.clicked.connect(self.apply_settings)
        self.buttonBox.accepted.connect(self.on_accept)
        self.chk_pg_connections.toggled.connect(self._on_use_pg_connections)
        self.cbo_pg_connections.currentIndexChanged.connect(
            self._on_pg_profile_changed)
        self.btn_db_conn_clear.clicked.connect(self.clear_properties)
        self.btn_test_db_connection.clicked.connect(self._on_test_connection)
        self.btn_supporting_docs.clicked.connect(
            self._on_choose_supporting_docs_path
        )
        self.btn_template_folder.clicked.connect(
            self._on_choose_doc_designer_template_path
        )
        self.btn_composer_out_folder.clicked.connect(
            self._on_choose_doc_generator_output_path
        )
        self.upgradeButton.toggled.connect(
            self.manage_upgrade
        )

        self._config = StdmConfiguration.instance()
        self._default_style_sheet = self.txtRepoLocation.styleSheet()

        self.manage_upgrade()

        self.init_gui()
Ejemplo n.º 19
0
    def __init__(self, old_new_tables):
        """
        Updates template views.
        :param old_new_tables: Dictionary of old and new tables.
        :type old_new_tables: Dictionary
        :return:
        :rtype:
        """
        if len(old_new_tables) < 1:
            return

        self.profile_name = list(old_new_tables.keys())[0].lower()
        self.prefix = self.profile_name[:2]
        self.old_new_tables = list(old_new_tables.values())[0]

        self.documents_path = source_documents_path()

        self.supporting_doc_columns = {
            'social_tenure_id': 'social_tenure_relationship_id',
            'source_doc_id': 'supporting_doc_id'
        }
        config = StdmConfiguration.instance()
        self.updater = ConfigurationFileUpdater(iface)
        self.all_profiles = list(config.profiles.keys())
Ejemplo n.º 20
0
    def __init__(self, old_new_tables):
        """
        Updates template views.
        :param old_new_tables: Dictionary of old and new tables.
        :type old_new_tables: Dictionary
        :return:
        :rtype:
        """
        if len(old_new_tables) < 1:
            return

        self.profile_name = old_new_tables.keys()[0].lower()
        self.prefix = self.profile_name[:2]
        self.old_new_tables = old_new_tables.values()[0]

        self.documents_path = source_documents_path()

        self.supporting_doc_columns = {
            'social_tenure_id': 'social_tenure_relationship_id',
            'source_doc_id': 'supporting_doc_id'
        }
        config = StdmConfiguration.instance()
        self.updater = ConfigurationFileUpdater(iface)
        self.all_profiles = config.profiles.keys()
Ejemplo n.º 21
0
 def setUp(self):
     self.config = StdmConfiguration.instance()
Ejemplo n.º 22
0
 def setUp(self):
     self.config = StdmConfiguration.instance()
Ejemplo n.º 23
0
 def setUp(self):
     self.config = StdmConfiguration.instance()
     self.profile = add_basic_profile(self.config)
Ejemplo n.º 24
0
 def setUp(self):
     self.config = StdmConfiguration.instance()
     self.profile = add_basic_profile(self.config)
Ejemplo n.º 25
0
 def setUp(self):
     self.config = StdmConfiguration.instance()
     self.serializer = ConfigurationFileSerializer(config_path)
Ejemplo n.º 26
0
 def setUp(self):
     self.config = StdmConfiguration.instance()
     populate_configuration(self.config)
Ejemplo n.º 27
0
 def setUp(self):
     self.config = StdmConfiguration.instance()
     populate_configuration(self.config)