text
stringlengths
0
234
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
Function Definition: procedure Load_List (Into : in out Post_List_Bean) is
Function Body: use AWA.Blogs.Models;
use AWA.Services;
Session : ADO.Sessions.Session := Into.Service.Get_Session;
Query : ADO.Queries.Context;
Count_Query : ADO.Queries.Context;
Tag_Id : ADO.Identifier;
First : constant Natural := (Into.Page - 1) * Into.Page_Size;
begin
AWA.Tags.Modules.Find_Tag_Id (Session, Ada.Strings.Unbounded.To_String (Into.Tag), Tag_Id);
if Tag_Id /= ADO.NO_IDENTIFIER then
Query.Set_Query (AWA.Blogs.Models.Query_Blog_Post_Tag_List);
Query.Bind_Param (Name => "tag", Value => Tag_Id);
Count_Query.Set_Count_Query (AWA.Blogs.Models.Query_Blog_Post_Tag_List);
Count_Query.Bind_Param (Name => "tag", Value => Tag_Id);
else
Query.Set_Query (AWA.Blogs.Models.Query_Blog_Post_List);
Count_Query.Set_Count_Query (AWA.Blogs.Models.Query_Blog_Post_List);
end if;
Query.Bind_Param (Name => "first", Value => First);
Query.Bind_Param (Name => "count", Value => Into.Page_Size);
ADO.Sessions.Entities.Bind_Param (Params => Query,
Name => "entity_type",
Table => AWA.Blogs.Models.POST_TABLE,
Session => Session);
ADO.Sessions.Entities.Bind_Param (Params => Count_Query,
Name => "entity_type",
Table => AWA.Blogs.Models.POST_TABLE,
Session => Session);
AWA.Blogs.Models.List (Into.Posts, Session, Query);
Into.Count := ADO.Datasets.Get_Count (Session, Count_Query);
declare
List : ADO.Utils.Identifier_Vector;
Iter : Post_Info_Vectors.Cursor := Into.Posts.List.First;
begin
while Post_Info_Vectors.Has_Element (Iter) loop
List.Append (Post_Info_Vectors.Element (Iter).Id);
Post_Info_Vectors.Next (Iter);
end loop;
Into.Tags.Load_Tags (Session, AWA.Blogs.Models.POST_TABLE.Table.all,
List);
Function Definition: function Create_Post_List_Bean (Module : in AWA.Blogs.Modules.Blog_Module_Access)
Function Body: return Util.Beans.Basic.Readonly_Bean_Access is
Object : constant Post_List_Bean_Access := new Post_List_Bean;
begin
Object.Service := Module;
Object.Posts_Bean := Object.Posts'Access;
Object.Page_Size := 20;
Object.Page := 1;
Object.Count := 0;
Object.Counter_Bean := Object.Counter'Access;
Object.Counter.Counter := AWA.Blogs.Modules.Read_Counter.Index;
return Object.all'Access;
end Create_Post_List_Bean;
-- ------------------------------
-- Create the Blog_List_Bean bean instance.
-- ------------------------------
function Create_Blog_Admin_Bean (Module : in AWA.Blogs.Modules.Blog_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access is
Object : constant Blog_Admin_Bean_Access := new Blog_Admin_Bean;
begin
Object.Module := Module;
Object.Flags := Object.Init_Flags'Access;
Object.Post_List_Bean := Object.Post_List'Access;
Object.Blog_List_Bean := Object.Blog_List'Access;
Object.Comment_List_Bean := Object.Comment_List'Access;
return Object.all'Access;
end Create_Blog_Admin_Bean;
function Create_From_Status is
new AWA.Helpers.Selectors.Create_From_Enum (AWA.Blogs.Models.Post_Status_Type,
"blog_status_");
-- ------------------------------
-- Get a select item list which contains a list of post status.
-- ------------------------------
function Create_Status_List (Module : in AWA.Blogs.Modules.Blog_Module_Access)
return Util.Beans.Basic.Readonly_Bean_Access is
pragma Unreferenced (Module);
use AWA.Helpers;
begin
return Selectors.Create_Selector_Bean (Bundle => "blogs",
Context => null,