Merge pull request #14 from jvelilla/roc_template

Update sqlite implemenation to make it compile
This commit is contained in:
jvelilla
2014-11-14 08:26:06 -03:00
7 changed files with 54 additions and 247 deletions

View File

@@ -1,7 +1,7 @@
note
description: "Object that handle a database connection for ODBC"
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
revision: "$Revision: 95678 $"
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
class
DATABASE_CONNECTION_ODBC
@@ -13,6 +13,8 @@ inherit
db_application
end
SHARED_LOGGER
create
make, make_common, make_basic, login_with_connection_string
@@ -24,7 +26,7 @@ feature -- Initialization
l_retried: BOOLEAN
do
create db_application.login (username, password)
create database_error_handler.make
if not l_retried then
db_application.set_hostname (hostname)
db_application.set_data_source (database_name)
@@ -34,14 +36,13 @@ feature -- Initialization
if keep_connection then
connect
end
set_successful
else
create db_control.make
end
rescue
create db_control.make
set_last_error_from_exception ("Connection execution")
log.write_critical (generator + ".make_common:" + last_error_message)
-- set_last_error_from_exception ("Connection execution")
-- log.write_critical (generator + ".make_common:" + last_error_message)
if is_connected then
disconnect
end
@@ -56,7 +57,7 @@ feature -- Initialization
l_retried: BOOLEAN
do
create db_application.login (username, password)
create database_error_handler.make
if not l_retried then
db_application.set_hostname (hostname)
db_application.set_data_source (a_database_name)
@@ -66,14 +67,13 @@ feature -- Initialization
if keep_connection then
connect
end
set_successful
else
create db_control.make
end
rescue
create db_control.make
set_last_error_from_exception ("Connection execution")
log.write_critical (generator + ".make_common:" + last_error_message)
-- set_last_error_from_exception ("Connection execution")
-- log.write_critical (generator + ".make_common:" + last_error_message)
if is_connected then
disconnect
end
@@ -88,6 +88,7 @@ feature -- Initialization
-- `database_name' to `a_database_name'
-- `connection' to `a_connection'
do
create database_error_handler.make
create db_application.login (a_username, a_password)
db_application.set_hostname (a_hostname)
db_application.set_data_source (a_database_name)
@@ -104,6 +105,7 @@ feature -- Initialization
do
log.write_debug (generator +".login_with_connection_string")
create db_application.login_with_connection_string (a_string)
create database_error_handler.make
db_application.set_base
create db_control.make
log.write_debug (generator +".login_with_connection_string, is_keep_connection? "+ is_keep_connection.out )

View File

@@ -13,7 +13,6 @@
<library name="layout" location="..\..\..\layout\layout-safe.ecf"/>
<library name="model" location="..\..\..\model\cms_model-safe.ecf"/>
<library name="logging" location="$ISE_LIBRARY\library\runtime\logging\logging-safe.ecf"/>
<library name="mysql" location="$ISE_LIBRARY\library\store\dbms\rdbms\mysql\mysql-safe.ecf"/>
<library name="odbc" location="$ISE_LIBRARY\library\store\dbms\rdbms\odbc\odbc-safe.ecf"/>
<library name="store" location="$ISE_LIBRARY\library\store\store-safe.ecf" readonly="false"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>

View File

