Project

General

Profile

« Previous | Next » 

Revision 41502

PROPERTY param

View differences:

modules/dnet-msro-service/branches/workflow_templates/src/main/java/eu/dnetlib/msro/workflows/graph/GraphLoader.java
7 7
import java.util.Map;
8 8
import java.util.Set;
9 9

  
10
import javax.annotation.Resource;
11

  
10 12
import org.apache.commons.lang.StringUtils;
13
import org.apache.commons.logging.Log;
14
import org.apache.commons.logging.LogFactory;
11 15
import org.dom4j.Document;
12 16
import org.dom4j.Element;
13 17
import org.springframework.beans.factory.annotation.Required;
14 18

  
15 19
import com.google.common.collect.Sets;
16 20

  
21
import eu.dnetlib.conf.PropertyFetcher;
17 22
import eu.dnetlib.msro.rmi.MSROException;
18 23
import eu.dnetlib.msro.workflows.util.NodeHelper;
19 24

  
......
24 29

  
25 30
	private NodeHelper nodeHelper;
26 31

  
32
	@Resource(name = "propertyFetcher")
33
	private PropertyFetcher propertyFetcher;
34

  
35
	private static final Log log = LogFactory.getLog(GraphLoader.class);
36

  
27 37
	public Graph loadGraph(final Document doc, final Map<String, String> globalParams) throws MSROException {
28 38
		final Graph graph = new Graph();
29 39

  
......
67 77
			final String pName = p.valueOf("@name");
68 78
			final String pValue = p.valueOf("@value");
69 79
			final String pRef = p.valueOf("@ref");
80
			final String pProp = p.valueOf("@property");
70 81

  
71 82
			if (StringUtils.isNotBlank(pRef) && StringUtils.isNotBlank(globalParams.get(pRef))) {
72 83
				params.put(pName, globalParams.get(pRef));
73 84
			} else if (StringUtils.isNotBlank(pValue)) {
74 85
				params.put(pName, pValue);
86
			} else if (StringUtils.isNotBlank(pProp)) {
87
				params.put(pName, resolveProperty(pProp));
75 88
			} else if (p.selectSingleNode("./MAP") != null) {
76 89

  
77 90
				final Map<String, String> map = new HashMap<String, String>();
......
80 93
					final String eKey = entry.valueOf("@key");
81 94
					final String eValue = entry.valueOf("@value");
82 95
					final String eRef = entry.valueOf("@ref");
96
					final String eProp = entry.valueOf("@property");
97

  
83 98
					if (StringUtils.isNotBlank(eRef) && StringUtils.isNotBlank(globalParams.get(eRef))) {
84 99
						map.put(eKey, globalParams.get(eRef));
85 100
					} else if (StringUtils.isNotBlank(eValue)) {
86 101
						map.put(eKey, eValue);
102
					} else if (StringUtils.isNotBlank(eProp)) {
103
						map.put(eKey, resolveProperty(eProp));
87 104
					}
88 105
				}
89 106
				params.put(pName, map);
......
93 110
					final Element item = (Element) i;
94 111
					final String iValue = item.valueOf("@value");
95 112
					final String iRef = item.valueOf("@ref");
113
					final String iProp = item.valueOf("@property");
114

  
96 115
					if (StringUtils.isNotBlank(iRef) && StringUtils.isNotBlank(globalParams.get(iRef))) {
97 116
						list.add(globalParams.get(iRef));
98 117
					} else if (StringUtils.isNotBlank(iValue)) {
99 118
						list.add(iValue);
119
					} else if (StringUtils.isNotBlank(iProp)) {
120
						list.add(resolveProperty(iProp));
100 121
					}
101 122
				}
102 123
				params.put(pName, list);
......
106 127
		return params;
107 128
	}
108 129

  
130
	private String resolveProperty(final String propertyName) {
131
		if (!this.propertyFetcher.getProps().containsKey(propertyName)) {
132
			log.warn("unable to find system property: " + propertyName);
133
		}
134
		return this.propertyFetcher.getProperty(propertyName);
135
	}
