use of org.motechproject.tasks.domain.mds.task.TaskError in project motech by motech.
the class TaskValidator method validateDataSource.
private Set<TaskError> validateDataSource(DataSource dataSource) {
Set<TaskError> errors = new HashSet<>();
String field = "taskConfig.dataSource[" + dataSource.getOrder() + "]";
for (Lookup lookup : dataSource.getLookup()) {
if (isEmpty(errors)) {
String objectName = "task." + field;
checkNullValue(errors, objectName, "objectId", dataSource.getObjectId());
checkBlankValue(errors, objectName, "type", dataSource.getType());
checkBlankValue(errors, objectName, "lookup.field", lookup.getField());
checkBlankValue(errors, objectName, "lookup.value", lookup.getValue());
}
}
return errors;
}
use of org.motechproject.tasks.domain.mds.task.TaskError in project motech by motech.
the class TaskServiceImpl method validateAction.
private Set<TaskError> validateAction(Task task, Channel channel, TaskActionInformation action) {
LOGGER.debug("Validating task action: {} from task: {} with ID: {}", action.getName(), task.getName(), task.getId());
Set<TaskError> errors = new HashSet<>();
if (channel == null) {
errors.add(new TaskError("task.validation.error.actionChannelNotRegistered"));
return errors;
}
if (channel.getModuleName().equalsIgnoreCase(action.getModuleName())) {
errors.addAll(taskValidator.validateAction(action, channel));
TriggerEvent trigger = triggerEventService.getTrigger(task.getTrigger());
Map<Long, TaskDataProvider> providers = getProviders(task);
ActionEvent actionEvent = channel.getAction(action);
if (actionEvent != null) {
errors.addAll(taskValidator.validateActionFields(action, actionEvent, trigger, providers));
}
}
logResultOfValidation("task action", task.getName(), errors);
return errors;
}
use of org.motechproject.tasks.domain.mds.task.TaskError in project motech by motech.
the class TaskServiceImpl method validateTasksAfterChannelUpdate.
@MotechListener(subjects = CHANNEL_UPDATE_SUBJECT)
@Transactional
public void validateTasksAfterChannelUpdate(MotechEvent event) {
String moduleName = event.getParameters().get(CHANNEL_MODULE_NAME).toString();
Channel channel = channelService.getChannel(moduleName);
LOGGER.debug("Handling Channel update: {} for module: {}", channel.getDisplayName(), moduleName);
List<Task> tasks = findTasksDependentOnModule(moduleName);
for (Task task : tasks) {
Set<TaskError> errors;
if (task.getTrigger() != null) {
errors = validateTrigger(task);
handleValidationErrors(task, errors, TASK_TRIGGER_VALIDATION_ERRORS);
}
errors = validateActions(task, channel);
handleValidationErrors(task, errors, TASK_ACTION_VALIDATION_ERRORS);
}
}
use of org.motechproject.tasks.domain.mds.task.TaskError in project motech by motech.
the class TaskServiceImpl method validateProvider.
private Set<TaskError> validateProvider(TaskDataProvider provider, DataSource dataSource, Task task, Map<Long, TaskDataProvider> availableDataProviders) {
LOGGER.debug("Validating task data provider: {} in task: {} with ID: {}", dataSource.getProviderName(), task.getName(), task.getId());
Set<TaskError> errors = new HashSet<>();
TaskTriggerInformation trigger = task.getTrigger();
if (provider != null) {
errors.addAll(taskValidator.validateProvider(provider, dataSource, triggerEventService.getTrigger(trigger), availableDataProviders));
} else {
errors.add(new TaskError("task.validation.error.providerNotExist", dataSource.getProviderName()));
}
logResultOfValidation("task data provider", task.getName(), errors);
return errors;
}
use of org.motechproject.tasks.domain.mds.task.TaskError in project motech by motech.
the class TaskServiceImpl method validateDataSources.
private Set<TaskError> validateDataSources(Task task) {
LOGGER.debug("Validating task data sources in task: {} with ID: {}", task.getName(), task.getId());
Set<TaskError> errors = new HashSet<>();
Map<Long, TaskDataProvider> availableDataProviders = new HashMap<>();
for (DataSource dataSource : task.getTaskConfig().getDataSources()) {
TaskDataProvider provider = providerService.getProvider(dataSource.getProviderName());
errors.addAll(validateProvider(provider, dataSource, task, availableDataProviders));
if (provider != null) {
availableDataProviders.put(provider.getId(), provider);
}
}
logResultOfValidation("task data sources", task.getName(), errors);
return errors;
}
Aggregations