Project

General

Profile

« Previous | Next » 

Revision 58646

By default sql is a classpath. if requested is the actual sql to be executed

View differences:

modules/dnet-msro-service/trunk/src/main/java/eu/dnetlib/msro/workflows/nodes/db/ExecuteSqlJobNode.java
20 20
	private String dbProperty;
21 21

  
22 22
	private String sql;
23
	private boolean sqlInClasspath = true;
23 24

  
24 25
	@Resource
25 26
	private UniqueServiceLocator serviceLocator;
......
27 28
	@Override
28 29
	protected String execute(final NodeToken token) throws Exception {
29 30
		serviceLocator.getService(DatabaseService.class).updateSQL(findDb(token), fetchSqlAsText(sql));
30

  
31 31
		return Arc.DEFAULT_ARC;
32 32
	}
33 33

  
34 34
	private String fetchSqlAsText(final String path) throws IOException {
35
		return IOUtils.toString(getClass().getResourceAsStream(path));
35
		if(sqlInClasspath)
36
			return IOUtils.toString(getClass().getResourceAsStream(path));
37
		else return sql;
36 38
	}
37 39

  
38 40
	private String findDb(final NodeToken token) {
......
77 79
		this.sql = sql;
78 80
	}
79 81

  
82
	public boolean isSqlInClasspath() { return sqlInClasspath; }
83

  
84
	public void setSqlInClasspath(boolean sqlInClasspath) { this.sqlInClasspath = sqlInClasspath; }
80 85
}

Also available in: Unified diff