indexing description: "Project change settings message" author: "Dominique Schneider " date: "$Date: 2008-03-06 02:46:58 +0100 (Thu, 06 Mar 2008) $" revision: "$Revision: 2047 $" class O_PROJECT_CHANGE_SETTINGS_MESSAGE inherit O_SESSION_MESSAGE rename make as make_session redefine make_from_generic, arguments end O_PROJECT_CONSTANTS undefine out end create make create {O_MESSAGE_FACTORY} make_from_generic feature {NONE} -- Initialization make (a_session: like session; a_project_id: like project_id; a_settings: like settings) is -- Create. require a_session_ok: a_session /= Void and then not a_session.is_empty a_settings_ok: a_settings /= Void a_project_id_ok: a_project_id > 0 do make_session (a_session) settings := a_settings project_id := a_project_id ensure settings_set: settings = a_settings project_id_set: project_id = a_project_id end make_from_generic (a_msg: O_GENERIC_MESSAGE) is -- Create from a generic message. local l_args: HASH_TABLE [STRING, STRING] i: INTEGER l_tuple: TUPLE[setting_type: STRING; setting_value: STRING] l_elements: LIST[STRING] l_setting_value: STRING do Precursor (a_msg) l_args := a_msg.arguments project_id := l_args.item (project_id_argument).to_integer from i := 1 create settings.make (l_args.count - 2) until i > l_args.count - 2 loop l_elements := l_args.item (settings_argument + i.out).split ('%N') check l_elements_count_correct: l_elements.count >= 2 end -- handle special informations with %N included if l_elements.count > 2 then from l_elements.start l_elements.forth l_setting_value := l_elements.item.out l_elements.forth until l_elements.after loop l_setting_value.append ("%N") l_setting_value.append (l_elements.item.out) l_elements.forth end else l_setting_value := l_elements.i_th (2).out end create l_tuple l_tuple.setting_type := l_elements.i_th (1).out l_tuple.setting_value := l_setting_value settings.force (l_tuple) i := i + 1 end end feature -- Access namespace: STRING is -- Namespace of the message type. once Result := project_namespace end type: STRING is -- Type of the message. once Result := project_change_settings_type end project_id: INTEGER -- ID of project settings: ARRAYED_LIST [TUPLE [setting_type: STRING; setting_value: STRING]] -- List of informations with [setting_type, setting_value] arguments: HASH_TABLE [STRING, STRING] is -- Named arguments. local i: INTEGER do Result := Precursor Result.force (project_id.out, project_id_argument) from settings.start i := 1 until settings.after loop Result.force (settings.item.setting_type.out + "%N" + settings.item.setting_value.out, settings_argument + i.out) settings.forth i := i + 1 end end feature {NONE} -- Implementation settings_argument: STRING is "settings" project_id_argument: STRING is "project_id" invariant settings_ok: settings /= Void project_id_ok: project_id > 0 end