text
stringlengths
0
234
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_1_NAME, -- public
Value => Object.Public);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_1_NAME, -- thumbnail_id
Value => Object.Thumbnail);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_1_NAME, -- folder_id
Value => Object.Folder);
Object.Clear_Modified (10);
end if;
if Object.Is_Modified (11) then
Stmt.Save_Field (Name => COL_10_1_NAME, -- owner_id
Value => Object.Owner);
Object.Clear_Modified (11);
end if;
if Object.Is_Modified (12) then
Stmt.Save_Field (Name => COL_11_1_NAME, -- storage_id
Value => Object.Storage);
Object.Clear_Modified (12);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
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 List (Object : in out Image_Vector;
Function Body: Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, IMAGE_DEF'Access);
begin
Stmt.Execute;
Image_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Image_Ref;
Impl : constant Image_Access := new Image_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
Function Definition: function Get is new AWA.Modules.Get (Question_Module, Question_Module_Access, NAME);
Function Body: begin
return Get;
end Get_Question_Module;
-- ------------------------------
-- Create or save the question.
-- ------------------------------
procedure Save_Question (Model : in Question_Module;
Question : in out AWA.Questions.Models.Question_Ref'Class) is
pragma Unreferenced (Model);
function To_Wide (Item : in String) return Wide_Wide_String
renames Ada.Characters.Conversions.To_Wide_Wide_String;
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
WS : AWA.Workspaces.Models.Workspace_Ref;
begin
Ctx.Start;
if Question.Is_Inserted then
Log.Info ("Updating question {0}", ADO.Identifier'Image (Question.Get_Id));
WS := AWA.Workspaces.Models.Workspace_Ref (Question.Get_Workspace);
else
Log.Info ("Creating new question {0}", String '(Question.Get_Title));
AWA.Workspaces.Modules.Get_Workspace (DB, Ctx, WS);
-- Check that the user has the create permission on the given workspace.
AWA.Permissions.Check (Permission => ACL_Create_Questions.Permission,
Entity => WS);
Question.Set_Workspace (WS);
Question.Set_Author (User);
end if;
declare
Text : constant String := Wiki.Utils.To_Text (To_Wide (Question.Get_Description),