{
Template template = das.queryTemplate(data.getTemplateId());
if(template == null)
return null;
Flow flow = das.queryFlow(template.getFlowId());
if(flow == null)
return null;
Action action = null;
if(data.getObject("logActionId") != null)
{
action = flow.getAction((UUID)data.getObject("logActionId"));
if(action == null)
return null;
}
StringBuffer sqlStrb = new StringBuffer();
sqlStrb.append("SELECT * FROM script_new WHERE 1=1");
sqlStrb.append(" AND (template_type_ids IS NULL");
sqlStrb.append(" OR template_type_ids LIKE '%").append(template.getTemplateTypeId()).append("%')");
sqlStrb.append(" AND (template_ids IS NULL");
sqlStrb.append(" OR template_ids LIKE '%").append(template.getId()).append("%')");
sqlStrb.append(" AND (flow_ids IS NULL");
sqlStrb.append(" OR flow_ids LIKE '%").append(flow.getId()).append("%')");
sqlStrb.append(" AND (end_stat_ids IS NULL");
sqlStrb.append(" OR end_stat_ids LIKE '%").append(data.getStatusId()).append("%')");
if(action == null)