use of org.motechproject.tasks.domain.mds.channel.ActionParameter in project motech by motech.
the class TaskActionExecutorTest method prepareActionEventWithService.
private ActionEvent prepareActionEventWithService() {
ActionEvent actionEvent = new ActionEventBuilder().setDisplayName("Action").setDescription("").setServiceInterface("serviceInterface").setServiceMethod("serviceMethod").build();
SortedSet<ActionParameter> parameters = new TreeSet<>();
ActionParameter parameter = new ActionParameter();
parameter.setDisplayName("test");
parameter.setKey("testKey");
parameter.setType(TEXTAREA);
parameter.setOrder(0);
parameters.add(parameter);
actionEvent.setActionParameters(parameters);
actionEvent.setPostActionParameters(parameters);
return actionEvent;
}
use of org.motechproject.tasks.domain.mds.channel.ActionParameter in project motech by motech.
the class TaskAnnotationBeanPostProcessorTest method getExpectedActionParameters.
private SortedSet<ActionParameter> getExpectedActionParameters() {
SortedSet<ActionParameter> set = new TreeSet<>();
set.add(new ActionParameterBuilder().setDisplayName(EXTERNAL_DISPLAY_NAME).setKey(EXTERNAL_KEY).setOrder(0).build());
set.add(new ActionParameterBuilder().setDisplayName(MOTECH_DISPLAY_NAME).setKey(MOTECH_KEY).setOrder(1).setType(ParameterType.INTEGER).build());
return set;
}
use of org.motechproject.tasks.domain.mds.channel.ActionParameter in project motech by motech.
the class TaskAnnotationBeanPostProcessorTest method getExpectedPostActionParameters.
private SortedSet<ActionParameter> getExpectedPostActionParameters() {
SortedSet<ActionParameter> set = new TreeSet<>();
set.add(new ActionParameterBuilder().setDisplayName(EXTERNAL_DISPLAY_NAME_2).setKey(EXTERNAL_KEY_2).setOrder(0).build());
return set;
}
use of org.motechproject.tasks.domain.mds.channel.ActionParameter in project motech by motech.
the class ChannelValidator method validateAction.
private static Set<TaskError> validateAction(int index, ActionEvent action) {
Set<TaskError> errors = new HashSet<>();
String field = "actionTaskEvents[" + index + "]";
checkNullValue(errors, CHANNEL, field, action);
if (isEmpty(errors)) {
String objectName = CHANNEL + "." + field;
checkBlankValue(errors, objectName, "displayName", action.getDisplayName());
if (!action.hasSubject() && !action.hasService()) {
errors.add(new TaskError("task.validation.error.channelAction"));
}
for (ActionParameter parameter : action.getActionParameters()) {
errors.addAll(validateActionParameter(objectName, "actionParameters[" + parameter.getOrder() + "]", parameter));
}
for (ActionParameter parameter : action.getPostActionParameters()) {
errors.addAll(validateActionParameter(objectName, "postActionParameters[" + parameter.getOrder() + "]", parameter));
}
}
return errors;
}
use of org.motechproject.tasks.domain.mds.channel.ActionParameter in project motech by motech.
the class TaskValidator method validateActionFields.
/**
* Validates whether fields of the the action are properly set.
*
* @param action the information about action, not null
* @param actionEvent the action event, not null
* @param trigger the trigger of the task the action belongs to, not null
* @param providers the map of IDs and providers, not null
* @return the set of encountered errors
*/
@Transactional
public Set<TaskError> validateActionFields(TaskActionInformation action, ActionEvent actionEvent, TriggerEvent trigger, Map<Long, TaskDataProvider> providers) {
Map<String, String> fields = action.getValues();
Map<String, ParameterType> fieldsTypes = new HashMap<>();
for (ActionParameter param : actionEvent.getActionParameters()) {
fieldsTypes.put(param.getKey(), param.getType());
}
return validateFieldsParameter(fields, fieldsTypes, trigger, providers);
}
Aggregations