text
stringlengths
0
234
AWA.Permissions.Check (Permission => Security.Permissions.Get_Permission_Index (Permission),
Entity => Id);
Log.Info ("User {0} removes tag {1} on {2}",
ADO.Identifier'Image (User.Get_Id), Tag, Ident);
Ctx.Start;
Kind := ADO.Sessions.Entities.Find_Entity_Type (DB, Entity_Type);
Remove_Tag (DB, Id, Kind, Tag);
Ctx.Commit;
end Remove_Tag;
-- ------------------------------
-- Remove the tags defined by the <tt>Deleted</tt> tag list and add the tags defined
-- in the <tt>Added</tt> tag list. The tags are associated with the database entity
-- referenced by <tt>Id</tt> in the table identified by <tt>Entity_Type</tt>.
-- The permission represented by <tt>Permission</tt> is checked to make sure the current user
-- can remove or add the tag.
-- ------------------------------
procedure Update_Tags (Model : in Tag_Module;
Id : in ADO.Identifier;
Entity_Type : in String;
Permission : in String;
Added : in Util.Strings.Vectors.Vector;
Deleted : in Util.Strings.Vectors.Vector) is
pragma Unreferenced (Model);
Ctx : constant ASC.Service_Context_Access := ASC.Current;
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
Ident : constant String := Entity_Type & ADO.Identifier'Image (Id);
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
Kind : ADO.Entity_Type;
Iter : Util.Strings.Vectors.Cursor;
begin
-- Check that the user has the permission on the given object.
AWA.Permissions.Check (Permission => Security.Permissions.Get_Permission_Index (Permission),
Entity => Id);
Ctx.Start;
Kind := ADO.Sessions.Entities.Find_Entity_Type (DB, Entity_Type);
-- Delete the tags that have been removed.
Iter := Deleted.First;
while Util.Strings.Vectors.Has_Element (Iter) loop
declare
Tag : constant String := Util.Strings.Vectors.Element (Iter);
begin
Log.Info ("User {0} removes tag {1} on {2}",
ADO.Identifier'Image (User.Get_Id), Tag, Ident);
Remove_Tag (DB, Id, Kind, Tag);
Function Definition: procedure Set_Permission (Into : in out Tag_List_Bean;
Function Body: Permission : in String) is
begin
Into.Permission := Ada.Strings.Unbounded.To_Unbounded_String (Permission);
end Set_Permission;
-- ------------------------------
-- Load the tags associated with the given database identifier.
-- ------------------------------
procedure Load_Tags (Into : in out Tag_List_Bean;
Session : in ADO.Sessions.Session;
For_Entity_Id : in ADO.Identifier) is
use ADO.Sessions.Entities;
Entity_Type : constant String := Ada.Strings.Unbounded.To_String (Into.Entity_Type);
Kind : constant ADO.Entity_Type := Find_Entity_Type (Session, Entity_Type);
Query : ADO.Queries.Context;
begin
Query.Set_Query (AWA.Tags.Models.Query_Tag_List);
Query.Bind_Param ("entity_type", Kind);
Query.Bind_Param ("entity_id", For_Entity_Id);
declare
Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query);
begin
Stmt.Execute;
while Stmt.Has_Elements loop
Into.List.Append (Util.Beans.Objects.To_Object (Stmt.Get_String (0)));
Stmt.Next;
end loop;
Function Definition: function Create_Tag_List_Bean (Module : in AWA.Tags.Modules.Tag_Module_Access)
Function Body: return Util.Beans.Basic.Readonly_Bean_Access is
Result : constant Tag_List_Bean_Access := new Tag_List_Bean;
begin
Result.Module := Module;
return Result.all'Access;
end Create_Tag_List_Bean;
-- ------------------------------
-- Search the tags that match the search string.
-- ------------------------------
procedure Search_Tags (Into : in out Tag_Search_Bean;
Session : in ADO.Sessions.Session;
Search : in String) is
use ADO.Sessions.Entities;
Entity_Type : constant String := Ada.Strings.Unbounded.To_String (Into.Entity_Type);