use of org.motechproject.tasks.service.util.TaskFilterExecutor in project motech by motech.
the class TaskInitializer method checkActionFilter.
@Transactional
public boolean checkActionFilter(int actualFilterIndex, List<FilterSet> filterSetList) throws TaskHandlerException {
boolean result;
TaskFilterExecutor taskFilterExecutor = new TaskFilterExecutor();
try {
result = taskFilterExecutor.checkFilters(filterSetList.get(actualFilterIndex).getFilters(), filterSetList.get(actualFilterIndex).getOperator(), taskContext);
} catch (RuntimeException e) {
throw new TaskHandlerException(FILTER, "task.error.filterError", e);
}
return result;
}
use of org.motechproject.tasks.service.util.TaskFilterExecutor in project motech by motech.
the class TaskInitializer method evalConfigSteps.
/**
* Executes all config steps (loading data from data sources, checking filters) defined for this task.
*
* @param dataProviders the map of data providers, not null or empty
* @return true if all steps were executed, false otherwise
* @throws TaskHandlerException if there were error while handling task
*/
@Transactional
public boolean evalConfigSteps(Map<String, DataProvider> dataProviders) throws TaskHandlerException {
LOGGER.info("Executing all config steps for task: {}", taskContext.getTask().getName());
Iterator<TaskConfigStep> iterator = taskContext.getTask().getTaskConfig().getSteps().iterator();
boolean result = true;
TaskFilterExecutor taskFilterExecutor = new TaskFilterExecutor();
while (result && iterator.hasNext()) {
TaskConfigStep step = iterator.next();
if (step instanceof DataSource) {
DataSource ds = (DataSource) step;
taskContext.addDataSourceObject(ds.getObjectId().toString(), getDataSourceObject(ds, dataProviders), ds.isFailIfDataNotFound());
LOGGER.info("Task data source: {} for task: {} added", ds.getName(), taskContext.getTask().getName());
} else if (step instanceof FilterSet && !isActionFilter((FilterSet) step)) {
try {
FilterSet filterSet = (FilterSet) step;
result = taskFilterExecutor.checkFilters(filterSet.getFilters(), filterSet.getOperator(), taskContext);
} catch (RuntimeException e) {
throw new TaskHandlerException(FILTER, "task.error.filterError", e);
}
}
}
return result;
}
Aggregations