Revision 41872
Added by Sandro La Bruzzo about 8 years ago
WorkflowsController.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
import java.io.StringReader; |
5 |
import java.time.LocalDate; |
|
5 | 6 |
import java.time.LocalDateTime; |
6 | 7 |
import java.time.format.DateTimeFormatter; |
7 |
import java.util.Collection; |
|
8 |
import java.util.Collections; |
|
9 |
import java.util.Comparator; |
|
10 |
import java.util.HashMap; |
|
11 |
import java.util.Iterator; |
|
12 |
import java.util.List; |
|
13 |
import java.util.Map; |
|
14 |
import java.util.Set; |
|
15 |
|
|
8 |
import java.util.*; |
|
16 | 9 |
import javax.annotation.Resource; |
17 | 10 |
import javax.servlet.http.HttpServletResponse; |
18 | 11 |
|
19 |
import org.apache.commons.io.IOUtils; |
|
20 |
import org.apache.commons.lang3.StringUtils; |
|
21 |
import org.apache.commons.lang3.math.NumberUtils; |
|
22 |
import org.apache.commons.logging.Log; |
|
23 |
import org.apache.commons.logging.LogFactory; |
|
24 |
import org.dom4j.Document; |
|
25 |
import org.dom4j.Element; |
|
26 |
import org.dom4j.Node; |
|
27 |
import org.dom4j.io.SAXReader; |
|
28 |
import org.springframework.beans.factory.annotation.Value; |
|
29 |
import org.springframework.core.io.ClassPathResource; |
|
30 |
import org.springframework.stereotype.Controller; |
|
31 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
32 |
import org.springframework.web.bind.annotation.RequestParam; |
|
33 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
34 |
|
|
35 | 12 |
import com.google.common.base.Function; |
36 | 13 |
import com.google.common.base.Splitter; |
37 | 14 |
import com.google.common.collect.Iterators; |
... | ... | |
40 | 17 |
import com.google.common.collect.Sets; |
41 | 18 |
import com.google.gson.Gson; |
42 | 19 |
import com.google.gson.reflect.TypeToken; |
43 |
|
|
44 | 20 |
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController; |
45 | 21 |
import eu.dnetlib.functionality.modular.ui.repositories.objects.RepoHIWorkflow; |
46 | 22 |
import eu.dnetlib.functionality.modular.ui.repositories.objects.VocabularyEntry; |
... | ... | |
61 | 37 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
62 | 38 |
import eu.dnetlib.rmi.data.ProtocolParameter; |
63 | 39 |
import eu.dnetlib.rmi.enabling.ISLookUpException; |
40 |
import org.apache.commons.io.IOUtils; |
|
41 |
import org.apache.commons.lang3.StringUtils; |
|
42 |
import org.apache.commons.lang3.math.NumberUtils; |
|
43 |
import org.apache.commons.logging.Log; |
|
44 |
import org.apache.commons.logging.LogFactory; |
|
45 |
import org.dom4j.Document; |
|
46 |
import org.dom4j.Element; |
|
47 |
import org.dom4j.Node; |
|
48 |
import org.dom4j.io.SAXReader; |
|
49 |
import org.springframework.beans.factory.annotation.Value; |
|
50 |
import org.springframework.core.io.ClassPathResource; |
|
51 |
import org.springframework.stereotype.Controller; |
|
52 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
53 |
import org.springframework.web.bind.annotation.RequestParam; |
|
54 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
64 | 55 |
|
65 | 56 |
/** |
66 | 57 |
* Web controller for the UI |
... | ... | |
237 | 228 |
final Map<String, ProcessInfo> res = Maps.newHashMap(); |
238 | 229 |
|
239 | 230 |
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
240 |
final LocalDateTime startDate = LocalDateTime.parse(start, formatter);
|
|
241 |
final LocalDateTime endDate = LocalDateTime.parse(start, formatter).plusHours(23).plusMinutes(59).plusSeconds(59);
|
|
231 |
final LocalDateTime startDate = LocalDate.parse(start, formatter).atTime(0, 0);
|
|
232 |
final LocalDateTime endDate = LocalDate.parse(end, formatter).atTime(23, 59);
|
|
242 | 233 |
|
243 | 234 |
final Iterator<ProcessInfo> iter = Iterators.transform(this.dnetLogger.range(startDate, endDate), new JournalEntryFunction()); |
244 | 235 |
while (iter.hasNext()) { |
245 | 236 |
final ProcessInfo e = iter.next(); |
246 |
|
|
247 |
e.setProcId("LOG: " + e.getProcId());; |
|
248 |
|
|
237 |
e.setProcId("LOG: " + e.getProcId()); |
|
249 | 238 |
res.put(e.getProcId(), e); |
250 | 239 |
} |
251 | 240 |
|
252 | 241 |
final LocalDateTime now = LocalDateTime.now(); |
253 |
|
|
254 | 242 |
if (startDate.isBefore(now) && endDate.isAfter(now)) { |
255 | 243 |
for (final WorkflowProcess proc : this.graphProcessRegistry.listProcesses()) { |
256 | 244 |
final ProcessInfo p = new ProcessInfo(proc); |
257 | 245 |
|
258 |
p.setProcId("REG: " + p.getProcId());;
|
|
246 |
p.setProcId("REG: " + p.getProcId()); |
|
259 | 247 |
|
260 | 248 |
res.put(proc.getId(), p); |
261 | 249 |
|
... | ... | |
343 | 331 |
return this.isRegistryClient.updateWorkflowProfile(wfId, xml, params); |
344 | 332 |
} |
345 | 333 |
|
346 |
private class JournalEntryFunction implements Function<Map<String, String>, ProcessInfo> { |
|
347 |
|
|
348 |
@Override |
|
349 |
public ProcessInfo apply(final Map<String, String> input) { |
|
350 |
final ProcessInfo info = new ProcessInfo(); |
|
351 |
|
|
352 |
info.setProcId(input.get(WorkflowsConstants.LOG_WF_PROCESS_ID)); |
|
353 |
info.setWfId(input.get(WorkflowsConstants.LOG_WF_PROFILE_ID)); |
|
354 |
info.setName(input.get(WorkflowsConstants.LOG_WF_NAME)); |
|
355 |
info.setFamily(input.get(WorkflowsConstants.LOG_WF_FAMILY)); |
|
356 |
info.setDatasource(input.containsKey(WorkflowsConstants.LOG_DATASOURCE_NAME) ? input.get(WorkflowsConstants.LOG_DATASOURCE_NAME) : ""); |
|
357 |
info.setStatus(input.get(WorkflowsConstants.LOG_WF_PROCESS_STATUS)); |
|
358 |
info.setDate(NumberUtils.toLong(input.get(LogMessage.LOG_DATE_FIELD), 0)); |
|
359 |
info.setStartDate(info.getStartDate()); |
|
360 |
info.setEndDate(info.getEndDate()); |
|
361 |
|
|
362 |
return info; |
|
363 |
} |
|
364 |
} |
|
365 |
|
|
366 | 334 |
@RequestMapping(value = "/ui/wf/obtainSubWorkflows.do") |
367 | 335 |
public @ResponseBody List<Map<String, String>> obtainSubWorkflows(@RequestParam(value = "id", required = true) final String wfId) { |
368 | 336 |
return this.isLookupClient.obtainSubWorkflows(wfId); |
... | ... | |
389 | 357 |
return Lists.newArrayList(this.workflowExecutor.startWorkflow(destroyWfId, null)); |
390 | 358 |
} |
391 | 359 |
|
360 |
private class JournalEntryFunction implements Function<Map<String, String>, ProcessInfo> { |
|
361 |
|
|
362 |
@Override |
|
363 |
public ProcessInfo apply(final Map<String, String> input) { |
|
364 |
final ProcessInfo info = new ProcessInfo(); |
|
365 |
|
|
366 |
info.setProcId(input.get(WorkflowsConstants.LOG_WF_PROCESS_ID)); |
|
367 |
info.setWfId(input.get(WorkflowsConstants.LOG_WF_PROFILE_ID)); |
|
368 |
info.setName(input.get(WorkflowsConstants.LOG_WF_NAME)); |
|
369 |
info.setFamily(input.get(WorkflowsConstants.LOG_WF_FAMILY)); |
|
370 |
info.setDatasource(input.containsKey(WorkflowsConstants.LOG_DATASOURCE_NAME) ? input.get(WorkflowsConstants.LOG_DATASOURCE_NAME) : ""); |
|
371 |
info.setStatus(input.get(WorkflowsConstants.LOG_WF_PROCESS_STATUS)); |
|
372 |
info.setDate(NumberUtils.toLong(input.get(LogMessage.LOG_DATE_FIELD), 0)); |
|
373 |
info.setStartDate(info.getStartDate()); |
|
374 |
info.setEndDate(info.getEndDate()); |
|
375 |
|
|
376 |
return info; |
|
377 |
} |
|
378 |
} |
|
379 |
|
|
392 | 380 |
} |
Also available in: Unified diff
have a nice holiday