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.extendfeedback.service;
35
36 import java.util.Locale;
37 import java.util.Optional;
38
39 import javax.inject.Inject;
40 import javax.inject.Named;
41 import javax.servlet.http.HttpServletRequest;
42
43 import fr.paris.lutece.plugins.extend.modules.feedback.business.ExtendFeedback;
44 import fr.paris.lutece.plugins.extend.modules.feedback.service.ExtendFeedbackService;
45 import fr.paris.lutece.plugins.extend.modules.feedback.service.IExtendFeedbackService;
46 import fr.paris.lutece.plugins.workflow.modules.extendfeedback.business.UpdateStatusFeedbackConfig;
47 import fr.paris.lutece.plugins.workflow.modules.extendfeedback.util.WfExtendFeedbackConstants;
48 import fr.paris.lutece.plugins.workflowcore.business.resource.ResourceHistory;
49 import fr.paris.lutece.plugins.workflowcore.service.config.ITaskConfigService;
50 import fr.paris.lutece.plugins.workflowcore.service.resource.IResourceHistoryService;
51 import fr.paris.lutece.plugins.workflowcore.service.resource.ResourceHistoryService;
52 import fr.paris.lutece.plugins.workflowcore.service.task.SimpleTask;
53 import fr.paris.lutece.portal.service.i18n.I18nService;
54
55
56
57
58
59
60 public class UpdateStatusFeedbackTask extends SimpleTask
61 {
62
63 @Inject
64 @Named( WfExtendFeedbackConstants.BEAN_TASK_CONFIG_SERVICE )
65 private ITaskConfigService _taskConfigService;
66
67 @Inject
68 @Named( ExtendFeedbackService.BEAN_SERVICE )
69 private IExtendFeedbackService _extendFeedbackService;
70
71 @Inject
72 @Named( ResourceHistoryService.BEAN_SERVICE )
73 private IResourceHistoryService _resourceHistoryService;
74
75 @Override
76 public void processTask( int nIdResourceHistory, HttpServletRequest request, Locale locale )
77 {
78 UpdateStatusFeedbackConfig config = _taskConfigService.findByPrimaryKey( getId( ) );
79
80 ResourceHistory resourceHistory = _resourceHistoryService.findByPrimaryKey( nIdResourceHistory );
81
82 if ( resourceHistory != null )
83 {
84 Optional<ExtendFeedback> extendFeedback = _extendFeedbackService.findById( resourceHistory.getIdResource( ) );
85
86 if ( extendFeedback.isPresent( ) && config != null )
87 {
88 extendFeedback.get( ).setStatus( config.isStatus( ) );
89 _extendFeedbackService.update( extendFeedback.get( ) );
90 }
91 }
92 }
93
94 @Override
95 public String getTitle( Locale locale )
96 {
97 return I18nService.getLocalizedString( getTaskType( ).getTitleI18nKey( ), locale );
98 }
99
100 @Override
101 public void doRemoveConfig( )
102 {
103 _taskConfigService.remove( getId( ) );
104 }
105
106 }