Add widgetDAO API to update tizen application id field
authorJihoon Chung <jihoon.chung@samsaung.com>
Sun, 4 Aug 2013 07:56:49 +0000 (16:56 +0900)
committerJihoon Chung <jihoon.chung@samsaung.com>
Sun, 4 Aug 2013 08:05:47 +0000 (17:05 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution]
Add updateTizenAppId WidgetDAO API
Deprecated registerOrUpdateWidget, backupAndUpdateWidget and
restoreUpdateWidget.
[SCMRequest] N/A

Change-Id: Iac505db9a7934741071fb8ca1657fac4738dd96f

modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h

index d9d0944a14c1988ad0a7898e61b4e7ed041d170e..e33290fcf0fc3122b975e6a3ac4802389ed7ffa0 100644 (file)
@@ -239,6 +239,39 @@ TizenAppId WidgetDAO::registerWidgetGeneratePkgId(
     return tzAppId;
 }
 
+void WidgetDAO::updateTizenAppId(
+    const TizenAppId & fromAppId,
+    const TizenAppId & toAppId)
+{
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        using namespace DPL::DB::ORM;
+        using namespace DPL::DB::ORM::wrt;
+
+        ScopedTransaction transaction(&WrtDatabase::interface());
+        if (!isWidgetInstalled(fromAppId)) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Cannot find widget. tzAppId: " << fromAppId);
+        }
+
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
+
+        WidgetInfo::Row row = select->GetSingleRow();
+
+        //WidgetInfo::Row row;
+        row.Set_tizen_appid(toAppId);
+
+        WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface())
+        update->Where(Equals<WidgetInfo::tizen_appid>(fromAppId));
+        update->Values(row);
+        update->Execute();
+
+        transaction.Commit();
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to update appid")
+}
+
 void WidgetDAO::registerWidgetInternal(
     const TizenAppId & tzAppId,
     const WidgetRegisterInfo &widgetRegInfo,
index 6781adc3ce32e28ddd7bad14bb2ab017084dbeec..a1fb78491e4b1fb46b295f829a16a58853b61a39 100644 (file)
@@ -87,6 +87,9 @@ class WidgetDAO : public WidgetDAOReadOnly
         const WidgetRegisterInfo &pWidgetRegisterInfo,
         const IWidgetSecurity &widgetSecurity);
 
+    static void updateTizenAppId(const TizenAppId & fromAppId,
+                                 const TizenAppId & toAppId);
+
     /**
      * This method re-registers the widget information to the DB when it is
      * installed.
@@ -103,7 +106,7 @@ class WidgetDAO : public WidgetDAOReadOnly
     static void registerOrUpdateWidget(
         const TizenAppId & tzAppId,
         const WidgetRegisterInfo &widgetRegInfo,
-        const IWidgetSecurity &widgetSecurity);
+        const IWidgetSecurity &widgetSecurity) __attribute__((deprecated));
 
     /* This method backup widget information and update new widget information
      * for restore widget information
@@ -112,11 +115,11 @@ class WidgetDAO : public WidgetDAOReadOnly
         const TizenAppId & oldAppId,
         const TizenAppId & newAppId,
         const WidgetRegisterInfo &widgetRegInfo,
-        const IWidgetSecurity &widgetSecurity);
+        const IWidgetSecurity &widgetSecurity) __attribute__((deprecated));
 
     static void restoreUpdateWidget(
         const TizenAppId & oldAppId,
-        const TizenAppId & newAppId);
+        const TizenAppId & newAppId) __attribute__((deprecated));
 
     /**
      * This method removes a widget's information from EmDB.
@@ -236,7 +239,7 @@ class WidgetDAO : public WidgetDAOReadOnly
 
     static void updateWidgetAppIdInternal(
         const TizenAppId & fromAppId,
-        const TizenAppId & toAppId);
+        const TizenAppId & toAppId) __attribute__((deprecated));
 
     static void insertAppControlInfo(DbWidgetHandle handle,
                                              DPL::String src,