1/** 2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import BaseDataSource from './BaseDataSource'; 17import FormConstants from '../common/constants/FormConstants'; 18import { Log } from '@ohos/common'; 19// @ts-ignore 20import dataSourceListCfg from '../../../resources/rawfile/service_form_config.json'; 21 22const TAG = 'BigDataDataSource'; 23const CONFIG_NAME = 'big_data_source_list'; 24 25/** 26 * 推荐卡片资源池数据源:大数据预置卡片列表 27 */ 28export default class BigDataDataSource extends BaseDataSource { 29 constructor() { 30 super(); 31 } 32 33 /** 34 * getInstance 35 * 36 * @return Instance 37 */ 38 static getInstance(): BigDataDataSource { 39 if (globalThis.BigDataDataSource == null) { 40 globalThis.BigDataDataSource = new BigDataDataSource(); 41 } 42 return globalThis.BigDataDataSource; 43 } 44 45 public getSourceDataList(): string[] { 46 let obj = JSON.parse(JSON.stringify(dataSourceListCfg)); 47 for (let key in obj) { 48 if (key === CONFIG_NAME) { 49 let bigDataSourceList: string[] = obj[key]; 50 Log.showInfo(TAG, 'get bigDataSourceList len: ' + bigDataSourceList.length); 51 Log.showInfo(TAG, 'get bigDataSourceList: ' + JSON.stringify(bigDataSourceList)); 52 return bigDataSourceList; 53 } 54 } 55 return []; 56 } 57 58 /** 59 * 获取卡片资源池数据源名 60 * 61 * @return 卡片资源池数据源名 62 */ 63 public getName(): string { 64 return FormConstants.FORM_DATA_SOURCE_POOL_NAME_BIG_DATA; 65 } 66 67 /** 68 * 获取卡片资源池阈值 69 * 70 * @return 卡片资源池阈值 71 */ 72 public getThreshold(): number { 73 return FormConstants.SERVICE_FORM_POOL_BIG_DATA_THRESHOLD; 74 } 75} 76