From 8047880c2b54408b03543aea55f11da3c5288d80 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Thu, 13 Nov 2014 23:46:02 -0300 Subject: [PATCH] Update sqlite implemenation to make it compile --- .../database/database_connection_odbc.e | 22 +-- .../sqlite/persistence_sqlite-safe.ecf | 1 - .../sqlite/src/cms_storage_sqlite.e | 59 +++---- .../src/database/database_connection_mysql.e | 145 ------------------ .../sqlite/src/provider/node_data_provider.e | 40 ++--- .../sqlite/src/provider/user_data_provider.e | 33 ++-- .../sqlite/tests/tests-safe.ecf | 1 + 7 files changed, 54 insertions(+), 247 deletions(-) delete mode 100644 library/persistence/implementation/sqlite/src/database/database_connection_mysql.e diff --git a/library/persistence/implementation/common/database/database_connection_odbc.e b/library/persistence/implementation/common/database/database_connection_odbc.e index 3e7ea74..cc03ea5 100644 --- a/library/persistence/implementation/common/database/database_connection_odbc.e +++ b/library/persistence/implementation/common/database/database_connection_odbc.e @@ -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 ) diff --git a/library/persistence/implementation/sqlite/persistence_sqlite-safe.ecf b/library/persistence/implementation/sqlite/persistence_sqlite-safe.ecf index 9e6d263..10aa724 100644 --- a/library/persistence/implementation/sqlite/persistence_sqlite-safe.ecf +++ b/library/persistence/implementation/sqlite/persistence_sqlite-safe.ecf @@ -13,7 +13,6 @@ - diff --git a/library/persistence/implementation/sqlite/src/cms_storage_sqlite.e b/library/persistence/implementation/sqlite/src/cms_storage_sqlite.e index 849685e..f463110 100644 --- a/library/persistence/implementation/sqlite/src/cms_storage_sqlite.e +++ b/library/persistence/implementation/sqlite/src/cms_storage_sqlite.e @@ -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. diff --git a/library/persistence/implementation/sqlite/src/database/database_connection_mysql.e b/library/persistence/implementation/sqlite/src/database/database_connection_mysql.e deleted file mode 100644 index bc5f890..0000000 --- a/library/persistence/implementation/sqlite/src/database/database_connection_mysql.e +++ /dev/null @@ -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 diff --git a/library/persistence/implementation/sqlite/src/provider/node_data_provider.e b/library/persistence/implementation/sqlite/src/provider/node_data_provider.e index eef4756..25c4606 100644 --- a/library/persistence/implementation/sqlite/src/provider/node_data_provider.e +++ b/library/persistence/implementation/sqlite/src/provider/node_data_provider.e @@ -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 diff --git a/library/persistence/implementation/sqlite/src/provider/user_data_provider.e b/library/persistence/implementation/sqlite/src/provider/user_data_provider.e index e603c05..60fd235 100644 --- a/library/persistence/implementation/sqlite/src/provider/user_data_provider.e +++ b/library/persistence/implementation/sqlite/src/provider/user_data_provider.e @@ -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 diff --git a/library/persistence/implementation/sqlite/tests/tests-safe.ecf b/library/persistence/implementation/sqlite/tests/tests-safe.ecf index cdeb22e..a905aec 100644 --- a/library/persistence/implementation/sqlite/tests/tests-safe.ecf +++ b/library/persistence/implementation/sqlite/tests/tests-safe.ecf @@ -8,6 +8,7 @@ +