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.task;
35
36 import fr.paris.lutece.plugins.workflow.modules.reply.business.task.Reply;
37 import fr.paris.lutece.plugins.workflow.modules.reply.service.IReplyService;
38 import fr.paris.lutece.plugins.workflow.modules.reply.util.constants.ReplyConstants;
39 import java.util.Locale;
40
41 import javax.servlet.http.HttpServletRequest;
42
43 import org.apache.commons.lang.StringUtils;
44
45 import fr.paris.lutece.plugins.workflowcore.service.config.ITaskConfigService;
46 import fr.paris.lutece.plugins.workflowcore.service.task.Task;
47 import fr.paris.lutece.portal.business.user.AdminUser;
48 import fr.paris.lutece.portal.service.i18n.I18nService;
49 import java.util.Map;
50 import javax.inject.Inject;
51 import javax.inject.Named;
52
53
54
55
56
57 public class TaskReply extends Task
58 {
59 private static final String MESSAGE_REPLY = "module.workflow.reply.task_reply.labelReply";
60
61
62 public static final String PARAMETER_USER_MESSAGE = "user_message";
63
64
65 private AdminUser _user;
66
67 @Inject
68 private IReplyService _replyService;
69 @Inject
70 @Named( ReplyConstants.BEAN_REPLY_CONFIG_SERVICE )
71 private ITaskConfigService _taskReplyConfigService;
72
73
74
75
76 @Override
77 public String getTitle( Locale locale )
78 {
79 return I18nService.getLocalizedString( MESSAGE_REPLY, locale );
80 }
81
82
83
84
85 @Override
86 public void init( )
87 {
88 }
89
90
91
92
93 @Override
94 public void processTask( int nIdResourceHistory, HttpServletRequest request, Locale locale )
95 {
96 String strMessage = request.getParameter( ReplyConstants.PARAMETER_REPLY_MESSAGE + ReplyConstants.UNDERSCORE + getId( ) );
97
98 boolean bCreate = false;
99
100 Reply reply = _replyService.find( nIdResourceHistory, getId( ) );
101
102 if ( reply == null )
103 {
104 reply = new Reply( );
105 reply.setIdHistory( nIdResourceHistory );
106 reply.setIdTask( getId( ) );
107 bCreate = true;
108 }
109
110 reply.setMessage( StringUtils.isNotBlank( strMessage ) ? strMessage : StringUtils.EMPTY );
111
112 if ( bCreate )
113 {
114 _replyService.create( reply );
115 }
116 else
117 {
118 _replyService.update( reply );
119 }
120 }
121
122
123
124
125
126
127 @Override
128 public Map<String, String> getTaskFormEntries( Locale locale )
129 {
130 return null;
131 }
132
133
134
135
136 @Override
137 public void doRemoveConfig( )
138 {
139 _replyService.removeByIdTask( getId( ) );
140 _taskReplyConfigService.remove( getId( ) );
141 }
142
143
144
145
146 @Override
147 public void doRemoveTaskInformation( int nIdHistory )
148 {
149 _replyService.removeByIdHistory( nIdHistory, getId( ) );
150 }
151 }