@Override public boolean isEmpty() { return (!this.isRequired() && null == this.getOgnlValidationRule()); }
@Override public boolean isEmpty() { return (!this.isRequired() && null == this.getOgnlValidationRule()); }
protected void fillJDOMConfigElement(Element configElement) { if (this.isRequired()) { Element element = new Element("required"); element.setText("true"); configElement.addContent(element); } if (null != this.getOgnlValidationRule()) { Element exprElement = this.getOgnlValidationRule().getConfigElement(); if (null != exprElement) { configElement.addContent(exprElement); } } }
protected void fillJDOMConfigElement(Element configElement) { if (this.isRequired()) { Element element = new Element("required"); element.setText("true"); configElement.addContent(element); } if (null != this.getOgnlValidationRule()) { Element exprElement = this.getOgnlValidationRule().getConfigElement(); if (null != exprElement) { configElement.addContent(exprElement); } } }
@Override public IAttributeValidationRules clone() { BaseAttributeValidationRules clone = null; try { Class validationConditionClass = Class.forName(this.getClass().getName()); clone = (BaseAttributeValidationRules) validationConditionClass.newInstance(); clone.setRequired(this.isRequired()); if (null != this.getOgnlValidationRule()) { clone.setOgnlValidationRule(this.getOgnlValidationRule().clone()); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { _logger.error("Error detected while cloning the ValidationRules", e); throw new RuntimeException("Error detected while cloning the ValidationRules class '" + this.getClass().getName() + "' "); } return clone; }
@Override public IAttributeValidationRules clone() { BaseAttributeValidationRules clone = null; try { Class validationConditionClass = Class.forName(this.getClass().getName()); clone = (BaseAttributeValidationRules) validationConditionClass.newInstance(); clone.setRequired(this.isRequired()); if (null != this.getOgnlValidationRule()) { clone.setOgnlValidationRule(this.getOgnlValidationRule().clone()); } } catch (Exception e) { ApsSystemUtils.logThrowable(e, this, "clone"); throw new RuntimeException("Error detected while cloning the ValidationRules class '" + this.getClass().getName() + "' "); } return clone; }
@Override public List<AttributeFieldError> validate(AttributeInterface attribute, AttributeTracer tracer, ILangManager langManager) { List<AttributeFieldError> errors = new ArrayList<>(); if (this.isEmpty()) { return errors; } try { if (this.isRequired() && attribute.getStatus().equals(AttributeInterface.Status.EMPTY)) { AttributeTracer tracerClone = tracer.clone(); tracerClone.setLang(langManager.getDefaultLang()); errors.add(new AttributeFieldError(attribute, FieldError.MANDATORY, tracerClone)); } OgnlValidationRule ognlValidationRule = this.getOgnlValidationRule(); if (null != ognlValidationRule) { AttributeFieldError error = ognlValidationRule.validate(attribute, tracer, langManager); if (null != error) { errors.add(error); } } } catch (Throwable t) { _logger.error("Error validating Attribute '{}'", attribute.getName(), t); throw new RuntimeException("Error validating Attribute '" + attribute.getName() + "'", t); } return errors; }
@Override public List<AttributeFieldError> validate(AttributeInterface attribute, AttributeTracer tracer, ILangManager langManager) { List<AttributeFieldError> errors = new ArrayList<AttributeFieldError>(); if (this.isEmpty()) { return errors; } try { if (this.isRequired() && attribute.getStatus().equals(AttributeInterface.Status.EMPTY)) { AttributeTracer tracerClone = tracer.clone(); tracerClone.setLang(langManager.getDefaultLang()); errors.add(new AttributeFieldError(attribute, FieldError.MANDATORY, tracerClone)); } OgnlValidationRule ognlValidationRule = this.getOgnlValidationRule(); if (null != ognlValidationRule) { AttributeFieldError error = ognlValidationRule.validate(attribute, tracer, langManager); if (null != error) { errors.add(error); } } } catch (Throwable t) { ApsSystemUtils.logThrowable(t, this, "validate", "Error validating Attribute '" + attribute.getName() + "'"); throw new RuntimeException("Error validating Attribute '" + attribute.getName() + "'", t); } return errors; }