Ejemplo n.º 1
0
    def compare(self, **kwargs):
        """
        This function is used to compare all the objects
        from two different schemas.

        :param kwargs:
        :return:
        """
        source_params = {'sid': kwargs.get('source_sid'),
                         'did': kwargs.get('source_did')}
        target_params = {'sid': kwargs.get('target_sid'),
                         'did': kwargs.get('target_did')}
        ignore_owner = kwargs.get('ignore_owner', False)
        ignore_whitespaces = kwargs.get('ignore_whitespaces', False)

        group_name = kwargs.get('group_name')
        source_schema_name = kwargs.get('source_schema_name', None)
        source = {}
        target = {}

        status, target_schema = self.get_schema(kwargs.get('target_sid'),
                                                kwargs.get('target_did'),
                                                kwargs.get('target_scid'))
        if not status:
            return internal_server_error(errormsg=target_schema)

        if group_name == 'Database Objects':
            source = self.fetch_objects_to_compare(**source_params)
            target = self.fetch_objects_to_compare(**target_params)
        else:
            source_params['scid'] = kwargs.get('source_scid')
            target_params['scid'] = kwargs.get('target_scid')

            if 'scid' in source_params and source_params['scid'] is not None:
                source = self.fetch_objects_to_compare(**source_params)

            if 'scid' in target_params and target_params['scid'] is not None:
                target = self.fetch_objects_to_compare(**target_params)

        # If both the dict have no items then return None.
        if not (source or target) or not \
            (isinstance(source, dict) and isinstance(target, dict)) or \
                (len(source) <= 0 and len(target) <= 0):
            return None

        return compare_dictionaries(view_object=self,
                                    source_params=source_params,
                                    target_params=target_params,
                                    target_schema=target_schema,
                                    source_dict=source,
                                    target_dict=target,
                                    node=self.node_type,
                                    node_label=self.blueprint.collection_label,
                                    group_name=group_name,
                                    ignore_keys=self.keys_to_ignore,
                                    source_schema_name=source_schema_name,
                                    ignore_owner=ignore_owner,
                                    ignore_whitespaces=ignore_whitespaces)
Ejemplo n.º 2
0
    def compare(self, **kwargs):
        """
        This function is used to compare all the objects
        from two different schemas.

        :param kwargs:
        :return:
        """
        source_params = {
            'sid': kwargs.get('source_sid'),
            'did': kwargs.get('source_did')
        }
        target_params = {
            'sid': kwargs.get('target_sid'),
            'did': kwargs.get('target_did')
        }

        group_name = kwargs.get('group_name')
        ignore_whitespaces = kwargs.get('ignore_whitespaces')
        source_schema_name = kwargs.get('source_schema_name', None)
        source = {}
        target = {}

        if group_name == 'Database Objects':
            source = self.fetch_objects_to_compare(**source_params)
            target = self.fetch_objects_to_compare(**target_params)
        else:
            source_params['scid'] = kwargs.get('source_scid')
            target_params['scid'] = kwargs.get('target_scid')

            if 'scid' in source_params and source_params['scid'] is not None:
                source = self.fetch_objects_to_compare(**source_params)

            if 'scid' in target_params and target_params['scid'] is not None:
                target = self.fetch_objects_to_compare(**target_params)

        # If both the dict have no items then return None.
        if not (source or target) or (len(source) <= 0 and len(target) <= 0):
            return None

        return compare_dictionaries(view_object=self,
                                    source_params=source_params,
                                    target_params=target_params,
                                    source_dict=source,
                                    target_dict=target,
                                    node=self.node_type,
                                    node_label=self.blueprint.collection_label,
                                    group_name=group_name,
                                    ignore_whitespaces=ignore_whitespaces,
                                    ignore_keys=self.keys_to_ignore,
                                    source_schema_name=source_schema_name)
Ejemplo n.º 3
0
    def compare(self, **kwargs):
        """
        This function is used to compare all the table objects
        from two different schemas.

        :param kwargs:
        :return:
        """
        source_params = {
            'sid': kwargs.get('source_sid'),
            'did': kwargs.get('source_did'),
            'scid': kwargs.get('source_scid')
        }
        target_params = {
            'sid': kwargs.get('target_sid'),
            'did': kwargs.get('target_did'),
            'scid': kwargs.get('target_scid')
        }

        group_name = kwargs.get('group_name')
        source_schema_name = kwargs.get('source_schema_name', None)
        source_tables = {}
        target_tables = {}

        status, target_schema = self.get_schema(**target_params)
        if not status:
            return internal_server_error(errormsg=target_schema)

        if 'scid' in source_params and source_params['scid'] is not None:
            source_tables = self.fetch_tables(**source_params)

        if 'scid' in target_params and target_params['scid'] is not None:
            target_tables = self.fetch_tables(**target_params)

        # If both the dict have no items then return None.
        if not (source_tables or target_tables) or (len(source_tables) <= 0 and
                                                    len(target_tables) <= 0):
            return None

        return compare_dictionaries(view_object=self,
                                    source_params=source_params,
                                    target_params=target_params,
                                    target_schema=target_schema,
                                    source_dict=source_tables,
                                    target_dict=target_tables,
                                    node=self.node_type,
                                    node_label=self.blueprint.collection_label,
                                    group_name=group_name,
                                    ignore_keys=self.keys_to_ignore,
                                    source_schema_name=source_schema_name)
