indexing description: "User set workitem subscription message." author: "Peter Wyss " date: "$Date$" revision: "$Revision$" class O_USER_SET_WORKITEM_SUBSCRIPTION_MESSAGE inherit O_SESSION_MESSAGE rename make as make_session redefine make_from_generic, arguments end O_USER_CONSTANTS undefine out end create make create {O_MESSAGE_FACTORY} make_from_generic feature {NONE} -- Initialization make (a_session: like session; a_project: like project; a_settings: like settings) is -- Create. require a_session_ok: a_session /= Void and then not a_session.is_empty a_project_ok: a_project > 0 a_settings_ok: a_settings /= Void and then not a_settings.is_empty do make_session (a_session) project := a_project settings := a_settings ensure project_set: project = a_project settings_set: settings = a_settings 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[workitem_type: INTEGER; subscription_type: INTEGER; is_enabled: BOOLEAN] l_elements: LIST[STRING] do Precursor (a_msg) l_args := a_msg.arguments project := l_args.item (project_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 = 3 end create l_tuple l_tuple.workitem_type := l_elements.i_th (1).to_integer l_tuple.subscription_type := l_elements.i_th (2).to_integer l_tuple.is_enabled := l_elements.i_th (3).to_boolean settings.force (l_tuple) i := i + 1 end end feature -- Access namespace: STRING is -- Namespace of the message type. once Result := user_namespace end type: STRING is -- Type of the message. once Result := user_set_workitem_subscription_type end project: INTEGER -- id of the project settings: ARRAYED_LIST [TUPLE [workitem_type: INTEGER; subscription_type: INTEGER; is_enabled: BOOLEAN]] -- List of settings with [workitem_type, subscription_type, is_enabled] arguments: HASH_TABLE [STRING, STRING] is -- Named arguments. local i: INTEGER do Result := Precursor Result.force (project.out, project_argument) from settings.start i := 1 until settings.after loop Result.force (settings.item.workitem_type.out + "%N" + settings.item.subscription_type.out + "%N" + settings.item.is_enabled.out, settings_argument + i.out) settings.forth i := i + 1 end end feature {NONE} -- Implementation project_argument: STRING is "project" settings_argument: STRING is "settings" invariant project_ok: project > 0 settings_ok: settings /= Void and then not settings.is_empty end