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
16 #include "rdb_data_handler.h"
17
18 namespace OHOS {
19 namespace FileManagement {
20 namespace CloudSync {
21 using namespace std;
22 using namespace NativeRdb;
23
BatchInsert(int64_t & outRowId,const string & table,const vector<ValuesBucket> & initialBatchValues)24 int32_t RdbDataHandler::BatchInsert(int64_t &outRowId, const string &table,
25 const vector<ValuesBucket> &initialBatchValues)
26 {
27 if (initialBatchValues.size() != 0) {
28 return rdb_->BatchInsert(outRowId, table, initialBatchValues);
29 }
30 return E_OK;
31 }
32
BeginTransaction()33 int32_t RdbDataHandler::BeginTransaction()
34 {
35 return rdb_->BeginTransaction();
36 }
37
RollBack()38 int32_t RdbDataHandler::RollBack()
39 {
40 return rdb_->RollBack();
41 }
42
Commit()43 int32_t RdbDataHandler::Commit()
44 {
45 return rdb_->Commit();
46 }
47
Insert(int64_t & outRowId,const ValuesBucket & initiavalues)48 int32_t RdbDataHandler::Insert(int64_t &outRowId, const ValuesBucket &initiavalues)
49 {
50 return rdb_->Insert(outRowId, tableName_, initiavalues);
51 }
52
Update(int & changedRows,const ValuesBucket & values,const string & whereClause,const vector<string> & whereArgs)53 int32_t RdbDataHandler::Update(int &changedRows, const ValuesBucket &values,
54 const string &whereClause, const vector<string> &whereArgs)
55 {
56 return rdb_->Update(changedRows, tableName_, values, whereClause, whereArgs);
57 }
58
Delete(int & deletedRows,const string & whereClause,const vector<string> & whereArgs)59 int32_t RdbDataHandler::Delete(int &deletedRows, const string &whereClause, const vector<string> &whereArgs)
60 {
61 return rdb_->Delete(deletedRows, tableName_, whereClause, whereArgs);
62 }
63
Query(const NativeRdb::AbsRdbPredicates & predicates,const std::vector<std::string> & columns)64 shared_ptr<NativeRdb::ResultSet> RdbDataHandler::Query(
65 const NativeRdb::AbsRdbPredicates &predicates, const std::vector<std::string> &columns)
66 {
67 return rdb_->Query(predicates, columns);
68 }
69
Insert(int64_t & outRowId,const std::string & tableName,const ValuesBucket & initiavalues)70 int32_t RdbDataHandler::Insert(int64_t &outRowId, const std::string &tableName, const ValuesBucket &initiavalues)
71 {
72 return rdb_->Insert(outRowId, tableName, initiavalues);
73 }
74
Update(int & changedRows,const std::string & tableName,const ValuesBucket & values,const string & whereClause,const vector<string> & whereArgs)75 int32_t RdbDataHandler::Update(int &changedRows, const std::string &tableName, const ValuesBucket &values,
76 const string &whereClause, const vector<string> &whereArgs)
77 {
78 return rdb_->Update(changedRows, tableName, values, whereClause, whereArgs);
79 }
80
Delete(int & deletedRows,const std::string & tableName,const string & whereClause,const vector<string> & whereArgs)81 int32_t RdbDataHandler::Delete(int &deletedRows, const std::string &tableName,
82 const string &whereClause, const vector<string> &whereArgs)
83 {
84 return rdb_->Delete(deletedRows, tableName, whereClause, whereArgs);
85 }
86
ExecuteSql(const std::string & sql,const std::vector<NativeRdb::ValueObject> & bindArgs)87 int32_t RdbDataHandler::ExecuteSql(const std::string &sql, const std::vector<NativeRdb::ValueObject> &bindArgs)
88 {
89 return rdb_->ExecuteSql(sql, bindArgs);
90 }
91 } // namespace CloudSync
92 } // namespace FileManagement
93 } // namespace OHOS