def test_json(self):
        json_shp = CJson()
        json_datasource = CJson()
        json_datasource.set_value_of_name('name', r'镶嵌影像\\石嘴山市-3xq.shp')
        json_datasource.set_value_of_name('description', 'ESRI Shapefile')
        json_datasource_str = json_datasource.to_json()
        print(json_datasource_str)
        json_shp.set_value_of_name('datasource', json_datasource.json_obj)
        json_shp.set_value_of_name('layer_count', '1')

        list_layers = list()
        list_layers.append(json_datasource.json_obj)
        json_shp.set_value_of_name('layers', list_layers)
        json_shp.set_value_of_name('valid', True)

        json_shp_str = json_shp.to_json()
        json_shp.to_file(r'c:\app\aa.txt')
        print(json_shp_str)
Exemple #2
0
    def merge_result(cls, result, message=None, base=None) -> str:
        new_result = CJson()
        if base is not None:
            new_result.load_json_text(base)

        new_result.set_value_of_name(cls.Name_Result, result)
        if message is not None:
            new_result.set_value_of_name(cls.Name_Message, message)
        return new_result.to_json()
Exemple #3
0
    def register_dm_metadata_plugins(self):
        sql_register_dm_metadata_plugins_clear = '''
        truncate table dm2_storage_object_def cascade
        '''

        sql_unregister_dm_metadata_plugins = '''
        delete from dm2_storage_object_def where dsodid = :dsodid
        '''
        sql_register_dm_metadata_plugins = '''
        insert into dm2_storage_object_def(
            dsodid, dsodtitle, dsodtype, dsodtypetitle, dsodtypecode, dsodgroup, dsodgrouptitle, 
            dsodcatalog, dsodcatalogtitle, dsod_otheroption) 
            values (:dsodid, :dsodtitle, :dsodtype, :dsodtypetitle, :dsodtypecode, :dsodgroup, :dsodgrouptitle, 
            :dsodcatalog, :dsodcatalogtitle, :dsod_otheroption) 
        '''

        CFactory().give_me_db().execute(sql_register_dm_metadata_plugins_clear)

        plugins_root_dir = CSys.get_plugins_root_dir()
        plugins_type_list = CFile.file_or_subpath_of_path(plugins_root_dir)
        for plugins_type in plugins_type_list:
            if CFile.is_dir(CFile.join_file(
                    plugins_root_dir, plugins_type)) and (
                        not (str(plugins_type)).startswith('_')):
                plugins_root_package_name = '{0}.{1}'.format(
                    CSys.get_plugins_package_root_name(), plugins_type)
                path = CFile.join_file(CSys.get_plugins_root_dir(),
                                       plugins_type)
                plugins_file_list = CFile.file_or_subpath_of_path(
                    path, '{0}_*.{1}'.format(self.Name_Plugins,
                                             self.FileExt_Py))
                for file_name_without_path in plugins_file_list:
                    file_main_name = CFile.file_main_name(
                        file_name_without_path)
                    class_classified_obj = CObject.create_plugins_instance(
                        plugins_root_package_name, file_main_name, None)
                    plugins_info = class_classified_obj.get_information()
                    json_obj = CJson()
                    json_obj.set_value_of_name(
                        self.Name_Is_Spatial,
                        CUtils.dict_value_by_name(
                            plugins_info, CPlugins.Plugins_Info_Is_Spatial,
                            False))
                    json_obj.set_value_of_name(
                        self.Name_Is_DataSet,
                        CUtils.dict_value_by_name(
                            plugins_info, CPlugins.Plugins_Info_Is_Dataset,
                            False))
                    plugins_info['dsod_otheroption'] = json_obj.to_json()

                    print('{0}/{1}:{2}'.format(plugins_type, file_main_name,
                                               plugins_info))
                    CFactory().give_me_db().execute(
                        sql_unregister_dm_metadata_plugins, plugins_info)
                    CFactory().give_me_db().execute(
                        sql_register_dm_metadata_plugins, plugins_info)
Exemple #4
0
 def summary(self) -> str:
     json_obj = CJson()
     json_obj.set_value_of_name(
         self.Name_Total,
         self.__quality_result_of_level(self.__XPath_Total))
     metadata_qa_s = {
         self.Name_Data:
         self.__quality_result_of_level(self.__XPath_MetaData_Data),
         self.Name_Business:
         self.__quality_result_of_level(self.__XPath_MetaData_Bus)
     }
     json_obj.set_value_of_name(self.Name_MetaData, metadata_qa_s)
     json_obj.set_value_of_name(
         self.Name_Data, {
             self.Name_Items:
             self.__quality_result_of_level(self.__XPath_Data_Items)
         })
     return json_obj.to_json()