Ejemplo n.º 4
0
    def compare(self, **kwargs):
        """
        This function is used to compare all the objects
        from two different schemas.

        :param kwargs:
        :return:
        """

        source_params = {
            'sid': kwargs.get('source_sid'),
            'did': kwargs.get('source_did'),
            'scid': kwargs.get('source_scid')
        }

        target_params = {
            'sid': kwargs.get('target_sid'),
            'did': kwargs.get('target_did'),
            'scid': kwargs.get('target_scid')
        }

        ignore_whitespaces = kwargs.get('ignore_whitespaces')
        status, target_schema = self.get_schema(kwargs.get('target_sid'),
                                                kwargs.get('target_did'),
                                                kwargs.get('target_scid'))
        if not status:
            return internal_server_error(errormsg=target_schema)

        source = self.fetch_objects_to_compare(**source_params)

        target = self.fetch_objects_to_compare(**target_params)

        # If both the dict have no items then return None.
        if not (source or target) or (len(source) <= 0 and len(target) <= 0):
            return None

        return compare_dictionaries(view_object=self,
                                    source_params=source_params,
                                    target_params=target_params,
                                    target_schema=target_schema,
                                    source_dict=source,
                                    target_dict=target,
                                    node=self.node_type,
                                    node_label=self.blueprint.collection_label,
                                    ignore_whitespaces=ignore_whitespaces,
                                    ignore_keys=self.keys_to_ignore)
Ejemplo n.º 5
0
    def compare(self, **kwargs):
        """
        This function is used to compare all the objects
        from two different schemas.

        :param kwargs:
        :return:
        """

        source_params = {
            'sid': kwargs.get('source_sid'),
            'did': kwargs.get('source_did'),
            'scid': kwargs.get('source_scid')
        }

        target_params = {
            'sid': kwargs.get('target_sid'),
            'did': kwargs.get('target_did'),
            'scid': kwargs.get('target_scid')
        }

        status, target_schema = self.get_schema(kwargs.get('target_sid'),
                                                kwargs.get('target_did'),
                                                kwargs.get('target_scid'))
        if not status:
            return internal_server_error(errormsg=target_schema)

        source = self.fetch_objects_to_compare(**source_params)

        target = self.fetch_objects_to_compare(**target_params)

        # If both the dict have no items then return None.
        if not (source or target) or (len(source) <= 0 and len(target) <= 0):
            return None

        return compare_dictionaries(self, source_params, target_params,
                                    target_schema, source, target,
                                    self.node_type,
                                    gettext(self.blueprint.COLLECTION_LABEL),
                                    self.keys_to_ignore)
Ejemplo n.º 6
0
    def compare(self, **kwargs):
        """
        This function is used to compare all the objects
        from two different schemas.

        :param kwargs:
        :return:
        """

        source_params = {
            'sid': kwargs.get('source_sid'),
            'did': kwargs.get('source_did'),
            'scid': kwargs.get('source_scid')
        }

        target_params = {
            'sid': kwargs.get('target_sid'),
            'did': kwargs.get('target_did'),
            'scid': kwargs.get('target_scid')
        }

        if 'source_tid' in kwargs:
            source_params['tid'] = kwargs['source_tid']
        if 'target_tid' in kwargs:
            target_params['tid'] = kwargs['target_tid']

        source = self.fetch_objects_to_compare(**source_params)

        target = self.fetch_objects_to_compare(**target_params)

        # If both the dict have no items then return None.
        if not (source or target) or (len(source) <= 0 and len(target) <= 0):
            return None

        return compare_dictionaries(source, target, self.node_type,
                                    self.blueprint.COLLECTION_LABEL,
                                    self.keys_to_ignore)
Ejemplo n.º 7
0
    def compare(self, **kwargs):
        """
        This function is used to compare all the table objects
        from two different schemas.

        :return: Comparison Dictionary
        """
        src_sid = kwargs.get('source_sid')
        src_did = kwargs.get('source_did')
        src_scid = kwargs.get('source_scid')
        tar_sid = kwargs.get('target_sid')
        tar_did = kwargs.get('target_did')
        tar_scid = kwargs.get('target_scid')
        sub_modules = ['index', 'rule', 'trigger']

        source_tables = self.fetch_tables(sid=src_sid,
                                          did=src_did,
                                          scid=src_scid)

        target_tables = self.fetch_tables(sid=tar_sid,
                                          did=tar_did,
                                          scid=tar_scid)

        if self.manager.version >= 120000:
            sub_modules.append('compound_trigger')

        # If both the dict have no items then return None.
        if not (source_tables or target_tables) or (len(source_tables) <= 0 and
                                                    len(target_tables) <= 0):
            return None

        src_server_type, tar_server_type = self.get_server_type(
            src_sid, tar_sid)
        for module in sub_modules:

            module_view = SchemaDiffRegistry.get_node_view(module)

            # Get sub module data for source tables
            if module_view.blueprint.server_type is None or \
                    src_server_type in module_view.blueprint.server_type:
                for key, val in source_tables.items():
                    source = module_view.fetch_objects_to_compare(
                        sid=src_sid,
                        did=src_did,
                        scid=src_scid,
                        tid=val['oid'],
                        oid=None,
                        ignore_keys=True)
                    source_tables[key][module] = source

            # Get sub module data for target tables
            if module_view.blueprint.server_type is None or \
                    tar_server_type in module_view.blueprint.server_type:
                for key, val in target_tables.items():
                    target = module_view.fetch_objects_to_compare(
                        sid=tar_sid,
                        did=tar_did,
                        scid=tar_scid,
                        tid=val['oid'],
                        oid=None,
                        ignore_keys=True)
                    target_tables[key][module] = target

        return compare_dictionaries(source_tables, target_tables,
                                    self.node_type,
                                    self.blueprint.COLLECTION_LABEL,
                                    self.keys_to_ignore)