text
stringlengths
0
234
function Get_Definition_Id (Object : in Visit_Ref)
return ADO.Identifier is
Impl : constant Visit_Access
:= Visit_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Definition_Id;
-- Copy of the object.
procedure Copy (Object : in Visit_Ref;
Into : in out Visit_Ref) is
Result : Visit_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Visit_Access
:= Visit_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Visit_Access
:= new Visit_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Object_Id := Impl.Object_Id;
Copy.Counter := Impl.Counter;
Copy.Date := Impl.Date;
Copy.User := Impl.User;
Function Definition: procedure Unchecked_Free is new Ada.Unchecked_Deallocation
Function Body: (Visit_Impl, Visit_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Visit_Impl_Ptr := Visit_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Visit_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, VISIT_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 Visit_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 ("definition_id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Visit_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (VISIT_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_3_NAME, -- object_id
Value => Object.Object_Id);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_3_NAME, -- counter
Value => Object.Counter);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_3_NAME, -- date
Value => Object.Date);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_3_NAME, -- user
Value => Object.User);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_3_NAME, -- definition_id
Value => Object.Get_Key);
Object.Clear_Modified (5);
end if;
if Stmt.Has_Save_Fields then
Stmt.Set_Filter (Filter => "definition_id = ? AND object_id = ? AND user = ?");