Exemple #5
0
        assert json.xpath_one('aa', -1) == -1
        assert json.xpath_one('student[0].name', '') == '小明'
        assert json.xpath_one('student[1].name', '') == '小王'

    def test_get_attr_by_class_method(self):
        value = CJson.json_attr_value(self.test_text, 'b', 1)
        assert value == 2

    def test_get_chn_attr_by_class_method(self):
        value = CJson.json_attr_value(self.test_text, '中文属性', 1)
        assert value == 5

    def test_load_obj(self):
        data = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
        json_obj = CJson()
        json_obj.load_obj(data)
        assert json_obj.xpath_one('a', -1) == 1


if __name__ == '__main__':
    file_name = '/Users/wangxiya/Downloads/gdb.json'
    json = CJson()
    json.load_file(file_name)
    data_source = json.xpath_one('datasource', None)
    layers = json.xpath_one('layers', None)
    target_json = CJson()
    target_json.set_value_of_name('datasource', data_source)
    target_json.set_value_of_name('layer_count', 1)
    target_json.set_value_of_name('layers', [layers[0]])
    print(target_json.to_json())
Exemple #6
0
    def parser_metadata_custom(self, parser: CMetaDataParser) -> str:
        """
        自定义的元数据解析, 在所有质检和其他处理之后触发
        :param parser:
        :return:
        """
        meta_data_json = parser.metadata.metadata_json()
        if meta_data_json is None:
            return CResult.merge_result(
                self.Success,
                '数据[{0}]的质检和空间等元数据解析完毕, 但子图层解析有误, 无法获取JSON格式的元数据! '.format(
                    self.file_info.file_name_with_full_path,
                )
            )

        json_data_source = meta_data_json.xpath_one('datasource', None)

        layer_list = meta_data_json.xpath_one(self.Name_Layers, None)
        if layer_list is None:
            return CResult.merge_result(
                self.Success,
                '数据[{0}]的质检和空间等元数据解析完毕, 但子图层解析有误, 元数据中无法找到layers节点! '.format(
                    self.file_info.file_name_with_full_path,
                )
            )

        mdb_ib_id = CFactory().give_me_db(self.file_info.db_server_id).one_value(
            '''
            select dso_ib_id
            from dm2_storage_object
            where dsoid = :object_id
            ''',
            {
                'object_id': parser.object_id
            }
        )

        error_message_list = []
        table = CTable()
        table.load_info(self.file_info.db_server_id, self.TableName_DM_Object)

        for layer in layer_list:
            layer_name = CUtils.dict_value_by_name(layer, self.Name_Name, '')
            if CUtils.equal_ignore_case(layer_name, ''):
                continue

            layer_alias_name = CUtils.dict_value_by_name(layer, self.Name_Description, layer_name)

            layer_metadata_json = CJson()
            layer_metadata_json.set_value_of_name('datasource', json_data_source)
            layer_metadata_json.set_value_of_name('layer_count', 1)
            layer_metadata_json.set_value_of_name('layers', [layer])
            layer_metadata_text = layer_metadata_json.to_json()

            try:
                sql_find_layer_existed = '''
                select dsoid as layer_id_existed
                from dm2_storage_object
                where upper(dsoobjectname) = upper(:layer_name)
                    and dsoparentobjid = :object_id
                '''
                layer_id_existed = CFactory().give_me_db(self.file_info.db_server_id).one_value(
                    sql_find_layer_existed,
                    {
                        'layer_name': layer_name,
                        'object_id': parser.object_id
                    }
                )
                if layer_id_existed is None:
                    layer_id_existed = CUtils.one_id()

                table.column_list.reset()
                table.column_list.column_by_name('dsoid').set_value(layer_id_existed)
                table.column_list.column_by_name('dsoobjectname').set_value(layer_name)
                table.column_list.column_by_name('dsoobjecttype').set_value(
                    CUtils.dict_value_by_name(
                        self.get_information(),
                        self.Plugins_Info_Child_Layer_Plugins_Name,
                        ''
                    )
                )
                table.column_list.column_by_name('dsodatatype').set_value(
                    CUtils.dict_value_by_name(
                        self.get_information(),
                        self.Plugins_Info_Child_Layer_Data_Type,
                        ''
                    )
                )
                table.column_list.column_by_name('dsoalphacode').set_value(CUtils.alpha_text(layer_name))
                table.column_list.column_by_name('dsoaliasname').set_value(layer_alias_name)
                table.column_list.column_by_name('dsoparentobjid').set_value(parser.object_id)
                table.column_list.column_by_name('dso_ib_id').set_value(mdb_ib_id)

                table.column_list.column_by_name('dsometadatatext').set_value(layer_metadata_text)
                table.column_list.column_by_name('dsometadatajson').set_value(layer_metadata_text)
                table.column_list.column_by_name('dsometadataparsestatus').set_value(self.ProcStatus_InQueue)
                table.column_list.column_by_name('dsotagsparsestatus').set_value(self.ProcStatus_InQueue)
                table.column_list.column_by_name('dsodetailparsestatus').set_value(self.ProcStatus_InQueue)
                result = table.save_data()
                if not CResult.result_success(result):
                    error_message_list.append(
                        '图层[{0}]的创建过程出现错误, 详细信息为: {1}'.format(
                            layer_name,
                            CResult.result_message(result)
                        )
                    )
            except Exception as error:
                error_message_list.append('图层[{0}]的创建过程出现错误, 详细信息为: {1}'.format(layer_name, error.__str__()))

        if len(error_message_list) > 0:
            return CResult.merge_result(
                self.Failure,
                '数据[{0}]的质检和空间等元数据解析完毕, 但子图层解析有误, 详细情况如下: \n{1}'.format(
                    self.file_info.file_name_with_full_path,
                    CUtils.list_2_str(error_message_list, '', '\n', '', True)
                )
            )
        else:
            return CResult.merge_result(
                self.Success,
                '数据[{0}]的自定义元数据解析完毕! '.format(
                    self.file_info.file_name_with_full_path,
                )
            )
