Revision 58440
Added by Michele Artini over 3 years ago
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/deploy.info | ||
---|---|---|
1 |
{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet45/modules/dnet-modular-workflows-ui/trunk/", "deploy_repository": "dnet45-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-snapshots", "name": "dnet-modular-workflows-ui"} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/test/java/eu/dnetlib/AppTest.java | ||
---|---|---|
1 |
package eu.dnetlib; |
|
2 |
|
|
3 |
import junit.framework.Test; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import junit.framework.TestSuite; |
|
6 |
|
|
7 |
/** |
|
8 |
* Unit test for simple App. |
|
9 |
*/ |
|
10 |
public class AppTest |
|
11 |
extends TestCase |
|
12 |
{ |
|
13 |
/** |
|
14 |
* Create the test case |
|
15 |
* |
|
16 |
* @param testName name of the test case |
|
17 |
*/ |
|
18 |
public AppTest( String testName ) |
|
19 |
{ |
|
20 |
super( testName ); |
|
21 |
} |
|
22 |
|
|
23 |
/** |
|
24 |
* @return the suite of tests being tested |
|
25 |
*/ |
|
26 |
public static Test suite() |
|
27 |
{ |
|
28 |
return new TestSuite( AppTest.class ); |
|
29 |
} |
|
30 |
|
|
31 |
/** |
|
32 |
* Rigourous Test :-) |
|
33 |
*/ |
|
34 |
public void testApp() |
|
35 |
{ |
|
36 |
assertTrue( true ); |
|
37 |
} |
|
38 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListProfilesValues.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.values; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import com.google.common.collect.Lists; |
|
9 |
|
|
10 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
11 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
12 |
import eu.dnetlib.msro.workflows.util.ValidNodeValuesFetcher; |
|
13 |
|
|
14 |
public class ListProfilesValues extends ValidNodeValuesFetcher { |
|
15 |
|
|
16 |
@Resource |
|
17 |
private UniqueServiceLocator serviceLocator; |
|
18 |
|
|
19 |
@Override |
|
20 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
|
21 |
verifyParams(params, "type", "xpath"); |
|
22 |
|
|
23 |
final List<DnetParamValue> values = Lists.newArrayList(); |
|
24 |
|
|
25 |
final String query = "for $x in /*[.//RESOURCE_TYPE/@value='" + params.get("type") + "']" + "return concat($x//RESOURCE_IDENTIFIER/@value, ' @@@ ', $x" |
|
26 |
+ params.get("xpath") + ")"; |
|
27 |
|
|
28 |
final List<String> result = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query); |
|
29 |
for (String s : result) { |
|
30 |
String[] arr = s.split("@@@"); |
|
31 |
values.add(new DnetParamValue(arr[0].trim(), arr[1].trim())); |
|
32 |
} |
|
33 |
|
|
34 |
return values; |
|
35 |
} |
|
36 |
|
|
37 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/values/ListFilesValues.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.values; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Map; |
|
6 |
|
|
7 |
import org.springframework.core.io.Resource; |
|
8 |
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
|
9 |
import org.springframework.core.io.support.ResourcePatternResolver; |
|
10 |
|
|
11 |
import com.google.common.collect.Lists; |
|
12 |
|
|
13 |
import eu.dnetlib.msro.workflows.util.ValidNodeValuesFetcher; |
|
14 |
|
|
15 |
public class ListFilesValues extends ValidNodeValuesFetcher { |
|
16 |
|
|
17 |
private final ResourcePatternResolver pathResolver = new PathMatchingResourcePatternResolver(); |
|
18 |
|
|
19 |
@Override |
|
20 |
protected List<DnetParamValue> obtainValues(final Map<String, String> params) throws Exception { |
|
21 |
verifyParams(params, "path", "ext"); |
|
22 |
|
|
23 |
final String pathTmp = params.get("path"); |
|
24 |
|
|
25 |
final String path = pathTmp.startsWith("/") ? pathTmp : "/" + pathTmp; |
|
26 |
|
|
27 |
final List<DnetParamValue> values = Lists.newArrayList(); |
|
28 |
for (Resource r : pathResolver.getResources("classpath*:" + path + "/*." + params.get("ext"))) { |
|
29 |
values.add(new DnetParamValue(path + File.separator + r.getFilename(), r.getFilename())); |
|
30 |
} |
|
31 |
|
|
32 |
return values; |
|
33 |
} |
|
34 |
|
|
35 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/menu/InfrastructureManagementGroup.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.menu; |
|
2 |
|
|
3 |
import java.util.Collections; |
|
4 |
import java.util.List; |
|
5 |
import java.util.Set; |
|
6 |
|
|
7 |
import javax.annotation.Resource; |
|
8 |
|
|
9 |
import com.google.common.collect.Lists; |
|
10 |
import com.google.common.collect.Sets; |
|
11 |
|
|
12 |
import eu.dnetlib.functionality.modular.ui.AbstractMenu; |
|
13 |
import eu.dnetlib.functionality.modular.ui.MenuEntry; |
|
14 |
import eu.dnetlib.functionality.modular.ui.users.AccessLimited; |
|
15 |
import eu.dnetlib.functionality.modular.ui.users.PermissionLevel; |
|
16 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.sections.WorkflowSectionGrouper; |
|
17 |
|
|
18 |
public class InfrastructureManagementGroup extends AbstractMenu implements AccessLimited { |
|
19 |
|
|
20 |
private int order; |
|
21 |
|
|
22 |
@Resource |
|
23 |
private WorkflowSectionGrouper workflowSectionGrouper; |
|
24 |
|
|
25 |
@Override |
|
26 |
public List<MenuEntry> getEntries() { |
|
27 |
final List<String> list = Lists.newArrayList(workflowSectionGrouper.getAllSectionNames()); |
|
28 |
|
|
29 |
Collections.sort(list); |
|
30 |
|
|
31 |
List<MenuEntry> res = Lists.newArrayList(); |
|
32 |
for(int i=0; i<list.size(); i++) { |
|
33 |
res.add(new WorkflowSectionEntryPoint(list.get(i), i)); |
|
34 |
} |
|
35 |
return res; |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
public int getOrder() { |
|
40 |
return order; |
|
41 |
} |
|
42 |
|
|
43 |
public void setOrder(int order) { |
|
44 |
this.order = order; |
|
45 |
} |
|
46 |
|
|
47 |
@Override |
|
48 |
public Set<PermissionLevel> getPermissionLevels() { |
|
49 |
return Sets.newHashSet(PermissionLevel.WF_ADMIN, PermissionLevel.IS_ADMIN); |
|
50 |
} |
|
51 |
|
|
52 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/menu/WorkflowSectionEntryPoint.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.menu; |
|
2 |
|
|
3 |
import java.io.UnsupportedEncodingException; |
|
4 |
import java.net.URLEncoder; |
|
5 |
|
|
6 |
import eu.dnetlib.functionality.modular.ui.MenuEntry; |
|
7 |
|
|
8 |
public class WorkflowSectionEntryPoint extends MenuEntry { |
|
9 |
|
|
10 |
public WorkflowSectionEntryPoint(String s, int order) { |
|
11 |
setTitle(s); |
|
12 |
setMenu(s); |
|
13 |
setDescription(s); |
|
14 |
setOrder(order); |
|
15 |
} |
|
16 |
|
|
17 |
@Override |
|
18 |
public String getRelativeUrl() { |
|
19 |
try { |
|
20 |
return "/ui/workflows.do?section=" + URLEncoder.encode(getMenu(), "UTF-8"); |
|
21 |
} catch (UnsupportedEncodingException e) { |
|
22 |
return "javascript:void(0)"; |
|
23 |
} |
|
24 |
} |
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/DnetParamValuesController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.controllers; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.StringReader; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Collections; |
|
7 |
import java.util.Enumeration; |
|
8 |
import java.util.List; |
|
9 |
import java.util.Map; |
|
10 |
|
|
11 |
import javax.annotation.Resource; |
|
12 |
import javax.servlet.http.HttpServletRequest; |
|
13 |
import javax.servlet.http.HttpServletResponse; |
|
14 |
|
|
15 |
import org.apache.commons.io.IOUtils; |
|
16 |
import org.apache.commons.logging.Log; |
|
17 |
import org.apache.commons.logging.LogFactory; |
|
18 |
import org.springframework.stereotype.Controller; |
|
19 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
20 |
import org.springframework.web.bind.annotation.RequestParam; |
|
21 |
|
|
22 |
import com.google.common.collect.Maps; |
|
23 |
import com.google.gson.Gson; |
|
24 |
|
|
25 |
import eu.dnetlib.msro.workflows.util.ValidNodeValuesFetcher; |
|
26 |
import eu.dnetlib.msro.workflows.util.ValidNodeValuesFetcher.DnetParamValue; |
|
27 |
|
|
28 |
@Controller |
|
29 |
public class DnetParamValuesController { |
|
30 |
|
|
31 |
@Resource |
|
32 |
private List<ValidNodeValuesFetcher> validNodesFetchers; |
|
33 |
|
|
34 |
private static final Log log = LogFactory.getLog(DnetParamValuesController.class); |
|
35 |
|
|
36 |
@RequestMapping("/ui/**/wf_obtainValidValues.list") |
|
37 |
public void obtainValidValues(final HttpServletRequest request, |
|
38 |
final HttpServletResponse response, |
|
39 |
@RequestParam(value = "bean", required = true) final String bean) throws IOException { |
|
40 |
|
|
41 |
final ValidNodeValuesFetcher fetcher = findValidNodeValuesFetcher(bean); |
|
42 |
|
|
43 |
if (fetcher == null) { |
|
44 |
log.error("ValidNodeValuesFetcher not found: " + bean); |
|
45 |
sendResponse(response, new ArrayList<ValidNodeValuesFetcher.DnetParamValue>()); |
|
46 |
} else { |
|
47 |
final Map<String, String> params = findParams(request); |
|
48 |
sendResponse(response, fetcher.evaluate(params)); |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
private ValidNodeValuesFetcher findValidNodeValuesFetcher(final String bean) { |
|
53 |
for (ValidNodeValuesFetcher fetcher : validNodesFetchers) { |
|
54 |
if (fetcher.getName().equals(bean)) { return fetcher; } |
|
55 |
} |
|
56 |
return null; |
|
57 |
} |
|
58 |
|
|
59 |
private Map<String, String> findParams(final HttpServletRequest request) { |
|
60 |
final Map<String, String> params = Maps.newHashMap(); |
|
61 |
|
|
62 |
final Enumeration<?> e = request.getParameterNames(); |
|
63 |
while (e.hasMoreElements()) { |
|
64 |
final String name = (String) e.nextElement(); |
|
65 |
params.put(name, request.getParameter(name)); |
|
66 |
} |
|
67 |
return params; |
|
68 |
} |
|
69 |
|
|
70 |
private void sendResponse(final HttpServletResponse response, final List<DnetParamValue> values) throws IOException { |
|
71 |
Collections.sort(values); |
|
72 |
|
|
73 |
response.setContentType("application/json;charset=UTF-8"); |
|
74 |
|
|
75 |
IOUtils.copy(new StringReader(new Gson().toJson(values)), response.getOutputStream()); |
|
76 |
} |
|
77 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/WorkflowsController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.controllers; |
|
2 |
|
|
3 |
import java.awt.image.BufferedImage; |
|
4 |
import java.io.IOException; |
|
5 |
import java.io.OutputStream; |
|
6 |
import java.io.StringReader; |
|
7 |
import java.util.Collection; |
|
8 |
import java.util.Collections; |
|
9 |
import java.util.Iterator; |
|
10 |
import java.util.List; |
|
11 |
import java.util.Map; |
|
12 |
import java.util.Set; |
|
13 |
|
|
14 |
import javax.annotation.Resource; |
|
15 |
import javax.imageio.ImageIO; |
|
16 |
import javax.servlet.http.HttpServletResponse; |
|
17 |
|
|
18 |
import org.apache.commons.lang.math.NumberUtils; |
|
19 |
import org.apache.commons.logging.Log; |
|
20 |
import org.apache.commons.logging.LogFactory; |
|
21 |
import org.dom4j.Document; |
|
22 |
import org.dom4j.Element; |
|
23 |
import org.dom4j.io.SAXReader; |
|
24 |
import org.joda.time.DateTime; |
|
25 |
import org.joda.time.format.DateTimeFormat; |
|
26 |
import org.joda.time.format.DateTimeFormatter; |
|
27 |
import org.springframework.stereotype.Controller; |
|
28 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
29 |
import org.springframework.web.bind.annotation.RequestParam; |
|
30 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
31 |
|
|
32 |
import com.google.common.base.Function; |
|
33 |
import com.google.common.collect.Iterators; |
|
34 |
import com.google.common.collect.Lists; |
|
35 |
import com.google.common.collect.Maps; |
|
36 |
import com.google.gson.Gson; |
|
37 |
import com.google.gson.reflect.TypeToken; |
|
38 |
import com.googlecode.sarasvati.GraphProcess; |
|
39 |
import com.googlecode.sarasvati.Node; |
|
40 |
import com.googlecode.sarasvati.NodeToken; |
|
41 |
import com.googlecode.sarasvati.ProcessState; |
|
42 |
|
|
43 |
import eu.dnetlib.common.logging.DnetLogger; |
|
44 |
import eu.dnetlib.common.logging.LogMessage; |
|
45 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; |
|
46 |
import eu.dnetlib.functionality.modular.ui.AbstractAjaxController; |
|
47 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.AdvancedMetaWorkflowDescriptor; |
|
48 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.AtomicWorkflowDescriptor; |
|
49 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.MetaWorkflowDescriptor; |
|
50 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.NodeInfo; |
|
51 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.NodeTokenInfo; |
|
52 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.NodeWithUserParams; |
|
53 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.ProcessListEntry; |
|
54 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.sections.WorkflowSectionGrouper; |
|
55 |
import eu.dnetlib.functionality.modular.ui.workflows.sarasvati.viewer.ProcessGraphGenerator; |
|
56 |
import eu.dnetlib.functionality.modular.ui.workflows.util.ISLookupClient; |
|
57 |
import eu.dnetlib.functionality.modular.ui.workflows.util.ISRegistryClient; |
|
58 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
59 |
import eu.dnetlib.msro.workflows.sarasvati.loader.ProfileToSarasvatiConverter; |
|
60 |
import eu.dnetlib.msro.workflows.sarasvati.loader.WorkflowExecutor; |
|
61 |
import eu.dnetlib.msro.workflows.sarasvati.registry.GraphProcessRegistry; |
|
62 |
import eu.dnetlib.msro.workflows.util.ProcessUtils; |
|
63 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants; |
|
64 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus; |
|
65 |
|
|
66 |
/** |
|
67 |
* Web controller for the UI |
|
68 |
* |
|
69 |
* @author Michele Artini |
|
70 |
*/ |
|
71 |
|
|
72 |
@Controller |
|
73 |
public class WorkflowsController extends AbstractAjaxController { |
|
74 |
|
|
75 |
private final class JournalEntryFunction implements Function<Map<String, String>, ProcessListEntry> { |
|
76 |
|
|
77 |
@Override |
|
78 |
public ProcessListEntry apply(final Map<String, String> input) { |
|
79 |
final String name = input.get(WorkflowsConstants.SYSTEM_WF_PROFILE_NAME); |
|
80 |
|
|
81 |
final String repo = input.containsKey(WorkflowsConstants.DATAPROVIDER_NAME) ? input.get(WorkflowsConstants.DATAPROVIDER_NAME) : ""; |
|
82 |
final String repoId = input.containsKey(WorkflowsConstants.DATAPROVIDER_ORIGINALID) ? input.get(WorkflowsConstants.DATAPROVIDER_ORIGINALID) : ""; |
|
83 |
final String apiId = input.containsKey(WorkflowsConstants.DATAPROVIDER_INTERFACE) ? input.get(WorkflowsConstants.DATAPROVIDER_INTERFACE) : ""; |
|
84 |
|
|
85 |
final String procId = input.get(WorkflowsConstants.SYSTEM_WF_PROCESS_ID); |
|
86 |
final String wfId = input.get(WorkflowsConstants.SYSTEM_WF_PROFILE_ID); |
|
87 |
final String family = input.get(WorkflowsConstants.SYSTEM_WF_PROFILE_FAMILY); |
|
88 |
final long date = NumberUtils.toLong(input.get(LogMessage.LOG_DATE_FIELD), 0); |
|
89 |
final String status = Boolean.valueOf(input.get(WorkflowsConstants.SYSTEM_COMPLETED_SUCCESSFULLY)) ? "SUCCESS" : "FAILURE"; |
|
90 |
|
|
91 |
return new ProcessListEntry(procId, wfId, name, family, status, date, repo, repoId, apiId); |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
@Resource |
|
96 |
private ISLookupClient isLookupClient; |
|
97 |
|
|
98 |
@Resource |
|
99 |
private ISRegistryClient isRegistryClient; |
|
100 |
|
|
101 |
@Resource |
|
102 |
private GraphProcessRegistry graphProcessRegistry; |
|
103 |
|
|
104 |
@Resource |
|
105 |
private ProcessGraphGenerator processGraphGenerator; |
|
106 |
|
|
107 |
@Resource |
|
108 |
private WorkflowSectionGrouper workflowSectionGrouper; |
|
109 |
|
|
110 |
@Resource |
|
111 |
private WorkflowExecutor workflowExecutor; |
|
112 |
|
|
113 |
@Resource |
|
114 |
private ProfileToSarasvatiConverter profileToSarasvatiConverter; |
|
115 |
|
|
116 |
@Resource(name = "msroWorkflowLogger") |
|
117 |
private DnetLogger dnetLogger; |
|
118 |
|
|
119 |
private static final Log log = LogFactory.getLog(WorkflowsController.class); |
|
120 |
|
|
121 |
@RequestMapping("/ui/list_metaworkflows.json") |
|
122 |
public @ResponseBody List<MetaWorkflowDescriptor> listMetaWorflowsForSection(@RequestParam(value = "section", required = false) final String sectionName, |
|
123 |
@RequestParam(value = "dsId", required = false) final String dsId) |
|
124 |
throws ISLookUpException, IOException { |
|
125 |
if (sectionName != null) { |
|
126 |
return workflowSectionGrouper.listMetaWorflowsForSection(sectionName); |
|
127 |
} else if (dsId != null) { |
|
128 |
return workflowSectionGrouper.listMetaWorflowsForDatasource(dsId); |
|
129 |
} else { |
|
130 |
return Lists.newArrayList(); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
@RequestMapping("/ui/wf_metaworkflow.json") |
|
135 |
public @ResponseBody AdvancedMetaWorkflowDescriptor getMetaWorkflow(@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
136 |
return isLookupClient.getMetaWorkflow(id); |
|
137 |
} |
|
138 |
|
|
139 |
@RequestMapping("/ui/wf_atomic_workflow.json") |
|
140 |
public @ResponseBody AtomicWorkflowDescriptor getAtomicWorkflow(@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
141 |
final AtomicWorkflowDescriptor wf = isLookupClient.getAtomicWorkflow(id); |
|
142 |
final String xml = profileToSarasvatiConverter.getSarasvatiWorkflow(id).getWorkflowXml(); |
|
143 |
|
|
144 |
wf.setMapContent(processGraphGenerator.getWfDescImageMap(id, xml)); |
|
145 |
|
|
146 |
return wf; |
|
147 |
} |
|
148 |
|
|
149 |
@RequestMapping("/ui/wf_atomic_workflow.img") |
|
150 |
public void showAtomicWorkflow(final HttpServletResponse response, @RequestParam(value = "id", required = true) final String id) throws Exception { |
|
151 |
|
|
152 |
final String xml = profileToSarasvatiConverter.getSarasvatiWorkflow(id).getWorkflowXml(); |
|
153 |
final Set<String> notConfiguredNodes = isLookupClient.getNotConfiguredNodes(id); |
|
154 |
final BufferedImage image = processGraphGenerator.getWfDescImage(id, xml, notConfiguredNodes); |
|
155 |
sendImage(response, image); |
|
156 |
} |
|
157 |
|
|
158 |
private void sendImage(final HttpServletResponse response, final BufferedImage image) throws IOException { |
|
159 |
response.setContentType("image/png"); |
|
160 |
final OutputStream out = response.getOutputStream(); |
|
161 |
ImageIO.write(image, "png", out); |
|
162 |
out.flush(); |
|
163 |
out.close(); |
|
164 |
} |
|
165 |
|
|
166 |
@RequestMapping("/ui/wf.start") |
|
167 |
public @ResponseBody String startWorkflow(@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
168 |
return workflowExecutor.startProcess(id); |
|
169 |
} |
|
170 |
|
|
171 |
@RequestMapping("/ui/metawf.start") |
|
172 |
public @ResponseBody String startMetaWorkflow(@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
173 |
workflowExecutor.startMetaWorkflow(id, true); |
|
174 |
return id; |
|
175 |
} |
|
176 |
|
|
177 |
@RequestMapping("/ui/wf_workflow_node.json") |
|
178 |
public @ResponseBody NodeInfo workflowNode_info(@RequestParam(value = "wf", required = true) final String wfId, |
|
179 |
@RequestParam(value = "node", required = true) final String nodeName) throws ISLookUpException, IOException { |
|
180 |
return isLookupClient.getNodeInfo(wfId, nodeName); |
|
181 |
} |
|
182 |
|
|
183 |
@RequestMapping("/ui/wf_metaworkflow.edit") |
|
184 |
public @ResponseBody boolean scheduleMetaWorkflow(@RequestParam(value = "json", required = true) final String json) throws Exception { |
|
185 |
|
|
186 |
final AdvancedMetaWorkflowDescriptor info = new Gson().fromJson(json, AdvancedMetaWorkflowDescriptor.class); |
|
187 |
|
|
188 |
log.info("Updating workflow " + info.getName()); |
|
189 |
|
|
190 |
final String xml = isLookupClient.getProfile(info.getWfId()); |
|
191 |
final boolean res = isRegistryClient.updateSarasvatiMetaWorkflow(info.getWfId(), xml, info); |
|
192 |
|
|
193 |
return res; |
|
194 |
} |
|
195 |
|
|
196 |
@RequestMapping("/ui/clone_metaworkflow.do") |
|
197 |
public @ResponseBody String cloneMetaWf(@RequestParam(value = "id", required = true) final String id, |
|
198 |
@RequestParam(value = "name", required = true) final String name) throws Exception { |
|
199 |
|
|
200 |
if (name.trim().length() > 0) { |
|
201 |
final String xml = isLookupClient.getProfile(id); |
|
202 |
final SAXReader reader = new SAXReader(); |
|
203 |
final Document doc = reader.read(new StringReader(xml)); |
|
204 |
doc.selectSingleNode("//METAWORKFLOW_NAME").setText(name); |
|
205 |
for (final Object o : doc.selectNodes("//WORKFLOW")) { |
|
206 |
final Element n = (Element) o; |
|
207 |
final String atomWfXml = isLookupClient.getProfile(n.valueOf("@id")); |
|
208 |
final String newAtomWfId = isRegistryClient.registerProfile(atomWfXml); |
|
209 |
n.addAttribute("id", newAtomWfId); |
|
210 |
} |
|
211 |
return isRegistryClient.registerProfile(doc.asXML()); |
|
212 |
} else { |
|
213 |
throw new IllegalArgumentException("Name is empty"); |
|
214 |
} |
|
215 |
} |
|
216 |
|
|
217 |
@RequestMapping("/ui/wf_proc_node.json") |
|
218 |
public @ResponseBody NodeTokenInfo getProcessWorkflowNode(@RequestParam(value = "id", required = true) final String pid, |
|
219 |
@RequestParam(value = "node", required = true) final long nid) throws Exception { |
|
220 |
|
|
221 |
final NodeToken token = findNodeToken(pid, nid); |
|
222 |
|
|
223 |
final NodeTokenInfo info = token == null ? new NodeTokenInfo(findNodeName(pid, nid)) : new NodeTokenInfo(token); |
|
224 |
|
|
225 |
return info; |
|
226 |
} |
|
227 |
|
|
228 |
private NodeToken findNodeToken(final String pid, final long nid) { |
|
229 |
final GraphProcess process = graphProcessRegistry.findProcess(pid); |
|
230 |
if (process != null) { |
|
231 |
for (final NodeToken token : process.getNodeTokens()) { |
|
232 |
if (token.getNode().getId() == nid) { return token; } |
|
233 |
} |
|
234 |
} |
|
235 |
return null; |
|
236 |
} |
|
237 |
|
|
238 |
private String findNodeName(final String pid, final long nid) { |
|
239 |
final GraphProcess process = graphProcessRegistry.findProcess(pid); |
|
240 |
if (process != null) { |
|
241 |
for (final Node node : process.getGraph().getNodes()) { |
|
242 |
if (node.getId() == nid) { return node.getName(); } |
|
243 |
} |
|
244 |
} |
|
245 |
return "-"; |
|
246 |
} |
|
247 |
|
|
248 |
@RequestMapping("/ui/wf_proc.img") |
|
249 |
public void showProcessWorkflow(final HttpServletResponse response, @RequestParam(value = "id", required = true) final String id) throws Exception { |
|
250 |
final BufferedImage image = processGraphGenerator.getProcessImage(id); |
|
251 |
sendImage(response, image); |
|
252 |
} |
|
253 |
|
|
254 |
@RequestMapping("/ui/wf_proc.kill") |
|
255 |
public @ResponseBody boolean killProcessWorkflow(@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
256 |
final GraphProcess proc = graphProcessRegistry.findProcess(id); |
|
257 |
proc.setState(ProcessState.Canceled); |
|
258 |
return true; |
|
259 |
} |
|
260 |
|
|
261 |
@RequestMapping("/ui/wf_journal.range") |
|
262 |
public @ResponseBody Collection<ProcessListEntry> rangeWfJournal(@RequestParam(value = "start", required = true) final String start, |
|
263 |
@RequestParam(value = "end", required = true) final String end) throws Exception { |
|
264 |
|
|
265 |
final Map<String, ProcessListEntry> res = Maps.newHashMap(); |
|
266 |
|
|
267 |
final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); |
|
268 |
final DateTime startDate = formatter.parseDateTime(start); |
|
269 |
final DateTime endDate = formatter.parseDateTime(end).plusHours(23).plusMinutes(59).plusSeconds(59); |
|
270 |
|
|
271 |
final Iterator<ProcessListEntry> iter = Iterators.transform(dnetLogger.range(startDate.toDate(), endDate.toDate()), new JournalEntryFunction()); |
|
272 |
while (iter.hasNext()) { |
|
273 |
final ProcessListEntry e = iter.next(); |
|
274 |
res.put(e.getProcId(), e); |
|
275 |
} |
|
276 |
|
|
277 |
final long now = DateUtils.now(); |
|
278 |
if (startDate.isBefore(now) && endDate.isAfter(now)) { |
|
279 |
for (final String pid : graphProcessRegistry.listIdentifiers()) { |
|
280 |
final GraphProcess proc = graphProcessRegistry.findProcess(pid); |
|
281 |
res.put(pid, new ProcessListEntry(pid, proc)); |
|
282 |
} |
|
283 |
} |
|
284 |
|
|
285 |
return res.values(); |
|
286 |
|
|
287 |
} |
|
288 |
|
|
289 |
@RequestMapping("/ui/wf_journal.find") |
|
290 |
public @ResponseBody Collection<ProcessListEntry> findWfJournal(@RequestParam(value = "wfs", required = true) final String wfs) { |
|
291 |
final Map<String, ProcessListEntry> res = Maps.newHashMap(); |
|
292 |
|
|
293 |
final Set<String> wfFilter = new Gson().fromJson(wfs, new TypeToken<Set<String>>() {}.getType()); |
|
294 |
|
|
295 |
for (final String wfId : wfFilter) { |
|
296 |
final Iterator<ProcessListEntry> iter = |
|
297 |
Iterators.transform(dnetLogger.find(WorkflowsConstants.SYSTEM_WF_PROFILE_ID, wfId), new JournalEntryFunction()); |
|
298 |
while (iter.hasNext()) { |
|
299 |
final ProcessListEntry e = iter.next(); |
|
300 |
res.put(e.getProcId(), e); |
|
301 |
} |
|
302 |
} |
|
303 |
|
|
304 |
for (final String pid : graphProcessRegistry.listIdentifiers()) { |
|
305 |
final GraphProcess proc = graphProcessRegistry.findProcess(pid); |
|
306 |
if (wfFilter.contains(ProcessUtils.calculateWfId(proc))) { |
|
307 |
res.put(pid, new ProcessListEntry(pid, proc)); |
|
308 |
} |
|
309 |
} |
|
310 |
|
|
311 |
return res.values(); |
|
312 |
} |
|
313 |
|
|
314 |
@RequestMapping("/ui/wf_journal_byFamily.find") |
|
315 |
public @ResponseBody Collection<ProcessListEntry> findWfJournalByFamily(@RequestParam(value = "family", required = true) final String family) |
|
316 |
throws IOException { |
|
317 |
final Iterator<ProcessListEntry> iter = |
|
318 |
Iterators.transform(dnetLogger.find(WorkflowsConstants.SYSTEM_WF_PROFILE_FAMILY, family), new JournalEntryFunction()); |
|
319 |
return Lists.newArrayList(iter); |
|
320 |
} |
|
321 |
|
|
322 |
@RequestMapping("/ui/wf_journal.get") |
|
323 |
public @ResponseBody Map<String, Object> getWfJournalLog(@RequestParam(value = "id", required = true) final String id) throws Exception { |
|
324 |
final Map<String, Object> res = Maps.newHashMap(); |
|
325 |
|
|
326 |
final Map<String, String> logs = dnetLogger.findOne("system:processId", id); |
|
327 |
|
|
328 |
if (logs != null && !logs.isEmpty()) { |
|
329 |
final List<String> keys = Lists.newArrayList(logs.keySet()); |
|
330 |
Collections.sort(keys); |
|
331 |
|
|
332 |
final List<Map<String, String>> journalEntry = Lists.newArrayList(); |
|
333 |
for (final String k : keys) { |
|
334 |
final Map<String, String> m = Maps.newHashMap(); |
|
335 |
m.put("name", k); |
|
336 |
m.put("value", logs.get(k)); |
|
337 |
journalEntry.add(m); |
|
338 |
} |
|
339 |
res.put("journal", journalEntry); |
|
340 |
} |
|
341 |
|
|
342 |
final GraphProcess process = graphProcessRegistry.findProcess(id); |
|
343 |
|
|
344 |
if (process != null) { |
|
345 |
final String mapContent = process.getState() == ProcessState.Created ? "" : processGraphGenerator.getProcessImageMap(id); |
|
346 |
|
|
347 |
String status = ""; |
|
348 |
if (!process.isComplete()) { |
|
349 |
status = process.getState().toString().toUpperCase(); |
|
350 |
} else if ("true".equals(process.getEnv().getAttribute(WorkflowsConstants.SYSTEM_COMPLETED_SUCCESSFULLY))) { |
|
351 |
status = "SUCCESS"; |
|
352 |
} else { |
|
353 |
status = "FAILURE"; |
|
354 |
} |
|
355 |
|
|
356 |
final String img = |
|
357 |
process.getState() == ProcessState.Created ? "../resources/img/notStarted.gif" : "wf_proc.img?id=" + id + "&t=" + DateUtils.now(); |
|
358 |
|
|
359 |
final String name = process.getGraph().getName(); |
|
360 |
|
|
361 |
final long startDate = NumberUtils.toLong(process.getEnv().getAttribute(WorkflowsConstants.SYSTEM_START_DATE), 0); |
|
362 |
final long endDate = NumberUtils.toLong(process.getEnv().getAttribute(WorkflowsConstants.SYSTEM_END_DATE), 0); |
|
363 |
|
|
364 |
final AtomicWorkflowDescriptor wf = new AtomicWorkflowDescriptor(id, name, status, mapContent, img, true, "auto", "RUNNING", startDate, endDate); |
|
365 |
|
|
366 |
res.put("graph", wf); |
|
367 |
} |
|
368 |
|
|
369 |
return res; |
|
370 |
} |
|
371 |
|
|
372 |
@RequestMapping("/ui/wf_atomic_workflow.enable") |
|
373 |
public @ResponseBody String enableAtomicWf(@RequestParam(value = "id", required = true) final String id, |
|
374 |
@RequestParam(value = "start", required = true) final String value) throws Exception { |
|
375 |
isRegistryClient.configureWorkflowStart(id, value); |
|
376 |
|
|
377 |
return value; |
|
378 |
} |
|
379 |
|
|
380 |
@RequestMapping("/ui/workflow_user_params.json") |
|
381 |
public @ResponseBody List<NodeWithUserParams> listWorkflowUserParams(@RequestParam(value = "wf", required = true) final String wfId) throws Exception { |
|
382 |
return isLookupClient.listWorkflowUserParams(wfId); |
|
383 |
} |
|
384 |
|
|
385 |
@RequestMapping(value = "/ui/save_user_params.do") |
|
386 |
public @ResponseBody boolean saveWorkflowUserParams(@RequestParam(value = "wf", required = true) final String wfId, |
|
387 |
@RequestParam(value = "params", required = true) final String jsonParams) throws Exception { |
|
388 |
|
|
389 |
final String xml = isLookupClient.getProfile(wfId); |
|
390 |
|
|
391 |
final List<NodeWithUserParams> params = new Gson().fromJson(jsonParams, new TypeToken<List<NodeWithUserParams>>() {}.getType()); |
|
392 |
|
|
393 |
final boolean res = isRegistryClient.updateSarasvatiWorkflow(wfId, xml, params); |
|
394 |
|
|
395 |
for (final String metaWfId : isLookupClient.listMetaWorflowsForWfId(wfId)) { |
|
396 |
if (isLookupClient.isExecutable(metaWfId)) { |
|
397 |
isRegistryClient.updateMetaWorkflowStatus(metaWfId, WorkflowStatus.EXECUTABLE); |
|
398 |
} else { |
|
399 |
isRegistryClient.updateMetaWorkflowStatus(metaWfId, WorkflowStatus.WAIT_USER_SETTINGS); |
|
400 |
} |
|
401 |
} |
|
402 |
|
|
403 |
return res; |
|
404 |
} |
|
405 |
|
|
406 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/WfTimelineEntryPointController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.controllers; |
|
2 |
|
|
3 |
import javax.servlet.http.HttpServletRequest; |
|
4 |
import javax.servlet.http.HttpServletResponse; |
|
5 |
|
|
6 |
import org.springframework.ui.ModelMap; |
|
7 |
|
|
8 |
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint; |
|
9 |
|
|
10 |
public class WfTimelineEntryPointController extends ModuleEntryPoint { |
|
11 |
|
|
12 |
@Override |
|
13 |
protected void initialize(ModelMap map, HttpServletRequest request, |
|
14 |
HttpServletResponse response) throws Exception { |
|
15 |
|
|
16 |
} |
|
17 |
|
|
18 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/WfEntryPointController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.controllers; |
|
2 |
|
|
3 |
import java.io.StringWriter; |
|
4 |
import java.net.URLEncoder; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import javax.annotation.Resource; |
|
8 |
import javax.servlet.http.HttpServletRequest; |
|
9 |
import javax.servlet.http.HttpServletResponse; |
|
10 |
|
|
11 |
import org.apache.commons.lang.StringUtils; |
|
12 |
import org.apache.commons.logging.Log; |
|
13 |
import org.apache.commons.logging.LogFactory; |
|
14 |
import org.springframework.ui.ModelMap; |
|
15 |
|
|
16 |
import com.google.gson.Gson; |
|
17 |
|
|
18 |
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; |
|
19 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
20 |
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint; |
|
21 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.sections.WorkflowSectionGrouper; |
|
22 |
|
|
23 |
public class WfEntryPointController extends ModuleEntryPoint { |
|
24 |
|
|
25 |
@Resource |
|
26 |
private WorkflowSectionGrouper workflowSectionGrouper; |
|
27 |
|
|
28 |
@Resource |
|
29 |
private UniqueServiceLocator serviceLocator; |
|
30 |
|
|
31 |
private static final Log log = LogFactory.getLog(WfEntryPointController.class); |
|
32 |
|
|
33 |
private final Gson gson = new Gson(); |
|
34 |
|
|
35 |
@Override |
|
36 |
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception { |
|
37 |
if (request.getParameterMap().containsKey("wfId")) { |
|
38 |
initialize_direct_wf(map, request); |
|
39 |
} else { |
|
40 |
initialize_normal(map, request); |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
private void initialize_direct_wf(final ModelMap map, final HttpServletRequest request) { |
|
45 |
|
|
46 |
final String wfId = request.getParameter("wfId"); |
|
47 |
|
|
48 |
final StringWriter sw = new StringWriter(); |
|
49 |
|
|
50 |
sw.append("for $x in collection('/db/DRIVER/MetaWorkflowDSResources/MetaWorkflowDSResourceType') "); |
|
51 |
sw.append("where $x//WORKFLOW/@id='"); |
|
52 |
sw.append(wfId); |
|
53 |
sw.append("' return concat("); |
|
54 |
sw.append("$x//METAWORKFLOW_SECTION, "); |
|
55 |
sw.append("' |=@=| ', "); |
|
56 |
sw.append("$x//RESOURCE_IDENTIFIER/@value, "); |
|
57 |
sw.append("' |=@=| ', "); |
|
58 |
sw.append("$x//DATAPROVIDER/@id, "); |
|
59 |
sw.append("' |=@=| ', "); |
|
60 |
sw.append("$x//DATAPROVIDER/@interface)"); |
|
61 |
|
|
62 |
try { |
|
63 |
final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(sw.toString()); |
|
64 |
if (list.size() > 0) { |
|
65 |
final String[] arr = list.get(0).split("\\|=@=\\|"); |
|
66 |
|
|
67 |
final String section = arr[0].trim(); |
|
68 |
final String metaWf = arr[1].trim(); |
|
69 |
final String repoId = arr[2].trim(); |
|
70 |
final String repoApi = arr[3].trim(); |
|
71 |
|
|
72 |
if (!StringUtils.isEmpty(repoId) |
|
73 |
&& !StringUtils.isEmpty(repoApi) |
|
74 |
&& !StringUtils.isEmpty(metaWf) |
|
75 |
&& !StringUtils.isEmpty(wfId)) { |
|
76 |
map.addAttribute("redirect", |
|
77 |
"repoApis.do#/api/" + |
|
78 |
URLEncoder.encode(repoId, "UTF-8") + "/" + |
|
79 |
URLEncoder.encode(repoApi, "UTF-8") + "/" + |
|
80 |
URLEncoder.encode(metaWf, "UTF-8") + "/" + |
|
81 |
URLEncoder.encode(wfId, "UTF-8")); |
|
82 |
|
|
83 |
} else { |
|
84 |
map.addAttribute("initialWf", gson.toJson(wfId)); |
|
85 |
map.addAttribute("initialMetaWf", gson.toJson(metaWf)); |
|
86 |
map.addAttribute("section", gson.toJson(section)); |
|
87 |
} |
|
88 |
} |
|
89 |
} catch (Exception e) { |
|
90 |
log.error("Error obtaining details of wf " + wfId); |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
private void initialize_normal(final ModelMap map, final HttpServletRequest request) { |
|
95 |
if (request.getParameterMap().containsKey("section")) { |
|
96 |
map.addAttribute("section", gson.toJson(request.getParameter("section"))); |
|
97 |
} |
|
98 |
if (request.getParameterMap().containsKey("metaWf")) { |
|
99 |
map.addAttribute("initialMetaWf", gson.toJson(request.getParameter("metaWf"))); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/WfHistoryEntryPointController.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.controllers; |
|
2 |
|
|
3 |
import javax.servlet.http.HttpServletRequest; |
|
4 |
import javax.servlet.http.HttpServletResponse; |
|
5 |
|
|
6 |
import org.springframework.ui.ModelMap; |
|
7 |
|
|
8 |
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint; |
|
9 |
|
|
10 |
public class WfHistoryEntryPointController extends ModuleEntryPoint { |
|
11 |
|
|
12 |
@Override |
|
13 |
protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception { |
|
14 |
if (request.getParameterMap().containsKey("procId")) { |
|
15 |
map.addAttribute("procId", request.getParameter("procId")); |
|
16 |
} |
|
17 |
if (request.getParameterMap().containsKey("family")) { |
|
18 |
map.addAttribute("family", request.getParameter("family")); |
|
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/MetaWorkflowDescriptor.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus; |
|
4 |
|
|
5 |
public class MetaWorkflowDescriptor extends AbstractWorkflowDescriptor { |
|
6 |
|
|
7 |
private WorkflowStatus statusEnum; |
|
8 |
private String familyName; |
|
9 |
|
|
10 |
public MetaWorkflowDescriptor(final String id, final String name, final WorkflowStatus statusEnum, final String familyName) { |
|
11 |
super(id, name, ""); |
|
12 |
this.statusEnum = statusEnum; |
|
13 |
this.familyName = familyName; |
|
14 |
} |
|
15 |
|
|
16 |
public String getStatus() { |
|
17 |
return statusEnum.displayName; |
|
18 |
} |
|
19 |
|
|
20 |
public WorkflowStatus getStatusEnum() { |
|
21 |
return statusEnum; |
|
22 |
} |
|
23 |
|
|
24 |
public void setStatusEnum(final WorkflowStatus statusEnum) { |
|
25 |
this.statusEnum = statusEnum; |
|
26 |
} |
|
27 |
|
|
28 |
public String getFamilyName() { |
|
29 |
return familyName; |
|
30 |
} |
|
31 |
|
|
32 |
public void setFamilyName(final String familyName) { |
|
33 |
this.familyName = familyName; |
|
34 |
} |
|
35 |
|
|
36 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/FilterCollection.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.HashMap; |
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
public class FilterCollection extends HashMap<String, List<FilterElem>> { |
|
8 |
|
|
9 |
/** |
|
10 |
* |
|
11 |
*/ |
|
12 |
private static final long serialVersionUID = 4856177328627952130L; |
|
13 |
|
|
14 |
public FilterCollection() { |
|
15 |
super(); |
|
16 |
} |
|
17 |
|
|
18 |
public void addElement(String collection, FilterElem elem) { |
|
19 |
if (!this.containsKey(collection)) { |
|
20 |
this.put(collection, new ArrayList<FilterElem>()); |
|
21 |
} |
|
22 |
this.get(collection).add(elem); |
|
23 |
} |
|
24 |
|
|
25 |
public void addElement(String collection, String name, String icon, String value) { |
|
26 |
addElement(collection, new FilterElem(name, icon, value)); |
|
27 |
} |
|
28 |
|
|
29 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/NodeInfo.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import eu.dnetlib.msro.workflows.util.WorkflowParam; |
|
6 |
|
|
7 |
public class NodeInfo { |
|
8 |
private String name; |
|
9 |
private String description; |
|
10 |
private List<WorkflowParam> params; |
|
11 |
|
|
12 |
public NodeInfo(String name, String description, List<WorkflowParam> params) { |
|
13 |
this.name = name; |
|
14 |
this.description = description; |
|
15 |
this.params = params; |
|
16 |
} |
|
17 |
|
|
18 |
public String getName() { |
|
19 |
return name; |
|
20 |
} |
|
21 |
|
|
22 |
public void setName(String name) { |
|
23 |
this.name = name; |
|
24 |
} |
|
25 |
|
|
26 |
public String getDescription() { |
|
27 |
return description; |
|
28 |
} |
|
29 |
|
|
30 |
public void setDescription(String description) { |
|
31 |
this.description = description; |
|
32 |
} |
|
33 |
|
|
34 |
public List<WorkflowParam> getParams() { |
|
35 |
return params; |
|
36 |
} |
|
37 |
|
|
38 |
public void setParams(List<WorkflowParam> params) { |
|
39 |
this.params = params; |
|
40 |
} |
|
41 |
|
|
42 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/NodeTokenInfo.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
import java.util.Collections; |
|
4 |
import java.util.Comparator; |
|
5 |
import java.util.Date; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
|
|
9 |
import com.google.common.collect.Lists; |
|
10 |
import com.google.common.collect.Maps; |
|
11 |
import com.googlecode.sarasvati.NodeToken; |
|
12 |
|
|
13 |
public class NodeTokenInfo { |
|
14 |
|
|
15 |
public class EnvParam { |
|
16 |
|
|
17 |
private String name; |
|
18 |
private String value; |
|
19 |
|
|
20 |
public EnvParam(final String name, final String value) { |
|
21 |
this.name = name; |
|
22 |
this.value = value; |
|
23 |
} |
|
24 |
|
|
25 |
public String getName() { |
|
26 |
return name; |
|
27 |
} |
|
28 |
|
|
29 |
public String getValue() { |
|
30 |
return value; |
|
31 |
} |
|
32 |
} |
|
33 |
|
|
34 |
private String name; |
|
35 |
private long start; |
|
36 |
private long end; |
|
37 |
private List<EnvParam> params; |
|
38 |
|
|
39 |
public NodeTokenInfo(final String name) { |
|
40 |
super(); |
|
41 |
this.name = name; |
|
42 |
this.start = 0; |
|
43 |
this.end = 0; |
|
44 |
this.params = Lists.newArrayList(); |
|
45 |
} |
|
46 |
|
|
47 |
public NodeTokenInfo(final NodeToken token) { |
|
48 |
super(); |
|
49 |
|
|
50 |
final Date start = token.getCreateDate(); |
|
51 |
final Date end = token.getCompleteDate(); |
|
52 |
|
|
53 |
this.name = token.getNode().getName(); |
|
54 |
this.start = start == null ? 0 : start.getTime(); |
|
55 |
this.end = end == null ? 0 : end.getTime(); |
|
56 |
|
|
57 |
final Map<String, EnvParam> map = Maps.newHashMap(); |
|
58 |
for (String name : token.getFullEnv().getAttributeNames()) { |
|
59 |
map.put(name, new EnvParam(name, token.getFullEnv().getAttribute(name))); |
|
60 |
} |
|
61 |
for (String name : token.getEnv().getAttributeNames()) { |
|
62 |
map.put(name, new EnvParam(name, token.getEnv().getAttribute(name))); |
|
63 |
} |
|
64 |
|
|
65 |
this.params = Lists.newArrayList(map.values()); |
|
66 |
|
|
67 |
Collections.sort(this.params, new Comparator<EnvParam>() { |
|
68 |
|
|
69 |
@Override |
|
70 |
public int compare(final EnvParam o1, final EnvParam o2) { |
|
71 |
if (o1 == null) { |
|
72 |
return -1; |
|
73 |
} else if (o2 == null) { |
|
74 |
return 1; |
|
75 |
} else { |
|
76 |
return o1.getName().compareTo(o2.getName()); |
|
77 |
} |
|
78 |
} |
|
79 |
}); |
|
80 |
} |
|
81 |
|
|
82 |
public String getName() { |
|
83 |
return name; |
|
84 |
} |
|
85 |
|
|
86 |
public long getStart() { |
|
87 |
return start; |
|
88 |
} |
|
89 |
|
|
90 |
public long getEnd() { |
|
91 |
return end; |
|
92 |
} |
|
93 |
|
|
94 |
public List<EnvParam> getParams() { |
|
95 |
return params; |
|
96 |
} |
|
97 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/NodeWithUserParams.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import eu.dnetlib.msro.workflows.util.WorkflowParam; |
|
6 |
|
|
7 |
public class NodeWithUserParams { |
|
8 |
private String node; |
|
9 |
private String desc; |
|
10 |
private List<WorkflowParam> params; |
|
11 |
|
|
12 |
public NodeWithUserParams() {} |
|
13 |
|
|
14 |
public NodeWithUserParams(final String node, final String desc, final List<WorkflowParam> params) { |
|
15 |
this.node = node; |
|
16 |
this.desc = desc; |
|
17 |
this.params = params; |
|
18 |
} |
|
19 |
|
|
20 |
public String getNode() { |
|
21 |
return node; |
|
22 |
} |
|
23 |
|
|
24 |
public void setNode(final String node) { |
|
25 |
this.node = node; |
|
26 |
} |
|
27 |
|
|
28 |
public String getDesc() { |
|
29 |
return desc; |
|
30 |
} |
|
31 |
|
|
32 |
public void setDesc(final String desc) { |
|
33 |
this.desc = desc; |
|
34 |
} |
|
35 |
|
|
36 |
public List<WorkflowParam> getParams() { |
|
37 |
return params; |
|
38 |
} |
|
39 |
|
|
40 |
public void setParams(final List<WorkflowParam> params) { |
|
41 |
this.params = params; |
|
42 |
} |
|
43 |
|
|
44 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/AdvancedMetaWorkflowDescriptor.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
import java.util.Set; |
|
4 |
|
|
5 |
import com.google.common.collect.Sets; |
|
6 |
|
|
7 |
import eu.dnetlib.msro.workflows.util.WorkflowsConstants.WorkflowStatus; |
|
8 |
|
|
9 |
public class AdvancedMetaWorkflowDescriptor extends MetaWorkflowDescriptor { |
|
10 |
private String email; |
|
11 |
private boolean scheduled; |
|
12 |
private String cronExpression; |
|
13 |
private int minInterval; |
|
14 |
private Set<String> innerWfs = Sets.newHashSet(); |
|
15 |
private String html; |
|
16 |
|
|
17 |
public AdvancedMetaWorkflowDescriptor(final String id, final String name, final String email, |
|
18 |
final boolean scheduled, final String cronExpression, final int minInterval, final WorkflowStatus statusEnum, final String family, final Set<String> innerWfs, final String html) { |
|
19 |
super(id, name, statusEnum, family); |
|
20 |
this.email = email; |
|
21 |
this.scheduled = scheduled; |
|
22 |
this.cronExpression = cronExpression; |
|
23 |
this.minInterval = minInterval; |
|
24 |
this.innerWfs = innerWfs; |
|
25 |
this.setHtml(html); |
|
26 |
} |
|
27 |
|
|
28 |
public boolean isScheduled() { |
|
29 |
return scheduled; |
|
30 |
} |
|
31 |
|
|
32 |
public void setScheduled(final boolean scheduled) { |
|
33 |
this.scheduled = scheduled; |
|
34 |
} |
|
35 |
|
|
36 |
public String getCronExpression() { |
|
37 |
return cronExpression; |
|
38 |
} |
|
39 |
|
|
40 |
public void setCronExpression(final String cronExpression) { |
|
41 |
this.cronExpression = cronExpression; |
|
42 |
} |
|
43 |
|
|
44 |
public int getMinInterval() { |
|
45 |
return minInterval; |
|
46 |
} |
|
47 |
|
|
48 |
public void setMinInterval(final int minInterval) { |
|
49 |
this.minInterval = minInterval; |
|
50 |
} |
|
51 |
|
|
52 |
public String getEmail() { |
|
53 |
return email; |
|
54 |
} |
|
55 |
|
|
56 |
public void setEmail(final String email) { |
|
57 |
this.email = email; |
|
58 |
} |
|
59 |
|
|
60 |
public Set<String> getInnerWfs() { |
|
61 |
return innerWfs; |
|
62 |
} |
|
63 |
|
|
64 |
public void setInnerWfs(Set<String> innerWfs) { |
|
65 |
this.innerWfs = innerWfs; |
|
66 |
} |
|
67 |
|
|
68 |
public String getHtml() { |
|
69 |
return html; |
|
70 |
} |
|
71 |
|
|
72 |
public void setHtml(String html) { |
|
73 |
this.html = html; |
|
74 |
} |
|
75 |
|
|
76 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/AtomicWorkflowDescriptor.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
public class AtomicWorkflowDescriptor extends AbstractWorkflowDescriptor implements WfGraphProvider { |
|
4 |
|
|
5 |
private String mapContent; |
|
6 |
private String status; |
|
7 |
private String imageUrl; |
|
8 |
private boolean ready; |
|
9 |
private String start; |
|
10 |
private String lastExecutionDate; |
|
11 |
private long startDate; |
|
12 |
private long endDate; |
|
13 |
|
|
14 |
public AtomicWorkflowDescriptor(final String id, final String name, final String status, final String mapContent, |
|
15 |
final String imageUrl, final boolean ready, final String start, final String lastExecutionDate, long startDate, long endDate) { |
|
16 |
super(id, name, ""); |
|
17 |
this.status = status; |
|
18 |
this.mapContent = mapContent; |
|
19 |
this.imageUrl = imageUrl; |
|
20 |
this.ready = ready; |
|
21 |
this.start = start; |
|
22 |
this.lastExecutionDate = lastExecutionDate; |
|
23 |
this.startDate = startDate; |
|
24 |
this.endDate = endDate; |
|
25 |
} |
|
26 |
|
|
27 |
public long getStartDate() { |
|
28 |
return startDate; |
|
29 |
} |
|
30 |
|
|
31 |
public void setStartDate(long startDate) { |
|
32 |
this.startDate = startDate; |
|
33 |
} |
|
34 |
|
|
35 |
public long getEndDate() { |
|
36 |
return endDate; |
|
37 |
} |
|
38 |
|
|
39 |
public void setEndDate(long endDate) { |
|
40 |
this.endDate = endDate; |
|
41 |
} |
|
42 |
|
|
43 |
public void setMapContent(final String mapContent) { |
|
44 |
this.mapContent = mapContent; |
|
45 |
} |
|
46 |
|
|
47 |
public void setImageUrl(final String imageUrl) { |
|
48 |
this.imageUrl = imageUrl; |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public String getMapContent() { |
|
53 |
return mapContent; |
|
54 |
} |
|
55 |
|
|
56 |
@Override |
|
57 |
public String getImageUrl() { |
|
58 |
return imageUrl; |
|
59 |
} |
|
60 |
|
|
61 |
public boolean isReady() { |
|
62 |
return ready; |
|
63 |
} |
|
64 |
|
|
65 |
public void setReady(final boolean ready) { |
|
66 |
this.ready = ready; |
|
67 |
} |
|
68 |
|
|
69 |
public String getLastExecutionDate() { |
|
70 |
return lastExecutionDate; |
|
71 |
} |
|
72 |
|
|
73 |
public void setLastExecutionDate(final String lastExecutionDate) { |
|
74 |
this.lastExecutionDate = lastExecutionDate; |
|
75 |
} |
|
76 |
|
|
77 |
public String getStatus() { |
|
78 |
return status; |
|
79 |
} |
|
80 |
|
|
81 |
public void setStatus(final String status) { |
|
82 |
this.status = status; |
|
83 |
} |
|
84 |
|
|
85 |
public String getStart() { |
|
86 |
return start; |
|
87 |
} |
|
88 |
|
|
89 |
public void setStart(final String start) { |
|
90 |
this.start = start; |
|
91 |
} |
|
92 |
|
|
93 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/sections/WorkflowSectionGrouper.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects.sections; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import java.util.Set; |
|
5 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
|
|
8 |
import com.google.common.collect.Sets; |
|
9 |
|
|
10 |
import eu.dnetlib.functionality.modular.ui.workflows.objects.MetaWorkflowDescriptor; |
|
11 |
import eu.dnetlib.functionality.modular.ui.workflows.util.ISLookupClient; |
|
12 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
13 |
|
|
14 |
public class WorkflowSectionGrouper { |
|
15 |
|
|
16 |
private Set<String> cache = Sets.newHashSet(); |
|
17 |
private long cacheDate = 0; |
|
18 |
private static final long CACHE_DURATION = 600000; // 10 minutes |
|
19 |
|
|
20 |
@Resource |
|
21 |
private ISLookupClient isLookupClient; |
|
22 |
|
|
23 |
|
|
24 |
public List<MetaWorkflowDescriptor> listMetaWorflowsForDatasource(String dsId) { |
|
25 |
return isLookupClient.listMetaWorflowsForDatasource(dsId); |
|
26 |
} |
|
27 |
|
|
28 |
public List<MetaWorkflowDescriptor> listMetaWorflowsForSection(String name) { |
|
29 |
return isLookupClient.listMetaWorflowsForSection(name); |
|
30 |
} |
|
31 |
|
|
32 |
public String getDatasourceName(String dsId) { |
|
33 |
return isLookupClient.getDatasourceName(dsId); |
|
34 |
} |
|
35 |
|
|
36 |
public Set<String> getAllSectionNames() { |
|
37 |
synchronized (cache) { |
|
38 |
if (cache.isEmpty() || DateUtils.now() - cacheDate > CACHE_DURATION) { |
|
39 |
cache.clear(); |
|
40 |
cache.addAll(isLookupClient.listSimpleWorflowSections()); |
|
41 |
cacheDate = DateUtils.now(); |
|
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
final Set<String> res = Sets.newHashSet(cache); |
|
46 |
|
|
47 |
res.remove("dataproviders"); |
|
48 |
|
|
49 |
return res; |
|
50 |
} |
|
51 |
|
|
52 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/FilterElem.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
public class FilterElem { |
|
4 |
private String name; |
|
5 |
private String icon; |
|
6 |
private String value; |
|
7 |
|
|
8 |
public FilterElem(String name, String icon, String value) { |
|
9 |
super(); |
|
10 |
this.name = name; |
|
11 |
this.icon = icon; |
|
12 |
this.value = value; |
|
13 |
} |
|
14 |
|
|
15 |
public String getName() { |
|
16 |
return name; |
|
17 |
} |
|
18 |
|
|
19 |
public void setName(String name) { |
|
20 |
this.name = name; |
|
21 |
} |
|
22 |
|
|
23 |
public String getIcon() { |
|
24 |
return icon; |
|
25 |
} |
|
26 |
|
|
27 |
public void setIcon(String icon) { |
|
28 |
this.icon = icon; |
|
29 |
} |
|
30 |
|
|
31 |
public String getValue() { |
|
32 |
return value; |
|
33 |
} |
|
34 |
|
|
35 |
public void setValue(String value) { |
|
36 |
this.value = value; |
|
37 |
} |
|
38 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/WfGraphProvider.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
public interface WfGraphProvider { |
|
4 |
|
|
5 |
public String getMapContent(); |
|
6 |
|
|
7 |
public String getImageUrl(); |
|
8 |
|
|
9 |
} |
modules/dnet-modular-workflows-ui/tags/dnet-modular-workflows-ui-4.0.6/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/objects/ProcessListEntry.java | ||
---|---|---|
1 |
package eu.dnetlib.functionality.modular.ui.workflows.objects; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
import com.googlecode.sarasvati.GraphProcess; |
|
6 |
|
|
7 |
import eu.dnetlib.msro.workflows.util.ProcessUtils; |
|
8 |
|
|
9 |
public class ProcessListEntry { |
|
10 |
|
|
11 |
private String procId; |
|
12 |
private String wfId; |
|
13 |
private String name; |
|
14 |
private String family; |
|
15 |
private String status; |
|
16 |
private long date; |
|
17 |
private String repo; |
|
18 |
private String repoId; |
|
19 |
private String apiId; |
|
20 |
|
|
21 |
public ProcessListEntry() {} |
|
22 |
|
|
23 |
public ProcessListEntry(final String procId, final String wfId, final String name, final String family, final String status, final long date, |
|
24 |
final String repo, final String repoId, final String apiId) { |
|
25 |
this.procId = procId; |
|
26 |
this.wfId = wfId; |
|
27 |
this.name = name; |
|
28 |
this.family = family; |
|
29 |
this.status = status; |
|
30 |
this.date = date; |
|
31 |
this.repo = repo; |
|
32 |
this.repoId = repoId; |
|
33 |
this.apiId = apiId; |
|
34 |
} |
|
35 |
|
|
36 |
public ProcessListEntry(final String procId, final String wfId, final String name, final String family, final String status, final Date date, |
|
37 |
final String repo, final String repoId, final String apiId) { |
|
38 |
this(procId, wfId, name, family, status, dateToLong(date), repo, repoId, apiId); |
|
39 |
} |
|
40 |
|
|
41 |
public ProcessListEntry(final String procId, final GraphProcess process) { |
|
42 |
this(procId, |
|
43 |
ProcessUtils.calculateWfId(process), |
|
44 |
ProcessUtils.calculateName(process), |
|
45 |
ProcessUtils.calculateFamily(process), |
|
46 |
ProcessUtils.calculateStatus(process), |
|
47 |
ProcessUtils.calculateLastActivityDate(process), |
|
48 |
ProcessUtils.calculateRepo(process), |
|
49 |
ProcessUtils.calculateRepoId(process), |
|
50 |
ProcessUtils.calculateApiId(process)); |
|
51 |
} |
|
52 |
|
|
53 |
public String getProcId() { |
|
54 |
return procId; |
|
55 |
} |
|
56 |
|
|
57 |
public void setProcId(final String procId) { |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-modular-workflows-ui-4.0.6