Project

General

Profile

« Previous | Next » 

Revision 40094

partial reimplementation of the wf engine

View differences:

QueryDbJobNode.java
1 1
package eu.dnetlib.msro.workflows.nodes.db;
2 2

  
3 3
import java.io.IOException;
4

  
5 4
import javax.annotation.Resource;
6 5
import javax.xml.ws.wsaddressing.W3CEndpointReference;
7 6

  
8
import org.apache.commons.io.IOUtils;
9
import org.apache.commons.lang.StringUtils;
10

  
11
import com.googlecode.sarasvati.Arc;
12
import com.googlecode.sarasvati.NodeToken;
13

  
14 7
import eu.dnetlib.enabling.database.rmi.DatabaseService;
15 8
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
9
import eu.dnetlib.msro.workflows.graph.Arc;
10
import eu.dnetlib.msro.workflows.graph.Env;
16 11
import eu.dnetlib.msro.workflows.nodes.AsyncJobNode;
12
import org.apache.commons.io.IOUtils;
13
import org.apache.commons.lang.StringUtils;
17 14

  
18 15
public class QueryDbJobNode extends AsyncJobNode {
19 16

  
......
30 27
	private UniqueServiceLocator serviceLocator;
31 28

  
32 29
	@Override
33
	protected String execute(final NodeToken token) throws Exception {
30
	protected String execute(final Env env) throws Exception {
34 31
		final String sqlText = fetchSqlAsText(sql);
35 32

  
36 33
		W3CEndpointReference epr = null;
......
41 38
			final String xsltText = IOUtils.toString(getClass().getResourceAsStream(xslt));
42 39

  
43 40
			if (StringUtils.isBlank(sqlForSize)) {
44
				epr = dbService.xsltSearchSQL(findDb(token), sqlText, xsltText);
41
				epr = dbService.xsltSearchSQL(findDb(env), sqlText, xsltText);
45 42
			} else {
46
				epr = dbService.alternativeXsltSearchSQL(findDb(token), sqlText, fetchSqlAsText(sqlForSize), xsltText);
43
				epr = dbService.alternativeXsltSearchSQL(findDb(env), sqlText, fetchSqlAsText(sqlForSize), xsltText);
47 44
			}
48 45
		} else {
49 46
			if (StringUtils.isBlank(sqlForSize)) {
50
				epr = dbService.searchSQL(findDb(token), sqlText);
47
				epr = dbService.searchSQL(findDb(env), sqlText);
51 48
			} else {
52
				epr = dbService.alternativeSearchSQL(findDb(token), sqlText, fetchSqlAsText(sqlForSize));
49
				epr = dbService.alternativeSearchSQL(findDb(env), sqlText, fetchSqlAsText(sqlForSize));
53 50
			}
54 51
		}
55 52

  
56
		token.getEnv().setAttribute(outputEprParam, epr.toString());
53
		env.setAttribute(outputEprParam, epr.toString());
57 54

  
58 55
		return Arc.DEFAULT_ARC;
59 56
	}
......
62 59
		return IOUtils.toString(getClass().getResourceAsStream(path));
63 60
	}
64 61

  
65
	private String findDb(final NodeToken token) {
62
	private String findDb(final Env env) {
66 63
		if (dbParam != null && !dbParam.isEmpty()) {
67
			return token.getEnv().getAttribute(dbParam);
64
			return env.getAttribute(dbParam, String.class);
68 65
		} else if (dbProperty != null && !dbProperty.isEmpty()) {
69 66
			return getPropertyFetcher().getProperty(dbProperty);
70 67
		} else {

Also available in: Unified diff