note description: "API interface to internal release services." author: "Peter Wyss " date: "$Date$" revision: "$Revision$" class INTERNAL_RELEASE_SERVICE inherit API_SERVICE create make feature -- Basic operations release_list (a_project: INTEGER_REF): ARRAY [DS_HASH_TABLE [ANY, STRING]] -- List releases for a_project local l_msg: O_RELEASE_LIST_INTERNAL_MESSAGE l_release_list_reply_msg: O_RELEASE_LIST_REPLY_MESSAGE l_release_map: DS_HASH_TABLE[O_RELEASE_RELEASE_MESSAGE, A_STRING_VALUE] l_release_files: DS_ARRAYED_LIST[O_RELEASE_LIST_FILE_MESSAGE] l_release: DS_HASH_TABLE [ANY, STRING] i, j: INTEGER l_rid_ref: INTEGER_REF l_pid_ref: INTEGER_REF l_creation_time_ref: INTEGER_REF l_release_files_count_ref: INTEGER_REF do -- argument validiation if a_project <= 0 then last_fault := err_invalid_project else create l_msg.make (create {A_INTEGER_VALUE}.make (a_project.item)) send_and_wait_for_reply (l_msg) if is_ok then l_release_list_reply_msg ?= last_reply check release_list_reply_message: l_release_list_reply_msg /= Void end l_release_map := l_release_list_reply_msg.release_list.map create Result.make (0, l_release_map.count-1) from l_release_map.start i := 0 until l_release_map.after loop create l_release.make (7) create l_rid_ref l_rid_ref.set_item (l_release_map.key_for_iteration.value.to_integer) l_release.force (l_rid_ref, "release_id") create l_pid_ref l_pid_ref.set_item (l_release_map.item_for_iteration.project.value.to_integer) l_release.force (l_pid_ref, "project_id") create l_creation_time_ref l_creation_time_ref.set_item (l_release_map.item_for_iteration.creation_time.value.to_integer) l_release.force (l_creation_time_ref, "creation_time") l_release.force (l_release_map.item_for_iteration.name.value, "name") l_release.force (l_release_map.item_for_iteration.description.value, "description") l_release.force (l_release_map.item_for_iteration.version.value, "version") l_release_files := l_release_map.item_for_iteration.files.sequence check l_release_files_valid: l_release_files /= Void end create l_release_files_count_ref l_release_files_count_ref.set_item (l_release_files.count) l_release.force (l_release_files_count_ref, "file_count") from l_release_files.start j := 1 until l_release_files.after loop l_release.force (l_release_files.item_for_iteration.name.value, "file_name_" + j.out) l_release.force (l_release_files.item_for_iteration.platform.value, "file_platform_" + j.out) l_release_files.forth j := j + 1 end Result.force (l_release, i) i := i + 1 l_release_map.forth end end end end release_retrieve (a_release_id: INTEGER_REF): DS_HASH_TABLE [ANY, STRING] -- Retrieve release local l_msg: O_RELEASE_RETRIEVE_INTERNAL_MESSAGE l_release_reply_msg: O_RELEASE_RETRIEVE_REPLY_MESSAGE l_release_files: DS_ARRAYED_LIST [O_RELEASE_RETRIEVE_FILE_MESSAGE] l_release_file: O_RELEASE_RETRIEVE_FILE_MESSAGE i: INTEGER l_rid_ref: INTEGER_REF l_pid_ref: INTEGER_REF l_creation_time_ref: INTEGER_REF l_release_files_count_ref: INTEGER_REF do -- argument validiation if a_release_id <= 0 then last_fault := err_invalid_release else create l_msg.make (create {A_INTEGER_VALUE}.make (a_release_id.item)) send_and_wait_for_reply (l_msg) if is_ok then l_release_reply_msg ?= last_reply check release_reply_message: l_release_reply_msg /= Void end create Result.make (7) create l_rid_ref l_rid_ref.set_item (a_release_id) Result.force (l_rid_ref, "release_id") create l_pid_ref l_pid_ref.set_item (l_release_reply_msg.project.value.to_integer) Result.force (l_pid_ref, "project_id") create l_creation_time_ref l_creation_time_ref.set_item (l_release_reply_msg.creation_time.value.to_integer) Result.force (l_creation_time_ref, "creation_time") Result.force (l_release_reply_msg.name.value, "name") Result.force (l_release_reply_msg.description.value, "description") Result.force (l_release_reply_msg.version.value, "version") l_release_files := l_release_reply_msg.files.sequence check release_files_valid: l_release_files /= Void end create l_release_files_count_ref l_release_files_count_ref.set_item (l_release_files.count) Result.force (l_release_files_count_ref, "file_count") check l_release_files_valid: l_release_files /= Void end from l_release_files.start i := 1 until l_release_files.after loop l_release_file := l_release_files.item_for_iteration Result.force (l_release_file.name.value, "file_name_" + i.out) Result.force (l_release_file.platform.value, "file_platform_" + i.out) -- Increment l_release_files.forth i := i + 1 end end end end feature -- Creation new_tuple (a_name: STRING): TUPLE -- Tuple of default-valued arguments to pass to call `a_name'. do if a_name.is_equal (release_list_name) then create {TUPLE [INTEGER_REF]}Result elseif a_name.is_equal (release_retrieve_name) then create {TUPLE [INTEGER_REF]}Result end end feature -- Initialisation self_register -- Register all actions for this service do register_with_help (agent release_list, release_list_name, "List releases.") register_with_help (agent release_retrieve, release_retrieve_name, "Retrieve releases.") end feature {NONE} -- Implementation release_list_name: STRING = "list" release_retrieve_name: STRING = "retrieve" end