Project

General

Profile

« Previous | Next » 

Revision 42094

cleaning

View differences:

modules/dnet-modular-uis/trunk/src/main/java/eu/dnetlib/functionality/modular/ui/workflows/controllers/WfEntryPointController.java
1 1
package eu.dnetlib.functionality.modular.ui.workflows.controllers;
2 2

  
3
import javax.annotation.Resource;
4 3
import javax.servlet.http.HttpServletRequest;
5 4
import javax.servlet.http.HttpServletResponse;
6 5

  
7
import com.google.gson.Gson;
8
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
9
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
10
import eu.dnetlib.functionality.modular.ui.workflows.objects.sections.WorkflowSectionGrouper;
11
import org.apache.commons.logging.Log;
12
import org.apache.commons.logging.LogFactory;
13 6
import org.springframework.ui.ModelMap;
14 7

  
8
import eu.dnetlib.functionality.modular.ui.ModuleEntryPoint;
9

  
15 10
public class WfEntryPointController extends ModuleEntryPoint {
16 11

  
17
	private static final Log log = LogFactory.getLog(WfEntryPointController.class);
18
	private final Gson gson = new Gson();
19
	@Resource
20
	private WorkflowSectionGrouper workflowSectionGrouper;
21
	@Resource
22
	private UniqueServiceLocator serviceLocator;
23

  
24 12
	@Override
25
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
26
		/* if (request.getParameterMap().containsKey("wfId")) {
27
			initialize_direct_wf(map, request);
28
		} else {
29
			initialize_normal(map, request);
30
		}
31
		*/
32
	}
13
	protected void initialize(final ModelMap map, final HttpServletRequest request, final HttpServletResponse response) throws Exception {}
33 14

  
34

  
35
	/*
36
	private void initialize_direct_wf(final ModelMap map, final HttpServletRequest request) {
37

  
38
		final String wfId = request.getParameter("wfId");
39

  
40
		final StringWriter sw = new StringWriter();
41

  
42
		sw.append("for $x in collection('/db/DRIVER/WorkflowDSResources/WorkflowDSResourceType') ");
43
		sw.append("where $x//RESOURCE_IDENTIFIER/@value='");
44
		sw.append(wfId);
45
		sw.append("' return concat(");
46
		sw.append("$x//WORKFLOW_name/@menuSection, ");
47
		sw.append("' |=@=| ', ");
48
		sw.append("$x//DATASOURCE/@id, ");
49
		sw.append("' |=@=| ', ");
50
		sw.append("$x//DATASOURCE/@interface)");
51

  
52
		try {
53
			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(sw.toString());
54
			if (list.size() > 0) {
55
				final String[] arr = list.get(0).split("\\|=@=\\|");
56

  
57
				final String section = arr[0].trim();
58
				final String wf = arr[1].trim();
59
				final String repoId = arr[2].trim();
60
				final String repoApi = arr[3].trim();
61

  
62
				if (!StringUtils.isEmpty(repoId)
63
						&& !StringUtils.isEmpty(repoApi)
64
						&& !StringUtils.isEmpty(wfId)) {
65
					map.addAttribute("redirect",
66
							"repoApis.do#/api/" +
67
									URLEncoder.encode(repoId, "UTF-8") + "/" +
68
									URLEncoder.encode(repoApi, "UTF-8") + "/" +
69
									URLEncoder.encode(wfId, "UTF-8"));
70

  
71
				} else {
72
					map.addAttribute("initialWf", gson.toJson(wfId));
73
					map.addAttribute("section", gson.toJson(section));
74
				}
75
			}
76
		} catch (Exception e) {
77
			log.error("Error obtaining details of wf " + wfId);
78
		}
79
	}
80

  
81
	private void initialize_normal(final ModelMap map, final HttpServletRequest request) {
82
		if (request.getParameterMap().containsKey("section")) {
83
			map.addAttribute("section", gson.toJson(request.getParameter("section")));
84
		}
85
		if (request.getParameterMap().containsKey("wf")) {
86
			map.addAttribute("initialWf", gson.toJson(request.getParameter("wf")));
87
		}
88
	}
89

  
90
	*/
91 15
}

Also available in: Unified diff