text
stringlengths
0
234
raise;
end Set_Cell;
procedure Build_Neighbors is
Stmt : ADO.Statements.Delete_Statement
:= DB.Create_Statement (AWA.Countries.Models.COUNTRY_NEIGHBOR_TABLE);
Iter : Neighbors_Map.Cursor := Neighbors.First;
Count : Natural := 0;
begin
Stmt.Execute;
while Neighbors_Map.Has_Element (Iter) loop
declare
Name : constant String := Neighbors_Map.Key (Iter);
List : constant String := Neighbors_Map.Element (Iter);
Pos : Natural := List'First;
N : Natural;
begin
Country := Countries.Element (Name);
while Pos < List'Last loop
N := Util.Strings.Index (List, ',', Pos);
if N = 0 then
N := List'Last;
else
N := N - 1;
end if;
if Pos < N and then Countries.Contains (List (Pos .. N)) then
declare
Neighbor : AWA.Countries.Models.Country_Neighbor_Ref;
begin
Neighbor.Set_Neighbor_Of (Country);
Neighbor.Set_Neighbor (Countries.Element (List (Pos .. N)));
Neighbor.Save (DB);
Count := Count + 1;
Function Definition: procedure Unchecked_Free is new Ada.Unchecked_Deallocation
Function Body: (Country_Impl, Country_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Country_Impl_Ptr := Country_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Country_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, COUNTRY_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 Country_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 Country_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (COUNTRY_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 (3) then
Stmt.Save_Field (Name => COL_2_1_NAME, -- continent
Value => Object.Continent);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_1_NAME, -- currency
Value => Object.Currency);
Object.Clear_Modified (4);