note description: "Provide an interface to release data." author: "Peter Wyss " date: "$Date$" revision: "$Revision$" class RELEASE_INTERFACE inherit BASE_INTERFACE O_WORKITEM_CONSTANTS create make feature -- Commands release_list_do (a_project: INTEGER; a_msg: A_MESSAGE) -- List workitems. require a_msg_ok: a_msg /= Void local l_reply: O_RELEASE_LIST_REPLY_MESSAGE l_releases: DS_HASH_TABLE [O_RELEASE_RELEASE_MESSAGE, A_STRING_VALUE] l_release_item: O_RELEASE_RELEASE_MESSAGE l_file_list: DS_ARRAYED_LIST[O_RELEASE_LIST_FILE_MESSAGE] l_files: ARRAYED_LIST [TUPLE [name: STRING; platform: STRING]] l_query_result: ARRAYED_LIST[TUPLE [release_id: INTEGER; project: INTEGER; creation_time: INTEGER; name: STRING; description: STRING; version: STRING; files: ARRAYED_LIST [TUPLE [name: STRING; platform: STRING]]]] do l_query_result := release_access.retrieve_releases (a_project) from create l_releases.make (l_query_result.count) l_query_result.start until l_query_result.after loop l_files := l_query_result.item.files create l_file_list.make (l_files.count) from l_files.start until l_files.after loop l_file_list.force_last (create {O_RELEASE_LIST_FILE_MESSAGE}.make ( create {A_STRING_VALUE}.make (l_files.item_for_iteration.name), create {A_STRING_VALUE}.make (l_files.item_for_iteration.platform)) ) l_files.forth end create l_release_item.make ( create {A_INTEGER_VALUE}.make(l_query_result.item.project), create {A_INTEGER_VALUE}.make(l_query_result.item.creation_time), create {A_STRING_VALUE}.make(l_query_result.item.name), create {A_STRING_VALUE}.make(l_query_result.item.description), create {A_STRING_VALUE}.make(l_query_result.item.version), create {A_SEQUENCE_VALUE [O_RELEASE_LIST_FILE_MESSAGE]}.make(l_file_list)) l_releases.force (l_release_item, create {A_STRING_VALUE}.make (l_query_result.item.release_id.out)) l_query_result.forth end create l_reply.make(create {A_MAP_VALUE [O_RELEASE_RELEASE_MESSAGE]}.make (l_releases)) node.send_message_reply (l_reply, a_msg) end release_list (a_msg: A_MESSAGE) -- List workitems. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_LIST_MESSAGE l_status: A_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check release_list_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session.value) if user_access.is_found then -- retrieve releases and map them into a HASH_TABLE release_list_do (l_msg.project.value.to_integer, a_msg) else create l_status.make (create {A_BOOLEAN_VALUE}.make (False), create {A_STRING_VALUE}.make (err_session_timeout)) node.send_message_reply (l_status, a_msg) end end release_list_internal (a_msg: A_MESSAGE) -- List workitems. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_LIST_INTERNAL_MESSAGE do l_msg ?= a_msg check release_list_message: l_msg /= Void end release_list_do (l_msg.project.value.to_integer, a_msg) end release_retrieve_do (a_release_id: INTEGER; a_msg: A_MESSAGE) -- Retrieve release. require a_msg_ok: a_msg /= Void local l_reply: O_RELEASE_RETRIEVE_REPLY_MESSAGE l_files: ARRAYED_LIST [TUPLE [name: STRING; platform: STRING]] l_file_list: DS_ARRAYED_LIST [O_RELEASE_RETRIEVE_FILE_MESSAGE] l_status: A_GENERAL_STATUS_MESSAGE do release_access.retrieve_release_by_id (a_release_id) if release_access.is_found then l_files := release_access.last_release.files create l_file_list.make (l_files.count) from l_files.start until l_files.after loop l_file_list.force_last ( create {O_RELEASE_RETRIEVE_FILE_MESSAGE}.make ( create {A_STRING_VALUE}.make (l_files.item_for_iteration.name), create {A_STRING_VALUE}.make (l_files.item_for_iteration.platform)) ) -- Increment l_files.forth end create l_reply.make ( create {A_INTEGER_VALUE}.make (release_access.last_release.project_id), create {A_INTEGER_VALUE}.make (release_access.last_release.creation_time), create {A_STRING_VALUE}.make (release_access.last_release.name), create {A_STRING_VALUE}.make (release_access.last_release.description), create {A_STRING_VALUE}.make (release_access.last_release.version), create {A_SEQUENCE_VALUE [O_RELEASE_RETRIEVE_FILE_MESSAGE]}.make (l_file_list)) node.send_message_reply (l_reply, a_msg) else create l_status.make (create {A_BOOLEAN_VALUE}.make (False), create {A_STRING_VALUE}.make (err_invalid_release)) node.send_message_reply (l_status, a_msg) end end release_retrieve (a_msg: A_MESSAGE) -- Retrieve release. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_RETRIEVE_MESSAGE l_status: A_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end user_access.retrieve_user_by_session (l_msg.session.value) if user_access.is_found then -- retrieve release release_retrieve_do(l_msg.release_id.value.to_integer, a_msg) else create l_status.make (create {A_BOOLEAN_VALUE}.make (False), create {A_STRING_VALUE}.make (err_session_timeout)) node.send_message_reply (l_status, a_msg) end end release_retrieve_internal (a_msg: A_MESSAGE) -- Retrieve release. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_RETRIEVE_INTERNAL_MESSAGE do l_msg ?= a_msg check valid_message: l_msg /= Void end release_retrieve_do(l_msg.release_id.value.to_integer, a_msg) end release_add (a_msg: A_MESSAGE) -- Add a new release according to a_msg. require a_msg_ok: a_msg /= Void local l_pc_msg: O_RELEASE_ADD_MESSAGE l_workitem_add_reply: O_RELEASE_ADD_STORAGE_REPLY_MESSAGE l_release: RELEASE l_release_file: RELEASE_FILE l_status: A_GENERAL_STATUS_MESSAGE l_user_ret: USER l_project_ret: PROJECT l_release_id: INTEGER l_file_list: DS_ARRAYED_LIST [O_RELEASE_ADD_FILE_MESSAGE] l_file_tuple_list: DS_ARRAYED_LIST [TUPLE [name: STRING_8; platform: STRING_8]] l_file_tuple: TUPLE [name: STRING_8; platform: STRING_8] l_release_workitem: WI_FULL_RELEASE do l_pc_msg ?= a_msg check release_add_message: l_pc_msg /= Void end user_access.retrieve_user_by_session (l_pc_msg.session.value) if user_access.is_found then l_user_ret := user_access.last_user project_access.retrieve_project_by_id (l_pc_msg.project_id.value.to_integer) if project_access.is_found then l_project_ret := project_access.last_project create l_release.make l_release.set_project_id (l_project_ret.project_id) l_release.set_name (l_pc_msg.name.value) l_release.set_description (l_pc_msg.description.value) l_release.set_version (l_pc_msg.version.value) release_access.insert_release(l_release) l_release_id := release_access.last_insert_id from l_file_list := l_pc_msg.files.sequence l_file_list.start create l_file_tuple_list.make (l_file_list.count) until l_file_list.after loop create l_release_file.make l_release_file.set_name (l_file_list.item_for_iteration.name.value) l_release_file.set_platform (l_file_list.item_for_iteration.platform.value) l_release_file.set_release_id (l_release_id) release_access.insert_release_file (l_release_file) -- Add to tuple-list create l_file_tuple l_file_tuple.name := l_file_list.item_for_iteration.name l_file_tuple.platform := l_file_list.item_for_iteration.platform l_file_tuple_list.force_last (l_file_tuple) -- Increment l_file_list.forth end -- Create work item create l_release_workitem.make ( l_project_ret.project_id, l_project_ret.name, l_user_ret.user_id, l_user_ret.name, get_project_link (l_project_ret.name) + "/download/" + l_release_id.out, l_pc_msg.name, l_release_id, l_pc_msg.version, l_pc_msg.description, l_file_tuple_list) workitem_access.store_wi (l_release_workitem) create l_workitem_add_reply.make ( workitem_access.last_insert_id, l_project_ret.name, l_user_ret.name, l_release_id) node.send_message_reply (l_workitem_add_reply, a_msg) else create l_status.make (False, err_invalid_project) node.send_message_reply (l_status, a_msg) end else create l_status.make (False, err_session_timeout) node.send_message_reply (l_status, a_msg) end end release_delete (a_msg: A_MESSAGE) -- Delete a release according to a_msg. require a_msg_ok: a_msg /= Void local l_msg: O_RELEASE_DELETE_MESSAGE l_status: A_GENERAL_STATUS_MESSAGE do l_msg ?= a_msg check valid_msg: l_msg /= Void end release_access.retrieve_release_by_id (l_msg.release_id.value.to_integer) if release_access.is_found then if release_access.last_release.project_id = l_msg.project_id.value then release_access.delete_release (l_msg.release_id.value.to_integer) create l_status.make (True, Void) else create l_status.make (False, err_access_denied) end else create l_status.make (False, err_invalid_release) end -- send status node.send_message_reply (l_status, a_msg) end end