Implemented CMS storage for user and nodes.

Implemented role and permission storage.
Introduced the CMS_PARTIAL_NODE and CMS_PARTIAL_USER.
Added support for node storage extension
  - storage of data specific to each node content type,
  - in addition to the core CMS_NODE)
  - For now, only implemented for SQL storage.
Note: in current version, CMS_PAGE support is hard coded in the core,
    (as opposed to be only supported by the node module.)
Commented/removed for now, the Web API code to update node summary, title, via REST request.
This commit is contained in:
2015-04-14 11:25:02 +02:00
parent 734f661add
commit 133c243126
46 changed files with 2262 additions and 468 deletions

View File

@@ -109,6 +109,11 @@ feature -- Query
db_handler.forth
end
sql_valid_item_index (a_index: INTEGER): BOOLEAN
do
Result := attached {DB_TUPLE} db_handler.item as l_item and then l_item.valid_index (a_index)
end
sql_item (a_index: INTEGER): detachable ANY
do
if attached {DB_TUPLE} db_handler.item as l_item and then l_item.count >= a_index then

View File

@@ -26,7 +26,9 @@ feature -- Access
do
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
across nodes_iterator as ic loop
Result.force (ic.item)
if attached ic.item as l_node then
Result.force (l_node)
end
end
end
@@ -34,27 +36,29 @@ feature -- Access
-- List of recent `a_count' nodes with an offset of `lower'.
do
create {ARRAYED_LIST [CMS_NODE]} Result.make (a_count)
across recent_nodes_iterator (a_lower, a_count) as c loop
Result.force (c.item)
across recent_nodes_iterator (a_lower, a_count) as ic loop
if attached ic.item as l_node then
Result.force (l_node)
end
end
end
feature -- Access: iterator
nodes_iterator: DATABASE_ITERATION_CURSOR [CMS_NODE]
nodes_iterator: DATABASE_ITERATION_CURSOR [detachable CMS_NODE]
-- List of nodes.
local
l_parameters: STRING_TABLE [ANY]
do
error_handler.reset
log.write_information (generator + ".nodes_iterator")
write_information_log (generator + ".nodes_iterator")
create l_parameters.make (0)
sql_query (select_nodes, l_parameters)
sql_query (sql_select_nodes, l_parameters)
create Result.make (db_handler, agent fetch_node)
sql_post_execution
end
recent_nodes_iterator (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [CMS_NODE]
recent_nodes_iterator (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [detachable CMS_NODE]
-- The most recent `a_rows'.
local
l_parameters: STRING_TABLE [ANY]
@@ -62,11 +66,11 @@ feature -- Access: iterator
do
-- FIXME: check implementation...
error_handler.reset
log.write_information (generator + ".recent_nodes_iterator")
write_information_log (generator + ".recent_nodes_iterator")
create l_parameters.make (2)
l_parameters.put (a_rows, "rows")
l_parameters.put (a_lower, "offset")
create l_query.make_from_string (select_recent_nodes)
create l_query.make_from_string (sql_select_recent_nodes)
sql_query (l_query, l_parameters)
create Result.make (db_handler, agent fetch_node)
sql_post_execution

View File

@@ -26,7 +26,9 @@ feature -- Access
do
create {ARRAYED_LIST [CMS_NODE]} Result.make (0)
across nodes_iterator as ic loop
Result.force (ic.item)
if attached ic.item as l_node then
Result.force (l_node)
end
end
end
@@ -34,14 +36,16 @@ feature -- Access
-- List of recent `a_count' nodes with an offset of `lower'.
do
create {ARRAYED_LIST [CMS_NODE]} Result.make (a_count)
across recent_nodes_iterator (a_lower, a_count) as c loop
Result.force (c.item)
across recent_nodes_iterator (a_lower, a_count) as ic loop
if attached ic.item as l_node then
Result.force (l_node)
end
end
end
feature -- Access: iterator
nodes_iterator: DATABASE_ITERATION_CURSOR [CMS_NODE]
nodes_iterator: DATABASE_ITERATION_CURSOR [detachable CMS_NODE]
-- List of nodes.
local
l_parameters: STRING_TABLE [ANY]
@@ -49,11 +53,11 @@ feature -- Access: iterator
error_handler.reset
write_information_log (generator + ".nodes_iterator")
create l_parameters.make (0)
sql_query (select_nodes, l_parameters)
sql_query (sql_select_nodes, l_parameters)
create Result.make (db_handler, agent fetch_node)
end
recent_nodes_iterator (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [CMS_NODE]
recent_nodes_iterator (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [detachable CMS_NODE]
-- The most recent `a_rows'.
local
l_parameters: STRING_TABLE [ANY]
@@ -65,7 +69,7 @@ feature -- Access: iterator
create l_parameters.make (2)
l_parameters.put (a_rows, "rows")
l_parameters.put (a_lower, "offset")
create l_query.make_from_string (select_recent_nodes)
create l_query.make_from_string (sql_select_recent_nodes)
sql_query (l_query, l_parameters)
create Result.make (db_handler, agent fetch_node)
end

View File

@@ -45,47 +45,27 @@ feature -- Factory
end
initialize (a_setup: CMS_SETUP; a_storage: CMS_STORAGE_STORE_SQL)
do
initialize_schema (a_setup, a_storage)
initialize_data (a_setup, a_storage)
end
initialize_schema (a_setup: CMS_SETUP; a_storage: CMS_STORAGE_STORE_SQL)
local
p: PATH
f: PLAIN_TEXT_FILE
sql: STRING
do
p := a_setup.layout.path.extended ("scripts").extended ("sqlite.sql")
create f.make_with_path (p)
if f.exists and then f.is_access_readable then
create sql.make (f.count)
f.open_read
from
f.start
until
f.exhausted or f.end_of_file
loop
f.read_stream_thread_aware (1_024)
sql.append (f.last_string)
end
f.close
a_storage.error_handler.reset
-- a_storage.sql_begin_transaction
a_storage.sql_change (sql, Void)
-- a_storage.sql_commit_transaction
end
end
initialize_data (a_setup: CMS_SETUP; a_storage: CMS_STORAGE_STORE_SQL)
local
u: CMS_USER
r: CMS_USER_ROLE
do
-- Schema
a_storage.sql_execute_file_script (a_setup.layout.path.extended ("scripts").extended ("core.sql"))
-- Data
-- Users
create u.make ("admin")
u.set_password ("#admin#")
u.set_password ("istrator#")
u.set_email (a_setup.site_email)
a_storage.new_user (u)
-- Roles
create r.make ("anonymous")
a_storage.save_user_role (r)
create r.make ("authenticated")
r.add_permission ("create page")
r.add_permission ("edit page")
a_storage.save_user_role (r)
end
end