text
stringlengths
0
234
Session => Session);
AWA.Blogs.Models.List (List.Comment_List_Bean.all, Session, Query);
List.Flags (INIT_COMMENT_LIST) := True;
end if;
end Load_Comments;
overriding
function Get_Value (List : in Blog_Admin_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "blogs" then
if not List.Init_Flags (INIT_BLOG_LIST) then
Load_Blogs (List);
end if;
return Util.Beans.Objects.To_Object (Value => List.Blog_List_Bean,
Storage => Util.Beans.Objects.STATIC);
elsif Name = "posts" then
if not List.Init_Flags (INIT_POST_LIST) then
Load_Posts (List);
end if;
return Util.Beans.Objects.To_Object (Value => List.Post_List_Bean,
Storage => Util.Beans.Objects.STATIC);
elsif Name = "comments" then
if not List.Init_Flags (INIT_COMMENT_LIST) then
Load_Comments (List);
end if;
return Util.Beans.Objects.To_Object (Value => List.Comment_List_Bean,
Storage => Util.Beans.Objects.STATIC);
elsif Name = "id" then
declare
Id : constant ADO.Identifier := List.Get_Blog_Id;
begin
if Id = ADO.NO_IDENTIFIER then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.To_Object (Long_Long_Integer (Id));
end if;
Function Definition: procedure Unchecked_Free is new Ada.Unchecked_Deallocation
Function Body: (Blog_Impl, Blog_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Blog_Impl_Ptr := Blog_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Blog_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, BLOG_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Blog_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Blog_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (BLOG_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_1_NAME, -- name
Value => Object.Name);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_1_NAME, -- uid