Compare commits
16 Commits
storage_re
...
concurrent
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c1d1325eb | |||
| 8382edf9d7 | |||
| e94d860fd8 | |||
| bd6524ebe7 | |||
| ca10c57b4b | |||
| 8d59d25ace | |||
| a810b1176c | |||
|
|
e40f8ee4d2 | ||
|
|
83af7f6a38 | ||
| 02368fe3d2 | |||
| be0b5c23d2 | |||
|
|
88ec1452d8 | ||
| 5ddc2006e2 | |||
| d97c4b1a4a | |||
| 7d5869f3b9 | |||
|
|
8c74c7a268 |
18
cms-safe.ecf
18
cms-safe.ecf
@@ -8,20 +8,20 @@
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="config" location=".\library\configuration\config-safe.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto-safe.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
||||
<library name="encoder" location="$EWF_LIBRARY\library\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||
<library name="error" location="$EWF_LIBRARY\library\utility\general\error\error-safe.ecf"/>
|
||||
<library name="http" location="$EWF_LIBRARY\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="http_authorization" location="$EWF_LIBRARY\library\server\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location=".\library\layout\layout-safe.ecf"/>
|
||||
<library name="model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="cms_model" location=".\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty-safe.ecf" readonly="false"/>
|
||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf" readonly="false"/>
|
||||
<cluster name="src" location=".\library\src\" recursive="true">
|
||||
<library name="wsf" location="$EWF_LIBRARY\library\server\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$EWF_LIBRARY\library\server\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
<library name="wsf_html" location="$EWF_LIBRARY\library\server\wsf_html\wsf_html-safe.ecf" readonly="false"/>
|
||||
<cluster name="src" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
|
||||
23
cms.ecf
23
cms.ecf
@@ -6,23 +6,22 @@
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
|
||||
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder.ecf" readonly="false"/>
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error.ecf"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http.ecf"/>
|
||||
<library name="http_authorization" location="$ISE_LIBRARY\contrib\library\network\authentication\http_authorization\http_authorization.ecf" readonly="false"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||
<library name="config" location=".\library\configuration\config.ecf"/>
|
||||
<library name="crypto" location="$ISE_LIBRARY\unstable\library\text\encryption\crypto\crypto.ecf"/>
|
||||
<library name="encoder" location="$EWF_LIBRARY\library\text\encoder\encoder.ecf" readonly="false"/>
|
||||
<library name="error" location="$EWF_LIBRARY\library\utility\general\error\error.ecf"/>
|
||||
<library name="http" location="$EWF_LIBRARY\library\network\protocol\http\http.ecf"/>
|
||||
<library name="http_authorization" location="$EWF_LIBRARY\library\network\authentication\http_authorization\http_authorization.ecf" readonly="false"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
|
||||
<library name="layout" location=".\library\layout\layout.ecf"/>
|
||||
<library name="model" location=".\library\model\cms_model.ecf" readonly="false"/>
|
||||
<library name="persistence_mysql" location=".\library\persistence\implementation\mysql\persistence_mysql.ecf" readonly="false"/>
|
||||
<library name="cms_model" location=".\library\model\cms_model.ecf" readonly="false"/>
|
||||
<library name="smarty" location="$ISE_LIBRARY\contrib\library\text\template\smarty\smarty.ecf" readonly="false"/>
|
||||
<library name="text_filter" location="$ISE_LIBRARY\unstable\library\text\text_filter\text_filter.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension.ecf" readonly="false"/>
|
||||
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html.ecf" readonly="false"/>
|
||||
<cluster name="src" location=".\library\src\" recursive="true">
|
||||
<library name="wsf" location="$EWF_LIBRARY\library\server\wsf\wsf.ecf"/>
|
||||
<library name="wsf_extension" location="$EWF_LIBRARY\library\server\wsf\wsf_extension.ecf" readonly="false"/>
|
||||
<library name="wsf_html" location="$EWF_LIBRARY\library\server\wsf_html\wsf_html.ecf" readonly="false"/>
|
||||
<cluster name="src" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
|
||||
@@ -9,38 +9,50 @@
|
||||
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<setting name="concurrency" value="scoop"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="cms" location="..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="cms_demo_module" location="modules\demo\cms_demo_module-safe.ecf" readonly="false"/>
|
||||
<library name="persistence_mysql" location="..\..\library\persistence\implementation\mysql\persistence_mysql-safe.ecf" readonly="false"/>
|
||||
|
||||
<library name="cms_model" location="..\..\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="layout" location="..\..\library\layout\layout-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
<library name="persistence_sqlite" location="..\..\library\persistence\sqlite\persistence_sqlite-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="$EWF_LIBRARY\library\server\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$EWF_LIBRARY\library\server\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
</target>
|
||||
<target name="demo_any" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\cgi-safe.ecf"/>
|
||||
<library name="libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\libfcgi-safe.ecf"/>
|
||||
<library name="nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\connector\nino-safe.ecf"/>
|
||||
<setting name="concurrency" value="scoop"/>
|
||||
<library name="cgi" location="$EWF_LIBRARY\library\server\wsf\connector\cgi-safe.ecf"/>
|
||||
<library name="libfcgi" location="$EWF_LIBRARY\library\server\wsf\connector\libfcgi-safe.ecf"/>
|
||||
<library name="nino" location="$EWF_LIBRARY\library\server\wsf\connector\nino-safe.ecf"/>
|
||||
<library name="standalone" location="$EWF_LIBRARY\library\server\wsf\connector\standalone-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\any\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_standalone" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<setting name="concurrency" value="scoop"/>
|
||||
<library name="default_standalone" location="$EWF_LIBRARY\library\server\wsf\default\standalone-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_nino" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_nino" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\nino-safe.ecf"/>
|
||||
<setting name="concurrency" value="none"/>
|
||||
<library name="default_nino" location="$EWF_LIBRARY\library\server\wsf\default\nino-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_cgi" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_cgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\cgi-safe.ecf"/>
|
||||
<library name="default_cgi" location="$EWF_LIBRARY\library\server\wsf\default\cgi-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
<target name="demo_libfcgi" extends="common">
|
||||
<root class="EWF_ROC_SERVER" feature="make_and_launch"/>
|
||||
<library name="default_libfcgi" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\default\libfcgi-safe.ecf"/>
|
||||
<library name="default_libfcgi" location="$EWF_LIBRARY\library\server\wsf\default\libfcgi-safe.ecf"/>
|
||||
<cluster name="launcher" location=".\launcher\default\" recursive="true"/>
|
||||
<cluster name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
port=8099
|
||||
#verbose=true
|
||||
port=9090
|
||||
#verbose=true
|
||||
|
||||
@@ -8,10 +8,10 @@ note
|
||||
revision: "$Revision: 36 $"
|
||||
|
||||
class
|
||||
APPLICATION_LAUNCHER
|
||||
APPLICATION_LAUNCHER [G -> WSF_EXECUTION create make end]
|
||||
|
||||
inherit
|
||||
APPLICATION_LAUNCHER_I
|
||||
APPLICATION_LAUNCHER_I [G]
|
||||
|
||||
feature -- Custom
|
||||
|
||||
|
||||
@@ -10,24 +10,28 @@ note
|
||||
revision: "$Revision: 36 $"
|
||||
|
||||
deferred class
|
||||
APPLICATION_LAUNCHER_I
|
||||
APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end]
|
||||
|
||||
inherit
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
feature -- Execution
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
nature: like launcher_nature
|
||||
do
|
||||
nature := launcher_nature
|
||||
if nature = Void or else nature = nature_nino then
|
||||
launch_nino (a_service, opts)
|
||||
if nature = Void then
|
||||
launch_standalone (opts)
|
||||
elseif nature = nature_standalone then
|
||||
launch_standalone (opts)
|
||||
elseif nature = nature_nino then
|
||||
launch_nino (opts)
|
||||
elseif nature = nature_cgi then
|
||||
launch_cgi (a_service, opts)
|
||||
launch_cgi (opts)
|
||||
elseif nature = nature_libfcgi then
|
||||
launch_libfcgi (a_service, opts)
|
||||
launch_libfcgi (opts)
|
||||
else
|
||||
-- bye bye
|
||||
(create {EXCEPTIONS}).die (-1)
|
||||
@@ -43,14 +47,16 @@ feature {NONE} -- Access
|
||||
--| and we could use WSF_DEFAULT_SERVICE_LAUNCHER to configure this at compilation time.
|
||||
local
|
||||
p: PATH
|
||||
l_entry_name: READABLE_STRING_32
|
||||
ext: detachable READABLE_STRING_32
|
||||
do
|
||||
create p.make_from_string (execution_environment.arguments.command_name)
|
||||
if attached p.entry as l_entry then
|
||||
ext := l_entry.extension
|
||||
ext := l_entry.extension
|
||||
end
|
||||
if ext /= Void then
|
||||
if ext.same_string (nature_standalone) then
|
||||
Result := nature_standalone
|
||||
end
|
||||
if ext.same_string (nature_nino) then
|
||||
Result := nature_nino
|
||||
end
|
||||
@@ -61,39 +67,58 @@ feature {NONE} -- Access
|
||||
Result := nature_libfcgi
|
||||
end
|
||||
end
|
||||
Result := default_nature
|
||||
end
|
||||
|
||||
feature {NONE} -- standalone
|
||||
|
||||
nature_standalone: STRING = "standalone"
|
||||
|
||||
launch_standalone (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_STANDALONE_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
feature {NONE} -- nino
|
||||
|
||||
nature_nino: STRING = "nino"
|
||||
|
||||
launch_nino (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch_nino (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_NINO_SERVICE_LAUNCHER
|
||||
launcher: WSF_NINO_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create launcher.make_and_launch (a_service, opts)
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
feature {NONE} -- cgi
|
||||
|
||||
nature_cgi: STRING = "cgi"
|
||||
|
||||
launch_cgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch_cgi (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_CGI_SERVICE_LAUNCHER
|
||||
launcher: WSF_CGI_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create launcher.make_and_launch (a_service, opts)
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
feature {NONE} -- libfcgi
|
||||
|
||||
nature_libfcgi: STRING = "libfcgi"
|
||||
|
||||
launch_libfcgi (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch_libfcgi (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_LIBFCGI_SERVICE_LAUNCHER
|
||||
launcher: WSF_LIBFCGI_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create launcher.make_and_launch (a_service, opts)
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
feature -- Default
|
||||
|
||||
default_nature: STRING
|
||||
do
|
||||
Result := nature_standalone
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ note
|
||||
revision: "$Revision: 36 $"
|
||||
|
||||
class
|
||||
APPLICATION_LAUNCHER
|
||||
APPLICATION_LAUNCHER [G -> WSF_EXECUTION create make end]
|
||||
|
||||
inherit
|
||||
APPLICATION_LAUNCHER_I
|
||||
APPLICATION_LAUNCHER_I [G]
|
||||
|
||||
feature -- Custom
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@ note
|
||||
|
||||
you can customize APPLICATION_LAUNCHER
|
||||
]"
|
||||
date: "$Date: 2013-06-12 13:55:42 +0200 (mer., 12 juin 2013) $"
|
||||
revision: "$Revision: 36 $"
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
deferred class
|
||||
APPLICATION_LAUNCHER_I
|
||||
APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end]
|
||||
|
||||
feature -- Execution
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
launcher: WSF_SERVICE_LAUNCHER
|
||||
launcher: WSF_DEFAULT_SERVICE_LAUNCHER [G]
|
||||
do
|
||||
create {WSF_DEFAULT_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts)
|
||||
create launcher.make_and_launch (opts)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
|
||||
<library name="cms" location="..\..\..\..\cms-safe.ecf" readonly="false"/>
|
||||
<library name="cms_model" location="..\..\..\..\library\model\cms_model-safe.ecf" readonly="false"/>
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="http" location="$EWF_LIBRARY\library\network\protocol\http\http-safe.ecf"/>
|
||||
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
|
||||
<library name="wsf" location="$EWF_LIBRARY\library\server\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_encoder" location="$EWF_LIBRARY\library\text\encoder\encoder-safe.ecf"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {CMS_DEMO_MODULE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-02-13 13:08:13 +0100 (ven., 13 févr. 2015) $"
|
||||
revision: "$Revision: 96616 $"
|
||||
|
||||
class
|
||||
CMS_DEMO_MODULE
|
||||
@@ -36,7 +36,6 @@ feature -- Access: router
|
||||
-- Node router.
|
||||
do
|
||||
create Result.make (2)
|
||||
|
||||
map_uri_template_agent (Result, "/demo/", agent handle_demo (?,?,a_api))
|
||||
map_uri_template_agent (Result, "/demo/{id}", agent handle_demo_entry (?,?,a_api))
|
||||
end
|
||||
@@ -85,11 +84,37 @@ feature -- Hooks
|
||||
|
||||
feature -- Handler
|
||||
|
||||
initialize_module (a_api: CMS_API)
|
||||
local
|
||||
sql: STRING
|
||||
do
|
||||
if attached {CMS_STORAGE_SQL} a_api.storage as sql_db then
|
||||
sql_db.sql_query ("select count(*) from tb_demo;", Void)
|
||||
if sql_db.has_error then
|
||||
-- Initialize db for demo module
|
||||
sql := "[
|
||||
CREATE TABLE "tb_demo"(
|
||||
"did" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("did">=0),
|
||||
"name" VARCHAR(100) NOT NULL,
|
||||
"value" TEXT
|
||||
);
|
||||
]"
|
||||
sql_db.reset_error
|
||||
sql_db.sql_change (sql, Void)
|
||||
if sql_db.has_error then
|
||||
a_api.logger.put_error ("Could not initialize database for demo module", generating_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
handle_demo,
|
||||
handle_demo_entry (req: WSF_REQUEST; res: WSF_RESPONSE; a_api: CMS_API)
|
||||
local
|
||||
r: NOT_IMPLEMENTED_ERROR_CMS_RESPONSE
|
||||
do
|
||||
initialize_module (a_api)
|
||||
|
||||
create r.make (req, res, a_api)
|
||||
r.set_main_content ("NODE module does not yet implement %"" + req.path_info + "%" ...")
|
||||
r.add_error_message ("NODE Module: not yet implemented")
|
||||
|
||||
34
examples/demo/site/scripts/sqlite.sql
Normal file
34
examples/demo/site/scripts/sqlite.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
BEGIN;
|
||||
CREATE TABLE "users"(
|
||||
"uid" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("uid">=0),
|
||||
"name" VARCHAR(100) NOT NULL,
|
||||
"password" VARCHAR(100) NOT NULL,
|
||||
"salt" VARCHAR(100) NOT NULL,
|
||||
"email" VARCHAR(250) NOT NULL,
|
||||
"status" INTEGER,
|
||||
"created" DATETIME NOT NULL,
|
||||
"signed" DATETIME,
|
||||
CONSTRAINT "name"
|
||||
UNIQUE("name")
|
||||
);
|
||||
|
||||
CREATE TABLE "users_roles"(
|
||||
"rid" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("rid">=0),
|
||||
"role" VARCHAR(100) NOT NULL,
|
||||
CONSTRAINT "role"
|
||||
UNIQUE("role")
|
||||
);
|
||||
|
||||
CREATE TABLE "nodes"(
|
||||
"nid" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("nid">=0),
|
||||
"version" INTEGER,
|
||||
"type" INTEGER,
|
||||
"title" VARCHAR(255) NOT NULL,
|
||||
"summary" TEXT NOT NULL,
|
||||
"content" MEDIUMTEXT NOT NULL,
|
||||
"author" INTEGER,
|
||||
"publish" DATETIME,
|
||||
"created" DATETIME NOT NULL,
|
||||
"changed" DATETIME NOT NULL
|
||||
);
|
||||
COMMIT;
|
||||
53
examples/demo/site/themes/bootstrap/assets/css/style.css
Normal file
53
examples/demo/site/themes/bootstrap/assets/css/style.css
Normal file
@@ -0,0 +1,53 @@
|
||||
ul.horizontal li {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
#header #primary.menu ul li {
|
||||
color: #555;
|
||||
background-color: #fff;
|
||||
padding: 10px;
|
||||
margin: 0;
|
||||
}
|
||||
#header #primary.menu ul li a {
|
||||
color: #555;
|
||||
text-decoration: none;
|
||||
}
|
||||
#header #primary.menu ul li a:hover {
|
||||
color: black;
|
||||
}
|
||||
#header #primary.menu ul.horizontal {
|
||||
border-bottom: solid 1px #ddd;
|
||||
}
|
||||
#header #primary.menu ul.horizontal li {
|
||||
border-top: solid 3px #fff;
|
||||
}
|
||||
#header #primary.menu ul.horizontal li:hover {
|
||||
background-color: #ffe;
|
||||
border-top: solid 3px #999;
|
||||
}
|
||||
#header #primary.menu ul.horizontal li.active {
|
||||
font-weight: bold;
|
||||
border-top: solid 3px #ddd;
|
||||
background-color: #ddd;
|
||||
}
|
||||
#header #primary.menu ul.horizontal li.active:hover {
|
||||
border-top: solid 3px blue;
|
||||
}
|
||||
|
||||
#content {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
padding: 5px;
|
||||
margin: 3px;
|
||||
border: solid 1px #ccc;
|
||||
}
|
||||
.sidebar#sidebar_first {
|
||||
width: 250px;
|
||||
float: left;
|
||||
}
|
||||
.sidebar#sidebar_second {
|
||||
width: 250px;
|
||||
float: right;
|
||||
}
|
||||
57
examples/demo/site/themes/bootstrap/assets/scss/style.scss
Normal file
57
examples/demo/site/themes/bootstrap/assets/scss/style.scss
Normal file
@@ -0,0 +1,57 @@
|
||||
ul.horizontal {
|
||||
li {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
|
||||
#header {
|
||||
#primary.menu {
|
||||
ul {
|
||||
li {
|
||||
color: #555;
|
||||
a {
|
||||
color: #555;
|
||||
text-decoration: none;
|
||||
&:hover { color: black; }
|
||||
}
|
||||
background-color: #fff;
|
||||
padding: 10px;
|
||||
margin: 0;
|
||||
}
|
||||
&.horizontal {
|
||||
border-bottom: solid 1px #ddd;
|
||||
li {
|
||||
border-top: solid 3px #fff;
|
||||
&:hover {
|
||||
background-color: #ffe;
|
||||
border-top: solid 3px #999;
|
||||
}
|
||||
&.active {
|
||||
font-weight: bold;
|
||||
border-top: solid 3px #ddd;
|
||||
background-color: #ddd;
|
||||
}
|
||||
&.active:hover {
|
||||
border-top: solid 3px blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#content {
|
||||
margin-left: 20px;
|
||||
}
|
||||
.sidebar {
|
||||
padding: 5px;
|
||||
margin: 3px;
|
||||
border: solid 1px #ccc;
|
||||
&#sidebar_first {
|
||||
width: 250px;
|
||||
float: left;
|
||||
}
|
||||
&#sidebar_second {
|
||||
width: 250px;
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
14
examples/demo/site/themes/bootstrap/debug.tpl
Normal file
14
examples/demo/site/themes/bootstrap/debug.tpl
Normal file
@@ -0,0 +1,14 @@
|
||||
{assign name="debug_enabled" value="True"/}
|
||||
{if condition="$debug_enabled"}
|
||||
<ul>
|
||||
{assign name="kpage" value="page"/}
|
||||
{assign name="kregions" value="regions"/}
|
||||
{foreach key="k" item="i" from="$page.variables"}
|
||||
{unless condition="$k ~ $kpage"}
|
||||
{unless condition="$k ~ $kregions"}
|
||||
<li><strong>{$k/}</strong>={$i/}</li>
|
||||
{/unless}
|
||||
{/unless}
|
||||
{/foreach}
|
||||
</ul>
|
||||
{/if}
|
||||
77
examples/demo/site/themes/bootstrap/page.tpl
Normal file
77
examples/demo/site/themes/bootstrap/page.tpl
Normal file
@@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- EWF CMS -->
|
||||
<link rel="stylesheet" href="{$site_url/}/theme/css/style.css">
|
||||
<!-- bootstrap framework -->
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
|
||||
|
||||
<title>{$head_title/}</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Page Top -->
|
||||
{if isset="$region_top"}
|
||||
{$region_top/}
|
||||
{/if}
|
||||
<!-- Body -->
|
||||
<div class='container-fluid'>
|
||||
|
||||
<!-- Page Header -->
|
||||
<div id="header">
|
||||
{if isset="$page.primary_nav"}
|
||||
{$page.primary_nav/}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- General Page Content -->
|
||||
<div id='content' class='row-fluid'>
|
||||
<!-- Left Sidebar sidebar_first -->
|
||||
{unless isempty="$page.region_sidebar_first"}
|
||||
<div id="sidebar_first" class="sidebar">{$page.region_sidebar_first/}</div>
|
||||
{/unless}
|
||||
<!-- Right Sidebar sidebar_second-->
|
||||
{unless isempty="$page.region_sidebar_second"}
|
||||
<div id="sidebar_second" class="sidebar">{$page.region_sidebar_second/}</div>
|
||||
{/unless}
|
||||
|
||||
<!-- Highlighted, Help, Content -->
|
||||
<div class='span8 main'>
|
||||
<!-- Highlighted Section -->
|
||||
{unless isempty="$page.region_highlighted"}
|
||||
<div id="highlighted">{$page.region_highlighted/}</div>
|
||||
{/unless}
|
||||
<!-- Help Section -->
|
||||
{unless isempty="$page.region_help"}
|
||||
<div id="help">{$page.region_help/}</div>
|
||||
{/unless}
|
||||
|
||||
<!-- Main Content Section -->
|
||||
{unless isempty="$page_title"}<h1 class="page-title">{$page_title/}</h1>{/unless}
|
||||
{$page.region_content/}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Page footer -->
|
||||
{$page.region_footer/}
|
||||
|
||||
<!-- Page Bottom -->
|
||||
{$page.region_bottom/}
|
||||
|
||||
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
|
||||
|
||||
<!--
|
||||
{include file="debug.tpl"/}
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,36 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{include file="master2/content.tpl"/}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
{if condition="$web"}
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
{/if}
|
||||
|
||||
{if condition="$html"}
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
{/if}
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,40 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
|
||||
<!--<header class="main-navi">
|
||||
{include file="master2/header.tpl"/}
|
||||
</header> -->
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{include file="master2/content.tpl"/}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
{if condition="$web"}
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
{/if}
|
||||
|
||||
{if condition="$html"}
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
{/if}
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,5 +0,0 @@
|
||||
<p>You have successfully signed out</p>
|
||||
|
||||
You may want to return
|
||||
|
||||
Press this neat little button:<a href="{$host/}/">Take Me Home </a>
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
<div itemscope itemtype="http://schema.org/ItemList">
|
||||
<h2 itemprop="name">Top most recent nodes</h2><br>
|
||||
<meta itemprop="itemListOrder" content="Descending" />
|
||||
|
||||
{foreach from="$nodes" item="item"}
|
||||
<div class="page-header">
|
||||
<h3><span itemprop="itemListElement"><a href="{$host/}/node/{$item.id/}" rel="node"><strong>{$item.title/}</strong></a></span> <small>{$item.summary/} - {$item.publication_date_output/} </small></h3>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
@@ -1,18 +0,0 @@
|
||||
<h3> Error: {$code/} </h3>
|
||||
|
||||
{assign name="status400" value="400"/}
|
||||
{assign name="status404" value="404"/}
|
||||
{assign name="status500" value="500"/}
|
||||
|
||||
{if condition="$code ~ $status500"}
|
||||
<p>Internal server error, for the request <strong>{$request/}</string> </p>
|
||||
{/if}
|
||||
|
||||
|
||||
{if condition="$code ~ $status404"}
|
||||
<p> Resourse not found, for the request <strong>{$request/}</string> </p>
|
||||
{/if}
|
||||
|
||||
{if condition="$code ~ $status400"}
|
||||
<p> Bad request, the request <strong>{$request/}</string> is not valid</p>
|
||||
{/if}
|
||||
@@ -1,7 +0,0 @@
|
||||
<small>
|
||||
<center>
|
||||
<p class="text-muted"><a href="#" target="_blank" class="info">API Documentation </a>
|
||||
<a href="#" target="_blank" class="info">Questions? Comments? Let us know! </a></p>
|
||||
<p>© Copyright 2014 Eiffel Software -- <a href="#" target="_blank" class="info">Privacy Policy</a>
|
||||
</center>
|
||||
</small>
|
||||
@@ -1,10 +0,0 @@
|
||||
<meta charset="utf-8">
|
||||
<link rel="icon" href="{$host/}/static/images/favicon.ico">
|
||||
<title>Eiffel RESTonCMS</title>
|
||||
{if condition="$web"}
|
||||
{include file="master2/optional_styling_css.tpl"/}
|
||||
{/if}
|
||||
{if condition="$html"}
|
||||
{include file="master2/optional_styling_css.tpl"/}
|
||||
{/if}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
<h1>RESTonCMS</h1>
|
||||
<p>Tagline</p>
|
||||
@@ -1,5 +0,0 @@
|
||||
<!--<ul>
|
||||
<li class="main-navi-item"><a href="">Nav1</a></li>
|
||||
<li><a href="">Nav2</a></li>
|
||||
</ul>
|
||||
-->
|
||||
@@ -1,5 +0,0 @@
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
|
||||
{if condition="$web"}
|
||||
<script src="{$host/}/static/js/roc.js"></script>
|
||||
{/if}
|
||||
@@ -1,9 +0,0 @@
|
||||
{if condition="$html"}
|
||||
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="http://getbootstrap.com/assets/css/docs.min.css">
|
||||
{/if}
|
||||
{if condition="$web"}
|
||||
<link rel="stylesheet" href="{$host/}/static/css/bootstrap.css">
|
||||
<link rel="stylesheet" href="{$host/}/static/css/dashboard.css">
|
||||
{/if}
|
||||
@@ -1,27 +0,0 @@
|
||||
<nav id="" class="navbar navbar-default navbar-inverse navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="{$host/}" rel="home">Rest on CMS</a>
|
||||
</div>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarCollapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="ListOfNodes"><a title="Nodes" href="{$host/}/nodes" rel="node">List of Nodes</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{if isset="$user"}
|
||||
<li><a>{$user/}</a></li>
|
||||
<li><a title="Node" href="{$host/}/node" rel="node">New Node</a></li>
|
||||
<li><a title="Logoff" href="{$host/}/basic_auth_logoff" rel="logoff">Logoff</a></li>
|
||||
{/if}
|
||||
{unless isset="$user"}
|
||||
<li><a title="Login" href="{$host/}/basic_auth_login" rel="login">Login</a></li>
|
||||
<li><a title="Register" href="{$host/}/user" rel="register">Register</a></li>
|
||||
{/unless}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{if isset="$user"}
|
||||
<a title="Logoff" class="" href="{$host/}/logoff">Logoff</a>
|
||||
{/if}
|
||||
{unless isset="$user"}
|
||||
<a title="Login" class="" href="{$host/}/login">Login</a>
|
||||
<a title="Register" class="" href="{$host/}/Register">Register</a>
|
||||
{/unless}
|
||||
<a title="Nodes" class="" href="{$host/}/nodes">List of Nodes</a>
|
||||
@@ -1,174 +0,0 @@
|
||||
{if condition="html"}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
{/if}
|
||||
|
||||
{unless condition="$web"}
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
{/unless}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{/if}
|
||||
|
||||
|
||||
<div class="bs-docs-example">
|
||||
{if condition="$web"}
|
||||
<ul id="myTab" class="nav nav-tabs" role="tablist">
|
||||
<li class=""><a href="#view" role="tab" data-toggle="tab">View</a></li>
|
||||
<li class="active"><a href="#edit" role="tab" data-toggle="tab">Edit</a></li>
|
||||
<li class=""><a href="#delete" role="tab" data-toggle="tab">Delete</a></li>
|
||||
</ul>
|
||||
{/if}
|
||||
{if condition="$html"}
|
||||
<ul id="myTab" class="nav nav-tabs" role="tablist">
|
||||
<li class=""><a href="#view" role="tab" data-toggle="tab">View</a></li>
|
||||
<li class="active"><a href="#edit" role="tab" data-toggle="tab">Edit</a></li>
|
||||
<li class=""><a href="#delete" role="tab" data-toggle="tab">Delete</a></li>
|
||||
</ul>
|
||||
{/if}
|
||||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane" id="view">
|
||||
{if isset="$node"}
|
||||
<hr>
|
||||
<div class="container-fluid">
|
||||
<div class="row" itemscope itemtype="http://schema.org/Article">
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-4 col-lg-3"><h1><span itemprop="name">{$node.title/}</span></h1></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-4 col-lg-3"><span itemprop="text">{$node.content/}<span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade active in" id="edit">
|
||||
{if isset="$user"}
|
||||
<hr>
|
||||
<div class="container-fluid">
|
||||
<div class="col-xs-12" itemscope itemtype="http://schema.org/Article">
|
||||
{if isset="$node"}
|
||||
<form class="form-inline well" action="{$host/}/node/{$node.id/}" itemprop="url" method="POST">
|
||||
<input type="hidden" name="method" value="PUT">
|
||||
{/if}
|
||||
{unless isset="$node"}
|
||||
<form class="form-inline well" action="{$host/}/node" itemprop="url" method="POST">
|
||||
{/unless/}
|
||||
<fieldset>
|
||||
<legend>Edit Node</legend>
|
||||
<div class="span3">
|
||||
<p>Add or Edit a Node</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
{if isset="$node"}
|
||||
<label><span itemprop="name"><a href="{$host/}/node/{$node.id/}/title" rel="node">Title:</a></span></label>
|
||||
{/if}
|
||||
{unless isset="$node"}
|
||||
<label><span itemprop="name">Title:</span> </label>
|
||||
{/unless}
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<input id="title" type="text" class="form-control" name="title" placeholder="Title" required value="{$node.title/}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
{if isset="$node"}
|
||||
<label> <span itemprop="description"><a href="{$host/}/node/{$node.id/}/summary" rel="node">Summary:</a></span></label>
|
||||
{/if}
|
||||
{unless isset="$node"}
|
||||
<label> <span itemprop="description">Summary:</span></label>
|
||||
{/unless}
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<textarea id="summary" rows="3" class="form-control" cols="100" name="summary" placeholder="Node summary" required>{$node.summary/}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
{if isset="$node"}
|
||||
<label> <span itemprop="text"><a href="{$host/}/node/{$node.id/}/content" rel="node">Content</a></span> </label>
|
||||
{/if}
|
||||
{unless isset="$node"}
|
||||
<label> <span itemprop="text">Content:</span> </label>
|
||||
{/unless}
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<textarea id="content" rows="25" cols="100" class="form-control" name="content" placeholder="Node content" required>{$node.content/}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<span> </span>
|
||||
<input type="Submit" value="Send" />
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="delete">
|
||||
{if isset="$user"}
|
||||
<hr>
|
||||
<div class="container-fluid">
|
||||
|
||||
{if isset="$node"}
|
||||
<form action="{$host/}/node/{$node.id/}" method="POST" class="">
|
||||
<input type="hidden" name="method" value="DELETE">
|
||||
<fieldset>
|
||||
<legend>Delete Node</legend>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<span> </span>
|
||||
<input type="Submit" value="Delete" />
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if condition="html"}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{/if}
|
||||
@@ -1,70 +0,0 @@
|
||||
{if condition="html"}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
{/if}
|
||||
|
||||
{unless condition="$web"}
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
{/unless}
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{/if}
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-xs-12" itemscope itemtype="http://schema.org/Article">
|
||||
<form class="form-inline well" action="{$host/}/node/{$id/}/content" method="POST" class="">
|
||||
<input type="hidden" name="method" value="PUT">
|
||||
<fieldset>
|
||||
<legend>Edit Node Content</legend>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
<label> <span itemprop="text">Content:</span> </label>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<textarea id="content" rows="25" cols="100" class="form-control" name="content" placeholder="Node content" required>{$node_content/}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<span> </span>
|
||||
<input type="Submit" value="Update" />
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{if condition="html"}
|
||||
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{/if}
|
||||
@@ -1,71 +0,0 @@
|
||||
{if condition="html"}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
{/if}
|
||||
|
||||
|
||||
{unless condition="$web"}
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
{/unless}
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{/if}
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-xs-12" itemscope itemtype="http://schema.org/Article">
|
||||
<form class="form-inline well" action="{$host/}/node/{$id/}/summary" method="POST">
|
||||
<input type="hidden" name="method" value="PUT">
|
||||
<fieldset>
|
||||
<legend>Edit Node Summary</legend>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
<label> <span itemprop="text">Summary:</span> </label>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<textarea id="summary" rows="3" cols="80" name="summary" placeholder="Node summary" required>{$node_summary/}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<span> </span>
|
||||
<input type="Submit" value="Send" />
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{/if}
|
||||
@@ -1,70 +0,0 @@
|
||||
{if condition="html"}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
{/if}
|
||||
|
||||
{unless condition="$web"}
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
{/unless}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{/if}
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-xs-12" itemscope itemtype="http://schema.org/Article">
|
||||
<form class="form-inline well" action="{$host/}/node/{$id/}/title" method="POST">
|
||||
<input type="hidden" name="method" value="PUT">
|
||||
<fieldset>
|
||||
<legend>Edit Node Title</legend>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-1">
|
||||
<label> <span itemprop="text">Title:</span> </label>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<input id="title" type="text" name="title" placeholder="Title" required value="{$node_title/}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<span> </span>
|
||||
<input type="Submit" value="Send" />
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{if condition="html"}
|
||||
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{/if}
|
||||
@@ -1,52 +0,0 @@
|
||||
{if condition="html"}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
{/if}
|
||||
|
||||
{unless condition="$web"}
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
{/unless}
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{/if}
|
||||
<div itemscope itemtype="http://schema.org/ItemList">
|
||||
<h2 itemprop="name">List nodes</h2><br>
|
||||
<meta itemprop="itemListOrder" content="Descending" />
|
||||
|
||||
{foreach from="$nodes" item="item"}
|
||||
<div class="page-header">
|
||||
<h3><span itemprop="itemListElement"><a href="{$host/}/node/{$item.id/}" rel="node"><strong>{$item.title/}</strong></a></span> <small>{$item.summary/} -{$item.publication_date_output/} </small></h3>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
{if condition="html"}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{/if}
|
||||
@@ -1,100 +0,0 @@
|
||||
{if condition="html"}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{include file="master2/head.tpl"/}
|
||||
</head>
|
||||
<body>
|
||||
{/if}
|
||||
|
||||
|
||||
{unless condition="$web"}
|
||||
<!-- Site Navigation -->
|
||||
{include file="master2/site_navigation.tpl"/}
|
||||
{/unless}
|
||||
|
||||
{if condition="html"}
|
||||
|
||||
<div class="container">
|
||||
<hr>
|
||||
<div class="row">
|
||||
<main class="main">
|
||||
{/if}
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="col-xs-12" itemscope itemtype="http://schema.org/Person">
|
||||
<form class="form-inline well" action="{$host/}/user" data-rel="user-register" method="POST" >
|
||||
<fieldset>
|
||||
<legend>Register</legend>
|
||||
<div class="span3">
|
||||
<p>Register new user</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-2">
|
||||
<label><span itemprop="name">Username:</span> </label>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<input id="username" type="text" name="username" placeholder="Username" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" itemscope itemtype="http://schema.org/Text">
|
||||
<div class="col-xs-2">
|
||||
<label><span itemprop="accessCode">Password:</span> </label>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<input id="password" type="password" name="password" placeholder="Password" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" itemscope itemtype="http://schema.org/Text">
|
||||
<div class="col-xs-2">
|
||||
<label><span itemprop="accessCode">Re-type Password:</span> </label>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<input id="check_password" type="password" name="check_password" placeholder="Password" required/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-2">
|
||||
<label><span itemprop="email">Email:</span> </label>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
<input id="email" type="email" name="email" placeholder="Email" required/>
|
||||
</div>
|
||||
s</div>
|
||||
|
||||
<div>
|
||||
<label>
|
||||
<span> </span>
|
||||
<input type="Submit" value="Send" />
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if condition="html"}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
{if condition="html"}
|
||||
<div id="footer">
|
||||
<footer class="site-footer">
|
||||
{include file="master2/footer.tpl"/}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
{include file="master2/optional_enhancement_js.tpl"/}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{/if}
|
||||
@@ -1,9 +0,0 @@
|
||||
name=api
|
||||
engine=smarty
|
||||
author=jvelilla
|
||||
version=0.1
|
||||
regions[header] = Header
|
||||
regions[content] = Content
|
||||
regions[footer] = Footer
|
||||
regions[first_sidebar] = first sidebar
|
||||
regions[second_sidebar] = second sidebar
|
||||
Binary file not shown.
@@ -1,84 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ROC- Layout with defualt Regions</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
|
||||
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<title>{$head_title/}</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Page Top -->
|
||||
{if isset="$region_top"}
|
||||
{$region_top/}
|
||||
{/if}
|
||||
<!-- Body -->
|
||||
<div class='container-fluid'>
|
||||
|
||||
<!-- Page Header -->
|
||||
<div id="header">
|
||||
{if isset="$page.primary_nav"}
|
||||
{$page.primary_nav/}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- General Page Content -->
|
||||
<div id='content' class='row-fluid'>
|
||||
<!-- Left Sidebar sidebar_first -->
|
||||
{unless empty="$page.region_sidebar_first"}
|
||||
<div style="float: left;">
|
||||
{$page.region_sidebar_first/}
|
||||
</div>
|
||||
{/unless}
|
||||
|
||||
|
||||
<!-- Highlighted, Help, Content -->
|
||||
<div class='span8 main'>
|
||||
<!-- Highlighted Section -->
|
||||
{$page.region_highlighted/}
|
||||
|
||||
<!-- Help Section -->
|
||||
{$page.region_help/}
|
||||
|
||||
<!-- Main Content Section -->
|
||||
{unless empty="$page_title"}<h1 class="page-title">{$page_title/}</h1>{/unless}
|
||||
{$page.region_content/}
|
||||
</div>
|
||||
|
||||
<!-- Right Sidebar sidebar_second-->
|
||||
{unless empty="$page.region_sidebar_second"}
|
||||
<div style="float: right;">
|
||||
{$page.region_sidebar_second/}
|
||||
</div>
|
||||
{/unless}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Page footer -->
|
||||
{$page.region_footer/}
|
||||
|
||||
<!-- Page Bottom -->
|
||||
{$page.region_bottom/}
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,108 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ROC- Layout with defualt Regions</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<title>ROC CMS - A responsive layout</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Page Top -->
|
||||
<!-- Page Header -->
|
||||
<div class='container-fluid'>
|
||||
<h1>ROC Layout with Defaul Regions</h1>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://www2.eiffel.com/beta" itemprop="home" rel="home">Eiffel Support Site</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse" itemscope="itemscope" itemtype="https://www2.eiffel.com/beta/profile/esa_api.xml#report" >
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
<li><a href="https://www2.eiffel.com/beta/reports" class="active" itemprop="all" rel="all">Reports</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
||||
|
||||
<li><a href="https://www2.eiffel.com/beta/register" itemprop="register" rel="register">Register</a></li>
|
||||
|
||||
|
||||
|
||||
|
||||
<!--<li><a class="login pull-right" data-toggle="modal" data-target="#myModalSignIn">Sign In</a></li> <! Custome Modal -->
|
||||
<li id="login_pe" ><a href="https://www2.eiffel.com/beta/login" itemprop="login" rel="login">Sign In</a></li> <!-- Custome Modal -->
|
||||
|
||||
</ul>
|
||||
<!--form class="navbar-form navbar-right">
|
||||
<input type="text" class="form-control" placeholder="Search..."/>
|
||||
</form -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id='content' class='row-fluid'>
|
||||
<!-- Highlighted-->
|
||||
|
||||
|
||||
<!-- Left Side Bard sidebar_first -->
|
||||
<div class='span2 sidebar'>
|
||||
<h3>Left Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href='#'>Another Link 1</a></li>
|
||||
<li><a href='#'>Another Link 2</a></li>
|
||||
<li><a href='#'>Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Highlighted, Help, Content -->
|
||||
<div class='span8 main'>
|
||||
<h1>Highlighted Section</h1>
|
||||
<h2>Help Section</h2>
|
||||
|
||||
<h2>Main Content Section</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.<p>
|
||||
|
||||
<p>Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</p>
|
||||
</div>
|
||||
|
||||
<!-- Left Side Bard sidebar_second-->
|
||||
<div class='span2 sidebar'>
|
||||
<h3>Right Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href='#'>Another Link 1</a></li>
|
||||
<li><a href='#'>Another Link 2</a></li>
|
||||
<li><a href='#'>Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Page footer -->
|
||||
<div id="footer">
|
||||
<small>
|
||||
<center>
|
||||
<p class="text-muted"><a href="#" target="_blank" class="info">ROC Documentation </a>
|
||||
<a href="http://www.eiffel.com/company/contact/" target="_blank" class="info">Questions? Comments? Let us know! </a></p>
|
||||
<p>© Copyright 2014 Eiffel Software -- <a href="#" target="_blank" class="info">Privacy Policy</a>
|
||||
</center>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Page Bottom -->
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,135 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ROC- Layout with defualt Regions</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
|
||||
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<head>
|
||||
<title>ROC CMS - A responsive layout</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Page Top -->
|
||||
<!-- Page Header -->
|
||||
<!-- <div class='container-fluid'>
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button> <a class="navbar-brand" href="#">Eiffel ROC</a>
|
||||
</div>
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
<li> <a href="#about">Home</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li> <a href="#about">About</a>
|
||||
</li>
|
||||
<li> <a href="#services">Service</a>
|
||||
</li>
|
||||
<li> <a href="#portfolio" class="">Portfolio</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
-->
|
||||
<div class="container-fluid">
|
||||
<div class="navbar navbar-default" role="navigation">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://www2.eiffel.com/beta" itemprop="home" rel="home">Eiffel Support Site</a>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse" itemscope="itemscope" itemtype="https://www2.eiffel.com/beta/profile/esa_api.xml#report" >
|
||||
<ul class="nav navbar-nav navbar-left">
|
||||
<li><a href="https://www2.eiffel.com/beta/reports" class="active" itemprop="all" rel="all">Reports</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
|
||||
|
||||
<li><a href="https://www2.eiffel.com/beta/register" itemprop="register" rel="register">Register</a></li>
|
||||
<li id="login_pe" ><a href="https://www2.eiffel.com/beta/login" itemprop="login" rel="login">Sign In</a></li> <!-- Custome Modal -->
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id='content' class='row-fluid'>
|
||||
<!-- Highlighted-->
|
||||
|
||||
|
||||
<!-- Left Side Bard sidebar_first -->
|
||||
<div class="sidebar col-sm-2 col-md-2">
|
||||
<h3>Left Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href="#">Another Link 1</a></li>
|
||||
<li><a href="#">Another Link 2</a></li>
|
||||
<li><a href="#">Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Highlighted, Help, Content -->
|
||||
<div class="main col-sm-8 col-md-8">
|
||||
<h1>Highlighted Section</h1>
|
||||
<h2>Help Section</h2>
|
||||
|
||||
<h2>Main Content Section</h2>
|
||||
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.<p>
|
||||
|
||||
<p>Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</p>
|
||||
</div>
|
||||
|
||||
<!-- Left Side Bard sidebar_second-->
|
||||
|
||||
<div class="sidebar col-sm-2 col-md-2">
|
||||
<h3>Right Sidebar</h3>
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<li><a href="#">Another Link 1</a></li>
|
||||
<li><a href="#">Another Link 2</a></li>
|
||||
<li><a href="#">Another Link 3</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--Page footer -->
|
||||
<div id="footer">
|
||||
<small>
|
||||
<center>
|
||||
<p class="text-muted"><a href="#" target="_blank" class="info">ROC Documentation </a>
|
||||
<a href="http://www.eiffel.com/company/contact/" target="_blank" class="info">Questions? Comments? Let us know! </a></p>
|
||||
<p>© Copyright 2014 Eiffel Software -- <a href="#" target="_blank" class="info">Privacy Policy</a>
|
||||
</center>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<!-- Page Bottom -->
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,12 +0,0 @@
|
||||
{include file="tpl/page-header.tpl"/}
|
||||
<div id="main-wrapper">
|
||||
<div id="main">
|
||||
<div id="first_sidebar" class="sidebar {if isset="$first_sidebar_css_class"}{$first_sidebar_css_class/}{/if}">{if isset="$first_sidebar"}{$first_sidebar/}{/if}</div>
|
||||
<div id="content" class="{if isset="$content_css_class"}{$content_css_class/}{/if}">
|
||||
Welcome ... this is the front page
|
||||
{if isset="$content"}{$content/}{/if}
|
||||
</div>
|
||||
<div id="second_sidebar" class="sidebar {if isset="$second_sidebar_css_class"}{$second_sidebar_css_class/}{/if}">{if isset="$second_sidebar"}{$second_sidebar/}{/if}</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file="tpl/page-footer.tpl"/}
|
||||
@@ -1,11 +0,0 @@
|
||||
{include file="tpl/page-header.tpl"/}
|
||||
<div id="main-wrapper">
|
||||
<div id="main">
|
||||
<div id="first_sidebar" class="sidebar {if isset="$first_sidebar_css_class"}{$first_sidebar_css_class/}{/if}">{if isset="$first_sidebar"}{$first_sidebar/}{/if}</div>
|
||||
<div id="content" class="{if isset="$content_css_class"}{$content_css_class/}{/if}">
|
||||
{if isset="$content"}{$content/}{/if}
|
||||
</div>
|
||||
<div id="second_sidebar" class="sidebar {if isset="$second_sidebar_css_class"}{$second_sidebar_css_class/}{/if}">{if isset="$second_sidebar"}{$second_sidebar/}{/if}</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file="tpl/page-footer.tpl"/}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* EWF CMS javascript based on JQuery
|
||||
*/
|
||||
|
||||
/**
|
||||
* Override jQuery.fn.init to guard against XSS attacks.
|
||||
*
|
||||
* See http://bugs.jquery.com/ticket/9521
|
||||
*/
|
||||
|
||||
(function () {
|
||||
var jquery_init = jQuery.fn.init;
|
||||
jQuery.fn.init = function (selector, context, rootjQuery) {
|
||||
// If the string contains a "#" before a "<", treat it as invalid HTML.
|
||||
if (selector && typeof selector === 'string') {
|
||||
var hash_position = selector.indexOf('#');
|
||||
if (hash_position >= 0) {
|
||||
var bracket_position = selector.indexOf('<');
|
||||
if (bracket_position > hash_position) {
|
||||
throw 'Syntax error, unrecognized expression: ' + selector;
|
||||
}
|
||||
}
|
||||
}
|
||||
return jquery_init.call(this, selector, context, rootjQuery);
|
||||
};
|
||||
jQuery.fn.init.prototype = jquery_init.prototype;
|
||||
})();
|
||||
|
||||
|
||||
var EWFCMS = EWFCMS || { };
|
||||
|
||||
EWFCMS.toggleFieldset = function(fieldset) {
|
||||
if ($(fieldset).is('.collapsed')) {
|
||||
var content = $('> div:not(.action)', fieldset);
|
||||
$(fieldset).removeClass('collapsed');
|
||||
content.hide();
|
||||
content.slideDown( {
|
||||
duration: 'fast',
|
||||
easing: 'linear',
|
||||
complete: function() {
|
||||
//Drupal.collapseScrollIntoView(this.parentNode);
|
||||
this.parentNode.animating = false;
|
||||
$('div.action', fieldset).show();
|
||||
},
|
||||
step: function() {
|
||||
// Scroll the fieldset into view
|
||||
//Drupal.collapseScrollIntoView(this.parentNode);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var content = $('> div:not(.action)', fieldset).slideUp('fast', function() {
|
||||
$(this.parentNode).addClass('collapsed');
|
||||
this.parentNode.animating = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
//$('.collapsed').hide();
|
||||
$('fieldset.collapsible > legend').each(function() {
|
||||
var fieldset = $(this.parentNode);
|
||||
// turn legen into clickable link and wrap contents
|
||||
var text = this.innerHTML;
|
||||
$(this).empty()
|
||||
.append($('<a href="#">'+ text + '</a>').click(function() {
|
||||
var fieldset = $(this).parents('fieldset:first')[0];
|
||||
if (!fieldset.animating) {
|
||||
fieldset.animating = true;
|
||||
EWFCMS.toggleFieldset(fieldset);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
))
|
||||
.after($('<div class="fieldset-wrapper"></div>')
|
||||
.append(fieldset.children(':not(legend):not(.action)')))
|
||||
.addClass('collapse-processed');
|
||||
});
|
||||
$('fieldset.collapsed').each(function() {
|
||||
$(this).removeClass('collapsed');
|
||||
EWFCMS.toggleFieldset(this);
|
||||
});
|
||||
});
|
||||
|
||||
jQuery(document).ready(function(){
|
||||
$('#tabs').tabs();
|
||||
});
|
||||
|
||||
//jQuery(document).ready(function(){
|
||||
//$('#second_sidebar').hide();
|
||||
//});
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 786 B |
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 108 B |
Binary file not shown.
|
Before Width: | Height: | Size: 106 B |
@@ -1,251 +0,0 @@
|
||||
body { margin: 0; background-color: #eeeeff;}
|
||||
div#header { background-color: #003; color: #fff; border: solid 1px #003; padding: 0px; margin: 0px;}
|
||||
div#header img#logo { float: left; margin: 5px 15px 5px 10px; }
|
||||
div#header div#title {font-size: 180%; font-weight: bold; margin-top: 10px; }
|
||||
ul.horizontal {
|
||||
list-style-type: none;
|
||||
}
|
||||
ul.horizontal li {
|
||||
display: inline;
|
||||
padding: 0 5px 0 5px;
|
||||
}
|
||||
|
||||
div#menu-bar li.active {
|
||||
border: solid 1px #ff0;
|
||||
color: #ff0;
|
||||
}
|
||||
div#menu-bar li:hover {
|
||||
background-color: #fff;
|
||||
color: #00f;
|
||||
}
|
||||
div#menu-bar li a {
|
||||
text-decoration: none;
|
||||
color: #fff;
|
||||
}
|
||||
div#menu-bar li:hover a {
|
||||
color: #00f;
|
||||
font-style: bold;
|
||||
}
|
||||
|
||||
|
||||
div#primary-tabs li {
|
||||
color: #00f;
|
||||
padding: 2px 5px 2px 5px;
|
||||
background-color: #eee;
|
||||
border: solid 1px #ccf;
|
||||
}
|
||||
div#primary-tabs li.active {
|
||||
padding: 2px 7px 1px 7px;
|
||||
border-top: solid 2px #99f;
|
||||
border-left: solid 1px #99f;
|
||||
border-right: solid 1px #99f;
|
||||
border-bottom: 0;
|
||||
background-color: #fff;
|
||||
color: #00f;
|
||||
}
|
||||
div#primary-tabs li:hover {
|
||||
background-color: #fff;
|
||||
color: #00f;
|
||||
}
|
||||
div#primary-tabs li a {
|
||||
text-decoration: none;
|
||||
color: #00f;
|
||||
}
|
||||
div#primary-tabs li:hover a {
|
||||
color: #00f;
|
||||
font-style: bold;
|
||||
}
|
||||
|
||||
|
||||
|
||||
div#menu-first { margin-left: 20%; color: #ccf; background-color: #003; }
|
||||
div#menu-first a { color: #ccf; }
|
||||
div#menu-second { color: #99f; background-color: #333; }
|
||||
div#menu-second a { color: #99f; }
|
||||
|
||||
div#main-wrapper {
|
||||
clear: both;
|
||||
display: block;
|
||||
height: 0;
|
||||
}
|
||||
div#main { margin: 0; padding: 0; clear: both; height:0; display: block; }
|
||||
|
||||
div#content {
|
||||
padding: 5px 3px 5px 20px;
|
||||
margin-top: 10px;
|
||||
min-width: 60%;
|
||||
display: inline;
|
||||
float: left;
|
||||
position: relative;
|
||||
background-color: #ffffff;
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
|
||||
div#first_sidebar {
|
||||
width: 20%;
|
||||
margin: 5px;
|
||||
padding: 5px;
|
||||
display: inline;
|
||||
float: left;
|
||||
position: relative;
|
||||
}
|
||||
div#second_sidebar {
|
||||
width: 20%;
|
||||
margin: 5px;
|
||||
padding: 5px;
|
||||
display: inline;
|
||||
float: left;
|
||||
position: relative;
|
||||
background-color: #eee;
|
||||
}
|
||||
div.sidebar div.block {
|
||||
margin-bottom: 5px;
|
||||
padding: 0;
|
||||
border: dotted 1px #999;
|
||||
background-color: #fff;
|
||||
}
|
||||
div.sidebar div.block div.title {
|
||||
padding: 3px 3px 3px 3px;
|
||||
font-weight: bold;
|
||||
background-color: #dedede;
|
||||
border-bottom: dotted 1px #999;
|
||||
}
|
||||
div.sidebar div.block div.inside {
|
||||
margin: 3px;
|
||||
}
|
||||
div#footer { margin: 10px 0 10px 0; clear: both; display: block; text-align: center; padding: 10px; border-top: solid 1px #00f; color: #fff; background-color: #333;}
|
||||
div#footer a { color: #ff0; }
|
||||
|
||||
form div.error {
|
||||
border-top: dotted 1px #f00;
|
||||
border-bottom: dotted 1px #f00;
|
||||
border-left: solid 3px #f00;
|
||||
}
|
||||
div.node div.title {
|
||||
font-weight: bold;
|
||||
font-size: 110%;
|
||||
border-bottom: dotted 1 px #009;
|
||||
}
|
||||
div.description {
|
||||
font-style: italic;
|
||||
font-color: #999;
|
||||
}
|
||||
|
||||
div.node-wrapper {
|
||||
margin: 5px 2px 5px 2px;
|
||||
border: dotted 1px #dddddd;
|
||||
padding: 5px 3px 5px 3px;
|
||||
}
|
||||
div.node div.title {
|
||||
font-weight: bold;
|
||||
font-size: 110%;
|
||||
border-bottom: dotted 1 px #009;
|
||||
float: left;
|
||||
}
|
||||
div.node div.description {
|
||||
text-align: right;
|
||||
}
|
||||
div.node div.inner {
|
||||
padding: 5px 5px 5px 10px;
|
||||
border-top: dotted 1px #dddddd;
|
||||
}
|
||||
|
||||
form#user-login {
|
||||
border: dotted 1px #099;
|
||||
display: inline-block;
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
form#user-login>div {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
form#user-login .input {
|
||||
float: left;
|
||||
}
|
||||
form#user-login img.logo {
|
||||
}
|
||||
|
||||
div#message {
|
||||
border: solid 1px #fc0;
|
||||
background-color: #fed;
|
||||
color: #000;
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
div#message li {
|
||||
padding-left: 5px;
|
||||
margin-left: 3px;
|
||||
}
|
||||
div#message li.success {
|
||||
color: #003300;
|
||||
background-color: #ccffcc;
|
||||
}
|
||||
|
||||
div#message li.error {
|
||||
color: #330000;
|
||||
background-color: #ff9494;
|
||||
}
|
||||
div#message li.warning {
|
||||
color: #aa2200;
|
||||
background-color: #ffcc99;
|
||||
}
|
||||
|
||||
div.columns {
|
||||
margin-top: 10px;
|
||||
display: inline-block;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
div.columns>* {
|
||||
padding-left: 10px;
|
||||
padding-top: 5px;
|
||||
border-top: dotted 1px #999;
|
||||
border-left: dotted 1px #999;
|
||||
margin-left: 1px;
|
||||
margin-right: 10px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
/* Link */
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
div.menu ul.vertical {
|
||||
margin: 0;
|
||||
padding-left: 10px;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
div.menu ul.vertical ul {
|
||||
border-left: solid 3px #eee;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding-left: 5px;
|
||||
margin-left: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
/* Fieldset and collapsible */
|
||||
|
||||
fieldset.collapsible legend a {
|
||||
padding-left: 15px;
|
||||
background: url(menu-expanded.png) 5px 75% no-repeat;
|
||||
}
|
||||
|
||||
fieldset.collapsed legend a {
|
||||
padding-left: 15px;
|
||||
background: url(menu-collapsed.png) 5px 50% no-repeat;
|
||||
}
|
||||
|
||||
fieldset.collapsed {
|
||||
border: none;
|
||||
border-top: dotted 1px #000;
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
name=smarty
|
||||
engine=smarty
|
||||
author=jfiat
|
||||
version=0.1
|
||||
;template_dir=templates
|
||||
regions[header] = Header
|
||||
regions[content] = Content
|
||||
regions[footer] = Footer
|
||||
regions[first_sidebar] = first sidebar
|
||||
regions[second_sidebar] = second sidebar
|
||||
@@ -1,6 +0,0 @@
|
||||
<div id="footer">{if isset="$footer"}{$footer/}{/if}</div>
|
||||
</div>
|
||||
</div>
|
||||
{if isset="$page_bottom"}{$page_bottom/}{/if}
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$language/}" lang="{$language/}" version="XHTML+RDFa 1.0" dir="ltr">
|
||||
<head>
|
||||
{if isset="$head"}{$head/}{/if}
|
||||
<title>{$head_title/}</title>
|
||||
{if isset="$styles"}{$styles/}{/if}
|
||||
{if isset="$scripts"}{$scripts/}{/if}
|
||||
{if isset="$head_lines"}{$head_lines/}{/if}
|
||||
</head>
|
||||
<div id="page-wrapper">
|
||||
<div id="page">
|
||||
<div id="header">
|
||||
{$header/}
|
||||
</div>
|
||||
@@ -2,8 +2,8 @@ note
|
||||
description: "[
|
||||
application service
|
||||
]"
|
||||
date: "$Date: 2014-11-20 15:03:29 +0100 (jeu., 20 nov. 2014) $"
|
||||
revision: "$Revision: 96138 $"
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
class
|
||||
EWF_ROC_SERVER
|
||||
@@ -16,16 +16,9 @@ inherit
|
||||
initialize
|
||||
end
|
||||
|
||||
WSF_SERVICE
|
||||
redefine
|
||||
execute
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
ARGUMENTS
|
||||
|
||||
SHARED_LOGGER
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
create
|
||||
make_and_launch
|
||||
@@ -43,36 +36,19 @@ feature {NONE} -- Initialization
|
||||
do
|
||||
Precursor
|
||||
create {WSF_SERVICE_LAUNCHER_OPTIONS_FROM_INI} service_options.make_from_file ("demo.ini")
|
||||
initialize_cms (cms_setup)
|
||||
end
|
||||
|
||||
feature -- Service
|
||||
|
||||
cms_service: CMS_SERVICE
|
||||
-- cms service.
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
cms_service.execute (req, res)
|
||||
end
|
||||
|
||||
feature -- Layout
|
||||
|
||||
layout: CMS_LAYOUT
|
||||
-- cms layout.
|
||||
|
||||
feature {NONE} -- Launch operation
|
||||
|
||||
launcher: APPLICATION_LAUNCHER
|
||||
launcher: APPLICATION_LAUNCHER [EWF_ROC_SERVER_EXECUTION]
|
||||
|
||||
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
|
||||
local
|
||||
l_retry: BOOLEAN
|
||||
l_message: STRING
|
||||
do
|
||||
if not l_retry then
|
||||
log.write_debug (generator + ".launch")
|
||||
launcher.launch (a_service, opts)
|
||||
launcher.launch (opts)
|
||||
else
|
||||
-- error hanling.
|
||||
create l_message.make (1024)
|
||||
@@ -92,63 +68,11 @@ feature {NONE} -- Launch operation
|
||||
l_message.append ("%N%N")
|
||||
end
|
||||
-- send email shutdown
|
||||
log.write_debug (generator + ".launch shutdown")
|
||||
end
|
||||
rescue
|
||||
l_retry := True
|
||||
retry
|
||||
end
|
||||
|
||||
feature -- CMS Initialization
|
||||
|
||||
cms_setup: CMS_DEFAULT_SETUP
|
||||
do
|
||||
if attached separate_character_option_value ('d') as l_dir then
|
||||
log.write_debug (generator + ".cms_setup using a command line argument -d " + l_dir )
|
||||
create layout.make_with_path (create {PATH}.make_from_string (l_dir))
|
||||
else
|
||||
log.write_debug (generator + ".cms_setup using current directory" )
|
||||
create layout.make_default
|
||||
end
|
||||
create Result.make (layout)
|
||||
setup_storage (Result)
|
||||
end
|
||||
|
||||
initialize_cms (a_setup: CMS_SETUP)
|
||||
local
|
||||
cms: CMS_SERVICE
|
||||
api: CMS_API
|
||||
do
|
||||
log.write_debug (generator + ".initialize_cms")
|
||||
setup_modules (a_setup)
|
||||
create api.make (a_setup)
|
||||
create cms.make (api)
|
||||
cms_service := cms
|
||||
end
|
||||
|
||||
feature -- CMS setup
|
||||
|
||||
setup_modules (a_setup: CMS_SETUP)
|
||||
-- Setup additional modules.
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
create {BASIC_AUTH_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
|
||||
create {CMS_DEMO_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
end
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
to_implement ("To implement custom storage")
|
||||
end
|
||||
a_setup.storage_drivers.force (create {CMS_STORAGE_MYSQL_BUILDER}.make, "mysql")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
57
examples/demo/src/ewf_roc_server_execution.e
Normal file
57
examples/demo/src/ewf_roc_server_execution.e
Normal file
@@ -0,0 +1,57 @@
|
||||
note
|
||||
description: "Summary description for {EWF_ROC_SERVER_EXECUTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
EWF_ROC_SERVER_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
redefine
|
||||
initialize
|
||||
end
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
initialize
|
||||
do
|
||||
Precursor
|
||||
end
|
||||
|
||||
feature -- CMS setup
|
||||
|
||||
setup_modules (a_setup: CMS_SETUP)
|
||||
-- Setup additional modules.
|
||||
local
|
||||
m: CMS_MODULE
|
||||
do
|
||||
create {BASIC_AUTH_MODULE} m.make
|
||||
if not a_setup.module_with_same_type_registered (m) then
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
end
|
||||
|
||||
create {CMS_DEMO_MODULE} m.make
|
||||
m.enable
|
||||
a_setup.register_module (m)
|
||||
end
|
||||
|
||||
setup_storage (a_setup: CMS_SETUP)
|
||||
do
|
||||
debug ("refactor_fixme")
|
||||
to_implement ("To implement custom storage")
|
||||
end
|
||||
-- a_setup.storage_drivers.force (create {CMS_STORAGE_MYSQL_BUILDER}.make, "mysql")
|
||||
a_setup.storage_drivers.force (create {CMS_STORAGE_SQLITE_BUILDER}.make, "sqlite")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -44,8 +44,8 @@ note
|
||||
@include=file-to-include
|
||||
|
||||
]"
|
||||
date: "$Date: 2014-12-18 16:37:11 +0100 (jeu., 18 déc. 2014) $"
|
||||
revision: "$Revision: 96383 $"
|
||||
date: "$Date: 2015-03-09 19:25:49 +0100 (lun., 09 mars 2015) $"
|
||||
revision: "$Revision: 96797 $"
|
||||
|
||||
class
|
||||
INI_CONFIG
|
||||
@@ -314,10 +314,13 @@ feature {NONE} -- Implementation
|
||||
f: PLAIN_TEXT_FILE
|
||||
l_last_section_name: like last_section_name
|
||||
retried: BOOLEAN
|
||||
l_old_associated_path: like associated_path
|
||||
do
|
||||
l_old_associated_path := associated_path
|
||||
if retried then
|
||||
has_error := True
|
||||
else
|
||||
associated_path := p
|
||||
l_last_section_name := last_section_name
|
||||
last_section_name := Void
|
||||
create f.make_with_path (p)
|
||||
@@ -337,6 +340,7 @@ feature {NONE} -- Implementation
|
||||
end
|
||||
end
|
||||
last_section_name := l_last_section_name
|
||||
associated_path := l_old_associated_path
|
||||
rescue
|
||||
retried := True
|
||||
retry
|
||||
@@ -351,6 +355,7 @@ feature {NONE} -- Implementation
|
||||
lst: LIST [STRING_8]
|
||||
tb: STRING_TABLE [STRING_8]
|
||||
i,j: INTEGER
|
||||
p: PATH
|
||||
l_section_name: like last_section_name
|
||||
do
|
||||
obj := Void
|
||||
@@ -384,7 +389,11 @@ feature {NONE} -- Implementation
|
||||
|
||||
|
||||
if k.is_case_insensitive_equal_general ("@include") then
|
||||
import_path (create {PATH}.make_from_string (v), last_section_name)
|
||||
create p.make_from_string (v)
|
||||
if not p.is_absolute and attached associated_path as l_path then
|
||||
p := l_path.parent.extended_path (p)
|
||||
end
|
||||
import_path (p, last_section_name)
|
||||
else
|
||||
i := k.index_of ('[', 1)
|
||||
if i > 0 then
|
||||
|
||||
@@ -11,15 +11,19 @@ note
|
||||
- templates (html, Collection+JSON, ...)
|
||||
- ...
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-02-05 10:25:53 +0100 (jeu., 05 févr. 2015) $"
|
||||
revision: "$Revision: 96584 $"
|
||||
|
||||
class
|
||||
APPLICATION_LAYOUT
|
||||
|
||||
inherit
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
create
|
||||
make_default,
|
||||
make_with_path
|
||||
make_with_path,
|
||||
make_with_directory_name
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
@@ -37,6 +41,34 @@ feature {NONE} -- Initialization
|
||||
-- Create a layour based on a path `p'.
|
||||
do
|
||||
path := p.absolute_path.canonical_path
|
||||
initialize_name
|
||||
end
|
||||
|
||||
make_with_directory_name (a_dirname: READABLE_STRING_GENERAL)
|
||||
-- Create a layour based on a path `p'.
|
||||
do
|
||||
make_with_path (create {PATH}.make_from_string (a_dirname))
|
||||
end
|
||||
|
||||
initialize_name
|
||||
-- Initialize `name'.
|
||||
local
|
||||
p: PATH
|
||||
s: STRING_32
|
||||
do
|
||||
create p.make_from_string (execution_environment.arguments.command_name)
|
||||
if attached p.entry as e then
|
||||
p := e
|
||||
end
|
||||
create s.make_from_string (p.name)
|
||||
if attached p.extension as l_extension then
|
||||
s.remove_tail (l_extension.count + 1)
|
||||
end
|
||||
if s.is_whitespace then
|
||||
set_name ({STRING_8} "app")
|
||||
else
|
||||
set_name (s)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -44,6 +76,17 @@ feature -- Access
|
||||
path: PATH
|
||||
-- Root location.
|
||||
|
||||
name: IMMUTABLE_STRING_32
|
||||
-- Application name, default is "app"
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_name (a_name: READABLE_STRING_GENERAL)
|
||||
-- Set `name' from `a_name'.
|
||||
do
|
||||
create name.make_from_string_general (a_name)
|
||||
end
|
||||
|
||||
feature -- Access: internal
|
||||
|
||||
config_path: PATH
|
||||
@@ -163,6 +206,6 @@ feature {NONE} -- Implementation
|
||||
-- Directory for templates (HTML, etc).
|
||||
|
||||
;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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
class
|
||||
DATABASE_CONFIGURATION
|
||||
@@ -33,10 +33,65 @@ feature -- Access
|
||||
connection_string: READABLE_STRING_32
|
||||
-- Connection string
|
||||
do
|
||||
Result := "Driver={"+driver+"};" + database_string;
|
||||
Result := {STRING_32} "Driver={" + driver + {STRING_32} "};" + 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Object that represents Logger configuration settings"
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
date: "$Date: 2015-02-03 19:11:23 +0100 (mar., 03 févr. 2015) $"
|
||||
revision: "$Revision: 96575 $"
|
||||
|
||||
class
|
||||
LOGGER_CONFIGURATION
|
||||
@@ -29,6 +29,7 @@ feature -- Initialization
|
||||
do
|
||||
backup_count := 4
|
||||
level := Log_debug
|
||||
location := Void
|
||||
ensure then
|
||||
backup_count_set: backup_count = 4
|
||||
level_set: level = Log_debug
|
||||
@@ -36,6 +37,9 @@ feature -- Initialization
|
||||
|
||||
feature -- Access
|
||||
|
||||
location: detachable PATH
|
||||
-- Location for logs files, if none use default logs location.
|
||||
|
||||
backup_count: NATURAL
|
||||
-- Max number of backup files.
|
||||
-- When 0, no backup files are created, and the log file is simply truncated when it becomes larger than `max_file_size'.
|
||||
@@ -46,6 +50,21 @@ feature -- Access
|
||||
|
||||
feature -- Element Change
|
||||
|
||||
set_location (a_location: detachable PATH)
|
||||
-- Set `location' to `a_location'.
|
||||
do
|
||||
location := a_location
|
||||
ensure
|
||||
location_set: a_location ~ location
|
||||
end
|
||||
|
||||
set_location_with_string (a_location: READABLE_STRING_GENERAL)
|
||||
require
|
||||
a_location /= Void and then not a_location.is_whitespace
|
||||
do
|
||||
set_location (create {PATH}.make_from_string (a_location))
|
||||
end
|
||||
|
||||
set_backup_count (a_backup: NATURAL)
|
||||
-- Set backup_count to `a_backup'.
|
||||
do
|
||||
@@ -78,6 +97,6 @@ feature -- Element Change
|
||||
end
|
||||
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
|
||||
|
||||
@@ -56,10 +56,10 @@ feature -- Element Settings
|
||||
l_message.append ("An unknown exception was raised.")
|
||||
end
|
||||
set_last_error (l_message, a_location)
|
||||
log.write_critical (generator + ".set_last_error_from_exception " + l_message)
|
||||
write_critical_log (generator + ".set_last_error_from_exception " + l_message)
|
||||
else
|
||||
set_last_error ("Generic error", "")
|
||||
log.write_critical (generator + ".set_last_error_from_exception Generic Error")
|
||||
write_critical_log (generator + ".set_last_error_from_exception Generic Error")
|
||||
end
|
||||
rescue
|
||||
l_retried := True
|
||||
@@ -75,7 +75,7 @@ feature -- Element Settings
|
||||
attached_location: a_location /= Void
|
||||
do
|
||||
create last_error.make (a_message, a_location)
|
||||
log.write_critical (generator + ".set_last_error " + a_message)
|
||||
write_critical_log (generator + ".set_last_error " + a_message)
|
||||
successful := False
|
||||
ensure
|
||||
last_error_set: attached last_error
|
||||
@@ -103,6 +103,6 @@ feature -- Element Settings
|
||||
successful: successful
|
||||
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
|
||||
|
||||
172
library/layout/src/logger/logger.e
Normal file
172
library/layout/src/logger/logger.e
Normal file
@@ -0,0 +1,172 @@
|
||||
note
|
||||
description: "Summary description for {LOGGER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
LOGGER
|
||||
|
||||
inherit
|
||||
ANY
|
||||
|
||||
LOG_PRIORITY_CONSTANTS
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
export
|
||||
{NONE} all
|
||||
end
|
||||
|
||||
create
|
||||
make,
|
||||
make_with_layout
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
create log.make
|
||||
end
|
||||
|
||||
make_with_layout (app: APPLICATION_LAYOUT)
|
||||
do
|
||||
make
|
||||
apply_layout (app)
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
apply_layout (app: APPLICATION_LAYOUT)
|
||||
do
|
||||
initialize_logger (app, log)
|
||||
end
|
||||
|
||||
feature {NONE} -- Internal
|
||||
|
||||
log: LOGGING_FACILITY
|
||||
|
||||
feature -- Logging
|
||||
|
||||
put_information (a_message: separate READABLE_STRING_8)
|
||||
do
|
||||
log.write_information (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
|
||||
put_error (a_message: separate READABLE_STRING_8)
|
||||
do
|
||||
log.write_error (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
|
||||
put_warning (a_message: separate READABLE_STRING_8)
|
||||
do
|
||||
log.write_warning (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
|
||||
put_critical (a_message: separate READABLE_STRING_8)
|
||||
do
|
||||
log.write_critical (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
|
||||
put_alert (a_message: separate READABLE_STRING_8)
|
||||
do
|
||||
log.write_alert (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
|
||||
put_debug (a_message: separate READABLE_STRING_8)
|
||||
do
|
||||
log.write_debug (create {STRING}.make_from_separate (a_message))
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
initialize_logger (app: APPLICATION_LAYOUT; a_log: like log)
|
||||
local
|
||||
l_log_writer_file: LOG_ROLLING_WRITER_FILE
|
||||
l_log_writer: LOG_WRITER
|
||||
l_logs_path: detachable PATH
|
||||
l_logger_config: LOGGER_CONFIGURATION
|
||||
ut: FILE_UTILITIES
|
||||
do
|
||||
l_logger_config := new_logger_level_configuration (app.application_config_path)
|
||||
l_logs_path := l_logger_config.location
|
||||
if l_logs_path = Void then
|
||||
l_logs_path := app.logs_path
|
||||
end
|
||||
if ut.directory_path_exists (l_logs_path) then
|
||||
create l_log_writer_file.make_at_location (l_logs_path.extended (app.name).appended_with_extension ("log"))
|
||||
l_log_writer_file.set_max_file_size ({NATURAL_64} 1024 * 1204)
|
||||
l_log_writer_file.set_max_backup_count (l_logger_config.backup_count)
|
||||
l_log_writer := l_log_writer_file
|
||||
else
|
||||
-- Should we create the directory anyway ?
|
||||
create {LOG_WRITER_NULL} l_log_writer
|
||||
end
|
||||
set_logger_level (l_log_writer, l_logger_config.level)
|
||||
a_log.register_log_writer (l_log_writer)
|
||||
end
|
||||
|
||||
set_logger_level (a_log_writer: LOG_WRITER; a_priority: INTEGER)
|
||||
-- Setup the logger level based on `a_priority'
|
||||
do
|
||||
if a_priority = log_debug then
|
||||
a_log_writer.enable_debug_log_level
|
||||
elseif a_priority = Log_emergency then
|
||||
a_log_writer.enable_emergency_log_level
|
||||
elseif a_priority = Log_alert then
|
||||
a_log_writer.enable_alert_log_level
|
||||
elseif a_priority = Log_critical then
|
||||
a_log_writer.enable_critical_log_level
|
||||
elseif a_priority = Log_error then
|
||||
a_log_writer.enable_error_log_level
|
||||
elseif a_priority = Log_warning then
|
||||
a_log_writer.enable_warning_log_level
|
||||
elseif a_priority = Log_notice then
|
||||
a_log_writer.enable_notice_log_level
|
||||
elseif a_priority = Log_information then
|
||||
a_log_writer.enable_information_log_level
|
||||
else
|
||||
a_log_writer.enable_unkno_log_level
|
||||
end
|
||||
end
|
||||
|
||||
new_logger_level_configuration (a_path: PATH): LOGGER_CONFIGURATION
|
||||
-- Retrieve a new logger level configuration.
|
||||
-- By default, level is set to `DEBUG'.
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
ut: FILE_UTILITIES
|
||||
do
|
||||
create Result
|
||||
if
|
||||
ut.file_path_exists (a_path) and then
|
||||
attached (create {JSON_FILE_READER}).read_json_from (a_path.name) as json_file
|
||||
then
|
||||
create l_parser.make_with_string (json_file)
|
||||
l_parser.parse_content
|
||||
if
|
||||
l_parser.is_valid and then
|
||||
attached l_parser.parsed_json_object as jv and then
|
||||
attached {JSON_OBJECT} jv.item ("logger") as l_logger
|
||||
then
|
||||
if attached {JSON_STRING} l_logger.item ("location") as l_location then
|
||||
Result.set_location_with_string (l_location.item)
|
||||
end
|
||||
if attached {JSON_STRING} l_logger.item ("backup_count") as l_count then
|
||||
if l_count.item.is_natural then
|
||||
Result.set_backup_count (l_count.item.to_natural)
|
||||
end
|
||||
end
|
||||
if attached {JSON_STRING} l_logger.item ("level") as l_level then
|
||||
Result.set_level (l_level.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
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
|
||||
@@ -67,7 +67,6 @@ feature -- Output
|
||||
rescue
|
||||
l_retry := True
|
||||
retry
|
||||
|
||||
end
|
||||
|
||||
write_emergency (msg: STRING)
|
||||
@@ -135,6 +134,6 @@ feature -- Output
|
||||
retry
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Provides logger information"
|
||||
date: "$Date: 2015-01-15 00:00:58 +0100 (jeu., 15 janv. 2015) $"
|
||||
revision: "$Revision: 96461 $"
|
||||
date: "$Date: 2015-02-05 10:25:53 +0100 (jeu., 05 févr. 2015) $"
|
||||
revision: "$Revision: 96584 $"
|
||||
|
||||
class
|
||||
SHARED_LOGGER
|
||||
@@ -9,103 +9,107 @@ class
|
||||
inherit
|
||||
LOG_PRIORITY_CONSTANTS
|
||||
|
||||
ARGUMENTS
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
|
||||
feature -- Logger
|
||||
|
||||
|
||||
log: LOGGING_FACILITY
|
||||
-- New `log' (once per process)
|
||||
logger: separate LOGGER
|
||||
-- `log' facility (once per process)
|
||||
-- that could be shared between threads
|
||||
-- without reinitializing it.
|
||||
local
|
||||
l_log_writer: LOG_ROLLING_WRITER_FILE
|
||||
l_environment: EXECUTION_ENVIRONMENT
|
||||
l_path: PATH
|
||||
l_logger_config: LOGGER_CONFIGURATION
|
||||
do
|
||||
Result := logger_cell_item (logger_cell)
|
||||
end
|
||||
|
||||
logger_cell: separate CELL [separate LOGGER]
|
||||
once ("PROCESS")
|
||||
--| Initialize the logging facility
|
||||
create Result.make
|
||||
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 ("logs").appended ("\api.log"))
|
||||
else
|
||||
l_path := create {PATH}.make_current
|
||||
create l_log_writer.make_at_location (l_path.extended("api.log"))
|
||||
end
|
||||
l_log_writer.set_max_file_size ({NATURAL_64}1024*1204)
|
||||
if attached separate_character_option_value ('d') as l_dir then
|
||||
l_logger_config := new_logger_level_configuration (l_path.extended("config").extended ("application_configuration.json"))
|
||||
else
|
||||
l_logger_config := new_logger_level_configuration (l_path.extended ("site").extended("config").extended ("application_configuration.json"))
|
||||
end
|
||||
l_log_writer.set_max_backup_count (l_logger_config.backup_count)
|
||||
set_logger_level (l_log_writer, l_logger_config.level)
|
||||
log.register_log_writer (l_log_writer)
|
||||
|
||||
--| Write an informational message
|
||||
Result.write_information ("The application is starting up...")
|
||||
create Result.put (create {separate LOGGER}.make)
|
||||
end
|
||||
|
||||
feature {NONE} -- JSON
|
||||
|
||||
set_logger_level (a_log_writer: LOG_ROLLING_WRITER_FILE; a_priority: INTEGER)
|
||||
-- Setup the logger level based on `a_priority'
|
||||
logger_cell_item (a_cell: like logger_cell): separate LOGGER
|
||||
do
|
||||
if a_priority = log_debug then
|
||||
a_log_writer.enable_debug_log_level
|
||||
elseif a_priority = Log_emergency then
|
||||
a_log_writer.enable_emergency_log_level
|
||||
elseif a_priority = Log_alert then
|
||||
a_log_writer.enable_alert_log_level
|
||||
elseif a_priority = Log_critical then
|
||||
a_log_writer.enable_critical_log_level
|
||||
elseif a_priority = Log_error then
|
||||
a_log_writer.enable_error_log_level
|
||||
elseif a_priority = Log_warning then
|
||||
a_log_writer.enable_warning_log_level
|
||||
elseif a_priority = Log_notice then
|
||||
a_log_writer.enable_notice_log_level
|
||||
elseif a_priority = Log_information then
|
||||
a_log_writer.enable_information_log_level
|
||||
else
|
||||
a_log_writer.enable_unkno_log_level
|
||||
end
|
||||
Result := a_cell.item
|
||||
end
|
||||
|
||||
new_logger_level_configuration (a_path: PATH): LOGGER_CONFIGURATION
|
||||
-- Retrieve a new logger level configuration.
|
||||
-- By default, level is set to `DEBUG'.
|
||||
feature -- Logging
|
||||
|
||||
write_debug_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_debug_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_information_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_information_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_warning_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_warning_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_error_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_error_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_critical_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_critical_log_to (m, logger)
|
||||
end
|
||||
|
||||
write_alert_log (m: READABLE_STRING_8)
|
||||
do
|
||||
write_alert_log_to (m, logger)
|
||||
end
|
||||
|
||||
feature {NONE} -- Logger: separate implementation
|
||||
|
||||
write_debug_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
do
|
||||
a_log.put_debug (m)
|
||||
end
|
||||
|
||||
write_information_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
do
|
||||
a_log.put_information (m)
|
||||
end
|
||||
|
||||
write_warning_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
do
|
||||
a_log.put_warning (m)
|
||||
end
|
||||
|
||||
write_error_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
do
|
||||
a_log.put_error (m)
|
||||
end
|
||||
|
||||
write_critical_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
do
|
||||
a_log.put_critical (m)
|
||||
end
|
||||
|
||||
write_alert_log_to (m: READABLE_STRING_8; a_log: like logger)
|
||||
do
|
||||
a_log.put_alert (m)
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
initialize_logger (app: APPLICATION_LAYOUT)
|
||||
local
|
||||
l_parser: JSON_PARSER
|
||||
l_logger: LOGGER
|
||||
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
|
||||
end
|
||||
create l_logger.make_with_layout (app)
|
||||
set_logger_to (l_logger, logger_cell)
|
||||
end
|
||||
|
||||
|
||||
json_file_from (a_fn: PATH): detachable STRING
|
||||
set_logger_to (a_logger: separate LOGGER; a_cell: like logger_cell)
|
||||
do
|
||||
Result := (create {JSON_FILE_READER}).read_json_from (a_fn.name.out)
|
||||
a_cell.replace (a_logger)
|
||||
end
|
||||
|
||||
new_json_parser (a_string: STRING): JSON_PARSER
|
||||
do
|
||||
create Result.make_parser (a_string)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<option warning="true" void_safety="all">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<cluster name="cms_model" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<option warning="true" void_safety="none">
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="console_application" value="true"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
|
||||
<cluster name="cms_model" location=".\src\" recursive="true">
|
||||
<file_rule>
|
||||
|
||||
@@ -3,8 +3,8 @@ note
|
||||
CMS abstraction for CMS content entity, named "node".
|
||||
]"
|
||||
status: "draft"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
CMS_NODE
|
||||
@@ -83,8 +83,8 @@ feature -- Access
|
||||
author: detachable CMS_USER
|
||||
-- Author of current node.
|
||||
|
||||
collaborators: detachable LIST[CMS_USER]
|
||||
-- Users contributed to current Node.
|
||||
-- collaborators: detachable LIST[CMS_USER]
|
||||
-- -- Users contributed to current Node.
|
||||
|
||||
feature -- status report
|
||||
|
||||
@@ -177,18 +177,18 @@ feature -- Element change
|
||||
auther_set: author = u
|
||||
end
|
||||
|
||||
add_collaborator (a_user: CMS_USER)
|
||||
-- Add collaborator `a_user' to the collaborators list.
|
||||
local
|
||||
lst: like collaborators
|
||||
do
|
||||
lst := collaborators
|
||||
if lst = Void then
|
||||
create {ARRAYED_SET [CMS_USER]} lst.make (1)
|
||||
collaborators := lst
|
||||
end
|
||||
lst.force (a_user)
|
||||
end
|
||||
-- add_collaborator (a_user: CMS_USER)
|
||||
-- -- Add collaborator `a_user' to the collaborators list.
|
||||
-- local
|
||||
-- lst: like collaborators
|
||||
-- do
|
||||
-- lst := collaborators
|
||||
-- if lst = Void then
|
||||
-- create {ARRAYED_SET [CMS_USER]} lst.make (1)
|
||||
-- collaborators := lst
|
||||
-- end
|
||||
-- lst.force (a_user)
|
||||
-- end
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
|
||||
@@ -2,18 +2,29 @@ note
|
||||
description: "[
|
||||
Abstraction to represent a URI link in the CMS system.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
deferred class
|
||||
CMS_LINK
|
||||
|
||||
inherit
|
||||
REFACTORING_HELPER
|
||||
undefine
|
||||
is_equal
|
||||
end
|
||||
|
||||
DEBUG_OUTPUT
|
||||
undefine
|
||||
is_equal
|
||||
end
|
||||
|
||||
ITERABLE [CMS_LINK]
|
||||
undefine
|
||||
is_equal
|
||||
end
|
||||
|
||||
COMPARABLE
|
||||
|
||||
feature -- Access
|
||||
|
||||
@@ -23,6 +34,21 @@ feature -- Access
|
||||
location: READABLE_STRING_8
|
||||
-- Associated url location.
|
||||
|
||||
weight: INTEGER
|
||||
-- Optional weight used for order.
|
||||
|
||||
feature -- Comparison
|
||||
|
||||
is_less alias "<" (other: like Current): BOOLEAN
|
||||
-- Is current object less than `other'?
|
||||
do
|
||||
if weight = other.weight then
|
||||
Result := title < other.title
|
||||
else
|
||||
Result := weight < other.weight
|
||||
end
|
||||
end
|
||||
|
||||
feature -- status report
|
||||
|
||||
is_active: BOOLEAN
|
||||
@@ -53,6 +79,16 @@ feature -- status report
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_weight (a_weight: INTEGER)
|
||||
-- Set `weight' to `a_weight'.
|
||||
do
|
||||
weight := a_weight
|
||||
ensure
|
||||
weight_set: weight = a_weight
|
||||
end
|
||||
|
||||
feature -- Query
|
||||
|
||||
parent: detachable CMS_LINK
|
||||
@@ -84,9 +120,12 @@ feature -- Status report
|
||||
create Result.make_from_string (title)
|
||||
Result.append_string_general (" -> ")
|
||||
Result.append_string_general (location)
|
||||
Result.append_string_general (" [")
|
||||
Result.append_integer (weight)
|
||||
Result.append_string_general ("]")
|
||||
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
|
||||
|
||||
@@ -2,8 +2,8 @@ note
|
||||
description: "[
|
||||
Abstraction to represent a links container in the CMS system.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
deferred class
|
||||
CMS_LINK_COMPOSITE
|
||||
@@ -30,6 +30,27 @@ feature -- Element change
|
||||
deferred
|
||||
end
|
||||
|
||||
sort
|
||||
-- Sort `items' and also recursively in sub items.
|
||||
local
|
||||
l_sorter: QUICK_SORTER [CMS_LINK]
|
||||
do
|
||||
create l_sorter.make (create {COMPARABLE_COMPARATOR [CMS_LINK]})
|
||||
if attached items as lst then
|
||||
l_sorter.sort (lst)
|
||||
across
|
||||
lst as ic
|
||||
loop
|
||||
if
|
||||
attached {CMS_LINK_COMPOSITE} ic.item as l_composite and then
|
||||
not l_composite.is_empty
|
||||
then
|
||||
l_composite.sort
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- status report
|
||||
|
||||
is_empty: BOOLEAN
|
||||
@@ -47,6 +68,6 @@ feature -- status report
|
||||
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
|
||||
|
||||
@@ -2,8 +2,8 @@ note
|
||||
description: "[
|
||||
Abstraction to represent a link to a CMS resource.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
class
|
||||
CMS_LOCAL_LINK
|
||||
@@ -16,6 +16,8 @@ inherit
|
||||
items as children,
|
||||
extend as add_link,
|
||||
remove as remove_link
|
||||
undefine
|
||||
is_equal
|
||||
end
|
||||
|
||||
create
|
||||
@@ -168,6 +170,6 @@ feature {NONE} -- Implementation
|
||||
invariant
|
||||
|
||||
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
|
||||
|
||||
@@ -3,8 +3,8 @@ note
|
||||
Abstraction to represent a MENU in the CMS system.
|
||||
It has items as sub menu/link.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
|
||||
revision: "$Revision: 96596 $"
|
||||
|
||||
class
|
||||
CMS_MENU
|
||||
@@ -61,6 +61,17 @@ feature -- Status report
|
||||
Result := items.is_empty
|
||||
end
|
||||
|
||||
has (lnk: CMS_LINK): BOOLEAN
|
||||
do
|
||||
across
|
||||
items as ic
|
||||
until
|
||||
Result
|
||||
loop
|
||||
Result := ic.item.location.same_string (lnk.location)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
extend (lnk: CMS_LINK)
|
||||
@@ -91,6 +102,6 @@ feature -- Access
|
||||
invariant
|
||||
|
||||
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
|
||||
|
||||
@@ -2,8 +2,8 @@ note
|
||||
description: "[
|
||||
Interface representing a USER in the CMS system.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
|
||||
revision: "$Revision: 96542 $"
|
||||
|
||||
class
|
||||
CMS_USER
|
||||
@@ -13,19 +13,38 @@ inherit
|
||||
DEBUG_OUTPUT
|
||||
|
||||
create
|
||||
make
|
||||
make,
|
||||
make_with_id -- MAYBE: export to CMS_STORAGE
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: READABLE_STRING_32)
|
||||
-- Create an object with name `a_name'.
|
||||
require
|
||||
a_name_not_empty: not a_name.is_whitespace
|
||||
do
|
||||
name := a_name
|
||||
create creation_date.make_now_utc
|
||||
initialize
|
||||
ensure
|
||||
name_set: name = a_name
|
||||
end
|
||||
|
||||
make_with_id (a_id: INTEGER_64)
|
||||
require
|
||||
a_id_valid: a_id > 0
|
||||
do
|
||||
id := a_id
|
||||
name := {STRING_32} ""
|
||||
initialize
|
||||
ensure
|
||||
id_set: id = a_id
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
create creation_date.make_now_utc
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
id: INTEGER_64
|
||||
@@ -35,7 +54,10 @@ feature -- Access
|
||||
-- User name.
|
||||
|
||||
password: detachable READABLE_STRING_32
|
||||
-- User password.
|
||||
-- User password (plain text password).
|
||||
|
||||
hashed_password: detachable READABLE_STRING_8
|
||||
-- Hashed user password.
|
||||
|
||||
email: detachable READABLE_STRING_32
|
||||
-- User email.
|
||||
@@ -113,8 +135,20 @@ feature -- Change element
|
||||
-- Set `password' with `a_password'.
|
||||
do
|
||||
password := a_password
|
||||
hashed_password := Void
|
||||
ensure
|
||||
password_set: password = a_password
|
||||
hashed_password_void: hashed_password = Void
|
||||
end
|
||||
|
||||
set_hashed_password (a_hashed_password: like hashed_password)
|
||||
-- Set `hashed_password' with `a_hashed_password'.
|
||||
do
|
||||
hashed_password := a_hashed_password
|
||||
password := Void
|
||||
ensure
|
||||
password_void: password = Void
|
||||
hashed_password_set: hashed_password = a_hashed_password
|
||||
end
|
||||
|
||||
set_email (a_email: like email)
|
||||
@@ -178,6 +212,10 @@ feature -- Change element: data
|
||||
end
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
id_or_name_set: id > 0 or else not name.is_whitespace
|
||||
|
||||
note
|
||||
copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {STRING_HELPER}."
|
||||
date: "$Date: 2014-08-08 16:02:11 -0300 (vi., 08 ago. 2014) $"
|
||||
revision: "$Revision: 95593 $"
|
||||
|
||||
class
|
||||
STRING_HELPER
|
||||
|
||||
feature -- Access
|
||||
|
||||
is_blank (s: detachable READABLE_STRING_32): BOOLEAN
|
||||
local
|
||||
i,n: INTEGER
|
||||
do
|
||||
Result := True
|
||||
if s /= Void then
|
||||
from
|
||||
i := 1
|
||||
n := s.count
|
||||
until
|
||||
i > n or not Result
|
||||
loop
|
||||
Result := s[i].is_space
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
indented_text (pre: READABLE_STRING_8; t: READABLE_STRING_8): READABLE_STRING_8
|
||||
-- Indendted text.
|
||||
local
|
||||
s8: STRING_8
|
||||
do
|
||||
s8 := t.string
|
||||
s8.prepend (pre)
|
||||
s8.replace_substring_all ("%N", "%N" + pre)
|
||||
Result := s8
|
||||
end
|
||||
|
||||
|
||||
json_encode (a_string: STRING): STRING
|
||||
-- json encode `a_string'.
|
||||
local
|
||||
encode: SHARED_JSON_ENCODER
|
||||
do
|
||||
create encode
|
||||
Result := encode.json_encoder.encoded_string (a_string)
|
||||
debug
|
||||
print ("%NResult" + Result)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,270 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_STORAGE_MYSQL}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_STORAGE_MYSQL
|
||||
|
||||
inherit
|
||||
|
||||
CMS_STORAGE
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_connection: DATABASE_CONNECTION)
|
||||
--
|
||||
require
|
||||
is_connected: a_connection.is_connected
|
||||
do
|
||||
connection := a_connection
|
||||
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)
|
||||
create error_handler.make
|
||||
end
|
||||
|
||||
|
||||
feature -- Access: user
|
||||
|
||||
has_user: BOOLEAN
|
||||
-- Has any user?
|
||||
do
|
||||
Result := user_provider.has_user
|
||||
end
|
||||
|
||||
all_users: LIST [CMS_USER]
|
||||
do
|
||||
to_implement (generator + ".all_users")
|
||||
create {ARRAYED_LIST[CMS_USER]} Result.make (0)
|
||||
end
|
||||
|
||||
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
|
||||
do
|
||||
Result := user_provider.user (a_id)
|
||||
|
||||
end
|
||||
|
||||
user_by_name (a_name: like {CMS_USER}.name): detachable CMS_USER
|
||||
do
|
||||
Result := user_provider.user_by_name (a_name)
|
||||
|
||||
end
|
||||
|
||||
user_by_email (a_email: like {CMS_USER}.email): detachable CMS_USER
|
||||
do
|
||||
Result := user_provider.user_by_email (a_email)
|
||||
|
||||
end
|
||||
|
||||
is_valid_credential (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
local
|
||||
l_security: SECURITY_PROVIDER
|
||||
do
|
||||
if attached user_provider.user_salt (l_auth_login) as l_hash then
|
||||
if attached user_provider.user_by_name (l_auth_login) as l_user then
|
||||
create l_security
|
||||
if
|
||||
attached l_user.password as l_password and then
|
||||
l_security.password_hash (l_auth_password, l_hash).is_case_insensitive_equal (l_password)
|
||||
then
|
||||
Result := True
|
||||
else
|
||||
log.write_information (generator + ".login_valid User: wrong username or password" )
|
||||
end
|
||||
else
|
||||
log.write_information (generator + ".login_valid User:" + l_auth_login + "does not exist" )
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
feature -- User Nodes
|
||||
|
||||
user_collaborator_nodes (a_id: like {CMS_USER}.id): LIST[CMS_NODE]
|
||||
-- Possible list of nodes where the user identified by `a_id', is a collaborator.
|
||||
do
|
||||
to_implement (generator + ".user_collaborator_nodes")
|
||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
||||
end
|
||||
|
||||
user_author_nodes (a_id: like {CMS_USER}.id): LIST[CMS_NODE]
|
||||
-- Possible list of nodes where the user identified by `a_id', is the author.
|
||||
do
|
||||
to_implement (generator + ".user_author_nodes")
|
||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
||||
end
|
||||
|
||||
feature -- Access: roles and permissions
|
||||
|
||||
user_role_by_id (a_id: like {CMS_USER_ROLE}.id): detachable CMS_USER_ROLE
|
||||
do
|
||||
to_implement (generator + ".user_role_by_id")
|
||||
end
|
||||
|
||||
user_roles: LIST [CMS_USER_ROLE]
|
||||
do
|
||||
to_implement (generator + ".user_roles")
|
||||
create {ARRAYED_LIST[CMS_USER_ROLE]} Result.make (0)
|
||||
end
|
||||
|
||||
feature -- Change: roles and permissions
|
||||
|
||||
save_user_role (a_user_role: CMS_USER_ROLE)
|
||||
do
|
||||
to_implement (generator + ".save_user_role")
|
||||
end
|
||||
|
||||
feature -- Change: user
|
||||
|
||||
save_user (a_user: CMS_USER)
|
||||
-- Add a new user `a_user'.
|
||||
do
|
||||
|
||||
if
|
||||
attached a_user.password as l_password and then
|
||||
attached a_user.email as l_email
|
||||
then
|
||||
connection.begin_transaction
|
||||
user_provider.new_user (a_user.name, l_password, l_email)
|
||||
connection.commit
|
||||
else
|
||||
debug ("refactor_fixme")
|
||||
fixme ("maybe we should not always carry password, in this case, to implement the else part..")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access: node
|
||||
|
||||
nodes: LIST[CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
||||
across node_provider.nodes as c loop
|
||||
Result.force (c.item)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||
-- List of the `a_count' most recent nodes, starting from `a_lower'.
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
||||
across node_provider.recent_nodes (a_lower,a_count) as c loop
|
||||
Result.force (c.item)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
node (a_id: INTEGER_64): detachable CMS_NODE
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := node_provider.node (a_id)
|
||||
|
||||
end
|
||||
|
||||
node_author (a_id: like {CMS_NODE}.id): detachable CMS_USER
|
||||
-- <Precursor>
|
||||
do
|
||||
Result := node_provider.node_author (a_id)
|
||||
|
||||
end
|
||||
|
||||
node_collaborators (a_id: like {CMS_NODE}.id): LIST [CMS_USER]
|
||||
-- Possible list of node's collaborator.
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_USER]} Result.make (0)
|
||||
across node_provider.node_collaborators (a_id) as c loop Result.force (c.item) end
|
||||
end
|
||||
|
||||
feature -- Node
|
||||
|
||||
save_node (a_node: CMS_NODE)
|
||||
-- <Precursor>
|
||||
do
|
||||
node_provider.new_node (a_node)
|
||||
|
||||
end
|
||||
|
||||
delete_node (a_id: INTEGER_64)
|
||||
do
|
||||
node_provider.delete_from_user_nodes(a_id)
|
||||
node_provider.delete_node (a_id)
|
||||
|
||||
end
|
||||
|
||||
update_node (a_id: like {CMS_USER}.id; a_node: CMS_NODE)
|
||||
-- <Precursor>
|
||||
do
|
||||
node_provider.update_node (a_id, a_node)
|
||||
|
||||
end
|
||||
|
||||
update_node_title (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_title: READABLE_STRING_32)
|
||||
-- <Precursor>
|
||||
do
|
||||
node_provider.update_node_title (a_node_id, a_title)
|
||||
internal_node_update (a_id, a_node_id)
|
||||
|
||||
end
|
||||
|
||||
update_node_summary (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_summary: READABLE_STRING_32)
|
||||
-- <Precursor>
|
||||
do
|
||||
node_provider.update_node_summary (a_node_id, a_summary)
|
||||
internal_node_update (a_id, a_node_id)
|
||||
|
||||
end
|
||||
|
||||
update_node_content (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id; a_content: READABLE_STRING_32)
|
||||
-- <Precursor>
|
||||
do
|
||||
node_provider.update_node_content (a_node_id, a_content)
|
||||
internal_node_update (a_id, a_node_id)
|
||||
|
||||
end
|
||||
|
||||
feature {NONE} -- NODE Implemenation
|
||||
|
||||
internal_node_update (a_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id)
|
||||
-- Update node editor or add collaborator.
|
||||
do
|
||||
if not node_provider.is_collaborator (a_id, a_node_id) then
|
||||
node_provider.add_collaborator (a_id, a_node_id)
|
||||
else
|
||||
node_provider.update_node_last_editor (a_id, a_node_id)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- User
|
||||
|
||||
new_user (a_user: CMS_USER)
|
||||
-- Add a new user `a_user'.
|
||||
do
|
||||
if
|
||||
attached a_user.password as l_password and then
|
||||
attached a_user.email as l_email
|
||||
then
|
||||
user_provider.new_user (a_user.name, l_password, l_email)
|
||||
else
|
||||
-- set error
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Post process
|
||||
|
||||
|
||||
node_provider: NODE_DATA_PROVIDER
|
||||
-- Node Data provider.
|
||||
|
||||
user_provider: USER_DATA_PROVIDER
|
||||
-- User Data provider.
|
||||
|
||||
connection: DATABASE_CONNECTION
|
||||
-- Current database connection.
|
||||
end
|
||||
@@ -1,511 +0,0 @@
|
||||
note
|
||||
description: "Database access for node uses cases."
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
NODE_DATA_PROVIDER
|
||||
|
||||
inherit
|
||||
|
||||
PARAMETER_NAME_HELPER
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_connection: DATABASE_CONNECTION)
|
||||
-- Create a data provider.
|
||||
do
|
||||
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||
create error_handler.make
|
||||
post_execution
|
||||
end
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
-- Db handler.
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
is_successful: BOOLEAN
|
||||
-- Is the last execution sucessful?
|
||||
do
|
||||
Result := not error_handler.has_error
|
||||
end
|
||||
|
||||
feature -- Error Handler
|
||||
|
||||
error_handler: ERROR_HANDLER
|
||||
|
||||
feature -- Access
|
||||
|
||||
nodes: DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
-- List of nodes.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".nodes")
|
||||
create l_parameters.make (0)
|
||||
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]
|
||||
-- The most recent `a_rows'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
l_query: STRING
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".recent_nodes")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_rows, "rows")
|
||||
create l_query.make_from_string (select_recent_nodes)
|
||||
l_query.replace_substring_all ("$offset", a_lower.out)
|
||||
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
|
||||
-- Node for the given id `a_id', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".node")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id,"id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_node_by_id, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_node
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
-- Number of items nodes.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".count")
|
||||
create l_parameters.make (0)
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_count, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := db_handler.read_integer_32 (1)
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
|
||||
last_inserted_node_id: INTEGER
|
||||
-- Last insert node id.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".last_inserted_node_id")
|
||||
create l_parameters.make (0)
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Sql_last_insert_node_id, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := db_handler.read_integer_32 (1)
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
new_node (a_node: CMS_NODE)
|
||||
-- Create a new node.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".new_node")
|
||||
create l_parameters.make (7)
|
||||
l_parameters.put (a_node.title, "title")
|
||||
l_parameters.put (a_node.summary, "summary")
|
||||
l_parameters.put (a_node.content, "content")
|
||||
l_parameters.put (a_node.publication_date, "publication_date")
|
||||
l_parameters.put (a_node.creation_date, "creation_date")
|
||||
l_parameters.put (a_node.modification_date, "modification_date")
|
||||
if
|
||||
attached a_node.author as l_author and then
|
||||
l_author.id > 0
|
||||
then
|
||||
l_parameters.put (l_author.id, "author_id")
|
||||
end
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_insert_node, l_parameters))
|
||||
db_handler.execute_change
|
||||
|
||||
a_node.set_id (last_inserted_node_id)
|
||||
post_execution
|
||||
end
|
||||
|
||||
update_node_title (a_id: INTEGER_64; a_title: READABLE_STRING_32)
|
||||
-- Update node title for the corresponding the report with id `a_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".update_node_title")
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_title, "title")
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "modification_date")
|
||||
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)
|
||||
-- Update node summary for the corresponding the report with id `a_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".update_node_summary")
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_summary, "summary")
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "modification_date")
|
||||
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)
|
||||
-- Update node content for the corresponding the report with id `a_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".update_node_content")
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_content, "content")
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "modification_date")
|
||||
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_id: like {CMS_USER}.id; a_node: CMS_NODE)
|
||||
-- Update node.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".update_node")
|
||||
create l_parameters.make (7)
|
||||
l_parameters.put (a_node.title, "title")
|
||||
l_parameters.put (a_node.summary, "summary")
|
||||
l_parameters.put (a_node.content, "content")
|
||||
l_parameters.put (a_node.publication_date, "publication_date")
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "modification_date")
|
||||
l_parameters.put (a_node.id, "id")
|
||||
l_parameters.put (a_id, "editor")
|
||||
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;)
|
||||
-- Delete node with id `a_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".delete_node")
|
||||
create l_parameters.make (1)
|
||||
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
|
||||
|
||||
delete_from_user_nodes (a_id: INTEGER_64)
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".delete_from_user_nodes")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id, "id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_delete_from_user_node, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
end
|
||||
|
||||
feature -- Basic Operations: User_Nodes
|
||||
|
||||
add_author (a_user_id: INTEGER_64; a_node_id: INTEGER_64)
|
||||
-- Add author `a_user_id' to node `a_node_id'
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".add_author")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_user_id,"user_id")
|
||||
l_parameters.put (a_node_id,"id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Sql_update_node_author, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
end
|
||||
|
||||
add_collaborator (a_user_id: INTEGER_64; a_node_id: INTEGER_64)
|
||||
-- Add collaborator `a_user_id' to node `a_node_id'
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".add_collaborator")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_user_id,"users_id")
|
||||
l_parameters.put (a_node_id,"nodes_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Sql_insert_users_nodes, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
end
|
||||
|
||||
update_node_last_editor (a_user_id: INTEGER_64; a_node_id: INTEGER_64)
|
||||
-- Update node last editor.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".add_collaborator")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_user_id,"users_id")
|
||||
l_parameters.put (a_node_id,"nodes_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Slq_update_editor, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
end
|
||||
|
||||
|
||||
author_nodes (a_id:INTEGER_64): DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
-- List of Nodes for the given user `a_id'. (the user is the author of the node)
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".author_nodes")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id, "user_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Select_user_author, l_parameters))
|
||||
db_handler.execute_query
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
post_execution
|
||||
end
|
||||
|
||||
collaborator_nodes (a_id:INTEGER_64): DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
-- List of Nodes for the given user `a_id' as collaborator.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".collaborator_nodes")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id, "user_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Select_user_collaborator, l_parameters))
|
||||
db_handler.execute_query
|
||||
create Result.make (db_handler, agent fetch_node)
|
||||
post_execution
|
||||
end
|
||||
|
||||
|
||||
node_author (a_id: INTEGER_64): detachable CMS_USER
|
||||
-- Node's author for the given node id.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".node_author")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id, "node_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_node_author, l_parameters))
|
||||
db_handler.execute_query
|
||||
if not db_handler.after then
|
||||
Result := fetch_user
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
node_collaborators (a_id: INTEGER_64): DATABASE_ITERATION_CURSOR [CMS_USER]
|
||||
-- List of possible node's collaborator.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".node_collaborators")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id, "node_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_node_collaborators, l_parameters))
|
||||
db_handler.execute_query
|
||||
create Result.make (db_handler, agent fetch_user)
|
||||
post_execution
|
||||
end
|
||||
|
||||
is_collaborator (a_user_id: like {CMS_USER}.id; a_node_id: like {CMS_NODE}.id): BOOLEAN
|
||||
-- Is the user `a_user_id' a collaborator of node `a_node_id'
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".node_collaborators")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_user_id, "user_id")
|
||||
l_parameters.put (a_node_id, "node_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_exist_user_node, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := db_handler.read_integer_32 (1) = 1
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
feature -- Connection
|
||||
|
||||
connect
|
||||
-- Connect to the database.
|
||||
do
|
||||
if not db_handler.is_connected then
|
||||
db_handler.connect
|
||||
end
|
||||
end
|
||||
|
||||
disconnect
|
||||
-- Disconnect to the database.
|
||||
do
|
||||
if db_handler.is_connected then
|
||||
db_handler.disconnect
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Queries
|
||||
|
||||
Select_count: STRING = "select count(*) from Nodes;"
|
||||
|
||||
Select_nodes: STRING = "select * from Nodes;"
|
||||
-- SQL Query to retrieve all nodes.
|
||||
|
||||
Select_node_by_id: STRING = "select * from Nodes where id =:id order by id desc, publication_date desc;"
|
||||
|
||||
Select_recent_nodes: STRING = "select * from Nodes order by id desc, publication_date desc Limit $offset , :rows "
|
||||
|
||||
SQL_Insert_node: STRING = "insert into nodes (title, summary, content, publication_date, creation_date, modification_date, author_id) values (:title, :summary, :content, :publication_date, :creation_date, :modification_date, :author_id);"
|
||||
-- SQL Insert to add a new node.
|
||||
|
||||
SQL_Update_node_title: STRING ="update nodes SET title=:title, modification_date=:modification_date, version = version + 1 where id=:id;"
|
||||
-- SQL update node title.
|
||||
|
||||
SQL_Update_node_summary: STRING ="update nodes SET summary=:summary, modification_date=:modification_date, version = version + 1 where id=:id;"
|
||||
-- SQL update node summary.
|
||||
|
||||
SQL_Update_node_content: STRING ="update nodes SET content=:content, modification_date=:modification_date, version = version + 1 where id=:id;"
|
||||
-- SQL node content.
|
||||
|
||||
Slq_update_editor: STRING ="update nodes SET editor_id=:users_id where id=:nodes_id;"
|
||||
-- SQL node content.
|
||||
|
||||
SQL_Update_node : STRING = "update nodes SET title=:title, summary=:summary, content=:content, publication_date=:publication_date, modification_date=:modification_date, version = version + 1, editor_id=:editor where id=:id;"
|
||||
-- SQL node.
|
||||
|
||||
SQL_Delete_node: STRING = "delete from nodes where id=:id;"
|
||||
|
||||
Sql_update_node_author: STRING = "update nodes SET author_id=:user_id where id=:id;"
|
||||
|
||||
Sql_last_insert_node_id: STRING = "SELECT MAX(id) from nodes;"
|
||||
|
||||
feature {NONE} -- Sql Queries: USER_ROLES collaborators, author
|
||||
|
||||
Sql_insert_users_nodes: STRING = "insert into users_nodes (users_id, nodes_id) values (:users_id, :nodes_id);"
|
||||
|
||||
select_node_collaborators: STRING = "SELECT * FROM Users INNER JOIN users_nodes ON users.id=users_nodes.users_id and users_nodes.nodes_id = :node_id;"
|
||||
|
||||
Select_user_author: STRING = "SELECT * FROM Nodes INNER JOIN users ON nodes.author_id=users.id and users.id = :user_id;"
|
||||
|
||||
Select_node_author: STRING = "SELECT * FROM Users INNER JOIN nodes ON nodes.author_id=users.id and nodes.id =:node_id;"
|
||||
|
||||
Select_user_collaborator: STRING = "SELECT * FROM Nodes INNER JOIN users_nodes ON users_nodes.nodes_id = nodes.id and users_nodes.users_id = :user_id;"
|
||||
|
||||
Select_exist_user_node: STRING= "Select Count(*) from Users_nodes where users_id=:user_id and nodes_id=:node_id;"
|
||||
|
||||
sql_delete_from_user_node: STRING = "delete from users_nodes where nodes_id=:id"
|
||||
|
||||
|
||||
feature --
|
||||
|
||||
|
||||
feature -- New Object
|
||||
|
||||
fetch_node: CMS_NODE
|
||||
do
|
||||
create Result.make ("", "", "")
|
||||
if attached db_handler.read_integer_32 (1) as l_id then
|
||||
Result.set_id (l_id)
|
||||
end
|
||||
if attached db_handler.read_date_time (2) as l_pd then
|
||||
Result.set_publication_date (l_pd)
|
||||
end
|
||||
if attached db_handler.read_date_time (3) as l_cd then
|
||||
Result.set_creation_date (l_cd)
|
||||
end
|
||||
if attached db_handler.read_date_time (4) as l_md then
|
||||
Result.set_modification_date (l_md)
|
||||
end
|
||||
if attached db_handler.read_string (5) as l_t then
|
||||
Result.set_title (l_t)
|
||||
end
|
||||
if attached db_handler.read_string (6) as l_s then
|
||||
Result.set_summary (l_s)
|
||||
end
|
||||
if attached db_handler.read_string (7) as l_c then
|
||||
Result.set_content (l_c)
|
||||
end
|
||||
end
|
||||
|
||||
fetch_user: CMS_USER
|
||||
do
|
||||
create Result.make ("")
|
||||
if attached db_handler.read_integer_32 (1) as l_id then
|
||||
Result.set_id (l_id)
|
||||
end
|
||||
if attached db_handler.read_string (2) as l_u then
|
||||
Result.set_name (l_u)
|
||||
end
|
||||
if attached db_handler.read_string (3) as l_p then
|
||||
Result.set_password (l_p)
|
||||
end
|
||||
if attached db_handler.read_string (5) as l_e then
|
||||
Result.set_email (l_e)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
post_execution
|
||||
-- Post database execution.
|
||||
do
|
||||
error_handler.add_synchronization (db_handler.database_error_handler)
|
||||
if error_handler.has_error then
|
||||
log.write_critical (generator + ".post_execution " + error_handler.as_string_representation)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,216 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {ROLE_DATA_PROVIDER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ROLE_DATA_PROVIDER
|
||||
|
||||
inherit
|
||||
|
||||
PARAMETER_NAME_HELPER
|
||||
|
||||
SHARED_ERROR
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_connection: DATABASE_CONNECTION)
|
||||
-- Create a data provider.
|
||||
do
|
||||
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||
post_execution
|
||||
end
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
-- Db handler.
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
is_successful: BOOLEAN
|
||||
-- Is the last execution sucessful?
|
||||
do
|
||||
-- Result := db_handler.successful
|
||||
end
|
||||
|
||||
has_roles: BOOLEAN
|
||||
-- Has any role?
|
||||
do
|
||||
Result := count > 0
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
roles: DATABASE_ITERATION_CURSOR [CMS_USER_ROLE]
|
||||
-- List of roles.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".roles")
|
||||
create l_parameters.make (0)
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Select_roles, l_parameters))
|
||||
db_handler.execute_query
|
||||
create Result.make (db_handler, agent fetch_role)
|
||||
post_execution
|
||||
end
|
||||
|
||||
feature -- Basic Operations
|
||||
|
||||
new_role (a_role: READABLE_STRING_32)
|
||||
-- Create a new node.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
log.write_information (generator + ".new_role")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_role,"name")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_insert_role, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
end
|
||||
|
||||
role (a_id: INTEGER_64): detachable CMS_USER_ROLE
|
||||
-- Role for the given id `a_id', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".role")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id,"id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_role_by_id, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_role
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
role_by_name (a_name: READABLE_STRING_32): detachable CMS_USER_ROLE
|
||||
-- Role for the given name `a_name', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".role_by_name")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_name,"name")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_role_by_name, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_role
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
-- Number of items users.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".count")
|
||||
create l_parameters.make (0)
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_count, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := db_handler.read_integer_32 (1)
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
save_role_permission (a_role_id: INTEGER; a_permission: READABLE_STRING_32)
|
||||
-- Add permission `a_permission' to the role id `a_role_id'.
|
||||
require
|
||||
valid_id: a_role_id > 0
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
log.write_information (generator + ".save_role_permission")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_permission,"name")
|
||||
l_parameters.put (a_role_id,"id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (SQL_Insert_permissions, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
end
|
||||
|
||||
permission_by_role (a_role_id: INTEGER_64): DATABASE_ITERATION_CURSOR [READABLE_STRING_32]
|
||||
-- List of permission by role `a_role_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".permission_by_role")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_role_id, "id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Select_permissions, l_parameters))
|
||||
db_handler.execute_query
|
||||
create Result.make (db_handler, agent fetch_permission)
|
||||
post_execution
|
||||
end
|
||||
|
||||
feature -- New Object
|
||||
|
||||
fetch_role: CMS_USER_ROLE
|
||||
do
|
||||
create Result.make_with_id (0,"")
|
||||
if attached db_handler.read_integer_32 (1) as l_id then
|
||||
Result.set_id (l_id)
|
||||
end
|
||||
if attached db_handler.read_string (2) as l_u then
|
||||
Result.set_name (l_u)
|
||||
end
|
||||
end
|
||||
|
||||
fetch_permission: STRING_32
|
||||
do
|
||||
create Result.make_empty
|
||||
if attached db_handler.read_string (1) as l_u then
|
||||
Result := l_u
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Sql Queries: Roles
|
||||
|
||||
Select_count: STRING = "select count(*) from Roles;"
|
||||
-- Number of roles.
|
||||
|
||||
Select_roles: STRING = "select * from Roles;"
|
||||
-- roles.
|
||||
|
||||
Select_role_by_id: STRING = "select * from Roles where id =:id;"
|
||||
-- Retrieve role by id if exists.
|
||||
|
||||
Select_role_by_name: STRING = "select * from Roles where role =:name;"
|
||||
-- Retrieve user by name if exists.
|
||||
|
||||
SQL_Insert_role: STRING = "insert into roles (role) values (:name);"
|
||||
-- SQL Insert to add a new node.
|
||||
|
||||
|
||||
feature {NONE} -- Sql Queries: Permissions
|
||||
|
||||
Select_permissions_count: STRING = "select count(*) from permissions where roles_id=:id;"
|
||||
-- Number of permissions for a given role.
|
||||
|
||||
Select_permissions: STRING = "select * from permissions where roles_id=:id;"
|
||||
-- List of permissions for a given role.
|
||||
|
||||
Select_permissions_by_id: STRING = "select name from permissions where roles_id=:id and id=:permissionid;"
|
||||
-- Permission for a given role and permission id
|
||||
|
||||
SQL_Insert_permissions: STRING = "insert into permissions (name, roles_id) values (:name, :id);"
|
||||
-- SQL Insert to add a new node.
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
post_execution
|
||||
-- Post database execution.
|
||||
do
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,337 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {USER_DATA_PROVIDER}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
USER_DATA_PROVIDER
|
||||
|
||||
inherit
|
||||
|
||||
PARAMETER_NAME_HELPER
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_connection: DATABASE_CONNECTION)
|
||||
-- Create a data provider.
|
||||
do
|
||||
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||
create error_handler.make
|
||||
post_execution
|
||||
end
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
-- Db handler.
|
||||
|
||||
feature -- Error Handler
|
||||
|
||||
error_handler: ERROR_HANDLER
|
||||
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
is_successful: BOOLEAN
|
||||
-- Is the last execution sucessful?
|
||||
do
|
||||
Result := not error_handler.has_error
|
||||
end
|
||||
|
||||
has_user: BOOLEAN
|
||||
-- Has any user?
|
||||
do
|
||||
Result := count > 0
|
||||
end
|
||||
|
||||
feature -- Basic Operations
|
||||
|
||||
new_user (a_user_name: READABLE_STRING_32; a_password: READABLE_STRING_32; a_email: READABLE_STRING_32)
|
||||
-- Create a new node.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
l_password_salt, l_password_hash: STRING
|
||||
l_security: SECURITY_PROVIDER
|
||||
do
|
||||
error_handler.reset
|
||||
create l_security
|
||||
l_password_salt := l_security.salt
|
||||
l_password_hash := l_security.password_hash (a_password, l_password_salt)
|
||||
|
||||
log.write_information (generator + ".new_user")
|
||||
create l_parameters.make (4)
|
||||
l_parameters.put (a_user_name,"username")
|
||||
l_parameters.put (l_password_hash,"password")
|
||||
l_parameters.put (l_password_salt,"salt")
|
||||
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
|
||||
-- User for the given id `a_id', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".user")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id,"id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_user_by_id, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_user
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
user_by_name (a_name: READABLE_STRING_32): detachable CMS_USER
|
||||
-- User for the given name `a_name', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".user_by_name")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_name,"name")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_user_by_name, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_user
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
|
||||
user_by_email (a_email: detachable READABLE_STRING_32): detachable CMS_USER
|
||||
-- User for the given email `a_email', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".user_by_email")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_email,"email")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_user_by_email, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_user
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
user_salt (a_username: READABLE_STRING_32): detachable READABLE_STRING_32
|
||||
-- User salt for the given user `a_username', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".user_salt")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_username,"name")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_salt_by_username, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
if attached db_handler.read_string (1) as l_salt then
|
||||
Result := l_salt.as_string_32
|
||||
end
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
-- Number of items users.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".count")
|
||||
create l_parameters.make (0)
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_count, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := db_handler.read_integer_32 (1)
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
feature -- Basic operations: User Roles
|
||||
|
||||
add_role (a_user_id: INTEGER; a_role_id: INTEGER)
|
||||
-- Add Role `a_role_id' to user `a_user_id'
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".add_role")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_user_id,"users_id")
|
||||
l_parameters.put (a_role_id,"roles_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (slq_insert_users_roles, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
end
|
||||
|
||||
user_roles (a_id:INTEGER_64): DATABASE_ITERATION_CURSOR [INTEGER]
|
||||
-- List of Roles id for the given user `a_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".user_roles")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id, "user_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Select_user_roles, l_parameters))
|
||||
db_handler.execute_query
|
||||
create Result.make (db_handler, agent fetch_role_id)
|
||||
post_execution
|
||||
end
|
||||
|
||||
|
||||
feature -- Basic operations: User Profiles
|
||||
|
||||
save_profile_item (a_user_id: INTEGER_64; a_key: READABLE_STRING_32; a_value: READABLE_STRING_32)
|
||||
-- Save a profile item with (a_key and a_value) to the given user `user_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".save_profile_item")
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_key, "key")
|
||||
l_parameters.put (a_value, "value")
|
||||
l_parameters.put (a_user_id, "users_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Select_instert_profile_item, l_parameters))
|
||||
db_handler.execute_change
|
||||
post_execution
|
||||
end
|
||||
|
||||
save_profile (a_user_id: INTEGER_64; a_user_profile: CMS_USER_PROFILE)
|
||||
-- Save a profile item with (a_key and a_value) to the given user `user_id'.
|
||||
local
|
||||
l_cursor: TABLE_ITERATION_CURSOR [READABLE_STRING_8, READABLE_STRING_GENERAL]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".save_profile")
|
||||
from
|
||||
l_cursor := a_user_profile.new_cursor
|
||||
until
|
||||
l_cursor.after
|
||||
loop
|
||||
save_profile_item (a_user_id, l_cursor.key.as_string_32, l_cursor.item)
|
||||
l_cursor.forth
|
||||
end
|
||||
|
||||
post_execution
|
||||
end
|
||||
|
||||
user_profile (a_user_id: INTEGER_64): CMS_USER_PROFILE
|
||||
-- User profile for a user with id `a_user_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
error_handler.reset
|
||||
log.write_information (generator + ".user_profile")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_user_id, "users_id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (Select_user_profile, l_parameters))
|
||||
db_handler.execute_query
|
||||
create Result.make
|
||||
if not db_handler.after then
|
||||
from
|
||||
db_handler.start
|
||||
until
|
||||
db_handler.after
|
||||
loop
|
||||
if
|
||||
attached db_handler.read_string (1) as l_key and then
|
||||
attached db_handler.read_string (2) as l_value
|
||||
then
|
||||
Result.force (l_value, l_key)
|
||||
end
|
||||
db_handler.forth
|
||||
end
|
||||
end
|
||||
post_execution
|
||||
end
|
||||
|
||||
|
||||
feature -- New Object
|
||||
|
||||
fetch_user: CMS_USER
|
||||
do
|
||||
create Result.make ("")
|
||||
if attached db_handler.read_integer_32 (1) as l_id then
|
||||
Result.set_id (l_id)
|
||||
end
|
||||
if attached db_handler.read_string (2) as l_u then
|
||||
Result.set_name (l_u)
|
||||
end
|
||||
if attached db_handler.read_string (3) as l_p then
|
||||
Result.set_password (l_p)
|
||||
end
|
||||
if attached db_handler.read_string (5) as l_e then
|
||||
Result.set_email (l_e)
|
||||
end
|
||||
end
|
||||
|
||||
fetch_role_id: INTEGER
|
||||
do
|
||||
if attached db_handler.read_integer_32 (1) as l_id then
|
||||
Result := l_id
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Sql Queries: USER
|
||||
|
||||
Select_count: STRING = "select count(*) from Users;"
|
||||
-- Number of users.
|
||||
|
||||
Select_user_by_id: STRING = "select * from Users where id =:id;"
|
||||
-- Retrieve user by id if exists.
|
||||
|
||||
Select_user_by_name: STRING = "select * from Users where username =:name;"
|
||||
-- Retrieve user by name if exists.
|
||||
|
||||
Select_user_by_email: STRING = "select * from Users where email =:email;"
|
||||
-- Retrieve user by email if exists.
|
||||
|
||||
Select_salt_by_username: STRING = "select salt from Users where username =:name;"
|
||||
-- Retrieve salt by username if exists.
|
||||
|
||||
SQL_Insert_user: STRING = "insert into users (username, password, salt, email) values (:username, :password, :salt, :email);"
|
||||
-- SQL Insert to add a new node.
|
||||
|
||||
|
||||
feature {NONE} -- Sql Queries: USER_ROLES
|
||||
|
||||
Slq_insert_users_roles: STRING = "insert into users_roles (users_id, roles_id) values (:users_id, :roles_id);"
|
||||
|
||||
Select_user_roles: STRING = "Select roles_id from users_roles where users_id = :user_id"
|
||||
|
||||
feature {NONE} -- SQL Queries: Profile
|
||||
|
||||
Select_instert_profile_item: STRING = "insert into profiles (profiles.key, value, users_id) values (:key, :value, :users_id);"
|
||||
|
||||
Select_user_profile: STRING = "Select profiles.key, value from profiles where users_id = :users_id;"
|
||||
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
post_execution
|
||||
-- Post database execution.
|
||||
do
|
||||
error_handler.add_synchronization (db_handler.database_error_handler)
|
||||
if error_handler.has_error then
|
||||
log.write_critical (generator + ".post_execution " + error_handler.as_string_representation)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,125 +0,0 @@
|
||||
note
|
||||
description : "tests application root class"
|
||||
date : "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision : "$Revision: 95678 $"
|
||||
|
||||
class
|
||||
APPLICATION
|
||||
|
||||
inherit
|
||||
ARGUMENTS
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Run application.
|
||||
local
|
||||
user: USER_DATA_PROVIDER
|
||||
node: NODE_DATA_PROVIDER
|
||||
l_security: SECURITY_PROVIDER
|
||||
l_profile, l_db_profile: CMS_USER_PROFILE
|
||||
l_cursor: TABLE_ITERATION_CURSOR [READABLE_STRING_8, READABLE_STRING_8]
|
||||
l_list: LIST[CMS_NODE]
|
||||
storage: CMS_STORAGE
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
create connection.login_with_schema ("cms_dev", "root", "")
|
||||
-- create user.make (connection)
|
||||
-- create node.make (connection)
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
|
||||
create {CMS_STORAGE_MYSQL} storage.make (connection)
|
||||
l_node := custom_node ("Content", "Summary", "Title")
|
||||
storage.save_user (default_user)
|
||||
storage.save_user (custom_user ("u2", "p2", "e2"))
|
||||
l_node.set_author (storage.user_by_email (default_user.email))
|
||||
storage.save_node (l_node)
|
||||
if attached {CMS_NODE} storage.node (1) as ll_node then
|
||||
storage.update_node_title (2,ll_node.id, "New Title")
|
||||
check
|
||||
attached {CMS_NODE} storage.node (1) as u_node and then not (u_node.title ~ ll_node.title) and then u_node.content ~ ll_node.content and then u_node.summary ~ ll_node.summary
|
||||
end
|
||||
end
|
||||
|
||||
-- user.new_user ("test", "test","test@admin.com")
|
||||
-- if attached {CMS_USER} user.user_by_name ("test") as l_user then
|
||||
-- create l_profile.make
|
||||
-- l_profile.force ("Eiffel", "language")
|
||||
-- l_profile.force ("Argentina", "country")
|
||||
-- l_profile.force ("GMT-3", "time zone")
|
||||
-- user.save_profile (l_user.id, l_profile)
|
||||
-- l_db_profile := user.user_profile (l_user.id)
|
||||
-- from
|
||||
-- l_cursor := l_db_profile.new_cursor
|
||||
-- until
|
||||
-- l_cursor.after
|
||||
-- loop
|
||||
-- print (l_cursor.item + " - " + l_cursor.key + "%N")
|
||||
-- l_cursor.forth
|
||||
-- end
|
||||
|
||||
-- create {ARRAYED_LIST[CMS_NODE]} l_list.make (0)
|
||||
-- node.new_node (default_node)
|
||||
-- node.new_node (custom_node ("content1", "summary1", "title1"))
|
||||
-- node.new_node (custom_node ("content2", "summary2", "title2"))
|
||||
-- node.new_node (custom_node ("content3", "summary3", "title3"))
|
||||
-- user.new_user ("u1", "u1", "email")
|
||||
-- if attached user.user_by_name ("u1") as ll_user then
|
||||
-- node.add_collaborator (ll_user.id, 1)
|
||||
-- node.add_collaborator (ll_user.id, 2)
|
||||
-- node.add_collaborator (ll_user.id, 3)
|
||||
-- node.add_collaborator (ll_user.id, 4)
|
||||
|
||||
-- across node.collaborator_nodes (l_user.id) as c loop
|
||||
-- print (c.item.title)
|
||||
-- end
|
||||
|
||||
-- end
|
||||
|
||||
|
||||
-- if attached user.user_by_name ("u1") as ll_user then
|
||||
-- node.add_author (ll_user.id, 1)
|
||||
-- if attached node.node_author (1) as l_author then
|
||||
-- print (l_author.name)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
-- end
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Fixture Factory: Users
|
||||
|
||||
default_user: CMS_USER
|
||||
do
|
||||
Result := custom_user ("test", "password", "test@test.com")
|
||||
end
|
||||
|
||||
custom_user (a_name, a_password, a_email: READABLE_STRING_32): CMS_USER
|
||||
do
|
||||
create Result.make (a_name)
|
||||
Result.set_password (a_password)
|
||||
Result.set_email (a_email)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
|
||||
connection: DATABASE_CONNECTION_MYSQL
|
||||
|
||||
|
||||
default_node: CMS_NODE
|
||||
do
|
||||
Result := custom_node ("Default content", "default summary", "Default")
|
||||
end
|
||||
|
||||
custom_node (a_content, a_summary, a_title: READABLE_STRING_32): CMS_NODE
|
||||
do
|
||||
create Result.make (a_content, a_summary, a_title)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,321 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing:"execution/isolated"
|
||||
|
||||
class
|
||||
NODE_TEST_SET
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare,
|
||||
on_clean
|
||||
select
|
||||
default_create
|
||||
end
|
||||
ABSTRACT_DB_TEST
|
||||
rename
|
||||
default_create as default_db_test
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Events
|
||||
|
||||
on_prepare
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_new_node
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
node_provider.new_node (default_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached node_provider.node (1))
|
||||
-- Not exist node with id 2
|
||||
assert ("Not exist node with id 2", node_provider.node (2) = Void)
|
||||
end
|
||||
|
||||
|
||||
test_update_node
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node (content and summary)
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
l_un.set_content ("<h1>Updating test node udpate </h1>")
|
||||
l_un.set_summary ("updating summary")
|
||||
node_provider.update_node (0,l_un)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then ll_node.title ~ l_node.title )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
|
||||
end
|
||||
|
||||
-- Update node (content and summary and title)
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
l_un.set_content ("<h1>Updating test node udpate </h1>")
|
||||
l_un.set_summary ("updating summary")
|
||||
l_un.set_title ("Updating Test case")
|
||||
node_provider.update_node (0,l_un)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then not (ll_node.title ~ l_node.title) )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
|
||||
end
|
||||
end
|
||||
|
||||
test_update_title
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node title
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
node_provider.update_node_title (l_un.id, "New Title")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then not ( ll_node.title ~ l_un.title) and then ll_node.title ~ "New Title" )
|
||||
end
|
||||
end
|
||||
|
||||
test_update_summary
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node summary
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
node_provider.update_node_summary (l_un.id,"New Summary")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then not (ll_node.summary ~ l_un.summary) and then ll_node.summary ~ "New Summary" and then ll_node.title ~ l_un.title)
|
||||
end
|
||||
end
|
||||
|
||||
test_update_content
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
connection.begin_transaction
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node content
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
node_provider.update_node_content (l_un.id,"New Content")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_un.content) and then ll_node.content ~ "New Content" and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title)
|
||||
end
|
||||
connection.commit
|
||||
end
|
||||
|
||||
|
||||
test_delete_node
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Delte node 1
|
||||
|
||||
node_provider.delete_node (1)
|
||||
assert ("Node does not exist", node_provider.node (1) = Void)
|
||||
end
|
||||
|
||||
test_recent_nodes
|
||||
-- Content_10, Summary_10, Title_10
|
||||
-- Content_9, Summary_9, Title_9
|
||||
-- ..
|
||||
-- Content_1, Summary_1, Title_1
|
||||
local
|
||||
i : INTEGER
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
across 1 |..| 10 as c loop
|
||||
node_provider.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
end
|
||||
|
||||
-- Scenario (0,10) rows, recents (10 down to 1)
|
||||
i := 10
|
||||
across node_provider.recent_nodes (0, 10) as c loop
|
||||
assert ("Same id:" + i.out, c.item.id = i)
|
||||
i := i - 1
|
||||
end
|
||||
|
||||
-- Scenario (5, 10) rows, recent nodes (5 down to 1)
|
||||
i := 5
|
||||
across node_provider.recent_nodes (5, 10) as c loop
|
||||
assert ("Same id:" + i.out, c.item.id = i)
|
||||
i := i - 1
|
||||
end
|
||||
|
||||
-- Scenario (9,10) rows, recent node 1
|
||||
i := 1
|
||||
across node_provider.recent_nodes (9, 10) as c loop
|
||||
assert ("Same id:" + i.out, c.item.id = i)
|
||||
i := i - 1
|
||||
end
|
||||
|
||||
-- Scenrario 10..10 empty
|
||||
assert ("Empty", node_provider.recent_nodes (10, 10).after)
|
||||
end
|
||||
|
||||
|
||||
test_new_node_without_user
|
||||
do
|
||||
node_provider.new_node (default_node)
|
||||
user_provider.new_user ("u1", "u1", "email")
|
||||
if attached user_provider.user_by_name ("u1") as l_user then
|
||||
assert ("Empty nodes", node_provider.author_nodes (l_user.id).after)
|
||||
end
|
||||
end
|
||||
|
||||
test_new_node_add_author
|
||||
do
|
||||
node_provider.new_node (default_node)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1))
|
||||
user_provider.new_user ("u1", "u1", "email")
|
||||
if attached user_provider.user_by_name ("u1") as l_user then
|
||||
node_provider.add_author (l_user.id, 1)
|
||||
assert ("Author not void for node 1", attached node_provider.node_author (1))
|
||||
end
|
||||
end
|
||||
|
||||
test_new_node_add_collaborator
|
||||
do
|
||||
node_provider.new_node (default_node)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1))
|
||||
user_provider.new_user ("u1", "u1", "email")
|
||||
if attached user_provider.user_by_name ("u1") as l_user then
|
||||
node_provider.add_collaborator (l_user.id, 1)
|
||||
assert ("Not Empty Collaborator for node 1", not node_provider.node_collaborators (1).after)
|
||||
end
|
||||
end
|
||||
|
||||
test_multiple_nodes_add_collaborator
|
||||
local
|
||||
l_list: LIST[CMS_NODE]
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_NODE]} l_list.make (0)
|
||||
node_provider.new_node (default_node)
|
||||
node_provider.new_node (custom_node ("content1", "summary1", "title1"))
|
||||
node_provider.new_node (custom_node ("content2", "summary2", "title2"))
|
||||
node_provider.new_node (custom_node ("content3", "summary3", "title3"))
|
||||
user_provider.new_user ("u1", "u1", "email")
|
||||
if attached user_provider.user_by_name ("u1") as l_user then
|
||||
node_provider.add_collaborator (l_user.id, 1)
|
||||
node_provider.add_collaborator (l_user.id, 2)
|
||||
node_provider.add_collaborator (l_user.id, 3)
|
||||
node_provider.add_collaborator (l_user.id, 4)
|
||||
assert ("Not Empty Collaborator for node 1", not node_provider.node_collaborators (1).after)
|
||||
assert ("Not Empty Collaborator for node 2", not node_provider.node_collaborators (2).after)
|
||||
assert ("Not Empty Collaborator for node 3", not node_provider.node_collaborators (3).after)
|
||||
assert ("Not Empty Collaborator for node 4", not node_provider.node_collaborators (4).after)
|
||||
end
|
||||
end
|
||||
|
||||
test_nodes_collaborator
|
||||
local
|
||||
l_list: LIST[CMS_NODE]
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_NODE]} l_list.make (0)
|
||||
node_provider.new_node (default_node)
|
||||
node_provider.new_node (custom_node ("content1", "summary1", "title1"))
|
||||
node_provider.new_node (custom_node ("content2", "summary2", "title2"))
|
||||
node_provider.new_node (custom_node ("content3", "summary3", "title3"))
|
||||
user_provider.new_user ("u1", "u1", "email")
|
||||
if attached user_provider.user_by_name ("u1") as l_user then
|
||||
node_provider.add_collaborator (l_user.id, 1)
|
||||
node_provider.add_collaborator (l_user.id, 2)
|
||||
node_provider.add_collaborator (l_user.id, 3)
|
||||
node_provider.add_collaborator (l_user.id, 4)
|
||||
across node_provider.collaborator_nodes (l_user.id) as c loop
|
||||
l_list.force (c.item)
|
||||
end
|
||||
|
||||
assert ("User is collaborating in 4 nodes", l_list.count = 4)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
node_provider: NODE_DATA_PROVIDER
|
||||
-- node provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
|
||||
user_provider: USER_DATA_PROVIDER
|
||||
-- user provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation Fixture Factories
|
||||
|
||||
default_node: CMS_NODE
|
||||
do
|
||||
Result := custom_node ("Default content", "default summary", "Default")
|
||||
end
|
||||
|
||||
custom_node (a_content, a_summary, a_title: READABLE_STRING_32): CMS_NODE
|
||||
do
|
||||
create Result.make (a_content, a_summary, a_title)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
TRANSACTION_TEST_SET
|
||||
|
||||
inherit
|
||||
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare,
|
||||
on_clean
|
||||
select
|
||||
default_create
|
||||
end
|
||||
ABSTRACT_DB_TEST
|
||||
rename
|
||||
default_create as default_db_test
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Events
|
||||
|
||||
on_prepare
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_user_rollback
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
do
|
||||
connection.begin_transaction
|
||||
user_provider.new_user ("test", "test","test@admin.com")
|
||||
assert ("Has user:", user_provider.has_user)
|
||||
connection.rollback
|
||||
assert ("Not has user:", not user_provider.has_user)
|
||||
end
|
||||
|
||||
test_user_node_rollback
|
||||
note
|
||||
testing: "execution/isolated"
|
||||
do
|
||||
connection.begin_transaction
|
||||
user_provider.new_user ("test", "test","test@admin.com")
|
||||
assert ("Has user:", user_provider.has_user)
|
||||
node_provider.new_node (default_node)
|
||||
node_provider.add_author (1, 1)
|
||||
assert ("Has one node:", node_provider.count = 1)
|
||||
connection.rollback
|
||||
assert ("Not has user:", not user_provider.has_user)
|
||||
assert ("Not has nodes:", node_provider.count = 0)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
node_provider: NODE_DATA_PROVIDER
|
||||
-- node provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
|
||||
user_provider: USER_DATA_PROVIDER
|
||||
-- user provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation Fixture Factories
|
||||
|
||||
default_node: CMS_NODE
|
||||
do
|
||||
Result := custom_node ("Default content", "default summary", "Default")
|
||||
end
|
||||
|
||||
custom_node (a_content, a_summary, a_title: READABLE_STRING_32): CMS_NODE
|
||||
do
|
||||
create Result.make (a_content, a_summary, a_title)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing:"execution/isolated"
|
||||
|
||||
class
|
||||
USER_TEST_SET
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare,
|
||||
on_clean
|
||||
select
|
||||
default_create
|
||||
end
|
||||
ABSTRACT_DB_TEST
|
||||
rename
|
||||
default_create as default_db_test
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Events
|
||||
|
||||
on_prepare
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
user_provider.new_user ("admin", "admin","admin@admin.com")
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
do
|
||||
-- (create {CLEAN_DB}).clean_db(connection)
|
||||
end
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_user_exist
|
||||
-- User admin exist
|
||||
do
|
||||
assert ("Not void", attached user_provider.user_by_email ("admin@admin.com"))
|
||||
assert ("Not void", attached user_provider.user (1))
|
||||
assert ("Not void", attached user_provider.user_by_name ("admin"))
|
||||
end
|
||||
|
||||
test_user_not_exist
|
||||
-- Uset test does not exist.
|
||||
do
|
||||
assert ("User by email: Void", user_provider.user_by_email ("test1@test.com") = Void)
|
||||
assert ("User by id: Void", user_provider.user(5) = Void )
|
||||
assert ("User by name: Void", user_provider.user_by_name ("test1") = Void)
|
||||
end
|
||||
|
||||
test_new_user
|
||||
do
|
||||
user_provider.new_user ("test", "test","test@admin.com")
|
||||
assert ("Not void", attached user_provider.user_by_email ("test@admin.com"))
|
||||
assert ("Not void", attached user_provider.user (2))
|
||||
assert ("Not void", attached user_provider.user (2) as l_user and then l_user.id = 2 and then l_user.name ~ "test")
|
||||
assert ("Not void", attached user_provider.user_by_name ("test"))
|
||||
end
|
||||
|
||||
test_new_user_with_roles
|
||||
do
|
||||
user_provider.new_user ("test", "test","test@admin.com")
|
||||
role_provider.new_role ("Admin")
|
||||
assert ("Empty roles for given user", user_provider.user_roles (1).after)
|
||||
user_provider.add_role (1, 1)
|
||||
assert ("Not empty roles for given user", not user_provider.user_roles (1).after)
|
||||
end
|
||||
|
||||
test_new_user_without_profile
|
||||
do
|
||||
user_provider.new_user ("test", "test","test@admin.com")
|
||||
assert ("Empty", user_provider.user_profile (1).new_cursor.after)
|
||||
end
|
||||
|
||||
test_new_user_with_profile
|
||||
local
|
||||
l_profile: CMS_USER_PROFILE
|
||||
l_db_profile: CMS_USER_PROFILE
|
||||
do
|
||||
user_provider.new_user ("test", "test","test@admin.com")
|
||||
if attached {CMS_USER} user_provider.user_by_name ("test") as l_user then
|
||||
assert ("Empty", user_provider.user_profile (l_user.id).new_cursor.after)
|
||||
create l_profile.make
|
||||
l_profile.force ("Eiffel", "language")
|
||||
l_profile.force ("Argentina", "country")
|
||||
l_profile.force ("GMT-3", "time zone")
|
||||
user_provider.save_profile (l_user.id, l_profile)
|
||||
l_db_profile := user_provider.user_profile (l_user.id)
|
||||
assert ("Not Empty", not l_db_profile.new_cursor.after)
|
||||
|
||||
assert ("Expected language Eiffel", attached l_db_profile.item ("language") as l_language and then l_language ~ "Eiffel")
|
||||
assert ("Expected time zone GMT-3", attached l_db_profile.item ("time zone") as l_language and then l_language ~ "GMT-3")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
user_provider: USER_DATA_PROVIDER
|
||||
-- user provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
|
||||
role_provider: ROLE_DATA_PROVIDER
|
||||
-- user provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {ABSTRACT_DB_TEST}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ABSTRACT_DB_TEST
|
||||
|
||||
|
||||
feature -- Database connection
|
||||
|
||||
connection: DATABASE_CONNECTION_MYSQL
|
||||
-- MYSQL database connection
|
||||
once
|
||||
create Result.login_with_schema ("cms_dev", "root", "")
|
||||
end
|
||||
end
|
||||
@@ -1,61 +0,0 @@
|
||||
-- Creator: MySQL Workbench 6.1.7/ExportSQLite plugin 2009.12.02
|
||||
-- Author: javier
|
||||
-- Caption: New Model
|
||||
-- Project: Name of the project
|
||||
-- Changed: 2014-09-16 23:12
|
||||
-- Created: 2014-09-16 23:12
|
||||
PRAGMA foreign_keys = OFF;
|
||||
|
||||
-- Schema: cms_dev
|
||||
BEGIN;
|
||||
CREATE TABLE "nodes"(
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("id">=0),
|
||||
"publication_date" DATE NOT NULL,
|
||||
"creation_date" DATE NOT NULL,
|
||||
"modification_date" DATE NOT NULL,
|
||||
"title" VARCHAR(255) NOT NULL,
|
||||
"summary" TEXT NOT NULL,
|
||||
"content" MEDIUMTEXT NOT NULL
|
||||
);
|
||||
CREATE TABLE "roles"(
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("id">=0),
|
||||
"role" VARCHAR(100) NOT NULL,
|
||||
CONSTRAINT "role"
|
||||
UNIQUE("role")
|
||||
);
|
||||
CREATE TABLE "users"(
|
||||
"id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL CHECK("id">=0),
|
||||
"username" VARCHAR(100) NOT NULL,
|
||||
"password" VARCHAR(100) NOT NULL,
|
||||
"salt" VARCHAR(100) NOT NULL,
|
||||
"email" VARCHAR(250) NOT NULL,
|
||||
CONSTRAINT "username"
|
||||
UNIQUE("username")
|
||||
);
|
||||
CREATE TABLE "users_nodes"(
|
||||
"users_id" INTEGER NOT NULL CHECK("users_id">=0),
|
||||
"nodes_id" INTEGER NOT NULL CHECK("nodes_id">=0),
|
||||
PRIMARY KEY("users_id","nodes_id"),
|
||||
CONSTRAINT "fk_users_has_nodes_nodes1"
|
||||
FOREIGN KEY("nodes_id")
|
||||
REFERENCES "nodes"("id"),
|
||||
CONSTRAINT "fk_users_has_nodes_users"
|
||||
FOREIGN KEY("users_id")
|
||||
REFERENCES "users"("id")
|
||||
);
|
||||
CREATE INDEX "users_nodes.fk_users_has_nodes_nodes1_idx" ON "users_nodes"("nodes_id");
|
||||
CREATE INDEX "users_nodes.fk_users_has_nodes_users_idx" ON "users_nodes"("users_id");
|
||||
CREATE TABLE "users_roles"(
|
||||
"users_id" INTEGER NOT NULL CHECK("users_id">=0),
|
||||
"roles_id" INTEGER NOT NULL CHECK("roles_id">=0),
|
||||
PRIMARY KEY("users_id","roles_id"),
|
||||
CONSTRAINT "fk_users_has_roles_roles1"
|
||||
FOREIGN KEY("roles_id")
|
||||
REFERENCES "roles"("id"),
|
||||
CONSTRAINT "fk_users_has_roles_users1"
|
||||
FOREIGN KEY("users_id")
|
||||
REFERENCES "users"("id")
|
||||
);
|
||||
CREATE INDEX "users_roles.fk_users_has_roles_roles1_idx" ON "users_roles"("roles_id");
|
||||
CREATE INDEX "users_roles.fk_users_has_roles_users1_idx" ON "users_roles"("users_id");
|
||||
COMMIT;
|
||||
@@ -1,14 +0,0 @@
|
||||
DROP TABLE IF EXISTS nodes;
|
||||
|
||||
CREATE TABLE nodes
|
||||
(
|
||||
id smallint unsigned NOT NULL auto_increment,
|
||||
publication_date date NOT NULL, #When the article was published
|
||||
creation_date date NOT NULL, #When the article was created
|
||||
modification_date date NOT NULL, #When the article was updated
|
||||
title varchar(255) NOT NULL, #Full title of the article
|
||||
summary text NOT NULL, #A short summary of the articule
|
||||
content mediumtext NOT NULL, #The HTML content of the article
|
||||
|
||||
PRIMARY KEY (ID)
|
||||
);
|
||||
@@ -1,249 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {CMS_STORAGE_MYSQL}."
|
||||
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
CMS_STORAGE_SQLITE
|
||||
|
||||
inherit
|
||||
|
||||
CMS_STORAGE
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_connection: DATABASE_CONNECTION)
|
||||
--
|
||||
require
|
||||
is_connected: a_connection.is_connected
|
||||
do
|
||||
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)
|
||||
create error_handler.make
|
||||
end
|
||||
|
||||
|
||||
feature -- Access: user
|
||||
|
||||
has_user: BOOLEAN
|
||||
-- Has any user?
|
||||
do
|
||||
Result := user_provider.has_user
|
||||
|
||||
end
|
||||
|
||||
|
||||
all_users: LIST [CMS_USER]
|
||||
do
|
||||
to_implement("Not implemented!!!")
|
||||
create {ARRAYED_LIST[CMS_USER]} Result.make (0)
|
||||
end
|
||||
|
||||
user_by_id (a_id: like {CMS_USER}.id): detachable CMS_USER
|
||||
do
|
||||
Result := user_provider.user (a_id)
|
||||
|
||||
end
|
||||
|
||||
user_by_name (a_name: like {CMS_USER}.name): detachable CMS_USER
|
||||
do
|
||||
Result := user_provider.user_by_name (a_name)
|
||||
|
||||
end
|
||||
|
||||
user_by_email (a_email: like {CMS_USER}.email): detachable CMS_USER
|
||||
do
|
||||
Result := user_provider.user_by_email (a_email)
|
||||
|
||||
end
|
||||
|
||||
is_valid_credential (l_auth_login, l_auth_password: READABLE_STRING_32): BOOLEAN
|
||||
local
|
||||
l_security: SECURITY_PROVIDER
|
||||
do
|
||||
if attached user_provider.user_salt (l_auth_login) as l_hash then
|
||||
if attached user_provider.user_by_name (l_auth_login) as l_user then
|
||||
create l_security
|
||||
if
|
||||
attached l_user.password as l_password and then
|
||||
l_security.password_hash (l_auth_password, l_hash).is_case_insensitive_equal (l_password)
|
||||
then
|
||||
Result := True
|
||||
else
|
||||
log.write_information (generator + ".login_valid User: wrong username or password" )
|
||||
end
|
||||
else
|
||||
log.write_information (generator + ".login_valid User:" + l_auth_login + "does not exist" )
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
feature -- Change: user
|
||||
|
||||
save_user (a_user: CMS_USER)
|
||||
-- Add a new user `a_user'.
|
||||
do
|
||||
if
|
||||
attached a_user.password as l_password and then
|
||||
attached a_user.email as l_email
|
||||
then
|
||||
user_provider.new_user (a_user.name, l_password, l_email)
|
||||
else
|
||||
-- set error
|
||||
end
|
||||
end
|
||||
|
||||
feature -- User Nodes
|
||||
|
||||
user_collaborator_nodes (a_id: like {CMS_USER}.id): LIST[CMS_NODE]
|
||||
-- Possible list of nodes where the user identified by `a_id', is a collaborator.
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
||||
to_implement ("Not implemented")
|
||||
end
|
||||
|
||||
user_author_nodes (a_id: like {CMS_USER}.id): LIST[CMS_NODE]
|
||||
-- Possible list of nodes where the user identified by `a_id', is the author.
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
||||
to_implement ("Not implemented")
|
||||
end
|
||||
|
||||
feature -- Users roles and permissions
|
||||
|
||||
user_role_by_id (a_id: like {CMS_USER_ROLE}.id): detachable CMS_USER_ROLE
|
||||
-- User role by id `a_id', if any.
|
||||
do
|
||||
to_implement ("Not implemented")
|
||||
end
|
||||
|
||||
user_roles: LIST [CMS_USER_ROLE]
|
||||
-- Possible list of user roles.
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_USER_ROLE]} Result.make (0)
|
||||
to_implement ("Not implemented")
|
||||
end
|
||||
|
||||
feature -- Change: roles and permissions
|
||||
|
||||
save_user_role (a_user_role: CMS_USER_ROLE)
|
||||
-- Save user role `a_user_role'
|
||||
do
|
||||
to_implement ("Not implemented")
|
||||
end
|
||||
|
||||
|
||||
feature -- Access: node
|
||||
|
||||
nodes: LIST[CMS_NODE]
|
||||
-- List of nodes.
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
||||
across node_provider.nodes as c loop
|
||||
Result.force (c.item)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
recent_nodes (a_lower: INTEGER; a_count: INTEGER): LIST [CMS_NODE]
|
||||
-- List of the `a_count' most recent nodes, starting from `a_lower'.
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_NODE]} Result.make (0)
|
||||
across node_provider.recent_nodes (a_lower,a_count) as c loop
|
||||
Result.force (c.item)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
node (a_id: INTEGER_64): detachable CMS_NODE
|
||||
--
|
||||
do
|
||||
Result := node_provider.node (a_id)
|
||||
|
||||
end
|
||||
|
||||
|
||||
feature -- Node
|
||||
|
||||
save_node (a_node: CMS_NODE)
|
||||
-- Add a new node
|
||||
do
|
||||
node_provider.new_node (a_node)
|
||||
|
||||
end
|
||||
|
||||
delete_node (a_id: INTEGER_64)
|
||||
do
|
||||
node_provider.delete_node (a_id)
|
||||
|
||||
end
|
||||
|
||||
update_node (a_id: like {CMS_USER}.id; a_node: CMS_NODE)
|
||||
do
|
||||
node_provider.update_node (a_node)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
end
|
||||
|
||||
|
||||
node_author (a_id: like {CMS_NODE}.id): detachable CMS_USER
|
||||
-- Node's author. if any.
|
||||
do
|
||||
to_implement ("Not implemented")
|
||||
end
|
||||
|
||||
node_collaborators (a_id: like {CMS_NODE}.id): LIST [CMS_USER]
|
||||
-- Possible list of node's collaborator.
|
||||
do
|
||||
create {ARRAYED_LIST[CMS_USER]} Result.make (0)
|
||||
to_implement ("Not implemented")
|
||||
end
|
||||
|
||||
|
||||
feature -- User
|
||||
|
||||
new_user (a_user: CMS_USER)
|
||||
-- Add a new user `a_user'.
|
||||
do
|
||||
if
|
||||
attached a_user.password as l_password and then
|
||||
attached a_user.email as l_email
|
||||
then
|
||||
user_provider.new_user (a_user.name, l_password, l_email)
|
||||
else
|
||||
-- set error
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
node_provider: NODE_DATA_PROVIDER
|
||||
-- Node Data provider.
|
||||
|
||||
user_provider: USER_DATA_PROVIDER
|
||||
-- User Data provider.
|
||||
|
||||
end
|
||||
@@ -1,275 +0,0 @@
|
||||
note
|
||||
description: "Database access for node uses cases."
|
||||
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
NODE_DATA_PROVIDER
|
||||
|
||||
inherit
|
||||
|
||||
PARAMETER_NAME_HELPER
|
||||
|
||||
SHARED_ERROR
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_connection: DATABASE_CONNECTION)
|
||||
-- Create a data provider.
|
||||
do
|
||||
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||
|
||||
end
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
-- Db handler.
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
is_successful: BOOLEAN
|
||||
-- Is the last execution sucessful?
|
||||
do
|
||||
Result := not db_handler.has_error
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
nodes: DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
-- List of nodes.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".nodes")
|
||||
create l_parameters.make (0)
|
||||
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)
|
||||
|
||||
end
|
||||
|
||||
recent_nodes (a_lower, a_rows: INTEGER): DATABASE_ITERATION_CURSOR [CMS_NODE]
|
||||
-- The most recent `a_rows'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
l_query: STRING
|
||||
do
|
||||
log.write_information (generator + ".recent_nodes")
|
||||
create l_parameters.make (2)
|
||||
l_parameters.put (a_rows, "rows")
|
||||
create l_query.make_from_string (select_recent_nodes)
|
||||
l_query.replace_substring_all ("$offset", a_lower.out)
|
||||
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)
|
||||
|
||||
end
|
||||
|
||||
node (a_id: INTEGER_64): detachable CMS_NODE
|
||||
-- Node for the given id `a_id', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".node")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id,"id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_node_by_id, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_node
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
-- Number of items nodes.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".count")
|
||||
create l_parameters.make (0)
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_count, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := db_handler.read_integer_32 (1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
feature -- Basic operations
|
||||
|
||||
new_node (a_node: CMS_NODE)
|
||||
-- Create a new node.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".new_node")
|
||||
create l_parameters.make (6)
|
||||
l_parameters.put (a_node.title, "title")
|
||||
l_parameters.put (a_node.summary, "summary")
|
||||
l_parameters.put (a_node.content, "content")
|
||||
l_parameters.put (a_node.publication_date, "publication_date")
|
||||
l_parameters.put (a_node.creation_date, "creation_date")
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
update_node_title (a_id: INTEGER_64; a_title: READABLE_STRING_32)
|
||||
-- Update node title for the corresponding the report with id `a_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".update_node_title")
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_title, "title")
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "modification_date")
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
update_node_summary (a_id: INTEGER_64; a_summary: READABLE_STRING_32)
|
||||
-- Update node summary for the corresponding the report with id `a_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".update_node_summary")
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_summary, "summary")
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "modification_date")
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
update_node_content (a_id: INTEGER_64; a_content: READABLE_STRING_32)
|
||||
-- Update node content for the corresponding the report with id `a_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".update_node_content")
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_content, "content")
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "modification_date")
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
update_node (a_node: CMS_NODE)
|
||||
-- Update node.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".update_node")
|
||||
create l_parameters.make (7)
|
||||
l_parameters.put (a_node.title, "title")
|
||||
l_parameters.put (a_node.summary, "summary")
|
||||
l_parameters.put (a_node.content, "content")
|
||||
l_parameters.put (a_node.publication_date, "publication_date")
|
||||
l_parameters.put (a_node.creation_date, "creation_date")
|
||||
l_parameters.put (create {DATE_TIME}.make_now_utc, "modification_date")
|
||||
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
|
||||
|
||||
end
|
||||
|
||||
delete_node (a_id: INTEGER_64;)
|
||||
-- Delete node with id `a_id'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".delete_node")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id, "id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_delete_node, l_parameters))
|
||||
db_handler.execute_change
|
||||
end
|
||||
|
||||
feature -- Connection
|
||||
|
||||
connect
|
||||
-- Connect to the database.
|
||||
do
|
||||
if not db_handler.is_connected then
|
||||
db_handler.connect
|
||||
end
|
||||
end
|
||||
|
||||
disconnect
|
||||
-- Disconnect to the database.
|
||||
do
|
||||
if db_handler.is_connected then
|
||||
db_handler.disconnect
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Queries
|
||||
|
||||
Select_count: STRING = "select count(*) from Nodes;"
|
||||
|
||||
Select_nodes: STRING = "select * from Nodes;"
|
||||
-- SQL Query to retrieve all nodes.
|
||||
|
||||
Select_node_by_id: STRING = "select * from Nodes where id =:id order by id desc, publication_date desc;"
|
||||
|
||||
Select_recent_nodes: STRING = "select * from Nodes order by id desc, publication_date desc Limit $offset , :rows "
|
||||
|
||||
SQL_Insert_node: STRING = "insert into nodes (title, summary, content, publication_date, creation_date, modification_date) values (:title, :summary, :content, :publication_date, :creation_date, :modification_date);"
|
||||
-- SQL Insert to add a new node.
|
||||
|
||||
SQL_Update_node_title: STRING ="update nodes SET title=:title, modification_date=:modification_date where id=:id;"
|
||||
-- SQL update node title.
|
||||
|
||||
SQL_Update_node_summary: STRING ="update nodes SET summary=:summary, modification_date=:modification_date where id=:id;"
|
||||
-- SQL update node summary.
|
||||
|
||||
SQL_Update_node_content: STRING ="update nodes SET content=:content, modification_date=:modification_date where id=:id;"
|
||||
-- SQL node content.
|
||||
|
||||
SQL_Update_node : STRING = "update nodes SET title=:title, summary=:summary, content=:content, publication_date=:publication_date, creation_date=:creation_date, modification_date=:modification_date where id=:id;"
|
||||
-- SQL node.
|
||||
|
||||
SQL_Delete_node: STRING = "delete from nodes where id=:id;"
|
||||
|
||||
|
||||
feature -- New Object
|
||||
|
||||
fetch_node: CMS_NODE
|
||||
do
|
||||
create Result.make ("", "", "")
|
||||
if attached db_handler.read_integer_32 (1) as l_id then
|
||||
Result.set_id (l_id)
|
||||
end
|
||||
if attached db_handler.read_date_time (2) as l_pd then
|
||||
Result.set_publication_date (l_pd)
|
||||
end
|
||||
if attached db_handler.read_date_time (3) as l_cd then
|
||||
Result.set_creation_date (l_cd)
|
||||
end
|
||||
if attached db_handler.read_date_time (4) as l_md then
|
||||
Result.set_modification_date (l_md)
|
||||
end
|
||||
if attached db_handler.read_string (5) as l_t then
|
||||
Result.set_title (l_t)
|
||||
end
|
||||
if attached db_handler.read_string (6) as l_s then
|
||||
Result.set_summary (l_s)
|
||||
end
|
||||
if attached db_handler.read_string (7) as l_c then
|
||||
Result.set_content (l_c)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -1,193 +0,0 @@
|
||||
note
|
||||
description: "Summary description for {USER_DATA_PROVIDER}."
|
||||
date: "$Date: 2014-11-13 12:23:47 -0300 (ju., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
USER_DATA_PROVIDER
|
||||
|
||||
inherit
|
||||
|
||||
PARAMETER_NAME_HELPER
|
||||
|
||||
SHARED_ERROR
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (a_connection: DATABASE_CONNECTION)
|
||||
-- Create a data provider.
|
||||
do
|
||||
create {DATABASE_HANDLER_IMPL} db_handler.make (a_connection)
|
||||
|
||||
end
|
||||
|
||||
db_handler: DATABASE_HANDLER
|
||||
-- Db handler.
|
||||
|
||||
feature -- Status Report
|
||||
|
||||
is_successful: BOOLEAN
|
||||
-- Is the last execution sucessful?
|
||||
do
|
||||
Result := not db_handler.has_error
|
||||
end
|
||||
|
||||
has_user: BOOLEAN
|
||||
-- Has any user?
|
||||
do
|
||||
Result := count > 0
|
||||
end
|
||||
|
||||
feature -- Basic Operations
|
||||
|
||||
new_user (a_user_name: READABLE_STRING_32; a_password: READABLE_STRING_32; a_email: READABLE_STRING_32)
|
||||
-- Create a new node.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
l_password_salt, l_password_hash: STRING
|
||||
l_security: SECURITY_PROVIDER
|
||||
do
|
||||
create l_security
|
||||
l_password_salt := l_security.salt
|
||||
l_password_hash := l_security.password_hash (a_password, l_password_salt)
|
||||
|
||||
log.write_information (generator + ".new_user")
|
||||
create l_parameters.make (4)
|
||||
l_parameters.put (a_user_name,"username")
|
||||
l_parameters.put (l_password_hash,"password")
|
||||
l_parameters.put (l_password_salt,"salt")
|
||||
l_parameters.put (a_email,"email")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (sql_insert_user, l_parameters))
|
||||
db_handler.execute_change
|
||||
|
||||
end
|
||||
|
||||
user (a_id: INTEGER_64): detachable CMS_USER
|
||||
-- User for the given id `a_id', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".user")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_id,"id")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_user_by_id, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_user
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
user_by_name (a_name: READABLE_STRING_32): detachable CMS_USER
|
||||
-- User for the given name `a_name', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".user_by_name")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_name,"name")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_user_by_name, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_user
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
user_by_email (a_email: detachable READABLE_STRING_32): detachable CMS_USER
|
||||
-- User for the given email `a_email', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
do
|
||||
log.write_information (generator + ".user_by_email")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_email,"email")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_user_by_email, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := fetch_user
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
user_salt (a_username: READABLE_STRING_32): detachable READABLE_STRING_32
|
||||
-- User salt for the given user `a_username', if any.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".user_salt")
|
||||
create l_parameters.make (1)
|
||||
l_parameters.put (a_username,"name")
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_salt_by_username, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
if attached db_handler.read_string (1) as l_salt then
|
||||
Result := l_salt.as_string_32
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
-- Number of items users.
|
||||
local
|
||||
l_parameters: STRING_TABLE [ANY]
|
||||
do
|
||||
log.write_information (generator + ".count")
|
||||
create l_parameters.make (0)
|
||||
db_handler.set_query (create {DATABASE_QUERY}.data_reader (select_count, l_parameters))
|
||||
db_handler.execute_query
|
||||
if db_handler.count = 1 then
|
||||
Result := db_handler.read_integer_32 (1)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
feature -- New Object
|
||||
|
||||
fetch_user: CMS_USER
|
||||
do
|
||||
create Result.make ("")
|
||||
if attached db_handler.read_integer_32 (1) as l_id then
|
||||
Result.set_id (l_id)
|
||||
end
|
||||
if attached db_handler.read_string (2) as l_u then
|
||||
Result.set_name (l_u)
|
||||
end
|
||||
if attached db_handler.read_string (3) as l_p then
|
||||
Result.set_password (l_p)
|
||||
end
|
||||
if attached db_handler.read_string (5) as l_e then
|
||||
Result.set_email (l_e)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Sql Queries
|
||||
|
||||
Select_count: STRING = "select count(*) from Users;"
|
||||
-- Number of users.
|
||||
|
||||
Select_user_by_id: STRING = "select * from Users where id =:id;"
|
||||
-- Retrieve user by id if exists.
|
||||
|
||||
Select_user_by_name: STRING = "select * from Users where username =:name;"
|
||||
-- Retrieve user by name if exists.
|
||||
|
||||
Select_user_by_email: STRING = "select * from Users where email =:email;"
|
||||
-- Retrieve user by email if exists.
|
||||
|
||||
Select_salt_by_username: STRING = "select salt from Users where username =:name;"
|
||||
-- Retrieve salt by username if exists.
|
||||
|
||||
SQL_Insert_user: STRING = "insert into users (username, password, salt, email) values (:username, :password, :salt, :email);"
|
||||
-- SQL Insert to add a new node.
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -1,225 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
NODE_TEST_SET
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare,
|
||||
on_clean
|
||||
select
|
||||
default_create
|
||||
end
|
||||
ABSTRACT_DB_TEST
|
||||
rename
|
||||
default_create as default_db_test
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Events
|
||||
|
||||
on_prepare
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_new_node
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
node_provider.new_node (default_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached node_provider.node (1))
|
||||
-- Not exist node with id 2
|
||||
assert ("Not exist node with id 2", node_provider.node (2) = Void)
|
||||
end
|
||||
|
||||
|
||||
test_update_node
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node (content and summary)
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
l_un.set_content ("<h1>Updating test node udpate </h1>")
|
||||
l_un.set_summary ("updating summary")
|
||||
node_provider.update_node (l_un)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then ll_node.title ~ l_node.title )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
|
||||
end
|
||||
|
||||
-- Update node (content and summary and title)
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
l_un.set_content ("<h1>Updating test node udpate </h1>")
|
||||
l_un.set_summary ("updating summary")
|
||||
l_un.set_title ("Updating Test case")
|
||||
node_provider.update_node (l_un)
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_node.content) and then not (ll_node.summary ~ l_node.summary) and then not (ll_node.title ~ l_node.title) )
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title )
|
||||
end
|
||||
end
|
||||
|
||||
test_update_title
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node title
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
node_provider.update_node_title (l_un.id, "New Title")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then ll_node.summary ~ l_un.summary and then not ( ll_node.title ~ l_un.title) and then ll_node.title ~ "New Title" )
|
||||
end
|
||||
end
|
||||
|
||||
test_update_summary
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node summary
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
node_provider.update_node_summary (l_un.id,"New Summary")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_un.content and then not (ll_node.summary ~ l_un.summary) and then ll_node.summary ~ "New Summary" and then ll_node.title ~ l_un.title)
|
||||
end
|
||||
end
|
||||
|
||||
test_update_content
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Update node content
|
||||
|
||||
if attached {CMS_NODE} node_provider.node (1) as l_un then
|
||||
node_provider.update_node_content (l_un.id,"New Content")
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then not (ll_node.content ~ l_un.content) and then ll_node.content ~ "New Content" and then ll_node.summary ~ l_un.summary and then ll_node.title ~ l_un.title)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
test_delete_node
|
||||
local
|
||||
l_node: CMS_NODE
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
l_node := custom_node ("<h1> test node udpate </h1>", "Update node", "Test case update")
|
||||
node_provider.new_node (l_node)
|
||||
assert ("Not empty Nodes after new_node", not node_provider.nodes.after)
|
||||
-- Exist node with id 1
|
||||
assert ("Exist node with id 1", attached {CMS_NODE} node_provider.node (1) as ll_node and then ll_node.content ~ l_node.content and then ll_node.summary ~ l_node.summary and then ll_node.title ~ l_node.title )
|
||||
|
||||
-- Delte node 1
|
||||
|
||||
node_provider.delete_node (1)
|
||||
assert ("Node does not exist", node_provider.node (1) = Void)
|
||||
end
|
||||
|
||||
test_recent_nodes
|
||||
-- Content_10, Summary_10, Title_10
|
||||
-- Content_9, Summary_9, Title_9
|
||||
-- ..
|
||||
-- Content_1, Summary_1, Title_1
|
||||
local
|
||||
i : INTEGER
|
||||
do
|
||||
assert ("Empty Nodes", node_provider.nodes.after)
|
||||
across 1 |..| 10 as c loop
|
||||
node_provider.new_node (custom_node ("Content_" + c.item.out, "Summary_" + c.item.out, "Title_" + c.item.out))
|
||||
end
|
||||
|
||||
-- Scenario (0,10) rows, recents (10 down to 1)
|
||||
i := 10
|
||||
across node_provider.recent_nodes (0, 10) as c loop
|
||||
assert ("Same id:" + i.out, c.item.id = i)
|
||||
i := i - 1
|
||||
end
|
||||
|
||||
-- Scenario (5, 10) rows, recent nodes (5 down to 1)
|
||||
i := 5
|
||||
across node_provider.recent_nodes (5, 10) as c loop
|
||||
assert ("Same id:" + i.out, c.item.id = i)
|
||||
i := i - 1
|
||||
end
|
||||
|
||||
-- Scenario (9,10) rows, recent node 1
|
||||
i := 1
|
||||
across node_provider.recent_nodes (9, 10) as c loop
|
||||
assert ("Same id:" + i.out, c.item.id = i)
|
||||
i := i - 1
|
||||
end
|
||||
|
||||
-- Scenrario 10..10 empty
|
||||
assert ("Empty", node_provider.recent_nodes (10, 10).after)
|
||||
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
node_provider: NODE_DATA_PROVIDER
|
||||
-- node provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation Fixture Factories
|
||||
|
||||
default_node: CMS_NODE
|
||||
do
|
||||
Result := custom_node ("Default content", "default summary", "Default")
|
||||
end
|
||||
|
||||
custom_node (a_content, a_summary, a_title: READABLE_STRING_32): CMS_NODE
|
||||
do
|
||||
create Result.make (a_content, a_summary, a_title)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
USER_TEST_SET
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
redefine
|
||||
on_prepare,
|
||||
on_clean
|
||||
select
|
||||
default_create
|
||||
end
|
||||
ABSTRACT_DB_TEST
|
||||
rename
|
||||
default_create as default_db_test
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Events
|
||||
|
||||
on_prepare
|
||||
-- <Precursor>
|
||||
do
|
||||
(create {CLEAN_DB}).clean_db(connection)
|
||||
user_provider.new_user ("admin", "admin","admin@admin.com")
|
||||
end
|
||||
|
||||
on_clean
|
||||
-- <Precursor>
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_user_exist
|
||||
-- User admin exist
|
||||
do
|
||||
assert ("Not void", attached user_provider.user_by_email ("admin@admin.com"))
|
||||
assert ("Not void", attached user_provider.user (1))
|
||||
assert ("Not void", attached user_provider.user_by_name ("admin"))
|
||||
end
|
||||
|
||||
test_user_not_exist
|
||||
-- Uset test does not exist.
|
||||
do
|
||||
assert ("Void", user_provider.user_by_email ("test@admin.com") = Void)
|
||||
assert ("Void", user_provider.user(2) = Void )
|
||||
assert ("Void", user_provider.user_by_name ("test") = Void)
|
||||
end
|
||||
|
||||
test_new_user
|
||||
do
|
||||
user_provider.new_user ("test", "test","test@admin.com")
|
||||
assert ("Not void", attached user_provider.user_by_email ("test@admin.com"))
|
||||
assert ("Not void", attached user_provider.user (2))
|
||||
assert ("Not void", attached user_provider.user (2) as l_user and then l_user.id = 2 and then l_user.name ~ "test")
|
||||
assert ("Not void", attached user_provider.user_by_name ("test"))
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
user_provider: USER_DATA_PROVIDER
|
||||
-- user provider.
|
||||
once
|
||||
create Result.make (connection)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user