Search in sources :

Example 1 with ActionForPlannedEventState

use of com.qcadoo.mes.cmmsMachineParts.constants.ActionForPlannedEventState in project mes by qcadoo.

the class ActionForPlannedEventValidators method validateRequiredFields.

public boolean validateRequiredFields(final DataDefinition actionDD, final Entity actionForPlannedEvent) {
    Entity defaultAction = actionsService.getDefaultAction();
    Entity action = actionForPlannedEvent.getBelongsToField(ActionForPlannedEventFields.ACTION);
    boolean correct = true;
    if (defaultAction != null && action != null && defaultAction.getId().equals(action.getId())) {
        if (StringUtils.isEmpty(actionForPlannedEvent.getStringField(ActionForPlannedEventFields.DESCRIPTION))) {
            actionForPlannedEvent.addError(actionDD.getField(ActionForPlannedEventFields.DESCRIPTION), "cmmsMachineParts.actionForPlannedEvent.error.descriptionRequired");
            correct = false;
        }
    }
    ActionForPlannedEventState state = ActionForPlannedEventState.from(actionForPlannedEvent);
    if (state.equals(ActionForPlannedEventState.INCORRECT)) {
        if (StringUtils.isEmpty(actionForPlannedEvent.getStringField(ActionForPlannedEventFields.REASON))) {
            actionForPlannedEvent.addError(actionDD.getField(ActionForPlannedEventFields.REASON), "cmmsMachineParts.actionForPlannedEvent.error.reasonRequired");
            correct = false;
        }
    }
    return correct;
}
Also used : Entity(com.qcadoo.model.api.Entity) ActionForPlannedEventState(com.qcadoo.mes.cmmsMachineParts.constants.ActionForPlannedEventState)

Aggregations

ActionForPlannedEventState (com.qcadoo.mes.cmmsMachineParts.constants.ActionForPlannedEventState)1 Entity (com.qcadoo.model.api.Entity)1