Revision 40094
Added by Michele Artini over 8 years ago
ExecuteSqlJobNode.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 |
|
7 |
import org.apache.commons.io.IOUtils; |
|
8 |
|
|
9 |
import com.googlecode.sarasvati.Arc; |
|
10 |
import com.googlecode.sarasvati.NodeToken; |
|
11 |
|
|
12 | 6 |
import eu.dnetlib.enabling.database.rmi.DatabaseService; |
13 | 7 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
8 |
import eu.dnetlib.msro.workflows.graph.Arc; |
|
9 |
import eu.dnetlib.msro.workflows.graph.Env; |
|
14 | 10 |
import eu.dnetlib.msro.workflows.nodes.AsyncJobNode; |
11 |
import org.apache.commons.io.IOUtils; |
|
15 | 12 |
|
16 | 13 |
public class ExecuteSqlJobNode extends AsyncJobNode { |
17 | 14 |
|
... | ... | |
25 | 22 |
private UniqueServiceLocator serviceLocator; |
26 | 23 |
|
27 | 24 |
@Override |
28 |
protected String execute(final NodeToken token) throws Exception { |
|
29 |
serviceLocator.getService(DatabaseService.class).updateSQL(findDb(token), fetchSqlAsText(sql)); |
|
30 |
|
|
25 |
protected String execute(final Env env) throws Exception { |
|
26 |
serviceLocator.getService(DatabaseService.class).updateSQL(findDb(env), fetchSqlAsText(sql)); |
|
31 | 27 |
return Arc.DEFAULT_ARC; |
32 | 28 |
} |
33 | 29 |
|
... | ... | |
35 | 31 |
return IOUtils.toString(getClass().getResourceAsStream(path)); |
36 | 32 |
} |
37 | 33 |
|
38 |
private String findDb(final NodeToken token) {
|
|
34 |
private String findDb(final Env env) {
|
|
39 | 35 |
if (dbParam != null && !dbParam.isEmpty()) { |
40 |
return token.getEnv().getAttribute(dbParam);
|
|
36 |
return env.getAttribute(dbParam, String.class);
|
|
41 | 37 |
} else if (dbProperty != null && !dbProperty.isEmpty()) { |
42 | 38 |
return getPropertyFetcher().getProperty(dbProperty); |
43 | 39 |
} else { |
Also available in: Unified diff
partial reimplementation of the wf engine