Files
ROC/modules/node/persistence/cms_node_storage_i.e
Dario Bösch 4dd980963a Moved filter of nodes of type blog to the node storage layer.
This is more efficient because the result set from the query will be smaller and it will be easier to implement the pagination
2015-05-21 14:06:08 +02:00

181 lines
4.3 KiB
Plaintext

note
description: "Summary description for {CMS_NODE_STORAGE_I}."
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
deferred class
CMS_NODE_STORAGE_I
feature -- Error Handling
error_handler: ERROR_HANDLER
-- Error handler.
deferred
end
feature -- Storage extension
register_node_storage_extension (a_extension: CMS_NODE_STORAGE_EXTENSION [CMS_NODE])
-- Register `a_extension' as extension to the node storage system.
local
tb: like node_storage_extensions
do
tb := node_storage_extensions
if tb = Void then
create tb.make_caseless (1)
node_storage_extensions := tb
end
tb.force (a_extension, a_extension.content_type)
end
node_storage_extension (a_node: CMS_NODE): detachable CMS_NODE_STORAGE_EXTENSION [CMS_NODE]
-- Extension to the node storage system for node `a_node'.
do
if attached node_storage_extensions as tb then
Result := tb.item (a_node.content_type)
end
end
feature {NONE} -- Implementation
node_storage_extensions: detachable STRING_TABLE [CMS_NODE_STORAGE_EXTENSION [CMS_NODE]]
-- Table of node storage extensions.
extended_store (a_node: CMS_NODE)
-- Store extended data from `a_node'.
do
if attached node_storage_extension (a_node) as ext then
ext.store_node (a_node)
end
end
extended_load (a_node: CMS_NODE)
-- Load extended data into `a_node'.
do
if attached node_storage_extension (a_node) as ext then
ext.load_node (a_node)
end
end
feature -- Access
nodes_count: INTEGER_64
-- Count of nodes.
deferred
end
nodes: LIST [CMS_NODE]
-- List of nodes.
deferred
end
blogs: LIST [CMS_NODE]
-- List of nodes ordered by creation date (descending).
deferred
end
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
-- List of recent `a_count' nodes with an offset of `lower'.
deferred
end
node_by_id (a_id: INTEGER_64): detachable CMS_NODE
-- Retrieve node by id `a_id', if any.
require
a_id > 0
deferred
end
node_author (a_id: like {CMS_NODE}.id): detachable CMS_USER
-- Node's author. if any.
require
valid_node: a_id > 0
deferred
end
feature -- Change: Node
save_node (a_node: CMS_NODE)
-- Create or update `a_node'.
do
if a_node.has_id then
update_node (a_node)
else
new_node (a_node)
end
end
new_node (a_node: CMS_NODE)
-- Save node `a_node'.
require
no_id: not a_node.has_id
valid_user: attached a_node.author as l_author and then l_author.id > 0
deferred
ensure
has_id: a_node.has_id
end
update_node (a_node: CMS_NODE)
-- Update node content `a_node'.
-- The user `a_id' is an existing or new collaborator.
require
has_id: a_node.has_id
has_author: attached a_node.author as l_author and then l_author.has_id
deferred
end
delete_node (a_node: CMS_NODE)
-- Delete `a_node'.
do
if a_node.has_id then
delete_node_by_id (a_node.id)
end
end
delete_node_by_id (a_id: INTEGER_64)
-- Remove node by id `a_id'.
require
valid_node_id: a_id > 0
deferred
end
-- update_node_title (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_title: READABLE_STRING_32)
-- -- Update node title to `a_title', node identified by id `a_node_id'.
-- -- The user `a_user_id' is an existing or new collaborator.
-- require
-- valid_node_id: a_node_id > 0
-- valid_user_id: a_user_id > 0
-- deferred
-- end
-- update_node_summary (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
-- -- Update node summary to `a_summary', node identified by id `a_node_id'.
-- -- The user `a_user_id' is an existing or new collaborator.
-- require
-- valid_id: a_node_id > 0
-- valid_user_id: a_user_id > 0
-- deferred
-- end
-- update_node_content (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
-- -- Update node content to `a_content', node identified by id `a_node_id'.
-- -- The user `a_user_id' is an existing or new collaborator.
-- require
-- valid_id: a_node_id > 0
-- valid_user_id: a_user_id > 0
-- deferred
-- end
feature -- Helpers
fill_node (a_node: CMS_NODE)
-- Fill `a_node' with extra information from database.
-- i.e: specific to each content type data.
require
has_id: a_node.has_id
deferred
end
end