Search in sources :

Example 1 with RuleAttribute

use of org.kuali.kfs.kew.rule.bo.RuleAttribute in project cu-kfs by CU-CommunityApps.

the class RuleAttributeServiceImpl method validate.

private void validate(RuleAttribute ruleAttribute) {
    LOG.debug("validating ruleAttribute");
    List<WorkflowServiceError> errors = new ArrayList<>();
    if (ruleAttribute.getName() == null || ruleAttribute.getName().trim().equals("")) {
        errors.add(new WorkflowServiceErrorImpl("Please enter a rule attribute name.", RULE_ATTRIBUTE_NAME_REQUIRED));
        LOG.error("Rule attribute name is missing");
    } else {
        ruleAttribute.setName(ruleAttribute.getName().trim());
        if (ruleAttribute.getId() == null) {
            RuleAttribute nameInUse = findByName(ruleAttribute.getName());
            if (nameInUse != null) {
                errors.add(new WorkflowServiceErrorImpl("Rule attribute name already in use", "routetemplate.ruleattribute.name.duplicate"));
                LOG.error("Rule attribute name already in use");
            }
        }
    }
    if (ruleAttribute.getResourceDescriptor() == null || ruleAttribute.getResourceDescriptor().trim().equals("")) {
        errors.add(new WorkflowServiceErrorImpl("Please enter a rule attribute class name.", RULE_ATTRIBUTE_CLASS_REQUIRED));
        LOG.error("Rule attribute class name is missing");
    } else {
        ruleAttribute.setResourceDescriptor(ruleAttribute.getResourceDescriptor().trim());
    }
    LOG.debug("end validating ruleAttribute");
    if (!errors.isEmpty()) {
        throw new WorkflowServiceErrorException("RuleAttribute Validation Error", errors);
    }
}
Also used : WorkflowServiceErrorImpl(org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl) RuleAttribute(org.kuali.kfs.kew.rule.bo.RuleAttribute) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) WorkflowServiceError(org.kuali.kfs.kew.exception.WorkflowServiceError) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 WorkflowServiceError (org.kuali.kfs.kew.exception.WorkflowServiceError)1 WorkflowServiceErrorException (org.kuali.kfs.kew.exception.WorkflowServiceErrorException)1 WorkflowServiceErrorImpl (org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl)1 RuleAttribute (org.kuali.kfs.kew.rule.bo.RuleAttribute)1