[DataControl] Added sort mode to select() function.
authorTomasz Marciniak <t.marciniak@samsung.com>
Tue, 5 Jan 2016 09:29:14 +0000 (10:29 +0100)
committerTomasz Marciniak <t.marciniak@samsung.com>
Tue, 5 Jan 2016 09:42:42 +0000 (10:42 +0100)
[Verification] Code compiles. Data is sorted regardring
to passed order mode.

Change-Id: Idbe925600f6f0065011a088e12ee2ddf079b14f0
Signed-off-by: Tomasz Marciniak <t.marciniak@samsung.com>
src/datacontrol/datacontrol_api.js
src/datacontrol/datacontrol_instance.cc

index d30d0f55a49ac4f615ed14585d2a207b12a8fa35..98b755954b313f2e6e554a00b2b3ba029be8e404 100755 (executable)
@@ -243,7 +243,8 @@ SQLDataControlConsumer.prototype.select = function(reqId, columns, where, succes
     {'name': 'successCallback', 'type': types_.FUNCTION},
     {'name': 'errorCallback', 'type': types_.FUNCTION, optional: true, nullable: true},
     {'name': 'page', 'type': types_.LONG, optional: true},
-    {'name': 'maxNumberPerPage', 'type': types_.LONG, optional: true}
+    {'name': 'maxNumberPerPage', 'type': types_.LONG, optional: true},
+    {'name': 'order', 'type': types_.STRING, optional: true, nullable: true}
   ]);
 
   var nativeParam = {
@@ -259,6 +260,10 @@ SQLDataControlConsumer.prototype.select = function(reqId, columns, where, succes
   if (args['maxNumberPerPage']) {
     nativeParam['maxNumberPerPage'] = args.maxNumberPerPage;
   }
+  if (args['order']) {
+    nativeParam['order'] = args.order;
+  }
+
   try {
     var syncResult =
         callNativeWithCallback('SQLDataControlConsumer_select', nativeParam, function(result) {
index dc9e6c85ed8f11a5b4db9c2b32740cc67979c470..8e6c258e1972379c32cfd28f519506053aaa2292 100755 (executable)
@@ -743,8 +743,13 @@ void DatacontrolInstance::SQLDataControlConsumerSelect(
         static_cast<int>(args.get("maxNumberPerPage").get<double>());
   }
 
+  char* order = nullptr;
+  if (args.contains("order")) {
+    order = const_cast<char*>(args.get("order").get<std::string>().c_str());
+  }
+
   int result = RunSQLDataControlJob(providerId, dataId, callbackId, reqId,
-                                    [&columns, &where, page, maxNumberPerPage](
+                                    [&columns, &where, order, page, maxNumberPerPage](
                                         data_control_h& handle,
                                         int *requestId) -> int {
     LoggerD("Enter");
@@ -756,11 +761,11 @@ void DatacontrolInstance::SQLDataControlConsumerSelect(
     if (page > 0 && maxNumberPerPage > 0) {
       return ::data_control_sql_select_with_page(handle, cColumns,
                                                  columnCount, where.c_str(),
-                                                 "1 ASC", page,
+                                                 order, page,
                                                  maxNumberPerPage, requestId);
     } else {
       return ::data_control_sql_select(handle, cColumns, columnCount,
-                                       where.c_str(), "1 ASC", requestId);
+                                       where.c_str(), order, requestId);
     }
   });