1 /* 2 * Copyright (C) 2024 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 16 #ifndef OHOS_BACKUP_MEDIA_TAB_OLD_PHOTOS_RESTORE 17 #define OHOS_BACKUP_MEDIA_TAB_OLD_PHOTOS_RESTORE 18 19 #include <string> 20 #include <vector> 21 22 #include "rdb_store.h" 23 #include "backup_const.h" 24 25 namespace OHOS::Media { 26 class TabOldPhotosRestore { 27 public: 28 int32_t Restore(std::shared_ptr<NativeRdb::RdbStore> &rdbStorePtr, const std::vector<FileInfo> fileInfos); 29 30 private: 31 std::string ToString(const std::vector<NativeRdb::ValueObject> &values); 32 std::string ToString(const FileInfo &fileInfo); 33 34 const std::string SQL_TAB_OLD_PHOTOS_INSERT = "\ 35 INSERT INTO tab_old_photos \ 36 ( \ 37 file_id, \ 38 data, \ 39 old_file_id, \ 40 old_data \ 41 ) \ 42 SELECT Photos.file_id, \ 43 INPUT.data, \ 44 INPUT.old_file_id, \ 45 INPUT.old_data \ 46 FROM Photos \ 47 INNER JOIN \ 48 ( \ 49 SELECT ? AS old_file_id, \ 50 ? AS old_data, \ 51 ? AS data \ 52 ) AS INPUT \ 53 ON Photos.data=INPUT.data \ 54 LEFT JOIN tab_old_photos \ 55 ON INPUT.old_data=tab_old_photos.old_data \ 56 WHERE tab_old_photos.old_data IS NULL AND \ 57 COALESCE(hidden, 0) = 0 AND \ 58 COALESCE(date_trashed, 0) = 0;"; 59 }; 60 } // namespace OHOS::Media 61 #endif // OHOS_BACKUP_MEDIA_TAB_OLD_PHOTOS_RESTORE