@@ -1,7 +1,7 @@
note
description: "Summary description for {CMS_STORAGE_MYSQL}."
date: "$Date$"
revision: "$Revision$"
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
class
CMS_STORAGE_SQLITE
@@ -24,8 +24,7 @@ feature {NONE} -- Initialization
log.write_information (generator+".make_with_database is database connected? "+ a_connection.is_connected.out )
create node_provider.make (a_connection)
create user_provider.make (a_connection)
post_node_provider_execution
post_user_provider_execution
create error_handler.make
end
@@ -35,7 +34,7 @@ feature -- Access: user
-- Has any user?
do
Result := user_provider.has_user
post_user_provider_execution
end
@@ -48,19 +47,19 @@ feature -- Access: user
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
do
Result := user_provider.user (a_id)
post_user_provider_execution
end
user_by_name (a_name: like {CMS_USER}.name): detachable CMS_USER
do
Result := user_provider.user_by_name (a_name)
post_user_provider_execution
end
user_by_email (a_email: like {CMS_USER}.email): detachable CMS_USER
do
Result := user_provider.user_by_email (a_email)
post_user_provider_execution
end
is_valid_credential (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
@@ -82,7 +81,7 @@ feature -- Access: user
log.write_information (generator + ".login_valid User:" + l_auth_login + "does not exist" )
end
end
post_user_provider_execution
end
feature -- Change: user
@@ -149,7 +148,7 @@ feature -- Access: node
across node_provider.nodes as c loop
Result.force (c.item)
end
post_node_provider_execution
end
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
@@ -159,14 +158,14 @@ feature -- Access: node
across node_provider.recent_nodes (a_lower,a_count) as c loop
Result.force (c.item)
end
post_node_provider_execution
end
node (a_id: INTEGER_64): detachable CMS_NODE
--
do
Result := node_provider.node (a_id)
post_node_provider_execution
end
@@ -176,37 +175,37 @@ feature -- Node
-- Add a new node
do
node_provider.new_node (a_node)
post_node_provider_execution
end
delete_node (a_id: INTEGER_64)
do
node_provider.delete_node (a_id)
post_node_provider_execution
end
update_node (a_id: like {CMS_USER}.id; a_node: CMS_NODE)
do
node_provider.update_node (a_node)
post_node_provider_execution
end
update_node_title (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_title: READABLE_STRING_32)
do
node_provider.update_node_title (a_id, a_title)
post_node_provider_execution
end
update_node_summary (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
do
node_provider.update_node_summary (a_id, a_summary)
post_node_provider_execution
end
update_node_content (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
do
node_provider.update_node_content (a_id, a_content)
post_node_provider_execution
end
@@ -239,29 +238,7 @@ feature -- User
end
end
feature {NONE} -- Post process
post_node_provider_execution
do
if node_provider.successful then
set_successful
else
if attached node_provider.last_error then
set_last_error_from_handler (node_provider.last_error)
end
end
end
post_user_provider_execution
do
if user_provider.successful then
set_successful
else
if attached user_provider.last_error then
set_last_error_from_handler (user_provider.last_error)
end
end
end
feature {NONE} -- Implementation
node_provider: NODE_DATA_PROVIDER
-- Node Data provider.

View File

@@ -1,145 +0,0 @@
note
description: "Object that handle a database connection for ODBC"
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
revision: "$Revision: 95678 $"
class
DATABASE_CONNECTION_MYSQL
inherit
DATABASE_CONNECTION
redefine
db_application
end
create
make, make_common, make_basic, login_with_connection_string, login_with_schema
feature -- Initialization
make_common
-- Create a database handler for MYSQL with common settings.
local
l_retried: BOOLEAN
do
create db_application.login (username, password)
if not l_retried then
db_application.set_hostname (hostname)
db_application.set_data_source (database_name)
db_application.set_base
create db_control.make
keep_connection := is_keep_connection
if keep_connection then
connect
end
set_successful
else
create db_control.make
end
rescue
create db_control.make
set_last_error_from_exception ("Connection execution")
log.write_critical (generator + ".make_common:" + last_error_message)
if is_connected then
disconnect
end
l_retried := True
retry
end
make_basic (a_database_name: STRING)
-- Create a database handler and
-- set database_name to `a_database_name'.
local
l_retried: BOOLEAN
do
create db_application.login (username, password)
if not l_retried then
db_application.set_hostname (hostname)
db_application.set_data_source (a_database_name)
db_application.set_base
create db_control.make
keep_connection := is_keep_connection
if keep_connection then
connect
end
set_successful
else
create db_control.make
end
rescue
create db_control.make
set_last_error_from_exception ("Connection execution")
log.write_critical (generator + ".make_common:" + last_error_message)
if is_connected then
disconnect
end
l_retried := True
retry
end
make (a_username: STRING; a_password: STRING; a_hostname: STRING; a_database_name: STRING; connection: BOOLEAN)
-- Create a database handler for ODBC and set `username' to `a_username',
-- `password' to `a_password'
-- `database_name' to `a_database_name'
-- `connection' to `a_connection'
do
create db_application.login (a_username, a_password)
db_application.set_hostname (a_hostname)
db_application.set_data_source (a_database_name)
db_application.set_base
create db_control.make
keep_connection := connection
if keep_connection then
connect
end
end
login_with_connection_string (a_string: STRING)
-- Login with `a_connection_string'and immediately connect to database.
local
l_string: LIST[STRING]
l_server: STRING
l_port: STRING
l_schema: STRING
l_user: STRING
l_password: STRING
do
l_string := a_string.split (';')
l_server := l_string.at (2).split ('=').at (2)
l_port := l_string.at (3).split ('=').at (2)
l_schema := l_string.at (4).split ('=').at (2)
l_user := l_string.at (5).split ('=').at (2)
l_password := l_string.at (6).split ('=').at (2)
create db_application
db_application.set_application (l_schema)
db_application.set_hostname (l_server + ":" + l_port)
db_application.login_and_connect (l_user, l_password)
db_application.set_base
create db_control.make
keep_connection := is_keep_connection
end
login_with_schema (a_schema: STRING; a_username: STRING; a_password: STRING)
-- Login with `a_connection_string'and immediately connect to database.
do
create db_application
db_application.set_application (a_schema)
db_application.login_and_connect (a_username, a_password)
db_application.set_base
create db_control.make
keep_connection := is_keep_connection
end
feature -- Databse Connection
db_application: DATABASE_APPL [MYSQL]
-- Database application.
end

View File

@@ -1,7 +1,7 @@
note
description: "Database access for node uses cases."
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
revision: "$Revision: 95678 $"
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
class
NODE_DATA_PROVIDER
@@ -23,7 +23,7 @@ feature -- Initialization
-- Create a data provider.
do
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
post_execution
end
db_handler: DATABASE_HANDLER
@@ -34,7 +34,7 @@ feature -- Status Report
is_successful: BOOLEAN
-- Is the last execution sucessful?
do
Result := db_handler.successful
Result := not db_handler.has_error
end
feature -- Access
@@ -49,7 +49,7 @@ feature -- Access
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Select_nodes, l_parameters))
db_handler.execute_query
create Result.make (db_handler, agent fetch_node)
post_execution
end
recent_nodes (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [CMS_NODE]
@@ -66,7 +66,7 @@ feature -- Access
db_handler.set_query (create {DATABASE_QUERY}.data_reader (l_query, l_parameters))
db_handler.execute_query
create Result.make (db_handler, agent fetch_node)
post_execution
end
node (a_id: INTEGER_64): detachable CMS_NODE
@@ -82,7 +82,7 @@ feature -- Access
if db_handler.count = 1 then
Result := fetch_node
end
post_execution
end
count: INTEGER
@@ -97,7 +97,7 @@ feature -- Access
if db_handler.count = 1 then
Result := db_handler.read_integer_32 (1)
end
post_execution
end
feature -- Basic operations
@@ -117,7 +117,7 @@ feature -- Basic operations
l_parameters.put (a_node.modification_date, "modification_date")
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_insert_node, l_parameters))
db_handler.execute_change
post_execution
end
update_node_title (a_id: INTEGER_64; a_title: READABLE_STRING_32)
@@ -132,7 +132,7 @@ feature -- Basic operations
l_parameters.put (a_id, "id")
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_update_node_title, l_parameters))
db_handler.execute_change
post_execution
end
update_node_summary (a_id: INTEGER_64; a_summary: READABLE_STRING_32)
@@ -147,7 +147,7 @@ feature -- Basic operations
l_parameters.put (a_id, "id")
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_update_node_summary, l_parameters))
db_handler.execute_change
post_execution
end
update_node_content (a_id: INTEGER_64; a_content: READABLE_STRING_32)
@@ -162,7 +162,7 @@ feature -- Basic operations
l_parameters.put (a_id, "id")
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_update_node_content, l_parameters))
db_handler.execute_change
post_execution
end
update_node (a_node: CMS_NODE)
@@ -181,7 +181,7 @@ feature -- Basic operations
l_parameters.put (a_node.id, "id")
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_update_node, l_parameters))
db_handler.execute_change
post_execution
end
delete_node (a_id: INTEGER_64;)
@@ -194,7 +194,6 @@ feature -- Basic operations
l_parameters.put (a_id, "id")
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_delete_node, l_parameters))
db_handler.execute_change
post_execution
end
feature -- Connection
@@ -272,18 +271,5 @@ feature -- New Object
end
end
feature {NONE} -- Implementation
post_execution
-- Post database execution.
do
if db_handler.successful then
set_successful
else
if attached db_handler.last_error then
set_last_error_from_handler (db_handler.last_error)
end
end
end
end

