1/** 2 * Copyright (c) 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 { SearchContacts } from '../contract/SearchContacts'; 17import { Data } from '../contract/Data'; 18import { DataItem } from '../entity/DataItem'; 19 20export default class SearchContact { 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): SearchContact{ 31 let contentValues: Map<string, any> = new Map(); 32 contentValues.set(SearchContacts.ACCOUNT_ID, resultSet.getLong(resultSet.getColumnIndex(SearchContacts.ACCOUNT_ID))); 33 contentValues.set(SearchContacts.CONTACT_ID, resultSet.getLong(resultSet.getColumnIndex(SearchContacts.CONTACT_ID))); 34 contentValues.set(SearchContacts.RAW_CONTACT_ID, resultSet.getLong(resultSet.getColumnIndex(SearchContacts.RAW_CONTACT_ID))); 35 contentValues.set(SearchContacts.SEARCH_NAME, resultSet.getString(resultSet.getColumnIndex(SearchContacts.SEARCH_NAME))); 36 contentValues.set(SearchContacts.DISPLAY_NAME, resultSet.getString(resultSet.getColumnIndex(SearchContacts.DISPLAY_NAME))); 37 contentValues.set(SearchContacts.PHONETIC_NAME, resultSet.getString(resultSet.getColumnIndex(SearchContacts.PHONETIC_NAME))); 38 contentValues.set(SearchContacts.PHOTO_ID, resultSet.getString(resultSet.getColumnIndex(SearchContacts.PHOTO_ID))); 39 contentValues.set(SearchContacts.PHOTO_FILE_ID, resultSet.getLong(resultSet.getColumnIndex(SearchContacts.PHOTO_FILE_ID))); 40 contentValues.set(SearchContacts.IS_DELETED, resultSet.getString(resultSet.getColumnIndex(SearchContacts.IS_DELETED))); 41 contentValues.set(SearchContacts.POSITION, resultSet.getString(resultSet.getColumnIndex(SearchContacts.POSITION))); 42 contentValues.set(SearchContacts.PHOTO_FIRST_NAME, resultSet.getString(resultSet.getColumnIndex(SearchContacts.PHOTO_FIRST_NAME))); 43 contentValues.set(SearchContacts.SORT_FIRST_LETTER, resultSet.getLong(resultSet.getColumnIndex(SearchContacts.SORT_FIRST_LETTER))); 44 contentValues.set(SearchContacts.CUSTOM_DATA, resultSet.getLong(resultSet.getColumnIndex(SearchContacts.CUSTOM_DATA))); 45 contentValues.set(SearchContacts.DETAIL_INFO, resultSet.getLong(resultSet.getColumnIndex(SearchContacts.DETAIL_INFO))); 46 contentValues.set(SearchContacts.CONTENT_TYPE, resultSet.getLong(resultSet.getColumnIndex(SearchContacts.CONTENT_TYPE))); 47 contentValues.set(SearchContacts.HAS_PHONE_NUMBER, resultSet.getLong(resultSet.getColumnIndex(SearchContacts.HAS_PHONE_NUMBER))); 48 return new SearchContact(resultSet.getLong(resultSet.getColumnIndex(SearchContacts.ID)), contentValues); 49 } 50} 51 52