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.comment.service;
35
36 import fr.paris.lutece.plugins.workflow.modules.comment.business.CommentValue;
37 import fr.paris.lutece.plugins.workflow.modules.comment.business.TaskCommentConfig;
38 import fr.paris.lutece.plugins.workflow.utils.WorkflowUtils;
39 import fr.paris.lutece.plugins.workflowcore.service.config.ITaskConfigService;
40 import fr.paris.lutece.plugins.workflowcore.service.task.Task;
41
42 import org.apache.commons.lang3.StringUtils;
43
44 import java.util.HashMap;
45 import java.util.Locale;
46 import java.util.Map;
47
48 import javax.inject.Inject;
49 import javax.inject.Named;
50
51 import javax.servlet.http.HttpServletRequest;
52
53
54
55
56
57
58 public class TaskComment extends Task
59 {
60 private static final String PARAMETER_COMMENT_VALUE = "comment_value";
61 private static final String BEAN_COMMENT_CONFIG_SERVICE = "workflow.taskCommentConfigService";
62 @Inject
63 @Named( BEAN_COMMENT_CONFIG_SERVICE )
64 private ITaskConfigService _taskCommentConfigService;
65 @Inject
66 private ICommentValueService _commentValueService;
67
68
69
70
71 @Override
72 public void init( )
73 {
74
75 }
76
77
78
79
80 @Override
81 public void processTask( int nIdResourceHistory, HttpServletRequest request, Locale locale )
82 {
83 String strCommentValue = request.getParameter( PARAMETER_COMMENT_VALUE + "_" + this.getId( ) );
84 CommentValueflow/modules/comment/business/CommentValue.html#CommentValue">CommentValue commentValue = new CommentValue( );
85 commentValue.setIdResourceHistory( nIdResourceHistory );
86 commentValue.setIdTask( this.getId( ) );
87 commentValue.setValue( strCommentValue );
88 _commentValueService.create( commentValue, WorkflowUtils.getPlugin( ) );
89 }
90
91
92
93
94 @Override
95 public void doRemoveConfig( )
96 {
97 _taskCommentConfigService.remove( this.getId( ) );
98 _commentValueService.removeByTask( this.getId( ), WorkflowUtils.getPlugin( ) );
99 }
100
101
102
103
104 @Override
105 public void doRemoveTaskInformation( int nIdHistory )
106 {
107 _commentValueService.removeByHistory( nIdHistory, this.getId( ), WorkflowUtils.getPlugin( ) );
108 }
109
110
111
112
113 @Override
114 public String getTitle( Locale locale )
115 {
116 TaskCommentConfig config = _taskCommentConfigService.findByPrimaryKey( this.getId( ) );
117
118 if ( config != null )
119 {
120 return config.getTitle( );
121 }
122
123 return StringUtils.EMPTY;
124 }
125
126
127
128
129 @Override
130 public Map<String, String> getTaskFormEntries( Locale locale )
131 {
132 Map<String, String> mapEntriesForm = null;
133 TaskCommentConfig config = _taskCommentConfigService.findByPrimaryKey( this.getId( ) );
134
135 if ( config != null )
136 {
137 mapEntriesForm = new HashMap<>( );
138 mapEntriesForm.put( PARAMETER_COMMENT_VALUE + "_" + this.getId( ), config.getTitle( ) );
139 }
140
141 return mapEntriesForm;
142 }
143 }