136

  
109 137
	private void checkValidity(final Graph graph) throws MSROException {
110 138

  
111 139
		final Set<String> nodesFromArcs = new HashSet<String>();
modules/dnet-msro-service/branches/workflow_templates/src/main/java/eu/dnetlib/msro/workflows/nodes/db/ExecuteSqlJobNode.java
1 1
package eu.dnetlib.msro.workflows.nodes.db;
2 2

  
3 3
import java.io.IOException;
4

  
4 5
import javax.annotation.Resource;
5 6

  
7
import org.apache.commons.io.IOUtils;
8

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

  
13 15
public class ExecuteSqlJobNode extends AsyncJobNode {
14 16

  
15 17
	private String db;
16 18
	private String dbParam;
17
	private String dbProperty;
18 19

  
19 20
	private String sql;
20 21

  
......
23 24

  
24 25
	@Override
25 26
	protected String execute(final Env env) throws Exception {
26
		serviceLocator.getService(DatabaseService.class).updateSQL(findDb(env), fetchSqlAsText(sql));
27
		this.serviceLocator.getService(DatabaseService.class).updateSQL(findDb(env), fetchSqlAsText(this.sql));
27 28
		return Arc.DEFAULT_ARC;
28 29
	}
29 30

  
......
32 33
	}
33 34

  
34 35
	private String findDb(final Env env) {
35
		if (dbParam != null && !dbParam.isEmpty()) {
36
			return env.getAttribute(dbParam, String.class);
37
		} else if (dbProperty != null && !dbProperty.isEmpty()) {
38
			return getPropertyFetcher().getProperty(dbProperty);
36
		if (this.dbParam != null && !this.dbParam.isEmpty()) {
37
			return env.getAttribute(this.dbParam, String.class);
39 38
		} else {
40
			return db;
39
			return this.db;
41 40
		}
42 41
	}
43 42

  
44 43
	public String getDb() {
45
		return db;
44
		return this.db;
46 45
	}
47 46

  
48 47
	public void setDb(final String db) {
......
50 49
	}
51 50

  
52 51
	public String getDbParam() {
53
		return dbParam;
52
		return this.dbParam;
54 53
	}
55 54

  
56 55
	public void setDbParam(final String dbParam) {
57 56
		this.dbParam = dbParam;
58 57
	}
59 58

  
60
	public String getDbProperty() {
61
		return dbProperty;
62
	}
63

  
64
	public void setDbProperty(final String dbProperty) {
65
		this.dbProperty = dbProperty;
66
	}
67

  
68 59
	public String getSql() {
69
		return sql;
60
		return this.sql;
70 61
	}
71 62

  
72 63
	public void setSql(final String sql) {
modules/dnet-msro-service/branches/workflow_templates/src/main/java/eu/dnetlib/msro/workflows/nodes/db/QueryDbJobNode.java
1 1
package eu.dnetlib.msro.workflows.nodes.db;
2 2

  
3 3
import java.io.IOException;
4

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

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

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

  
15 17
public class QueryDbJobNode extends AsyncJobNode {
16 18

  
17 19
	private String db;
18 20
	private String dbParam;
19
	private String dbProperty;
20 21

  
21 22
	private String sql;
22 23
	private String sqlForSize;
......
28 29

  
29 30
	@Override
30 31
	protected String execute(final Env env) throws Exception {
31
		final String sqlText = fetchSqlAsText(sql);
32
		final String sqlText = fetchSqlAsText(this.sql);
32 33

  
33 34
		W3CEndpointReference epr = null;
34 35

  
35
		final DatabaseService dbService = serviceLocator.getService(DatabaseService.class);
36
		final DatabaseService dbService = this.serviceLocator.getService(DatabaseService.class);
36 37

  
37
		if (StringUtils.isNotBlank(xslt)) {
38
			final String xsltText = IOUtils.toString(getClass().getResourceAsStream(xslt));
38
		if (StringUtils.isNotBlank(this.xslt)) {
39
			final String xsltText = IOUtils.toString(getClass().getResourceAsStream(this.xslt));
39 40

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

  
53
		env.setAttribute(outputEprParam, epr.toString());
54
		env.setAttribute(this.outputEprParam, epr.toString());
54 55

  
55 56
		return Arc.DEFAULT_ARC;
56 57
	}
......
60 61
	}
61 62

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

  
72 71
	public String getDb() {
73
		return db;
72
		return this.db;
74 73
	}
75 74

  
76 75
	public void setDb(final String db) {
......
78 77
	}
79 78

  
80 79
	public String getDbParam() {
81
		return dbParam;
80
		return this.dbParam;
82 81
	}
83 82

  
84 83
	public void setDbParam(final String dbParam) {
......
86 85
	}
87 86

  
88 87
	public String getSql() {
89
		return sql;
88
		return this.sql;
90 89
	}
91 90

  
92 91
	public void setSql(final String sql) {
......
94 93
	}
95 94

  
96 95
	public String getXslt() {
97
		return xslt;
96
		return this.xslt;
98 97
	}
99 98

  
100 99
	public void setXslt(final String xslt) {
......
102 101
	}
103 102

  
104 103
	public String getOutputEprParam() {
105
		return outputEprParam;
104
		return this.outputEprParam;
106 105
	}
107 106

  
108 107
	public void setOutputEprParam(final String outputEprParam) {
109 108
		this.outputEprParam = outputEprParam;
110 109
	}
111 110

  
112
	public String getDbProperty() {
113
		return dbProperty;
114
	}
115

  
116
	public void setDbProperty(final String dbProperty) {
117
		this.dbProperty = dbProperty;
118
	}
119

  
120 111
	public String getSqlForSize() {
121
		return sqlForSize;
112
		return this.sqlForSize;
122 113
	}
123 114

  
124 115
	public void setSqlForSize(final String sqlForSize) {
modules/dnet-msro-service/branches/workflow_templates/src/main/java/eu/dnetlib/msro/workflows/nodes/ProcessNode.java
1 1
package eu.dnetlib.msro.workflows.nodes;
2 2

  
3
import java.util.HashMap;
4
import java.util.Map;
5
import javax.annotation.Resource;
3
import org.springframework.beans.factory.BeanNameAware;
6 4

  
7
import com.google.gson.Gson;
8
import eu.dnetlib.conf.PropertyFetcher;
9
import eu.dnetlib.msro.workflows.procs.Env;
10 5
import eu.dnetlib.msro.workflows.procs.Token;
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.beans.factory.BeanNameAware;
15 6

  
16 7
/**
17 8
 * Created by michele on 19/11/15.
18 9
 */
19 10
public abstract class ProcessNode implements BeanNameAware {
20 11

  
21
	private static final Log log = LogFactory.getLog(ProcessNode.class);
22 12
	private String beanName;
23 13

  
24
	@Resource(name = "propertyFetcher")
25
	private PropertyFetcher propertyFetcher;
26

  
27
	/**
28
	 * parameter values injected as json map into subclasses instance beans.
29
	 */
30
	private String jsonParams;
31

  
32
	/**
33
	 * parameter values retrieved from the process Env.
34
	 */
35
	private String jsonEnvParams;
36

  
37
	/**
38
	 * parameter values retrieved from the system properties.
39
	 */
40
	private String jsonSystemPropertyParams;
41

  
42 14
	public abstract void execute(final Token token);
43 15

  
44
	protected final Map<String, Object> parseJsonParameters(final Env env) {
45
		final Map<String, Object> res = new HashMap<String, Object>();
46

  
47
		for (Map.Entry<?, ?> e : asMap(getJsonEnvParams()).entrySet()) {
48
			final String propertyName = e.getValue().toString();
49

  
50
			if (!getPropertyFetcher().getProps().containsKey(propertyName)) {
51
				log.warn("unable to find system property: " + propertyName);
52
			}
53

  
54
			final String propertyValue = getPropertyFetcher().getProperty(propertyName);
55
			res.put(e.getKey().toString(), propertyValue);
56
		}
57

  
58
		for (Map.Entry<?, ?> e : asMap(getJsonEnvParams()).entrySet()) {
59
			res.put(e.getKey().toString(), env.getAttribute(e.getValue().toString()));
60
		}
61

  
62
		for (Map.Entry<?, ?> e : asMap(getJsonParams()).entrySet()) {
63
			res.put(e.getKey().toString(), e.getValue());
64
		}
65

  
66
		return res;
67
	}
68

  
69
	private Map<?, ?> asMap(final String s) {
70
		return StringUtils.isNotBlank(s) ? new Gson().fromJson(s, Map.class) : new HashMap<String, Object>();
71
	}
72

  
73 16
	public String getBeanName() {
74
		return beanName;
17
		return this.beanName;
75 18
	}
76 19

  
77 20
	@Override
......
79 22
		this.beanName = beanName;
80 23
	}
81 24

  
82
	public PropertyFetcher getPropertyFetcher() {
83
		return propertyFetcher;
84
	}
85

  
86
	public void setPropertyFetcher(final PropertyFetcher propertyFetcher) {
87
		this.propertyFetcher = propertyFetcher;
88
	}
89

  
90
	public String getJsonParams() {
91
		return jsonParams;
92
	}
93

  
94
	public void setJsonParams(final String jsonParams) {
95
		this.jsonParams = jsonParams;
96
	}
97

  
98
	public String getJsonEnvParams() {
99
		return jsonEnvParams;
100
	}
101

  
102
	public void setJsonEnvParams(final String jsonEnvParams) {
103
		this.jsonEnvParams = jsonEnvParams;
104
	}
105

  
106
	public String getJsonSystemPropertyParams() {
107
		return jsonSystemPropertyParams;
108
	}
109

  
110
	public void setJsonSystemPropertyParams(final String jsonSystemPropertyParams) {
111
		this.jsonSystemPropertyParams = jsonSystemPropertyParams;
112
	}
113

  
114 25
	@Override
115 26
	public String toString() {
116
		return String.format("[node beanName=%s]", beanName);
27
		return String.format("[node beanName=%s]", this.beanName);
117 28
	}
118 29
}
modules/dnet-msro-service/branches/workflow_templates/src/main/java/eu/dnetlib/msro/workflows/nodes/transform/ApplyXsltJobNode.java
2 2

  
3 3
import java.util.HashMap;
4 4
import java.util.Map;
5

  
5 6
import javax.xml.ws.wsaddressing.W3CEndpointReference;
6 7

  
8
import org.springframework.beans.factory.annotation.Required;
9
import org.springframework.core.io.ClassPathResource;
10

  
7 11
import eu.dnetlib.enabling.resultset.XSLTMappedResultSetFactory;
8 12
import eu.dnetlib.enabling.resultset.client.utils.EPRUtils;
9 13
import eu.dnetlib.msro.rmi.MSROException;
10 14
import eu.dnetlib.msro.workflows.graph.Arc;
11 15
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode;
12 16
import eu.dnetlib.msro.workflows.procs.Env;
13
import org.springframework.beans.factory.annotation.Required;
14
import org.springframework.core.io.ClassPathResource;
15 17

  
16 18
public class ApplyXsltJobNode extends SimpleJobNode {
17 19

  
18 20
	private String inputEprParam;
19 21
	private String outputEprParam;
20 22
	private String xsltClasspath;
23
	private Map<String, String> xsltParams;
21 24

  
22 25
	private XSLTMappedResultSetFactory xsltMappedResultSetFactory;
23 26

  
24 27
	@Override
25 28
	protected String execute(final Env env) throws Exception {
26
		final String inputEpr = env.getAttribute(inputEprParam, String.class);
27
		if ((inputEpr == null) || inputEpr.isEmpty()) throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV");
29
		final String inputEpr = env.getAttribute(this.inputEprParam, String.class);
30
		if ((inputEpr == null) || inputEpr.isEmpty()) { throw new MSROException("InputEprParam (" + this.inputEprParam + ") not found in ENV"); }
28 31

  
29
		final Map<String, String> xsltParams = new HashMap<String, String>();
32
		final Map<String, String> params = new HashMap<String, String>();
30 33

  
31
		for (Map.Entry<String, Object> e : env.getAttributes().entrySet()) {
32
			xsltParams.put(e.getKey().replaceAll(":", "_"), e.getValue().toString());
34
		if (this.xsltParams != null) {
35
			params.putAll(this.xsltParams);
33 36
		}
34 37

  
35
		for (Map.Entry<String, Object> e : parseJsonParameters(env).entrySet()) {
36
			xsltParams.put(e.getKey(), e.getValue().toString());
38
		for (final Map.Entry<String, Object> e : env.getAttributes().entrySet()) {
39
			params.put(e.getKey().replaceAll(":", "_"), e.getValue().toString());
37 40
		}
38 41

  
39
		final W3CEndpointReference epr = xsltMappedResultSetFactory.createMappedResultSet(new EPRUtils().getEpr(inputEpr),
40
				(new ClassPathResource(xsltClasspath)), xsltParams);
42
		final W3CEndpointReference epr = this.xsltMappedResultSetFactory.createMappedResultSet(new EPRUtils().getEpr(inputEpr),
43
				(new ClassPathResource(this.xsltClasspath)), params);
41 44

  
42
		env.setAttribute(outputEprParam, epr.toString());
45
		env.setAttribute(this.outputEprParam, epr.toString());
43 46

  
44 47
		return Arc.DEFAULT_ARC;
45 48
	}
46 49

  
47 50
	public String getInputEprParam() {
48
		return inputEprParam;
51
		return this.inputEprParam;
49 52
	}
50 53

  
51 54
	public void setInputEprParam(final String inputEprParam) {
......
53 56
	}
54 57

  
55 58
	public String getOutputEprParam() {
56
		return outputEprParam;
59
		return this.outputEprParam;
57 60
	}
58 61

  
59 62
	public void setOutputEprParam(final String outputEprParam) {
......
61 64
	}
62 65

  
63 66
	public String getXsltClasspath() {
64
		return xsltClasspath;
67
		return this.xsltClasspath;
65 68
	}
66 69

  
67 70
	public void setXsltClasspath(final String xsltClasspath) {
......
69 72
	}
70 73

  
71 74
	public XSLTMappedResultSetFactory getXsltMappedResultSetFactory() {
72
		return xsltMappedResultSetFactory;
75
		return this.xsltMappedResultSetFactory;
73 76
	}
74 77

  
75 78
	@Required
......
77 80
		this.xsltMappedResultSetFactory = xsltMappedResultSetFactory;
78 81
	}
79 82

  
83
	public Map<String, String> getXsltParams() {
84
		return this.xsltParams;
85
	}
86

  
87
	public void setXsltParams(final Map<String, String> xsltParams) {
88
		this.xsltParams = xsltParams;
89
	}
90

  
80 91
}
modules/dnet-msro-service/branches/workflow_templates/src/main/java/eu/dnetlib/msro/workflows/nodes/transform/GroovyJobNode.java
2 2

  
3 3
import java.io.IOException;
4 4
import java.util.Map;
5

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

  
9
import org.apache.commons.logging.Log;
10
import org.apache.commons.logging.LogFactory;
11
import org.springframework.beans.factory.annotation.Required;
12

  
8 13
import com.google.common.collect.Maps;
14

  
9 15
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
10 16
import eu.dnetlib.enabling.locators.UniqueServiceLocator;
11 17
import eu.dnetlib.enabling.resultset.MappedResultSetFactory;
......
16 22
import eu.dnetlib.msro.workflows.procs.Env;
17 23
import groovy.lang.GroovyShell;
18 24
import groovy.util.GroovyScriptEngine;
19
import org.apache.commons.logging.Log;
20
import org.apache.commons.logging.LogFactory;
21
import org.springframework.beans.factory.annotation.Required;
22 25

  
23 26
public class GroovyJobNode extends SimpleJobNode {
24 27

  
......
33 36
	private String inputEprParam;
34 37
	private String outputEprParam;
35 38
	private String transformationRuleId;
36
	// private String groovyParams;
39
	private Map<String, String> groovyParams;
37 40

  
38 41
	@Resource
39 42
	private UniqueServiceLocator serviceLocator;
40 43

  
41 44
	private Map<String, String> retrieveGroovyParameter() {
42
		Map<String, String> out = Maps.newHashMap();
45
		final Map<String, String> out = Maps.newHashMap();
43 46

  
44
		String query = "for $x in collection('/db/DRIVER/GroovyProcessingDSResource/GroovyProcessingDSResourceType')"
45
				+ "where $x[.//RESOURCE_IDENTIFIER/@value='" + transformationRuleId + "']"
47
		final String query = "for $x in collection('/db/DRIVER/GroovyProcessingDSResource/GroovyProcessingDSResourceType')"
48
				+ "where $x[.//RESOURCE_IDENTIFIER/@value='" + this.transformationRuleId + "']"
46 49
				+ "return concat($x//GROOVY_CLASSPATH/text(),':::',$x//GROOVY_DNETCLASS/text())";
47 50
		try {
48
			String result = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query).get(0);
51
			final String result = this.serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query).get(0);
49 52
			if (result == null) { return null; }
50
			String[] data = result.trim().split(":::");
53
			final String[] data = result.trim().split(":::");
51 54
			if (data.length == 2) {
52 55
				out.put("classpath", data[0]);
53 56
				out.put("mainClass", data[1]);
54 57
			}
55 58

  
56 59
			return out;
57
		} catch (Exception e) {
60
		} catch (final Exception e) {
58 61
			log.error(e);
59 62
			return null;
60 63
		}
......
62 65

  
63 66
	@Override
64 67
	protected String execute(final Env env) throws Exception {
65
		final String inputEprString = env.getAttribute(inputEprParam, String.class);
66
		if (inputEprString == null || inputEprString.isEmpty()) { throw new MSROException("InputEprParam (" + inputEprParam + ") not found in ENV"); }
68
		final String inputEprString = env.getAttribute(this.inputEprParam, String.class);
69
		if (inputEprString == null || inputEprString.isEmpty()) { throw new MSROException("InputEprParam (" + this.inputEprParam + ") not found in ENV"); }
67 70
		final W3CEndpointReference inputEpr = new EPRUtils().getEpr(inputEprString);
68 71
		String groovyClasspath, groovyDnetClass;
69
		Map<String, String> prop = retrieveGroovyParameter();
72
		final Map<String, String> prop = retrieveGroovyParameter();
70 73
		groovyClasspath = prop.get("classpath");
71 74
		groovyDnetClass = prop.get("mainClass");
72
		W3CEndpointReference epr = transformGroovy(inputEpr, groovyClasspath, groovyDnetClass, parseJsonParameters(env));
73
		env.setAttribute(outputEprParam, epr.toString());
75
		final W3CEndpointReference epr = transformGroovy(inputEpr, groovyClasspath, groovyDnetClass, this.groovyParams);
76
		env.setAttribute(this.outputEprParam, epr.toString());
74 77
		return Arc.DEFAULT_ARC;
75 78
	}
76 79

  
77 80
	private W3CEndpointReference transformGroovy(final W3CEndpointReference source,
78 81
			final String groovyClasspath,
79 82
			final String groovyDnetClass,
80
			final Map<String, Object> params) throws ClassNotFoundException, IOException {
83
			final Map<String, String> params) throws ClassNotFoundException, IOException {
81 84

  
82
		GroovyScriptEngine gse = new GroovyScriptEngine(groovyClasspath);
85
		final GroovyScriptEngine gse = new GroovyScriptEngine(groovyClasspath);
83 86
		gse.getGroovyClassLoader().loadClass(groovyDnetClass);
84 87
		log.info("***********************************************");
85 88
		log.info("Loaded Groovy classes:");
86
		for (Class<?> c : gse.getGroovyClassLoader().getLoadedClasses()) {
89
		for (final Class<?> c : gse.getGroovyClassLoader().getLoadedClasses()) {
87 90
			log.info(c.getCanonicalName());
88 91
		}
89 92
		log.info("***********************************************");
90
		GroovyShell groovyShell = new GroovyShell(gse.getGroovyClassLoader());
93
		final GroovyShell groovyShell = new GroovyShell(gse.getGroovyClassLoader());
91 94

  
92
		Object go = groovyShell.evaluate("new " + groovyDnetClass + "()");
95
		final Object go = groovyShell.evaluate("new " + groovyDnetClass + "()");
93 96
		if (go instanceof GroovyUnaryFunction) {
94
			GroovyUnaryFunction groovyUnaryFunction = (GroovyUnaryFunction) go;
97
			final GroovyUnaryFunction groovyUnaryFunction = (GroovyUnaryFunction) go;
95 98
			if (params != null) {
96 99
				groovyUnaryFunction.setParams(params);
97 100
			}
98
			return mappedResultSetFactory.createMappedResultSet(source, groovyUnaryFunction);
101
			return this.mappedResultSetFactory.createMappedResultSet(source, groovyUnaryFunction);
99 102
		} else {
100 103
			throw new RuntimeException("Groovy object " + go + " is not supported");
101 104
		}
102 105
	}
103 106

  
104 107
	public MappedResultSetFactory getMappedResultSetFactory() {
105
		return mappedResultSetFactory;
108
		return this.mappedResultSetFactory;
106 109
	}
107 110

  
108 111
	@Required
......
111 114
	}
112 115

  
113 116
	public String getInputEprParam() {
114
		return inputEprParam;
117
		return this.inputEprParam;
115 118
	}
116 119

  
117 120
	public void setInputEprParam(final String inputEprParam) {
......
119 122
	}
120 123

  
121 124
	public String getOutputEprParam() {
122
		return outputEprParam;
125
		return this.outputEprParam;
123 126
	}
124 127

  
125 128
	public void setOutputEprParam(final String outputEprParam) {
......
127 130
	}
128 131

  
129 132
	public String getTransformationRuleId() {
130
		return transformationRuleId;
133
		return this.transformationRuleId;
131 134
	}
132 135

  
133 136
	public void setTransformationRuleId(final String transformationRuleId) {
134 137
		this.transformationRuleId = transformationRuleId;
135 138
	}
136 139

  
140
	public Map<String, String> getGroovyParams() {
141
		return this.groovyParams;
142
	}
143

  
144
	public void setGroovyParams(final Map<String, String> groovyParams) {
145
		this.groovyParams = groovyParams;
146
	}
147

  
137 148
}
modules/dnet-msro-service/branches/workflow_templates/src/main/java/eu/dnetlib/msro/workflows/nodes/transform/GroovyUnaryFunction.java
6 6

  
7 7
public abstract class GroovyUnaryFunction implements UnaryFunction<String, String> {
8 8

  
9
	private Map<String, Object> params;
9
	private Map<String, String> params;
10 10

  
11 11
	@Override
12 12
	abstract public String evaluate(String input);
13 13

  
14
	public Map<String, Object> getParams() {
15
		return params;
14
	public Map<String, String> getParams() {
15
		return this.params;
16 16
	}
17 17

  
18
	public void setParams(final Map<String, Object> params) {
18
	public void setParams(final Map<String, String> params) {
19 19
		this.params = params;
20 20
	}
21 21

  
modules/dnet-msro-service/branches/workflow_templates/src/main/resources/eu/dnetlib/test/schemas/WorkflowTemplateDSResourceType.xsd
92 92
																											<xs:attribute name="key" type="xs:NCName" use="required" />
93 93
																											<xs:attribute name="ref" use="optional" type="xs:string" />
94 94
																											<xs:attribute name="value" use="optional" type="xs:string" />
95
																											<xs:attribute name="property" use="optional" type="xs:string" />
95 96
																										</xs:complexType>
96 97
																									</xs:element>
97 98
																								</xs:sequence>
......
104 105
																										<xs:complexType>
105 106
																											<xs:attribute name="ref" use="optional" type="xs:string" />
106 107
																											<xs:attribute name="value" use="optional" type="xs:string" />
108
																											<xs:attribute name="property" use="optional" type="xs:string" />
107 109
																										</xs:complexType>
108 110
																									</xs:element>
109 111
																								</xs:sequence>
......
113 115
																					<xs:attribute name="name" use="required" type="xs:NCName" />
114 116
																					<xs:attribute name="ref" use="optional" type="xs:string" />
115 117
																					<xs:attribute name="value" use="optional" type="xs:string" />
118
																					<xs:attribute name="property" use="optional" type="xs:string" />
116 119
																				</xs:complexType>
117 120
																			</xs:element>
118 121
																		</xs:sequence>
modules/dnet-msro-service/branches/workflow_templates/src/main/resources/eu/dnetlib/test/schemas/WorkflowDSResourceType.xsd
146 146
																											<xs:attribute name="key" type="xs:NCName" use="required" />
147 147
																											<xs:attribute name="ref" use="optional" type="xs:string" />
148 148
																											<xs:attribute name="value" use="optional" type="xs:string" />
149
																											<xs:attribute name="property" use="optional" type="xs:string" />
149 150
																										</xs:complexType>
150 151
																									</xs:element>
151 152
																								</xs:sequence>
......
158 159
																										<xs:complexType>
159 160
																											<xs:attribute name="ref" use="optional" type="xs:string" />
160 161
																											<xs:attribute name="value" use="optional" type="xs:string" />
162
																											<xs:attribute name="property" use="optional" type="xs:string" />
161 163
																										</xs:complexType>
162 164
																									</xs:element>
163 165
																								</xs:sequence>
......
167 169
																					<xs:attribute name="name" use="required" type="xs:NCName" />
168 170
																					<xs:attribute name="ref" use="optional" type="xs:string" />
169 171
																					<xs:attribute name="value" use="optional" type="xs:string" />
172
																					<xs:attribute name="property" use="optional" type="xs:string" />
170 173
																				</xs:complexType>
171 174
																			</xs:element>
172 175
																		</xs:sequence>

Also available in: Unified diff