Package org.springframework.rules

Examples of org.springframework.rules.Rules


        }
        return rules;
    }

    private void buildRules(Class beanClass) {
        Rules rules = new Rules(beanClass);
        PropertyDescriptor[] propertDescriptors = new BeanWrapperImpl(beanClass).getPropertyDescriptors();
        for (int i = 0; i < propertDescriptors.length; i++) {
            loadPropertyConstraints(rules, propertDescriptors[i]);
        }
        addRules(rules);
View Full Code Here


        model.setValidating(true);
    }

    private void setRulesAndHibernateValidator()
    {
        Rules rules = new Rules(ValidatingObject.class);
        Constraints c = Constraints.instance();
        rules.add(c.eq("intValue", 8));
        rules.add(c.eq("stringValue", "valid"));
        DefaultRulesSource source = new DefaultRulesSource();
        source.addRules(rules);
        RulesValidator rulesValidator = new RulesValidator(model, source);
        hibernateRulesValidator = new HibernateRulesValidator(model, ValidatingObject.class);
        CompositeRichValidator compositeValidator = new CompositeRichValidator(rulesValidator, hibernateRulesValidator);
View Full Code Here

        applicationServices.setRulesSource(new BusinessRulesSource());
    }

    private class BusinessRulesSource extends DefaultRulesSource {
        public BusinessRulesSource() {
            Rules rules = new Rules(BusinessObject.class);
            rules.add(BUSINESS_FIELD, rules.required());
            addRules(rules);
        }
View Full Code Here

     * May be implemented in subclasses that need to register services with the global
     * application services instance.
     */
    protected void registerAdditionalServices( DefaultApplicationServices applicationServices ) {
        DefaultRulesSource rulesSource = new DefaultRulesSource();
        Rules rules = new Rules(TestBean.class);
        rules.add("field", rules.required());
        rulesSource.addRules(rules);

        applicationServices.setRulesSource(rulesSource);
    }
View Full Code Here

    private Rules interfaceRules;

    protected void setUp() throws Exception {
        source = new DefaultRulesSource();
        interfaceRules = new Rules(TestInterface.class);
    }
View Full Code Here

    // also clear results.
    if ((propertyName == null) || ((objectClass != null) && objectClass != object.getClass())) {
      clearMessages();
    }
    objectClass = object.getClass();
    Rules rules = null;
    if (object instanceof PropertyConstraintProvider) {
      PropertyConstraintProvider propertyConstraintProvider = (PropertyConstraintProvider) object;
      if (propertyName != null) {
        PropertyConstraint validationRule = propertyConstraintProvider.getPropertyConstraint(propertyName);
        checkRule(validationRule);
      }
      else {
        for (Iterator fieldNamesIter = formModel.getFieldNames().iterator(); fieldNamesIter.hasNext();) {
          PropertyConstraint validationRule = propertyConstraintProvider
              .getPropertyConstraint((String) fieldNamesIter.next());
          checkRule(validationRule);
        }
      }
    }
    else {
      if (getRulesSource() != null) {
        rules = getRulesSource().getRules(objectClass, getRulesContextId());
        if (rules != null) {
          for (Iterator i = rules.iterator(); i.hasNext();) {
            PropertyConstraint validationRule = (PropertyConstraint) i.next();
            if (propertyName == null) {
              if (formModel.hasValueModel(validationRule.getPropertyName())) {
                checkRule(validationRule);
              }
View Full Code Here

TOP

Related Classes of org.springframework.rules.Rules

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.