1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.workflow.modules.reply.service.provider;
35
36 import java.util.ArrayList;
37 import java.util.Collection;
38 import java.util.List;
39
40 import javax.inject.Inject;
41 import javax.servlet.http.HttpServletRequest;
42
43 import fr.paris.lutece.plugins.workflow.service.taskinfo.ITaskInfoProvider;
44 import fr.paris.lutece.plugins.workflowcore.business.resource.ResourceHistory;
45 import fr.paris.lutece.plugins.workflowcore.service.provider.IMarkerProvider;
46 import fr.paris.lutece.plugins.workflowcore.service.provider.InfoMarker;
47 import fr.paris.lutece.plugins.workflowcore.service.task.ITask;
48 import fr.paris.lutece.plugins.workflowcore.service.task.ITaskService;
49 import javax.inject.Named;
50 import net.sf.json.JSONObject;
51
52
53
54
55
56 public class ReplyMarkerProvider implements IMarkerProvider
57 {
58 private static final String ID = "workflow-reply.taskReplyMarkerProvider";
59
60
61 private static final String MESSAGE_TITLE_KEY = "module.workflow.reply.marker.provider.taskreply.title";
62 private static final String MESSAGE_MARKER_MSG_DESCRIPTION_KEY = "module.workflow.reply.marker.provider.taskreply.msg.description";
63
64
65 private static final String MARK_REPLY_MESSAGE = "task_reply_message";
66
67
68
69 @Inject
70 private ITaskService _taskService;
71
72 @Inject
73 @Named(value="workflow-reply.replyTaskInfoProvider")
74 private ITaskInfoProvider _replyTaskInfoProvider;
75
76
77
78
79
80 @Override
81 public String getId( )
82 {
83 return ID;
84 }
85
86
87
88
89 @Override
90 public String getTitleI18nKey( )
91 {
92 return MESSAGE_TITLE_KEY ;
93 }
94
95
96
97
98 @Override
99 public Collection<InfoMarker> provideMarkerDescriptions( )
100 {
101 List<InfoMarker> listMarkers = new ArrayList<>( );
102
103 InfoMarker notifyGruMarkerMsg = new InfoMarker( MARK_REPLY_MESSAGE );
104 notifyGruMarkerMsg.setDescription( MESSAGE_MARKER_MSG_DESCRIPTION_KEY );
105 listMarkers.add( notifyGruMarkerMsg );
106
107 return listMarkers;
108 }
109
110
111
112
113 @Override
114 public Collection<InfoMarker> provideMarkerValues( ResourceHistory resourceHistory, ITask task, HttpServletRequest request )
115 {
116 List<InfoMarker> listMarkers = new ArrayList<>( );
117
118 for ( ITask taskOther : _taskService.getListTaskByIdAction( resourceHistory.getAction( ).getId( ), request.getLocale( ) ) )
119 {
120 if ( taskOther.getTaskType( ).getKey( ).equals( _replyTaskInfoProvider.getTaskType( ).getKey( ) ) )
121 {
122 String strJsonInfos = _replyTaskInfoProvider.getTaskResourceInfo( resourceHistory.getId( ), taskOther.getId( ), request ) ;
123
124 JSONObject jsonInfos = JSONObject.fromObject( strJsonInfos );
125 String strMsg = jsonInfos.getString( MARK_REPLY_MESSAGE );
126
127
128 InfoMarker notifyGruMarkerMsg = new InfoMarker( MARK_REPLY_MESSAGE );
129 notifyGruMarkerMsg.setValue( strMsg );
130 listMarkers.add( notifyGruMarkerMsg );
131
132 break;
133 }
134 }
135
136 return listMarkers;
137 }
138
139 }
140