12-05-2012 06:50 PM
public class UpdateSQLProcessTask extends SQLProcessTask {
@Override
protected void executeSQL(DelegateExecution execution) {
Properties props = new Properties();
int rows = this.getTemplate().update(this.getSQL(execution));
props.setProperty("rows", String.valueOf(rows));
}
}
public abstract class SQLProcessTask extends DataSourceTask implements JavaDelegate {
protected FixedValue fixedSQL;
protected JuelExpression expressionSQL;
public void execute(DelegateExecution execution) {
this.executeSQL(execution);
this.closeDatasource();
}
protected abstract void executeSQL(DelegateExecution execution);
protected void closeDatasource() {
try {
DataSourceUtils.releaseConnection(this.datasource.getConnection(), this.datasource);
this.datasource = null;
} catch (SQLException e) {
e.printStackTrace();
}
}
public void setFixedSQL(FixedValue fixedSQL) {
this.fixedSQL = fixedSQL;
}
public void setExpressionSQL(JuelExpression expressionSQL) {
this.expressionSQL = expressionSQL;
}
public String getSQL(DelegateExecution execution) {
if (expressionSQL != null) {
return expressionSQL.getValue(execution).toString();
} else if (fixedSQL != null) {
return fixedSQL.getValue(execution).toString();
}
return null;
}
}
public class DataSourceTask {
protected DataSource datasource = createDatasource();
protected JdbcTemplate template = new JdbcTemplate(datasource);
protected JdbcTemplate getTemplate() {
return template;
}
private DataSource createDatasource() {
return new DriverManagerDataSource(
"jdbc:mysql://someHost:3306/someDB", "user",
"hardPassword");
}
}
12-06-2012 01:58 AM
12-06-2012 04:21 AM
12-06-2012 07:01 AM
12-06-2012 11:28 AM
12-06-2012 11:35 AM
public abstract class SQLProcessTask extends DataSourceTask implements JavaDelegate {
protected FixedValue fixedSQL;
protected JuelExpression expressionSQL;
public void execute(DelegateExecution execution) {
this.openDatasource();
this.executeSQL(execution);
}
private void openDatasource() {
this.datasource = (DataSource) Context.getProcessEngineConfiguration().getBeans().get("dataSource.single");
this.template = new JdbcTemplate(datasource);
}
protected abstract void executeSQL(DelegateExecution execution);
public void setFixedSQL(FixedValue fixedSQL) {
this.fixedSQL = fixedSQL;
}
public void setExpressionSQL(JuelExpression expressionSQL) {
this.expressionSQL = expressionSQL;
}
public String getSQL(DelegateExecution execution) {
if (expressionSQL != null) {
return expressionSQL.getValue(execution).toString();
} else if (fixedSQL != null) {
return fixedSQL.getValue(execution).toString();
}
return null;
}
}
12-07-2012 03:41 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.