note description: "Summary description for {POLICY_CACHE_ACCESS}." author: "" date: "$Date$" revision: "$Revision$" class POLICY_CACHE_ACCESS inherit DATABASE_ACCESS create {POLICY_CACHE} make_policy_access feature {POLICY_CACHE} make_policy_access (a_db_handler: like db_handler) -- Initialize Access Layer Object. -- If `a_db_interface' is provided, it can be used to call other access-layer functions require a_db_handler_ok: a_db_handler /= Void do db_handler := a_db_handler db_interface := Void create select_query.make (Current) ensure db_handler_set: db_handler = a_db_handler interface_void: db_interface = Void end feature -- Access last_user_associations: LIST [USER_ASSOCIATION] -- Last retrieved user associations. last_user_project_associations: LIST [USER_PROJECT_ASSOCIATION] -- Last retrieved user project associations. last_user_community_associations: LIST [USER_COMMUNITY_ASSOCIATION] -- Last retrieved user community associations. last_access_groups: ARRAYED_LIST [INTEGER] -- last retrieved access groups. policies: LIST [POLICY] -- Last retrieved policies. feature -- Select Queries retrieve_user_association (a_user: INTEGER) -- Retrieve user associations for a_user. require a_user_set: a_user >= 0 local l_selection: DB_SELECTION l_list_filling: DB_ACTION [USER_ASSOCIATION] l_obj: USER_ASSOCIATION do create l_obj.make create l_selection.make l_selection.set_map_name (a_user, "user_id") l_selection.set_query ("SELECT * FROM user_association WHERE user_id=:user_id") l_selection.execute_query handle_errors_and_warnings l_selection.object_convert (l_obj) create l_list_filling.make (l_selection, l_obj) l_selection.set_action (l_list_filling) l_selection.load_result l_selection.terminate last_user_associations := l_list_filling.list ensure last_user_associations_filled: last_user_associations /= Void end retrieve_user_project_association (a_user: INTEGER) -- Retrieve user project associations for a_user. require a_user_set: a_user >= 0 local l_selection: DB_SELECTION l_list_filling: DB_ACTION [USER_PROJECT_ASSOCIATION] l_obj: USER_PROJECT_ASSOCIATION do create l_obj.make create l_selection.make l_selection.set_map_name (a_user, "user_id") l_selection.set_query ("SELECT * FROM user_project_association WHERE user_id=:user_id") l_selection.execute_query handle_errors_and_warnings l_selection.object_convert (l_obj) create l_list_filling.make (l_selection, l_obj) l_selection.set_action (l_list_filling) l_selection.load_result l_selection.terminate last_user_project_associations := l_list_filling.list ensure last_user_project_associations_filled: last_user_project_associations /= Void end retrieve_user_community_association (a_user_id: INTEGER) -- Retrieve user community associations for a_user. require a_user_id_set: a_user_id >= 0 local l_selection: DB_SELECTION l_list_filling: DB_ACTION [USER_COMMUNITY_ASSOCIATION] l_obj: USER_COMMUNITY_ASSOCIATION do create l_obj.make create l_selection.make l_selection.set_map_name (a_user_id, "user_id") l_selection.set_query ("SELECT * FROM user_community_association WHERE user_id=:user_id") l_selection.execute_query handle_errors_and_warnings l_selection.object_convert (l_obj) create l_list_filling.make (l_selection, l_obj) l_selection.set_action (l_list_filling) l_selection.load_result l_selection.terminate last_user_community_associations := l_list_filling.list ensure last_user_community_associations_filled: last_user_community_associations /= Void end retrieve_access_groups (a_kind: STRING) -- Retrieve all possible global access groups. require a_kind_valid: a_kind /= Void and then (a_kind.is_equal ("global") or a_kind.is_equal ("project") or a_kind.is_equal ("community")) local l_selection: DB_SELECTION l_groups: ARRAYED_LIST [DB_RESULT] l_grp: DB_TUPLE do create l_groups.make (10) create l_selection.make l_selection.set_container (l_groups) l_selection.set_map_name (a_kind, "kind") l_selection.set_query ("SELECT group_id FROM access_group WHERE kind=:kind") l_selection.execute_query handle_errors_and_warnings l_selection.load_result l_selection.terminate from create last_access_groups.make (l_groups.count) l_groups.start until l_groups.after loop create l_grp.copy (l_groups.item) last_access_groups.force (l_grp.item (1).out.to_integer) l_groups.forth end ensure last_access_groups_set: last_access_groups /= Void end retrieve_policies -- Retrieve all policies. local l_selection: DB_SELECTION l_list_filling: DB_ACTION [POLICY] l_policy: POLICY do create l_policy.make create l_selection.make l_selection.set_query ("SELECT * FROM policy") l_selection.execute_query handle_errors_and_warnings l_selection.object_convert (l_policy) create l_list_filling.make (l_selection, l_policy) l_selection.set_action (l_list_filling) l_selection.load_result l_selection.terminate policies := l_list_filling.list ensure policies_filled: policies /= Void end end