1/** 2 * Copyright (c) 2022 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 { RawContacts } from '../contract/RawContacts'; 17import { Data } from '../contract/Data'; 18import { DataItem } from '../entity/DataItem'; 19 20export default class RawContact { 21 readonly id: number; 22 readonly values: Map<string, any>; 23 readonly dataItems: DataItem[]; 24 constructor(id: number, values: Map<string, any>) { 25 this.id = id; 26 this.values = values; 27 this.dataItems = []; 28 } 29 30 static fromResultSet(resultSet: any): RawContact{ 31 let contentValues: Map<string, any> = new Map(); 32 contentValues.set(RawContacts.CONTACT_ID, resultSet.getLong(resultSet.getColumnIndex(RawContacts.CONTACT_ID))); 33 contentValues.set(RawContacts.PHOTO_ID, resultSet.getLong(resultSet.getColumnIndex(RawContacts.PHOTO_ID))); 34 contentValues.set(RawContacts.PHOTO_FILE_ID, resultSet.getLong(resultSet.getColumnIndex(RawContacts.PHOTO_FILE_ID))); 35 contentValues.set(RawContacts.IS_TRANSFER_VOICEMAIL, resultSet.getLong(resultSet.getColumnIndex(RawContacts.IS_TRANSFER_VOICEMAIL)) > 0 ? true : false); 36 contentValues.set(RawContacts.PERSONAL_RINGTONE, resultSet.getString(resultSet.getColumnIndex(RawContacts.PERSONAL_RINGTONE))); 37 contentValues.set(RawContacts.PERSONAL_NOTIFICATION_RINGTONE, resultSet.getString(resultSet.getColumnIndex(RawContacts.PERSONAL_NOTIFICATION_RINGTONE))); 38 contentValues.set(RawContacts.PHOTO_FIRST_NAME, resultSet.getString(resultSet.getColumnIndex(RawContacts.PHOTO_FIRST_NAME))); 39 contentValues.set(RawContacts.ACCOUNT_ID, resultSet.getLong(resultSet.getColumnIndex(RawContacts.ACCOUNT_ID))); 40 contentValues.set(RawContacts.DISPLAY_NAME, resultSet.getString(resultSet.getColumnIndex(RawContacts.DISPLAY_NAME))); 41 contentValues.set(RawContacts.SORT, resultSet.getLong(resultSet.getColumnIndex(RawContacts.SORT))); 42 contentValues.set(RawContacts.CONTACTED_COUNT, resultSet.getLong(resultSet.getColumnIndex(RawContacts.CONTACTED_COUNT))); 43 contentValues.set(RawContacts.LASTEST_CONTACTED_TIME, resultSet.getLong(resultSet.getColumnIndex(RawContacts.LASTEST_CONTACTED_TIME))); 44 contentValues.set(RawContacts.FAVORITE, resultSet.getString(resultSet.getColumnIndex(RawContacts.FAVORITE))); 45 contentValues.set(RawContacts.FAVORITE_ORDER, resultSet.getLong(resultSet.getColumnIndex(RawContacts.FAVORITE_ORDER))); 46 contentValues.set(RawContacts.PHONETIC_NAME, resultSet.getString(resultSet.getColumnIndex(RawContacts.PHONETIC_NAME))); 47 contentValues.set(RawContacts.COMPANY, resultSet.getString(resultSet.getColumnIndex(RawContacts.COMPANY))); 48 contentValues.set(RawContacts.POSITION, resultSet.getString(resultSet.getColumnIndex(RawContacts.POSITION))); 49 return new RawContact(resultSet.getLong(resultSet.getColumnIndex(Data.RAW_CONTACT_ID)), contentValues); 50 } 51} 52 53