Exemple #7
0
    def process_mission(self, dataset):
        dso_id = dataset.value_by_name(0, 'dsoid', '')
        dso_data_type = dataset.value_by_name(0, 'dsodatatype', '')
        dso_object_type = dataset.value_by_name(0, 'dsoobjecttype', '')
        dso_object_name = dataset.value_by_name(0, 'dsoobjectname', '')
        dso_object_da_content = CUtils.any_2_str(dataset.value_by_name(0, 'dso_da_result', ''))
        dso_object_quality = dataset.value_by_name(0, 'dso_quality', '')

        ds_retry_times = dataset.value_by_name(0, 'retry_times', 0)
        if ds_retry_times >= self.abnormal_job_retry_times():
            ds_last_process_memo = CUtils.any_2_str(dataset.value_by_name(0, 'last_process_memo', None))
            process_result = CResult.merge_result(
                self.Failure,
                '{0}, \n系统已经重试{1}次, 仍然未能解决, 请人工检查修正后重试!'.format(
                    ds_last_process_memo,
                    ds_retry_times
                )
            )
            self.update_status(dso_id, None, process_result, self.ProcStatus_Error)
            return process_result

        dso_quality = CXml()
        dso_quality.load_xml(dso_object_quality)

        dso_da_json = CJson()
        dso_da_json.load_json_text(dso_object_da_content)

        CLogger().debug(
            '开始处理对象: {0}.{1}.{2}.{3}对各个子系统的支撑能力'.format(dso_id, dso_data_type, dso_object_type, dso_object_name))

        try:
            modules_root_dir = CSys.get_metadata_data_access_modules_root_dir()
            modules_file_list = CFile.file_or_subpath_of_path(
                modules_root_dir,
                '{0}_*.{1}'.format(self.Name_Module, self.FileExt_Py)
            )
            for file_name_without_path in modules_file_list:
                file_main_name = CFile.file_main_name(file_name_without_path)
                # 判断模块的可访问是否已经被人工审批, 如果人工审批, 则这里不再计算和覆盖
                module_access = dso_da_json.xpath_one(
                    '{0}.{1}'.format(file_main_name, self.Name_Audit),
                    self.Name_System
                )
                if CUtils.equal_ignore_case(module_access, self.Name_User):
                    continue

                try:
                    module_obj = CObject.create_module_instance(
                        CSys.get_metadata_data_access_modules_root_name(),
                        file_main_name,
                        self.get_mission_db_id()
                    )
                    module_title = CUtils.dict_value_by_name(module_obj.information(), self.Name_Title, '')
                    result = CUtils.any_2_str(module_obj.access(dso_id,
                                                                dso_object_name,
                                                                dso_data_type,
                                                                dso_quality)
                                              )
                    if CResult.result_success(result):
                        module_access = CResult.result_info(result, self.Name_Access, self.DataAccess_Forbid)
                    else:
                        CLogger().debug('模块[{0}]解析出现错误, 系统将忽略本模块, 继续处理下一个!'.format(file_main_name))
                        module_access = self.DataAccess_Unknown

                    module_access_message = CResult.result_message(result)
                    module_obj = {self.Name_Audit: self.Name_System, self.Name_Result: module_access,
                                  self.Name_Title: module_title, self.Name_Message: module_access_message}
                    dso_da_json.set_value_of_name(file_main_name, module_obj)
                except Exception as error:
                    CLogger().debug('模块[{0}]解析出现异常, 原因为[{1}], 请检查!'.format(file_main_name, error.__str__()))

                    module_access = self.DataAccess_Unknown
                    module_access_message = '模块[{0}]解析出现异常, 原因为[{1}], 请检查!'.format(file_main_name, error.__str__())
                    module_obj = {self.Name_Audit: self.Name_System, self.Name_Result: module_access,
                                  self.Name_Title: file_main_name, self.Name_Message: module_access_message}
                    dso_da_json.set_value_of_name(file_main_name, module_obj)

            process_result = CResult.merge_result(
                self.Success,
                '对象[{0}.{1}]访问权限解析成功!'.format(dso_id, dso_object_name)
            )
            self.update_status(
                dso_id,
                dso_da_json.to_json(),
                process_result
            )
            return process_result
        except Exception as error:
            process_result = CResult.merge_result(
                self.Failure,
                '对象[{0}.{1}]访问权限解析出错, 原因为[{2}]!'.format(dso_id, dso_object_name, error.__str__())
            )
            self.update_status(dso_id, None, process_result)
            return process_result
