Revisited the persistence layer.

Simplified schema to focus on user and node.
Now possible to have sqlite via ODBC and/or mysql support, and select using configuration file.
Updated demo example.
This commit is contained in:
2015-01-27 19:48:37 +01:00
parent db9e40cec4
commit 7d5869f3b9
71 changed files with 2665 additions and 3313 deletions

View File

@@ -1,7 +1,7 @@
note
description: "Provide access to json configuration"
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision: 96454 $"
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
class
APPLICATION_JSON_CONFIGURATION_HELPER
@@ -47,7 +47,7 @@ feature -- Application Configuration
attached {JSON_OBJECT} l_environments.item (l_envrionment.item) as l_environment_selected and then
attached {JSON_STRING} l_environment_selected.item ("connection_string") as l_connection_string
then
create Result.make (l_driver.item, l_connection_string.unescaped_string_8)
create Result.make (l_driver.item, l_connection_string.unescaped_string_32)
end
end
end

View File

@@ -1,7 +1,7 @@
note
description: "Object that represent Database configuration settings"
date: "$Date: 2015-01-14 16:13:47 +0100 (mer., 14 janv. 2015) $"
revision: "$Revision: 96454 $"
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
class
DATABASE_CONFIGURATION
@@ -33,10 +33,65 @@ feature -- Access
connection_string: READABLE_STRING_32
-- Connection string
do
Result := "Driver={"+driver+"};" + database_string;
Result := "Driver={" + driver + "};" + database_string
end
item (a_param: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
local
s: READABLE_STRING_32
lower_s: READABLE_STRING_32
i,j: INTEGER
k: STRING_32
do
create k.make_from_string_general (a_param)
k.to_lower
s := database_string
lower_s := s.as_lower
i := lower_s.substring_index (k + {STRING_32} "=", 1)
if i > 0 then
if i = 1 or else s[i-1] = ';' then
j := s.index_of (';', i + k.count + 1)
if j = 0 then
j := s.count + 1
end
Result := s.substring (i + k.count + 1, j - 1)
end
end
end
server_name: detachable READABLE_STRING_32
do
Result := item ("Server")
end
port: INTEGER
do
if
attached item ("Port") as l_port and then
l_port.is_integer
then
Result := l_port.to_integer
end
end
database_name: detachable READABLE_STRING_32
do
Result := item ("Database")
end
user_id: detachable READABLE_STRING_32
do
Result := item ("Uid")
end
user_password: detachable READABLE_STRING_32
do
Result := item ("Pwd")
end
note
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -1,7 +1,7 @@
note
description: "Provides logger information"
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
revision: "$Revision: 95678 $"
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
class
SHARED_LOGGER
@@ -29,7 +29,7 @@ feature -- Logger
create l_environment
if attached separate_character_option_value ('d') as l_dir then
l_path := create {PATH}.make_from_string (l_dir)
create l_log_writer.make_at_location (l_path.extended ("..").appended ("\api.log"))
create l_log_writer.make_at_location (l_path.extended ("logs").appended ("\api.log"))
else
l_path := create {PATH}.make_current
create l_log_writer.make_at_location (l_path.extended("api.log"))
@@ -82,23 +82,26 @@ feature {NONE} -- JSON
do
create Result
if attached json_file_from (a_path) as json_file then
l_parser := new_json_parser (json_file)
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
attached {JSON_OBJECT} jv.item ("logger") as l_logger and then
attached {JSON_STRING} l_logger.item ("backup_count") as l_count and then
attached {JSON_STRING} l_logger.item ("level") as l_level then
Result.set_level (l_level.item)
if l_count.item.is_natural then
Result.set_backup_count (l_count.item.to_natural)
end
end
l_parser := new_json_parser (json_file)
if attached {JSON_OBJECT} l_parser.parse as jv and then l_parser.is_parsed and then
attached {JSON_OBJECT} jv.item ("logger") as l_logger and then
attached {JSON_STRING} l_logger.item ("backup_count") as l_count and then
attached {JSON_STRING} l_logger.item ("level") as l_level then
Result.set_level (l_level.item)
if l_count.item.is_natural then
Result.set_backup_count (l_count.item.to_natural)
end
end
end
end
json_file_from (a_fn: PATH): detachable STRING
local
ut: FILE_UTILITIES
do
Result := (create {JSON_FILE_READER}).read_json_from (a_fn.name.out)
if ut.file_path_exists (a_fn) then
Result := (create {JSON_FILE_READER}).read_json_from (a_fn.name)
end
end
new_json_parser (a_string: STRING): JSON_PARSER
@@ -107,6 +110,6 @@ feature {NONE} -- JSON
end
note
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end