Search in sources :

Example 1 with ManipulationType

use of org.motechproject.tasks.domain.ManipulationType in project motech by motech.

the class TaskValidator method validateDateManipulation.

private TaskError validateDateManipulation(String manipulation, ParameterType fieldType, String foundAt) {
    TaskError error = null;
    ManipulationType type = ManipulationType.fromString(manipulation.replaceAll("\\((.*?)\\)", ""));
    if (type.getTarget() != ManipulationTarget.DATE) {
        if (type.getTarget() == ManipulationTarget.ALL) {
            error = new TaskError("task.validation.error.wrongAnotherManipulation", manipulation, foundAt);
        } else {
            error = new TaskError("task.validation.error.wrongDateManipulation", manipulation, foundAt);
        }
    } else if (fieldType.equals(ParameterType.DATE) && !type.allowResultType(ManipulationTarget.DATE)) {
        error = new TaskError("task.validation.error.wrongDateManipulationTarget", manipulation, foundAt);
    }
    return error;
}
Also used : TaskError(org.motechproject.tasks.domain.mds.task.TaskError) ManipulationType(org.motechproject.tasks.domain.ManipulationType)

Example 2 with ManipulationType

use of org.motechproject.tasks.domain.ManipulationType in project motech by motech.

the class TaskValidator method validateStringManipulation.

private TaskError validateStringManipulation(String manipulation, String foundAt) {
    TaskError error = null;
    ManipulationType type = ManipulationType.fromString(manipulation.replaceAll("\\((.*?)\\)", ""));
    if (type.getTarget() != ManipulationTarget.STRING) {
        if (type.getTarget() == ManipulationTarget.ALL) {
            error = new TaskError("task.validation.error.wrongAnotherManipulation", manipulation, foundAt);
        } else {
            error = new TaskError("task.validation.error.wrongStringManipulation", manipulation, foundAt);
        }
    }
    return error;
}
Also used : TaskError(org.motechproject.tasks.domain.mds.task.TaskError) ManipulationType(org.motechproject.tasks.domain.ManipulationType)

Aggregations

ManipulationType (org.motechproject.tasks.domain.ManipulationType)2 TaskError (org.motechproject.tasks.domain.mds.task.TaskError)2