Exemple #8
0
    def object_copy_stat(self, storage_id, object_id, object_name,
                         object_relation_name):
        try:
            ds_object_stat = CFactory().give_me_db(
                self.get_mission_db_id()).one_row(
                    '''
                select sum(dodfilesize), max(dodfilemodifytime) from dm2_storage_obj_detail where dodobjectid = :object_id
                ''', {'object_id': object_id})

            object_size = None
            object_last_modify_time = None
            if not ds_object_stat.is_empty():
                object_size = ds_object_stat.value_by_index(0, 0, 0)
                object_last_modify_time = ds_object_stat.value_by_index(
                    0, 1, None)

            batch_root_relation_dir = CFactory().give_me_db(
                self.get_mission_db_id()).one_value(
                    '''
                select dsddirectory 
                from dm2_storage_directory 
                where dsdStorageid = :storage_id and position(dsddirectory || '{0}' in :directory) = 1 
                    and dsddirectory <> '' 
                order by dsddirectory 
                limit 1 
                '''.format(CFile.sep()), {
                        'storage_id': storage_id,
                        'directory': object_relation_name
                    }, object_relation_name)

            # 更新当前对象的存储大小, 以及最后修改时间
            CFactory().give_me_db(self.get_mission_db_id()).execute(
                '''
                update dm2_storage_object 
                set dso_volumn_now = :object_size, dso_obj_lastmodifytime = :object_last_modify_time
                where dsoid = :object_id
                ''', {
                    'object_id': object_id,
                    'object_size': object_size,
                    'object_last_modify_time': object_last_modify_time
                })

            count_copy_same_filename_core = CFactory().give_me_db(
                self.get_mission_db_id()).one_value(
                    '''
                select count(dm2_storage_object.dsoid)
                from dm2_storage_object
                    left join dm2_storage_directory on dm2_storage_object.dsoid = dm2_storage_directory.dsd_object_id 
                    left join dm2_storage on dm2_storage_directory.dsdstorageid = dm2_storage.dstid 
                where 
                    dm2_storage.dstid is not null
                    and dm2_storage.dsttype = '{0}'
                    and dm2_storage_object.dsoobjectname = :object_name
                    and dm2_storage_object.dsoid <> :object_id
                    and dm2_storage_object.dsodatatype = '{1}'
                '''.format(self.Storage_Type_Core, self.FileType_Dir), {
                        'object_id': object_id,
                        'object_name': object_name
                    }, 0) + CFactory().give_me_db(
                        self.get_mission_db_id()).one_value(
                            '''
                select count(dm2_storage_object.dsoid)
                from dm2_storage_object
                    left join dm2_storage_file on dm2_storage_file.dsf_object_id = dm2_storage_object.dsoid
                    left join dm2_storage on dm2_storage_file.dsfstorageid = dm2_storage.dstid 
                where 
                    dm2_storage.dstid is not null
                    and dm2_storage.dsttype = '{0}'
                    and dm2_storage_object.dsoobjectname = :object_name
                    and dm2_storage_object.dsoid <> :object_id
                    and dm2_storage_object.dsodatatype = '{1}'
                '''.format(self.Storage_Type_Core, self.FileType_File), {
                                'object_id': object_id,
                                'object_name': object_name
                            }, 0)

            count_copy_same_filename_and_size_core = CFactory().give_me_db(
                self.get_mission_db_id()).one_value(
                    '''
                select count(dm2_storage_object.dsoid)
                from dm2_storage_object
                    left join dm2_storage_directory on dm2_storage_object.dsoid = dm2_storage_directory.dsd_object_id 
                    left join dm2_storage on dm2_storage_directory.dsdstorageid = dm2_storage.dstid 
                where 
                    dm2_storage.dstid is not null
                    and dm2_storage.dsttype = '{0}'
                    and dm2_storage_object.dso_volumn_now = :object_size
                    and dm2_storage_object.dsoobjectname = :object_name
                    and dm2_storage_object.dsoid <> :object_id
                    and dm2_storage_object.dsodatatype = '{1}'
                '''.format(self.Storage_Type_Core, self.FileType_Dir), {
                        'object_id': object_id,
                        'object_name': object_name,
                        'object_size': object_size
                    }, 0) + CFactory().give_me_db(
                        self.get_mission_db_id()).one_value(
                            '''
                select count(dm2_storage_object.dsoid)
                from dm2_storage_object
                    left join dm2_storage_file on dm2_storage_file.dsf_object_id = dm2_storage_object.dsoid
                    left join dm2_storage on dm2_storage_file.dsfstorageid = dm2_storage.dstid 
                where 
                    dm2_storage.dstid is not null
                    and dm2_storage.dsttype = '{0}'
                    and dm2_storage_object.dso_volumn_now = :object_size
                    and dm2_storage_object.dsoobjectname = :object_name
                    and dm2_storage_object.dsoid <> :object_id
                    and dm2_storage_object.dsodatatype = '{1}'
                '''.format(self.Storage_Type_Core, self.FileType_File), {
                                'object_id': object_id,
                                'object_name': object_name,
                                'object_size': object_size
                            }, 0)

            count_copy_same_filename_same_batch = CFactory().give_me_db(
                self.get_mission_db_id()).one_value(
                    '''
                select count(dm2_storage_object.dsoid)
                from dm2_storage_object
                    left join dm2_storage_directory on dm2_storage_object.dsoid = dm2_storage_directory.dsd_object_id 
                    left join dm2_storage on dm2_storage_directory.dsdstorageid = dm2_storage.dstid 
                where 
                    dm2_storage.dstid = :storage_id
                    and position(:directory in dm2_storage_directory.dsddirectory) = 1
                    and dm2_storage_object.dsoobjectname = :object_name
                    and dm2_storage_object.dsoid <> :object_id
                    and dm2_storage_object.dsodatatype = '{0}'
                '''.format(self.FileType_Dir), {
                        'storage_id': storage_id,
                        'object_id': object_id,
                        'object_name': object_name,
                        'directory': batch_root_relation_dir
                    }, 0) + CFactory().give_me_db(
                        self.get_mission_db_id()).one_value(
                            '''
                select count(dm2_storage_object.dsoid)
                from dm2_storage_object
                    left join dm2_storage_file on dm2_storage_file.dsf_object_id = dm2_storage_object.dsoid
                    left join dm2_storage on dm2_storage_file.dsfstorageid = dm2_storage.dstid 
                where 
                    dm2_storage.dstid = :storage_id
                    and position(:directory in dm2_storage_file.dsffilerelationname) = 1
                    and dm2_storage_object.dsoobjectname = :object_name
                    and dm2_storage_object.dsoid <> :object_id
                    and dm2_storage_object.dsodatatype = '{0}'
                '''.format(self.FileType_File), {
                                'storage_id': storage_id,
                                'object_id': object_id,
                                'object_name': object_name,
                                'directory': batch_root_relation_dir
                            }, 0)

            count_copy_same_filename_and_size_same_batch = CFactory(
            ).give_me_db(self.get_mission_db_id()).one_value(
                '''
                select count(dm2_storage_object.dsoid)
                from dm2_storage_object
                    left join dm2_storage_directory on dm2_storage_object.dsoid = dm2_storage_directory.dsd_object_id 
                    left join dm2_storage on dm2_storage_directory.dsdstorageid = dm2_storage.dstid 
                where 
                    dm2_storage.dstid = :storage_id
                    and position(:directory in dm2_storage_directory.dsddirectory) = 1
                    and dm2_storage_object.dso_volumn_now = :object_size
                    and dm2_storage_object.dsoobjectname = :object_name
                    and dm2_storage_object.dsoid <> :object_id
                    and dm2_storage_object.dsodatatype = '{0}'
                '''.format(self.FileType_Dir), {
                    'storage_id': storage_id,
                    'object_id': object_id,
                    'object_name': object_name,
                    'object_size': object_size,
                    'directory': object_relation_name
                }, 0) + CFactory().give_me_db(
                    self.get_mission_db_id()).one_value(
                        '''
                select count(dm2_storage_object.dsoid)
                from dm2_storage_object
                    left join dm2_storage_file on dm2_storage_file.dsf_object_id = dm2_storage_object.dsoid
                    left join dm2_storage on dm2_storage_file.dsfstorageid = dm2_storage.dstid 
                where 
                    dm2_storage.dstid = :storage_id
                    and position(:directory in dm2_storage_file.dsffilerelationname) = 1
                    and dm2_storage_object.dso_volumn_now = :object_size
                    and dm2_storage_object.dsoobjectname = :object_name
                    and dm2_storage_object.dsoid <> :object_id
                    and dm2_storage_object.dsodatatype = '{0}'
                '''.format(self.FileType_File), {
                            'storage_id': storage_id,
                            'object_id': object_id,
                            'object_name': object_name,
                            'object_size': object_size,
                            'directory': object_relation_name
                        }, 0)

            json_text = None
            if count_copy_same_filename_and_size_same_batch + \
                    count_copy_same_filename_and_size_core + \
                    count_copy_same_filename_same_batch + count_copy_same_filename_core > 0:
                json_obj = CJson()
                json_obj.load_obj({
                    self.Storage_Type_Core: {
                        self.Name_FileName:
                        count_copy_same_filename_core,
                        '{0}_{1}'.format(self.Name_FileName, self.Name_Size):
                        count_copy_same_filename_and_size_core
                    },
                    self.Storage_Type_InBound: {
                        self.Name_FileName:
                        count_copy_same_filename_same_batch,
                        '{0}_{1}'.format(self.Name_FileName, self.Name_Size):
                        count_copy_same_filename_and_size_same_batch
                    }
                })
                json_text = json_obj.to_json()

            CFactory().give_me_db(self.get_mission_db_id()).execute(
                '''
                update dm2_storage_object
                set dsocopystat = :copy_stat
                where dsoid = :dsoid
                ''', {
                    'dsoid': object_id,
                    'copy_stat': json_text
                })
            return CResult.merge_result(self.Success, '数据容量统计和数据重复数据分析成功完成! ')
        except Exception as error:
            return CResult.merge_result(
                self.Failure,
                '数据容量统计和数据重复数据分析过程出现错误, 详细情况: {0}'.format(error.__str__()))
