From 3c73202a0de7037152f5bae7d8fe6051a99480b5 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Wed, 15 Oct 2014 19:41:47 -0300 Subject: [PATCH] Initial Import Model Library --- cms/cms-safe.ecf | 2 + model/model-safe.ecf | 19 +++ model/src/cms_content_type.e | 10 ++ model/src/cms_link.e | 71 ++++++++++++ model/src/cms_link_composite.e | 27 +++++ model/src/cms_local_link.e | 109 ++++++++++++++++++ model/src/cms_menu.e | 72 ++++++++++++ .../common/model => model/src}/cms_node.e | 0 .../common/model => model/src}/cms_user.e | 0 .../model => model/src}/cms_user_profile.e | 0 .../model => model/src}/cms_user_role.e | 0 .../database/error/shared_error_handler.e | 2 +- .../mysql/persistence_mysql-safe.ecf | 1 + 13 files changed, 312 insertions(+), 1 deletion(-) create mode 100644 model/model-safe.ecf create mode 100644 model/src/cms_content_type.e create mode 100644 model/src/cms_link.e create mode 100644 model/src/cms_link_composite.e create mode 100644 model/src/cms_local_link.e create mode 100644 model/src/cms_menu.e rename {persistence/implementation/common/model => model/src}/cms_node.e (100%) rename {persistence/implementation/common/model => model/src}/cms_user.e (100%) rename {persistence/implementation/common/model => model/src}/cms_user_profile.e (100%) rename {persistence/implementation/common/model => model/src}/cms_user_role.e (100%) diff --git a/cms/cms-safe.ecf b/cms/cms-safe.ecf index 5da317c..3a5945e 100644 --- a/cms/cms-safe.ecf +++ b/cms/cms-safe.ecf @@ -10,6 +10,8 @@ + + diff --git a/model/model-safe.ecf b/model/model-safe.ecf new file mode 100644 index 0000000..cc50b08 --- /dev/null +++ b/model/model-safe.ecf @@ -0,0 +1,19 @@ + + + + + + + + + + + /EIFGENs$ + /.svn$ + /CVS$ + + + + diff --git a/model/src/cms_content_type.e b/model/src/cms_content_type.e new file mode 100644 index 0000000..fc6cec2 --- /dev/null +++ b/model/src/cms_content_type.e @@ -0,0 +1,10 @@ +note + description: "Summary description for {CMS_CONTENT_TYPE}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + CMS_CONTENT_TYPE + +end diff --git a/model/src/cms_link.e b/model/src/cms_link.e new file mode 100644 index 0000000..7606366 --- /dev/null +++ b/model/src/cms_link.e @@ -0,0 +1,71 @@ +note + description: "Summary description for {CMS_MENU}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + CMS_LINK + +inherit + REFACTORING_HELPER + + DEBUG_OUTPUT + + ITERABLE [CMS_LINK] + +feature -- Access + + title: READABLE_STRING_32 + -- link's title. + + location: READABLE_STRING_8 + -- link's location. + +feature -- status report + + is_active: BOOLEAN + deferred + end + + is_expanded: BOOLEAN + deferred + end + + is_expandable: BOOLEAN + deferred + end + + has_children: BOOLEAN + deferred + end + +feature -- Query + + parent: detachable CMS_LINK + + children: detachable LIST [CMS_LINK] + deferred + end + +feature -- Access + + new_cursor: ITERATION_CURSOR [CMS_LINK] + -- Fresh cursor associated with current structure + do + if attached children as lst then + Result := lst.new_cursor + else + Result := (create {ARRAYED_LIST [CMS_LINK]}.make (0)).new_cursor + end + end + +feature -- Status report + + debug_output: STRING + -- String that should be displayed in debugger to represent `Current'. + do + Result := title.as_string_8 + " -> " + location + end + +end diff --git a/model/src/cms_link_composite.e b/model/src/cms_link_composite.e new file mode 100644 index 0000000..3a9c7da --- /dev/null +++ b/model/src/cms_link_composite.e @@ -0,0 +1,27 @@ +note + description: "Summary description for {CMS_LINK_COMPOSITE}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + CMS_LINK_COMPOSITE + +inherit + ITERABLE [CMS_LINK] + +feature -- Access + + items: detachable LIST [CMS_LINK] + deferred + end + + extend (lnk: CMS_LINK) + deferred + end + + remove (lnk: CMS_LINK) + deferred + end + +end diff --git a/model/src/cms_local_link.e b/model/src/cms_local_link.e new file mode 100644 index 0000000..9633fc0 --- /dev/null +++ b/model/src/cms_local_link.e @@ -0,0 +1,109 @@ +note + description: "Summary description for {CMS_LOCAL_MENU}." + date: "$Date$" + revision: "$Revision$" + +class + CMS_LOCAL_LINK + +inherit + CMS_LINK + + CMS_LINK_COMPOSITE + rename + items as children, + extend as add_link, + remove as remove_link + end + +create + make + +feature {NONE} -- Initialization + + make (a_title: detachable like title; a_location: like location) + do + if a_title /= Void then + title := a_title + else + title := a_location + end + location := a_location + end + +feature -- Status report + + is_active: BOOLEAN + + is_expanded: BOOLEAN + do + Result := is_expandable and then internal_is_expanded + end + + is_expandable: BOOLEAN + do + Result := internal_is_expandable or internal_is_expanded or has_children + end + + has_children: BOOLEAN + do + Result := attached children as l_children and then not l_children.is_empty + end + + permission_arguments: detachable ITERABLE [READABLE_STRING_8] + + children: detachable LIST [CMS_LINK] + + internal_is_expandable: BOOLEAN + + internal_is_expanded: BOOLEAN + +feature -- Element change + + add_link (lnk: CMS_LINK) + local + lst: like children + do + lst := children + if lst = Void then + create {ARRAYED_LIST [CMS_LINK]} lst.make (1) + children := lst + end + lst.force (lnk) + end + + remove_link (lnk: CMS_LINK) + local + lst: like children + do + lst := children + if lst /= Void then + lst.prune_all (lnk) + if lst.is_empty then + children := Void + end + end + end + + set_children (lst: like children) + do + children := lst + end + + set_expanded (b: like is_expanded) + do + internal_is_expanded := b + end + + set_expandable (b: like is_expandable) + do + internal_is_expandable := b + end + + + set_permission_arguments (args: like permission_arguments) + do + permission_arguments := args + end + +end diff --git a/model/src/cms_menu.e b/model/src/cms_menu.e new file mode 100644 index 0000000..6cb332f --- /dev/null +++ b/model/src/cms_menu.e @@ -0,0 +1,72 @@ +note + description: "Summary description for {CMS_MENU}." + date: "$Date$" + revision: "$Revision$" + +class + CMS_MENU + +inherit + CMS_LINK_COMPOSITE + +create + make, + make_with_title + +feature {NONE} -- Initialization + + make (a_name: like name; n: INTEGER) + do + name := a_name + create items.make (n) + end + + make_with_title (a_name: like name; a_title: READABLE_STRING_32; n: INTEGER) + do + make (a_name, n) + set_title (a_title) + end + +feature -- Access + + name: READABLE_STRING_8 + + title: detachable READABLE_STRING_32 + + items: ARRAYED_LIST [CMS_LINK] + + extend (lnk: CMS_LINK) + do + items.extend (lnk) + end + + remove (lnk: CMS_LINK) + do + items.prune_all (lnk) + end + +feature -- status report + + is_empty: BOOLEAN + do + Result := items.is_empty + end + +feature -- Element change + + set_title (t: like title) + do + title := t + end + +feature -- Access + + new_cursor: ITERATION_CURSOR [CMS_LINK] + -- Fresh cursor associated with current structure + do + Result := items.new_cursor + end + +invariant + +end diff --git a/persistence/implementation/common/model/cms_node.e b/model/src/cms_node.e similarity index 100% rename from persistence/implementation/common/model/cms_node.e rename to model/src/cms_node.e diff --git a/persistence/implementation/common/model/cms_user.e b/model/src/cms_user.e similarity index 100% rename from persistence/implementation/common/model/cms_user.e rename to model/src/cms_user.e diff --git a/persistence/implementation/common/model/cms_user_profile.e b/model/src/cms_user_profile.e similarity index 100% rename from persistence/implementation/common/model/cms_user_profile.e rename to model/src/cms_user_profile.e diff --git a/persistence/implementation/common/model/cms_user_role.e b/model/src/cms_user_role.e similarity index 100% rename from persistence/implementation/common/model/cms_user_role.e rename to model/src/cms_user_role.e diff --git a/persistence/implementation/common/database/error/shared_error_handler.e b/persistence/implementation/common/database/error/shared_error_handler.e index 15c06c1..f5a80ca 100644 --- a/persistence/implementation/common/database/error/shared_error_handler.e +++ b/persistence/implementation/common/database/error/shared_error_handler.e @@ -31,7 +31,7 @@ feature -- Helper exception_as_error (a_e: like {EXCEPTION_MANAGER}.last_exception) -- Record exception as an error. do - if attached a_e as l_e and then attached l_e.exception_trace as l_trace then + if attached a_e as l_e and then attached l_e.trace as l_trace then database_error_handler.add_error_details (l_e.code, once "Exception", l_trace.as_string_32) end end diff --git a/persistence/implementation/mysql/persistence_mysql-safe.ecf b/persistence/implementation/mysql/persistence_mysql-safe.ecf index 6811629..9d99a01 100644 --- a/persistence/implementation/mysql/persistence_mysql-safe.ecf +++ b/persistence/implementation/mysql/persistence_mysql-safe.ecf @@ -13,6 +13,7 @@ +