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.web.task;
35
36 import fr.paris.lutece.plugins.workflowcore.service.task.ITask;
37 import fr.paris.lutece.plugins.workflowcore.web.task.ITaskComponent;
38 import fr.paris.lutece.plugins.workflowcore.web.task.ITaskComponentManager;
39 import fr.paris.lutece.portal.service.spring.SpringContextService;
40
41 import java.util.List;
42 import java.util.Locale;
43
44 import javax.servlet.http.HttpServletRequest;
45
46
47
48
49
50
51 public class TaskComponentManager implements ITaskComponentManager
52 {
53
54
55
56 public static final String BEAN_MANAGER = "workflow.taskComponentManager";
57
58
59
60
61 @Override
62 public List<ITaskComponent> getTaskComponents( )
63 {
64 return SpringContextService.getBeansOfType( ITaskComponent.class );
65 }
66
67
68
69
70 @Override
71 public ITaskComponent getTaskComponent( String strKey )
72 {
73 for ( ITaskComponent component : getTaskComponents( ) )
74 {
75 if ( component.isInvoked( strKey ) )
76 {
77 return component;
78 }
79 }
80
81 return null;
82 }
83
84
85
86
87 @Override
88 public ITaskComponent getTaskComponent( ITask task )
89 {
90 if ( ( task != null ) && ( task.getTaskType( ) != null ) )
91 {
92 return getTaskComponent( task.getTaskType( ).getKey( ) );
93 }
94
95 return null;
96 }
97
98
99
100
101 @Override
102 public String getDisplayTaskForm( int nIdResource, String strResourceType, HttpServletRequest request, Locale locale, ITask task )
103 {
104 ITaskComponent component = getTaskComponent( task );
105
106 if ( component != null )
107 {
108 return component.getDisplayTaskForm( nIdResource, strResourceType, request, locale, task );
109 }
110
111 return null;
112 }
113
114
115
116
117 @Override
118 public String getDisplayConfigForm( HttpServletRequest request, Locale locale, ITask task )
119 {
120 ITaskComponent component = getTaskComponent( task );
121
122 if ( component != null )
123 {
124 return component.getDisplayConfigForm( request, locale, task );
125 }
126
127 return null;
128 }
129
130
131
132
133 @Override
134 public String getDisplayTaskInformation( int nIdHistory, HttpServletRequest request, Locale locale, ITask task )
135 {
136 ITaskComponent component = getTaskComponent( task );
137
138 if ( component != null )
139 {
140 return component.getDisplayTaskInformation( nIdHistory, request, locale, task );
141 }
142
143 return null;
144 }
145
146
147
148
149 @Override
150 public String doValidateTask( int nIdResource, String strResourceType, HttpServletRequest request, Locale locale, ITask task )
151 {
152 ITaskComponent component = getTaskComponent( task );
153
154 if ( component != null )
155 {
156 return component.doValidateTask( nIdResource, strResourceType, request, locale, task );
157 }
158
159 return null;
160 }
161
162
163
164
165 @Override
166 public String doSaveConfig( HttpServletRequest request, Locale locale, ITask task )
167 {
168 ITaskComponent component = getTaskComponent( task );
169
170 if ( component != null )
171 {
172 return component.doSaveConfig( request, locale, task );
173 }
174
175 return null;
176 }
177 }