1
|
package eu.dnetlib.msro.worker;
|
2
|
|
3
|
import java.awt.Image;
|
4
|
import java.io.IOException;
|
5
|
|
6
|
import javax.imageio.ImageIO;
|
7
|
import javax.xml.ws.soap.MTOM;
|
8
|
|
9
|
import org.apache.commons.logging.Log;
|
10
|
import org.apache.commons.logging.LogFactory;
|
11
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
|
13
|
import com.googlecode.sarasvati.GraphProcess;
|
14
|
import com.googlecode.sarasvati.visual.ProcessImageMapCreator;
|
15
|
|
16
|
import eu.dnetlib.common.services.AbstractBaseService;
|
17
|
import eu.dnetlib.msro.worker.ui.ProcessToImageMapHelper;
|
18
|
import eu.dnetlib.rmi.soap.ManagerWorkerService;
|
19
|
|
20
|
@MTOM
|
21
|
public class ManagerWorkerServiceImpl extends AbstractBaseService implements ManagerWorkerService {
|
22
|
|
23
|
@Autowired
|
24
|
private LocalWorkflowRegistry registry;
|
25
|
private static final Log log = LogFactory.getLog(ManagerWorkerServiceImpl.class);
|
26
|
|
27
|
@Override
|
28
|
public Image getProcessImage(final String procId) {
|
29
|
final GraphProcess proc = registry.findProcess(procId);
|
30
|
try {
|
31
|
if (proc != null) {
|
32
|
try {
|
33
|
final ProcessImageMapCreator imageMapCreator = new ProcessImageMapCreator(proc, new ProcessToImageMapHelper(procId));
|
34
|
return imageMapCreator.getImage();
|
35
|
} catch (Throwable e) {
|
36
|
return ImageIO.read(getClass().getResourceAsStream("/eu/dnetlib/msro/worker/ui/wf_problem.png"));
|
37
|
}
|
38
|
} else {
|
39
|
return ImageIO.read(getClass().getResourceAsStream("/eu/dnetlib/msro/worker/ui/wf_not_found.png"));
|
40
|
}
|
41
|
} catch (IOException e) {
|
42
|
log.error("Error generating wf image for process: " + procId, e);
|
43
|
return null;
|
44
|
}
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
public String getProcessImageMap(final String procId) {
|
49
|
final GraphProcess proc = registry.findProcess(procId);
|
50
|
if (proc != null) {
|
51
|
try {
|
52
|
final ProcessImageMapCreator imageMapCreator = new ProcessImageMapCreator(proc, new ProcessToImageMapHelper(procId));
|
53
|
return imageMapCreator.getMapContents();
|
54
|
} catch (Throwable e) {}
|
55
|
}
|
56
|
return "";
|
57
|
}
|
58
|
}
|