From d526661bbda95fac478a75f75d9c911af90d4d5f Mon Sep 17 00:00:00 2001 From: Jihoon Chung Date: Mon, 21 Oct 2013 16:50:18 +0900 Subject: [PATCH] Add "GetDeviceCapability" to FeatureDAO * "GetDeviceCapability" moves from GlobalDAO to FeatureDAO [Issue#] LINUXWRT-1020 [Problem] GlobalDAO has unnecessary API. [Cause] N/A [Solution] Add GetDeviceCapability to FeatureDAO - As GlobalDAO is deprecated, move GetDeviceCapability to FeatureDAO. - This commit add new API to FeatureDAO. [Verification] Build repos. [SCMRequest] Needed by https://review.tizendev.org/gerrit/#/c/93617/ Change-Id: Idb9cb6f94d258a0d6758ea55b6fc5b86319fb4b3 --- modules/widget_dao/dao/feature_dao_read_only.cpp | 43 ++++++++++++++++++++++ .../include/dpl/wrt-dao-ro/feature_dao_read_only.h | 5 +++ 2 files changed, 48 insertions(+) diff --git a/modules/widget_dao/dao/feature_dao_read_only.cpp b/modules/widget_dao/dao/feature_dao_read_only.cpp index cab3fba..ee188bd 100644 --- a/modules/widget_dao/dao/feature_dao_read_only.cpp +++ b/modules/widget_dao/dao/feature_dao_read_only.cpp @@ -370,6 +370,49 @@ FeatureDAOReadOnly::GetDevCapWithFeatureHandle() } } +DeviceCapabilitySet FeatureDAOReadOnly::GetDeviceCapability( + const DPL::String &apifeature) +{ + // This could be done with one simply sql query but support for join is + // needed in orm. + Try { + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + + int featureUUID; + FeatureDeviceCapProxy::Select::RowList rows; + DeviceCapabilitySet result; + + { + WRT_DB_SELECT(select, FeaturesList, &WrtDatabase::interface()) + select->Where(Equals(apifeature)); + featureUUID = select->GetSingleValue(); + } + + { + WRT_DB_SELECT(select, + FeatureDeviceCapProxy, + &WrtDatabase::interface()) + select->Where(Equals( + featureUUID)); + rows = select->GetRowList(); + } + + FOREACH(it, rows){ + WRT_DB_SELECT(select, DeviceCapabilities, &WrtDatabase::interface()) + select->Where(Equals( + it->Get_DeviceCapID())); + result.insert(select-> + GetSingleValue()); + } + + return result; + } Catch(DPL::DB::SqlConnection::Exception::Base){ + ReThrowMsg(FeatureDAOReadOnly::Exception::DatabaseError, + "Failed to get device capability"); + } +} + FeatureDAOReadOnly::FeatureMap FeatureDAOReadOnly::GetFeatures(const std::list& featureNames) { diff --git a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h index 14aec55..f366012 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h +++ b/modules/widget_dao/include/dpl/wrt-dao-ro/feature_dao_read_only.h @@ -32,6 +32,9 @@ #include namespace WrtDB { +// TODO: Move to feature_model.h +typedef std::set DeviceCapabilitySet; + class FeatureDAOReadOnly { public: @@ -46,6 +49,7 @@ class FeatureDAOReadOnly DECLARE_EXCEPTION_TYPE(Base, FeatureNotExist) }; + // TODO: Move to feature_model.h typedef std::set DeviceCapabilitiesList; typedef std::multimap DeviceCapabilitiesMap; typedef std::map NameMap; @@ -72,6 +76,7 @@ class FeatureDAOReadOnly static NameMap GetNames(); static DeviceCapabilitiesMap GetDevCapWithFeatureHandle(); + static DeviceCapabilitySet GetDeviceCapability(const DPL::String &apifeature); static FeatureMap GetFeatures(const std::list& featureNames); -- 2.7.4