Exemple #9
0
class CMetaData(CResource):
    def __init__(self):
        self.__quality__ = CQuality()

        self.__metadata_extract_result__ = self.Not_Support
        self.__metadata_extract_memo__ = ''
        self.__metadata_text__ = None
        self.__metadata_xml__ = CXml()
        self.__metadata_json__ = CJson()
        self.__metadata_type__ = self.MetaDataFormat_Text

        self.__metadata_bus_extract_result__ = self.Not_Support
        self.__metadata_bus_extract_memo__ = ''
        self.__metadata_bus_text__ = None
        self.__metadata_bus_xml__ = CXml()
        self.__metadata_bus_json__ = CJson()
        self.__metadata_bus_type__ = self.MetaDataFormat_Text

        self.__thumb_img_file_name__ = ''
        self.__browse_img_file_name__ = ''
        self.__metadata_view_extract_result__ = self.Not_Support
        self.__metadata_view_extract_memo__ = ''

        self.__time_information__ = CJson()
        self.__metadata_time_extract_result__ = self.Not_Support
        self.__metadata_time_extract_memo__ = ''

        self.__metadata_spatial_extract_result__ = self.Not_Support
        self.__metadata_spatial_extract_memo__ = ''
        self.__metadata_spatial__ = CMDSpatial()

    def metadata_time(self):
        if self.__metadata_time_extract_result__ == self.DB_True:
            return self.__metadata_time_extract_result__, self.__metadata_time_extract_memo__, self.__time_information__.to_json(
            )
        else:
            return self.__metadata_time_extract_result__, self.__metadata_time_extract_memo__, ''

    def metadata_view(self):
        if self.__metadata_view_extract_result__ == self.DB_True:
            return self.__metadata_view_extract_result__, self.__metadata_view_extract_memo__, self.__thumb_img_file_name__, self.__browse_img_file_name__
        else:
            return self.__metadata_view_extract_result__, self.__metadata_view_extract_memo__, '', ''

    def metadata_spatial(self):
        if self.__metadata_spatial_extract_result__ == self.DB_True:
            return self.__metadata_spatial_extract_result__, self.__metadata_spatial_extract_memo__, self.__metadata_spatial__
        else:
            return self.__metadata_spatial_extract_result__, self.__metadata_spatial_extract_memo__, self.__metadata_spatial__

    @property
    def quality(self):
        return self.__quality__

    @property
    def thumb_img_file_name(self):
        return self.__thumb_img_file_name__

    @thumb_img_file_name.setter
    def thumb_img_file_name(self, value):
        self.__thumb_img_file_name__ = value

    @property
    def browse_img_file_name(self):
        return self.__browse_img_file_name__

    @browse_img_file_name.setter
    def browse_img_file_name(self, value):
        self.__browse_img_file_name__ = value

    @property
    def time_information(self) -> CJson:
        return self.__time_information__

    @property
    def metadata_extract_result(self):
        return self.__metadata_extract_result__

    @property
    def metadata_bus_extract_result(self):
        return self.__metadata_bus_extract_result__

    @property
    def metadata_view_extract_result(self):
        return self.__metadata_view_extract_result__

    @property
    def metadata_time_extract_result(self):
        return self.__metadata_time_extract_result__

    @property
    def metadata_spatial_extract_result(self):
        return self.__metadata_spatial_extract_result__

    def metadata(self):
        if self.__metadata_extract_result__ != self.DB_True:
            return self.__metadata_extract_result__, self.__metadata_extract_memo__, self.__metadata_type__, None
        elif self.__metadata_type__ == self.MetaDataFormat_Json:
            return self.__metadata_extract_result__, self.__metadata_extract_memo__, self.__metadata_type__, self.__metadata_json__.to_json(
            )
        elif self.__metadata_type__ == self.MetaDataFormat_XML:
            return self.__metadata_extract_result__, self.__metadata_extract_memo__, self.__metadata_type__, self.__metadata_xml__.to_xml(
            )
        else:
            return self.__metadata_extract_result__, self.__metadata_extract_memo__, self.__metadata_type__, self.__metadata_text__

    @property
    def metadata_type(self):
        return self.__metadata_type__

    @property
    def metadata_bus_type(self):
        return self.__metadata_bus_type__

    def metadata_xml(self) -> CXml:
        return self.__metadata_xml__

    def metadata_json(self) -> CJson:
        return self.__metadata_json__

    def metadata_bus_xml(self) -> CXml:
        return self.__metadata_bus_xml__

    def metadata_bus_json(self) -> CJson:
        return self.__metadata_bus_json__

    def metadata_spatial_obj(self) -> CMDSpatial:
        return self.__metadata_spatial__

    def set_metadata_spatial(self,
                             result: int,
                             memo: str,
                             spatial_metadata_type=None,
                             spatial_metadata=None):
        self.__metadata_spatial_extract_result__ = result
        self.__metadata_spatial_extract_memo__ = memo
        if spatial_metadata_type is None:
            return

        if spatial_metadata_type == CResource.Spatial_MetaData_Type_Native_Center:
            self.__metadata_spatial__.native_center = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Native_BBox:
            self.__metadata_spatial__.native_box = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Native_Geom:
            self.__metadata_spatial__.native_geom = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Wgs84_Center:
            self.__metadata_spatial__.wgs84_center = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Wgs84_BBox:
            self.__metadata_spatial__.wgs84_bbox = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Wgs84_Geom:
            self.__metadata_spatial__.wgs84_geom = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Prj_Wkt:
            self.__metadata_spatial__.prj_wkt = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Prj_Proj4:
            self.__metadata_spatial__.prj_proj4 = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Prj_Project:
            self.__metadata_spatial__.prj_project = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Prj_Coordinate:
            self.__metadata_spatial__.prj_coordinate = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Prj_Degree:
            self.__metadata_spatial__.prj_degree = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Prj_Zone:
            self.__metadata_spatial__.prj_zone = spatial_metadata
        elif spatial_metadata_type == CResource.Spatial_MetaData_Type_Prj_Source:
            self.__metadata_spatial__.prj_source = spatial_metadata
        else:
            pass

    def set_metadata_view(self,
                          result: int,
                          memo: str,
                          view_metadata_type=None,
                          view_metadata=None):
        self.__metadata_view_extract_result__ = result
        self.__metadata_view_extract_memo__ = memo
        if view_metadata_type is None:
            self.__browse_img_file_name__ = None
            self.__thumb_img_file_name__ = None
            return

        if view_metadata_type == CResource.View_MetaData_Type_Browse:
            self.__browse_img_file_name__ = view_metadata
        elif view_metadata_type == CResource.View_MetaData_Type_Thumb:
            self.__thumb_img_file_name__ = view_metadata
        else:
            pass

    def set_metadata_time(self,
                          result: int,
                          memo: str,
                          time_attr_name=None,
                          time_attr_value=None):
        self.__metadata_time_extract_result__ = result
        self.__metadata_time_extract_memo__ = memo
        if time_attr_name is not None:
            self.__time_information__.set_value_of_name(
                CUtils.any_2_str(time_attr_name), time_attr_value)

    def set_metadata(self, metadata_extract_result: int,
                     metadata_extract_memo: str, metadata_type: int,
                     metadata_text):
        self.__metadata_extract_result__ = metadata_extract_result
        self.__metadata_extract_memo__ = metadata_extract_memo
        self.__metadata_type__ = metadata_type
        if self.__metadata_type__ == self.MetaDataFormat_Json:
            self.__metadata_text__ = ''
            self.__metadata_xml__ = CXml()
            self.__metadata_json__.load_json_text(metadata_text)
        elif self.__metadata_type__ == self.MetaDataFormat_XML:
            self.__metadata_text__ = ''
            self.__metadata_xml__.load_xml(metadata_text)
            self.__metadata_json__ = CJson()
        else:
            self.__metadata_text__ = metadata_text
            self.__metadata_xml__ = CXml()
            self.__metadata_json__ = CJson()

    def set_metadata_file(self, metadata_extract_result: int,
                          metadata_extract_memo: str, metadata_type: int,
                          file_name):
        self.__metadata_extract_result__ = metadata_extract_result
        self.__metadata_extract_memo__ = metadata_extract_memo
        self.__metadata_type__ = metadata_type
        if self.__metadata_type__ == self.MetaDataFormat_Json:
            self.__metadata_text__ = ''
            self.__metadata_xml__ = CXml()
            self.__metadata_json__.load_file(file_name)
        elif self.__metadata_type__ == self.MetaDataFormat_XML:
            self.__metadata_text__ = ''
            self.__metadata_xml__.load_file(file_name)
            self.__metadata_json__ = CJson()
        else:
            self.__metadata_text__ = CFile.file_2_str(file_name)
            self.__metadata_xml__ = CXml()
            self.__metadata_json__ = CJson()

    def metadata_bus(self):
        if self.__metadata_bus_extract_result__ != self.DB_True:
            return self.__metadata_bus_extract_result__, self.__metadata_bus_extract_memo__, self.__metadata_bus_type__, None
        elif self.__metadata_bus_type__ == self.MetaDataFormat_Json:
            return self.__metadata_bus_extract_result__, self.__metadata_bus_extract_memo__, self.__metadata_bus_type__, self.__metadata_bus_json__.to_json(
            )
        elif self.__metadata_bus_type__ == self.MetaDataFormat_XML:
            return self.__metadata_bus_extract_result__, self.__metadata_bus_extract_memo__, self.__metadata_bus_type__, self.__metadata_bus_xml__.to_xml(
            )
        else:
            return self.__metadata_bus_extract_result__, self.__metadata_bus_extract_memo__, self.__metadata_bus_type__, self.__metadata_bus_text__

    def set_metadata_bus(self, metadata_bus_extract_result: int,
                         metadata_bus_extract_memo: str,
                         metadata_bus_type: int, metadata_bus_text):
        self.__metadata_bus_extract_result__ = metadata_bus_extract_result
        self.__metadata_bus_extract_memo__ = metadata_bus_extract_memo
        self.__metadata_bus_type__ = metadata_bus_type
        if self.__metadata_bus_type__ == self.MetaDataFormat_Json:
            self.__metadata_bus_text__ = ''
            self.__metadata_bus_xml__ = CXml()
            self.__metadata_bus_json__.load_json_text(metadata_bus_text)
        elif self.__metadata_bus_type__ == self.MetaDataFormat_XML:
            self.__metadata_bus_text__ = ''
            self.__metadata_bus_xml__.load_xml(metadata_bus_text)
            self.__metadata_bus_json__ = CJson()
        else:
            self.__metadata_bus_text__ = metadata_bus_text
            self.__metadata_bus_xml__ = CXml()
            self.__metadata_bus_json__ = CJson()

    def set_metadata_bus_file(self, metadata_bus_extract_result: int,
                              metadata_bus_extract_memo: str,
                              metadata_type: int, file_name):
        self.__metadata_bus_extract_result__ = metadata_bus_extract_result
        self.__metadata_bus_extract_memo__ = metadata_bus_extract_memo
        self.__metadata_bus_type__ = metadata_type
        if self.__metadata_bus_type__ == self.MetaDataFormat_Json:
            self.__metadata_bus_text__ = ''
            self.__metadata_bus_xml__ = CXml()
            self.__metadata_bus_json__.load_file(file_name)
        elif self.__metadata_bus_type__ == self.MetaDataFormat_XML:
            self.__metadata_bus_text__ = ''
            self.__metadata_bus_xml__.load_file(file_name)
            self.__metadata_bus_json__ = CJson()
        else:
            self.__metadata_bus_text__ = CFile.file_2_str(file_name)
            self.__metadata_bus_xml__ = CXml()
            self.__metadata_bus_json__ = CJson()