2023-03-10 15:20:49 +01:00
|
|
|
package eu.dnetlib.manager.wf;
|
|
|
|
|
|
|
|
import java.util.List;
|
2023-03-21 12:13:23 +01:00
|
|
|
import java.util.stream.Collectors;
|
2023-03-10 15:20:49 +01:00
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
2023-03-21 12:13:23 +01:00
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
2023-03-10 15:20:49 +01:00
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import eu.dnetlib.common.controller.AbstractDnetController;
|
2023-03-21 12:13:23 +01:00
|
|
|
import eu.dnetlib.is.info.KeyValue;
|
2023-03-10 15:20:49 +01:00
|
|
|
import eu.dnetlib.manager.wf.model.WorkflowInstance;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/ajax/wf_instances")
|
|
|
|
public class WfInstancesController extends AbstractDnetController {
|
|
|
|
|
|
|
|
private WorkflowManagerService wfManagerService;
|
|
|
|
|
|
|
|
@GetMapping("/instance/{id}")
|
|
|
|
public WorkflowInstance getWfInstance(@PathVariable final String id) throws Exception {
|
|
|
|
return wfManagerService.findWorkflowInstance(id);
|
|
|
|
}
|
|
|
|
|
2023-03-21 12:13:23 +01:00
|
|
|
@GetMapping("/search")
|
|
|
|
public List<KeyValue<String>> listWfInstances(@RequestParam final String section) throws Exception {
|
|
|
|
return wfManagerService.streamWfInstancesBySection(section)
|
|
|
|
.map(x -> new KeyValue<>(x.getId(), x.getName()))
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/sections")
|
|
|
|
public List<KeyValue<Long>> listWfFamilies() throws Exception {
|
|
|
|
return wfManagerService.streamSections()
|
|
|
|
.map(x -> new KeyValue<>(x.getValue(), x.getCount()))
|
|
|
|
.collect(Collectors.toList());
|
2023-03-10 15:20:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|