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 Calls from '../contract/Calls'; 178779efd5Sopenharmony_ci 188779efd5Sopenharmony_ciexport default class CallLogBuilder { 198779efd5Sopenharmony_ci readonly id: number = -1; 208779efd5Sopenharmony_ci readonly phoneNumber: string; 218779efd5Sopenharmony_ci displayName: string; 228779efd5Sopenharmony_ci callDirection: number; 238779efd5Sopenharmony_ci voicemailUri: string; 248779efd5Sopenharmony_ci simId: number; 258779efd5Sopenharmony_ci simType: number; 268779efd5Sopenharmony_ci isHD: boolean; 278779efd5Sopenharmony_ci isRead: boolean; 288779efd5Sopenharmony_ci ringDuration: number; 298779efd5Sopenharmony_ci talkDuration: number; 308779efd5Sopenharmony_ci formattedNumber: string; 318779efd5Sopenharmony_ci quickSearchKey: string; 328779efd5Sopenharmony_ci numberType: number; 338779efd5Sopenharmony_ci numberTypeName: string; 348779efd5Sopenharmony_ci beginTime: number; 358779efd5Sopenharmony_ci endTime: number; 368779efd5Sopenharmony_ci answerState: number; 378779efd5Sopenharmony_ci createTime: number; 388779efd5Sopenharmony_ci numberLocation: string; 398779efd5Sopenharmony_ci photoId: number; 408779efd5Sopenharmony_ci photoUri: string; 418779efd5Sopenharmony_ci countryIsoCode: number; 428779efd5Sopenharmony_ci constructor(id: number, phoneNumber: string) { 438779efd5Sopenharmony_ci this.id = id; 448779efd5Sopenharmony_ci this.phoneNumber = phoneNumber; 458779efd5Sopenharmony_ci } 468779efd5Sopenharmony_ci 478779efd5Sopenharmony_ci static fromResultSet(resultSet: any): CallLogBuilder{ 488779efd5Sopenharmony_ci let callLogBuilder = new CallLogBuilder(resultSet.getLong(resultSet.getColumnIndex(Calls.ID)), 498779efd5Sopenharmony_ci resultSet.getString(resultSet.getColumnIndex(Calls.PHONE_NUMBER))); 508779efd5Sopenharmony_ci callLogBuilder.setDisplayName(resultSet.getString(resultSet.getColumnIndex(Calls.DISPLAY_NAME))); 518779efd5Sopenharmony_ci callLogBuilder.setCallDirection(resultSet.getLong(resultSet.getColumnIndex(Calls.CALL_DIRECTION))); 528779efd5Sopenharmony_ci callLogBuilder.setDisplayName(resultSet.getString(resultSet.getColumnIndex(Calls.DISPLAY_NAME))); 538779efd5Sopenharmony_ci callLogBuilder.setVoicemailUri(resultSet.getString(resultSet.getColumnIndex(Calls.VOICEMAIL_URI))); 548779efd5Sopenharmony_ci callLogBuilder.setSimId(resultSet.getLong(resultSet.getColumnIndex(Calls.SIM_ID))); 558779efd5Sopenharmony_ci callLogBuilder.setSimType(resultSet.getLong(resultSet.getColumnIndex(Calls.SIM_TYPE))); 568779efd5Sopenharmony_ci callLogBuilder.setIsHD(resultSet.getLong(resultSet.getColumnIndex(Calls.IS_HD)) > 0 ? true : false); 578779efd5Sopenharmony_ci callLogBuilder.setIsRead(resultSet.getLong(resultSet.getColumnIndex(Calls.IS_READ)) > 0 ? true : false); 588779efd5Sopenharmony_ci callLogBuilder.setRingDuration(resultSet.getLong(resultSet.getColumnIndex(Calls.RING_DURATION))); 598779efd5Sopenharmony_ci callLogBuilder.setTalkDuration(resultSet.getLong(resultSet.getColumnIndex(Calls.TALK_DURATION))); 608779efd5Sopenharmony_ci callLogBuilder.setFormattedNumber(resultSet.getString(resultSet.getColumnIndex(Calls.FORMAT_NUMBER))); 618779efd5Sopenharmony_ci callLogBuilder.setQuickSearchKey(resultSet.getString(resultSet.getColumnIndex(Calls.QUICK_SEARCH_KEY))); 628779efd5Sopenharmony_ci callLogBuilder.setNumberType(resultSet.getLong(resultSet.getColumnIndex(Calls.NUMBER_TYPE))); 638779efd5Sopenharmony_ci callLogBuilder.setNumberTypeName(resultSet.getString(resultSet.getColumnIndex(Calls.NUMBER_TYPE_NAME))); 648779efd5Sopenharmony_ci callLogBuilder.setBeginTime(resultSet.getLong(resultSet.getColumnIndex(Calls.BEGIN_TIME))); 658779efd5Sopenharmony_ci callLogBuilder.setEndTime(resultSet.getLong(resultSet.getColumnIndex(Calls.END_TIME))); 668779efd5Sopenharmony_ci callLogBuilder.setAnswerState(resultSet.getLong(resultSet.getColumnIndex(Calls.ANSWER_STATE))); 678779efd5Sopenharmony_ci callLogBuilder.setCreateTime(resultSet.getLong(resultSet.getColumnIndex(Calls.CREATE_TIME))); 688779efd5Sopenharmony_ci callLogBuilder.setNumberLocation(resultSet.getString(resultSet.getColumnIndex(Calls.NUMBER_LOCATION))); 698779efd5Sopenharmony_ci callLogBuilder.setPhotoUri(resultSet.getString(resultSet.getColumnIndex(Calls.PHOTO_URI))); 708779efd5Sopenharmony_ci callLogBuilder.setPhotoId(resultSet.getLong(resultSet.getColumnIndex(Calls.PHOTO_ID))); 718779efd5Sopenharmony_ci callLogBuilder.setCountryIsoCode(resultSet.getLong(resultSet.getColumnIndex(Calls.COUNTRY_ISO_CODE))); 728779efd5Sopenharmony_ci return callLogBuilder; 738779efd5Sopenharmony_ci } 748779efd5Sopenharmony_ci 758779efd5Sopenharmony_ci setDisplayName(displayName: string) { 768779efd5Sopenharmony_ci this.displayName = displayName; 778779efd5Sopenharmony_ci return this; 788779efd5Sopenharmony_ci } 798779efd5Sopenharmony_ci 808779efd5Sopenharmony_ci setCallDirection(callDirection: number) { 818779efd5Sopenharmony_ci this.callDirection = callDirection; 828779efd5Sopenharmony_ci return this; 838779efd5Sopenharmony_ci } 848779efd5Sopenharmony_ci 858779efd5Sopenharmony_ci setVoicemailUri(voicemailUri: string) { 868779efd5Sopenharmony_ci this.voicemailUri = voicemailUri; 878779efd5Sopenharmony_ci return this; 888779efd5Sopenharmony_ci } 898779efd5Sopenharmony_ci 908779efd5Sopenharmony_ci setSimId(simId: number) { 918779efd5Sopenharmony_ci this.simId = simId; 928779efd5Sopenharmony_ci return this; 938779efd5Sopenharmony_ci } 948779efd5Sopenharmony_ci 958779efd5Sopenharmony_ci setSimType(simType: number) { 968779efd5Sopenharmony_ci this.simType = simType; 978779efd5Sopenharmony_ci return this; 988779efd5Sopenharmony_ci } 998779efd5Sopenharmony_ci 1008779efd5Sopenharmony_ci setIsHD(isHD: boolean) { 1018779efd5Sopenharmony_ci this.isHD = isHD; 1028779efd5Sopenharmony_ci return this; 1038779efd5Sopenharmony_ci } 1048779efd5Sopenharmony_ci 1058779efd5Sopenharmony_ci setIsRead(isRead: boolean) { 1068779efd5Sopenharmony_ci this.isRead = isRead; 1078779efd5Sopenharmony_ci return this; 1088779efd5Sopenharmony_ci } 1098779efd5Sopenharmony_ci 1108779efd5Sopenharmony_ci setRingDuration(ringDuration: number) { 1118779efd5Sopenharmony_ci this.ringDuration = ringDuration; 1128779efd5Sopenharmony_ci return this; 1138779efd5Sopenharmony_ci } 1148779efd5Sopenharmony_ci 1158779efd5Sopenharmony_ci setTalkDuration(talkDuration: number) { 1168779efd5Sopenharmony_ci this.talkDuration = talkDuration; 1178779efd5Sopenharmony_ci return this; 1188779efd5Sopenharmony_ci } 1198779efd5Sopenharmony_ci 1208779efd5Sopenharmony_ci setFormattedNumber(formattedNumber: string) { 1218779efd5Sopenharmony_ci this.formattedNumber = formattedNumber; 1228779efd5Sopenharmony_ci return this; 1238779efd5Sopenharmony_ci } 1248779efd5Sopenharmony_ci 1258779efd5Sopenharmony_ci setQuickSearchKey(quickSearchKey: string) { 1268779efd5Sopenharmony_ci this.quickSearchKey = quickSearchKey; 1278779efd5Sopenharmony_ci return this; 1288779efd5Sopenharmony_ci } 1298779efd5Sopenharmony_ci 1308779efd5Sopenharmony_ci setNumberType(numberType: number) { 1318779efd5Sopenharmony_ci this.numberType = numberType; 1328779efd5Sopenharmony_ci return this; 1338779efd5Sopenharmony_ci } 1348779efd5Sopenharmony_ci 1358779efd5Sopenharmony_ci setNumberTypeName(numberTypeName: string) { 1368779efd5Sopenharmony_ci this.numberTypeName = numberTypeName; 1378779efd5Sopenharmony_ci return this; 1388779efd5Sopenharmony_ci } 1398779efd5Sopenharmony_ci 1408779efd5Sopenharmony_ci setBeginTime(beginTime: number) { 1418779efd5Sopenharmony_ci this.beginTime = beginTime; 1428779efd5Sopenharmony_ci return this; 1438779efd5Sopenharmony_ci } 1448779efd5Sopenharmony_ci 1458779efd5Sopenharmony_ci setEndTime(endTime: number) { 1468779efd5Sopenharmony_ci this.endTime = endTime; 1478779efd5Sopenharmony_ci return this; 1488779efd5Sopenharmony_ci } 1498779efd5Sopenharmony_ci 1508779efd5Sopenharmony_ci setAnswerState(answerState: number) { 1518779efd5Sopenharmony_ci this.answerState = answerState; 1528779efd5Sopenharmony_ci return this; 1538779efd5Sopenharmony_ci } 1548779efd5Sopenharmony_ci 1558779efd5Sopenharmony_ci setCreateTime(createTime: number) { 1568779efd5Sopenharmony_ci this.createTime = createTime; 1578779efd5Sopenharmony_ci return this; 1588779efd5Sopenharmony_ci } 1598779efd5Sopenharmony_ci 1608779efd5Sopenharmony_ci setNumberLocation(numberLocation: string) { 1618779efd5Sopenharmony_ci this.numberLocation = numberLocation; 1628779efd5Sopenharmony_ci return this; 1638779efd5Sopenharmony_ci } 1648779efd5Sopenharmony_ci 1658779efd5Sopenharmony_ci setPhotoId(photoId: number) { 1668779efd5Sopenharmony_ci this.photoId = photoId; 1678779efd5Sopenharmony_ci return this; 1688779efd5Sopenharmony_ci } 1698779efd5Sopenharmony_ci 1708779efd5Sopenharmony_ci setPhotoUri(photoUri: string) { 1718779efd5Sopenharmony_ci this.photoUri = photoUri; 1728779efd5Sopenharmony_ci return this; 1738779efd5Sopenharmony_ci } 1748779efd5Sopenharmony_ci 1758779efd5Sopenharmony_ci setCountryIsoCode(countryIsoCode: number) { 1768779efd5Sopenharmony_ci this.countryIsoCode = countryIsoCode; 1778779efd5Sopenharmony_ci return this; 1788779efd5Sopenharmony_ci } 1798779efd5Sopenharmony_ci}