View File

@@ -1,7 +1,7 @@
note
description: "Summary description for {USER_DATA_PROVIDER}."
date: "$Date$"
revision: "$Revision$"
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
revision: "$Revision: 96085 $"
class
USER_DATA_PROVIDER
@@ -23,7 +23,7 @@ feature -- Initialization
-- Create a data provider.
do
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
post_execution
end
db_handler: DATABASE_HANDLER
@@ -34,7 +34,7 @@ feature -- Status Report
is_successful: BOOLEAN
-- Is the last execution sucessful?
do
Result := db_handler.successful
Result := not db_handler.has_error
end
has_user: BOOLEAN
@@ -64,7 +64,7 @@ feature -- Basic Operations
l_parameters.put (a_email,"email")
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_insert_user, l_parameters))
db_handler.execute_change
post_execution
end
user (a_id: INTEGER_64): detachable CMS_USER
@@ -80,7 +80,7 @@ feature -- Basic Operations
if db_handler.count = 1 then
Result := fetch_user
end
post_execution
end
user_by_name (a_name: READABLE_STRING_32): detachable CMS_USER
@@ -96,7 +96,7 @@ feature -- Basic Operations
if db_handler.count = 1 then
Result := fetch_user
end
post_execution
end
@@ -113,7 +113,7 @@ feature -- Basic Operations
if db_handler.count = 1 then
Result := fetch_user
end
post_execution
end
user_salt (a_username: READABLE_STRING_32): detachable READABLE_STRING_32
@@ -131,7 +131,7 @@ feature -- Basic Operations
Result := l_salt.as_string_32
end
end
post_execution
end
count: INTEGER
@@ -146,7 +146,7 @@ feature -- Basic Operations
if db_handler.count = 1 then
Result := db_handler.read_integer_32 (1)
end
post_execution
end
feature -- New Object
@@ -189,18 +189,5 @@ feature -- Sql Queries
-- SQL Insert to add a new node.
feature {NONE} -- Implementation
post_execution
-- Post database execution.
do
if db_handler.successful then
set_successful
else
if attached db_handler.last_error then
set_last_error_from_handler (db_handler.last_error)
end
end
end
end

View File

@@ -8,6 +8,7 @@
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
<library name="model" location="..\..\..\..\model\cms_model-safe.ecf"/>
<library name="persitence_sqlite" location="..\persistence_sqlite-safe.ecf" readonly="false"/>
<library name="process" location="$ISE_LIBRARY\library\process\process-safe.ecf"/>
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>