18779efd5Sopenharmony_ci/**
28779efd5Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
38779efd5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
48779efd5Sopenharmony_ci * you may not use this file except in compliance with the License.
58779efd5Sopenharmony_ci * You may obtain a copy of the License at
68779efd5Sopenharmony_ci *
78779efd5Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
88779efd5Sopenharmony_ci *
98779efd5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
108779efd5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
118779efd5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
128779efd5Sopenharmony_ci * See the License for the specific language governing permissions and
138779efd5Sopenharmony_ci * limitations under the License.
148779efd5Sopenharmony_ci */
158779efd5Sopenharmony_ci
168779efd5Sopenharmony_ciimport { RawContacts } from '../contract/RawContacts';
178779efd5Sopenharmony_ciimport { Data } from '../contract/Data';
188779efd5Sopenharmony_ciimport { DataItem } from '../entity/DataItem';
198779efd5Sopenharmony_ci
208779efd5Sopenharmony_ciexport default class RawContact {
218779efd5Sopenharmony_ci  readonly id: number;
228779efd5Sopenharmony_ci  readonly values: Map<string, any>;
238779efd5Sopenharmony_ci  readonly dataItems: DataItem[];
248779efd5Sopenharmony_ci  constructor(id: number, values: Map<string, any>) {
258779efd5Sopenharmony_ci    this.id = id;
268779efd5Sopenharmony_ci    this.values = values;
278779efd5Sopenharmony_ci    this.dataItems = [];
288779efd5Sopenharmony_ci  }
298779efd5Sopenharmony_ci
308779efd5Sopenharmony_ci  static fromResultSet(resultSet: any): RawContact{
318779efd5Sopenharmony_ci    let contentValues: Map<string, any> = new Map();
328779efd5Sopenharmony_ci    contentValues.set(RawContacts.CONTACT_ID, resultSet.getLong(resultSet.getColumnIndex(RawContacts.CONTACT_ID)));
338779efd5Sopenharmony_ci    contentValues.set(RawContacts.PHOTO_ID, resultSet.getLong(resultSet.getColumnIndex(RawContacts.PHOTO_ID)));
348779efd5Sopenharmony_ci    contentValues.set(RawContacts.PHOTO_FILE_ID, resultSet.getLong(resultSet.getColumnIndex(RawContacts.PHOTO_FILE_ID)));
358779efd5Sopenharmony_ci    contentValues.set(RawContacts.IS_TRANSFER_VOICEMAIL, resultSet.getLong(resultSet.getColumnIndex(RawContacts.IS_TRANSFER_VOICEMAIL)) > 0 ? true : false);
368779efd5Sopenharmony_ci    contentValues.set(RawContacts.PERSONAL_RINGTONE, resultSet.getString(resultSet.getColumnIndex(RawContacts.PERSONAL_RINGTONE)));
378779efd5Sopenharmony_ci    contentValues.set(RawContacts.PERSONAL_NOTIFICATION_RINGTONE, resultSet.getString(resultSet.getColumnIndex(RawContacts.PERSONAL_NOTIFICATION_RINGTONE)));
388779efd5Sopenharmony_ci    contentValues.set(RawContacts.PHOTO_FIRST_NAME, resultSet.getString(resultSet.getColumnIndex(RawContacts.PHOTO_FIRST_NAME)));
398779efd5Sopenharmony_ci    contentValues.set(RawContacts.ACCOUNT_ID, resultSet.getLong(resultSet.getColumnIndex(RawContacts.ACCOUNT_ID)));
408779efd5Sopenharmony_ci    contentValues.set(RawContacts.DISPLAY_NAME, resultSet.getString(resultSet.getColumnIndex(RawContacts.DISPLAY_NAME)));
418779efd5Sopenharmony_ci    contentValues.set(RawContacts.SORT, resultSet.getLong(resultSet.getColumnIndex(RawContacts.SORT)));
428779efd5Sopenharmony_ci    contentValues.set(RawContacts.CONTACTED_COUNT, resultSet.getLong(resultSet.getColumnIndex(RawContacts.CONTACTED_COUNT)));
438779efd5Sopenharmony_ci    contentValues.set(RawContacts.LASTEST_CONTACTED_TIME, resultSet.getLong(resultSet.getColumnIndex(RawContacts.LASTEST_CONTACTED_TIME)));
448779efd5Sopenharmony_ci    contentValues.set(RawContacts.FAVORITE, resultSet.getString(resultSet.getColumnIndex(RawContacts.FAVORITE)));
458779efd5Sopenharmony_ci    contentValues.set(RawContacts.FAVORITE_ORDER, resultSet.getLong(resultSet.getColumnIndex(RawContacts.FAVORITE_ORDER)));
468779efd5Sopenharmony_ci    contentValues.set(RawContacts.PHONETIC_NAME, resultSet.getString(resultSet.getColumnIndex(RawContacts.PHONETIC_NAME)));
478779efd5Sopenharmony_ci    contentValues.set(RawContacts.COMPANY, resultSet.getString(resultSet.getColumnIndex(RawContacts.COMPANY)));
488779efd5Sopenharmony_ci    contentValues.set(RawContacts.POSITION, resultSet.getString(resultSet.getColumnIndex(RawContacts.POSITION)));
498779efd5Sopenharmony_ci    return new RawContact(resultSet.getLong(resultSet.getColumnIndex(Data.RAW_CONTACT_ID)), contentValues);
508779efd5Sopenharmony_ci  }
518779efd5Sopenharmony_ci}
528779efd5Sopenharmony_ci
53