namespace {
DPL::DB::SqlConnection::Flag::Type DATABASE_FLAGS =
DPL::DB::SqlConnection::Flag::UseLucene;
+DPL::DB::SqlConnection::Flag::Option DATABASE_OPTIONS =
+ DPL::DB::SqlConnection::Flag::RW;
const char *KEY_WIDGET_ARG = "widget_arg";
}
if (!checkDatabase()) {
LogError("There is a problem with database");
}
- m_databaseInterface.AttachToThread();
+ m_databaseInterface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
}
WidgetInterfaceDAO::~WidgetInterfaceDAO()
Try
{
- DPL::DB::SqlConnection con(databaseFile);
+ DPL::DB::SqlConnection con(databaseFile,
+ DATABASE_FLAGS, DATABASE_OPTIONS);
con.ExecCommand(buffer.str().c_str());
}
Catch(DPL::DB::SqlConnection::Exception::Base)
using namespace DPL::DB::ORM::widget_interface;
bool result = true;
- WrtDB::WrtDatabase::attachToThread();
- m_databaseInterface.AttachToThread();
+ WrtDB::WrtDatabase::attachToThreadRO();
+ m_databaseInterface.AttachToThread(DPL::DB::SqlConnection::Flag::RW);
Try
{
//check if key exists
Properties::Select select(&m_databaseInterface);
select.Where(
- Equals<Properties::key>(DPL::FromASCIIString(key)));
+ Equals<Properties::key>(DPL::FromUTF8String(key)));
std::list<Properties::Row> rows = select.GetRowList();
if (rows.size() == 0) {
Properties::Insert insert(&m_databaseInterface);
Properties::Row row;
- row.Set_key(DPL::FromASCIIString(key));
- row.Set_value(DPL::FromASCIIString(value));
+ row.Set_key(DPL::FromUTF8String(key));
+ row.Set_value(DPL::FromUTF8String(value));
row.Set_readonly(readOnly ? 1 : 0);
row.Set_configxml(fromConfigXml ? 1 : 0);
insert.Values(row);
if (row.Get_readonly() != 0) {
Throw(Commons::LocalStorageValueNoModifableException);
}
- row.Set_value(DPL::FromASCIIString(value));
+ row.Set_value(DPL::FromUTF8String(value));
row.Set_readonly(readOnly ? 1 : 0);
Properties::Update update(&m_databaseInterface);
- update.Where(Equals<Properties::key>(DPL::FromASCIIString(key)));
+ update.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
update.Values(row);
update.Execute();
}
Try
{
Properties::Select select(&m_databaseInterface);
- select.Where(Equals<Properties::key>(DPL::FromASCIIString(key)));
+ select.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
bool readonly = select.GetSingleValue<Properties::readonly>();
if (readonly) {
ThrowMsg(Commons::LocalStorageValueNoModifableException,
"Cannot delete item. Item is readonly");
}
Properties::Delete deleteItem(&m_databaseInterface);
- deleteItem.Where(Equals<Properties::key>(DPL::FromASCIIString(key)));
+ deleteItem.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
deleteItem.Execute();
}
Catch(DPL::DB::SqlConnection::Exception::Base)
Try
{
Properties::Select select(&m_databaseInterface);
- select.Where(Equals<Properties::key>(DPL::FromASCIIString(key)));
+ select.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
std::list<DPL::String> value = select.GetValueList<Properties::value>();
if (value.size() == 0) {
return DPL::Optional<std::string>();
return 0;
}
-std::string WidgetInterfaceDAO::getValueByIndex(size_t index) const
+std::string WidgetInterfaceDAO::getKeyByIndex(size_t index) const
{
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::widget_interface;
Properties::Select select(&m_databaseInterface);
select.OrderBy("key");
std::list<DPL::String> list =
- select.GetValueList<Properties::value>();
+ select.GetValueList<Properties::key>();
if (index >= list.size()) {
Throw(Commons::InvalidArgumentException);
}
using namespace WrtDB::WidgetConfig;
using namespace WrtDB::GlobalConfig;
- WrtDB::WrtDatabase::attachToThread();
+ WrtDB::WrtDatabase::attachToThreadRO();
std::stringstream filename;
Try