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'; 23 24/** 25 * 推荐卡片资源池数据源:大数据预置卡片列表 26 */ 27export default class BigDataDataSource extends BaseDataSource { 28 private CONFIG_NAME: string = 'big_data_source_list'; 29 30 constructor() { 31 super(); 32 } 33 34 /** 35 * getInstance 36 * 37 * @return Instance 38 */ 39 static getInstance(): BigDataDataSource { 40 if (globalThis.BigDataDataSource == null) { 41 globalThis.BigDataDataSource = new BigDataDataSource(); 42 } 43 return globalThis.BigDataDataSource; 44 } 45 46 public getSourceDataList(): string[] { 47 let obj = JSON.parse(JSON.stringify(dataSourceListCfg)); 48 for (let key in obj) { 49 if (key === this.CONFIG_NAME) { 50 let bigDataSourceList: string[] = obj[key]; 51 Log.showInfo(TAG, 'get bigDataSourceList len: ' + bigDataSourceList.length); 52 Log.showInfo(TAG, 'get bigDataSourceList: ' + JSON.stringify(bigDataSourceList)); 53 return bigDataSourceList; 54 } 55 } 56 return []; 57 } 58 59 /** 60 * 获取卡片资源池数据源名 61 * 62 * @return 卡片资源池数据源名 63 */ 64 public getName(): string { 65 return FormConstants.FORM_DATA_SOURCE_POOL_NAME_BIG_DATA; 66 } 67 68 /** 69 * 获取卡片资源池阈值 70 * 71 * @return 卡片资源池阈值 72 */ 73 public getThreshold(): number { 74 return FormConstants.SERVICE_FORM_POOL_BIG_DATA_THRESHOLD; 75 } 76} 77