Package org.infoglue.cms.util.validators

Examples of org.infoglue.cms.util.validators.ConstraintRule


   
    // Loop through rules and create validators
      Iterator iterator = vo.getConstraintRules().iterator();
      while (iterator.hasNext())
      {
        ConstraintRule cr = (ConstraintRule) iterator.next();
        Integer intId = vo.getId();

      // an ugly switch for now.       
        switch (cr.getConstraintType())
        {
          case Constants.EMAIL:
          {
          if (cr.getValue() != null)
          {
            // Create validator
              EmailValidator v = new EmailValidator(cr.getFieldName());
             
              // Set properties
              v.setObjectClass(vo.getConstraintRuleList().getEntityClass());
              v.setRange(cr.getValidRange());
              v.setIsRequired(cr.required);
              v.setMustBeUnique(cr.unique);
              v.setExcludeId(intId);

            // Do the limbo
              v.validate((String) cr.getValue(), ceb);
             
              // <todo>
              // Note: the actual value validated should be extracted
              // from the vo using the fieldname with reflection.
              // </todo>
             
          }             
            break;
          }
        case Constants.STRING:
          {
          if (cr.getValue() != null)
          {           
              StringValidator v = new StringValidator(cr.getFieldName());
              v.setObjectClass(vo.getConstraintRuleList().getEntityClass());
              v.setRange(cr.getValidRange());
              v.setIsRequired(cr.required);
              v.setMustBeUnique(cr.unique);
              v.setExcludeId(intId);

              v.validate((String) cr.getValue(), ceb);
          }             
            break;
          }
          case Constants.FLOAT:
          {
View Full Code Here


   
    // Loop through rules and create validators
      Iterator iterator = vo.getConstraintRules().iterator();
      while (iterator.hasNext())
      {
        ConstraintRule cr = (ConstraintRule) iterator.next();
        Integer intId = vo.getId();
        logger.info("Validating object id: " + intId);

      // an ugly switch for now.       
        switch (cr.getConstraintType())
        {
          case Constants.EMAIL:
          {
          if (cr.getValue() != null)
          {
            // Create validator
              EmailValidator v = new EmailValidator(cr.getFieldName());
             
              // Set properties
              v.setObjectClass(vo.getConstraintRuleList().getEntityClass());
              v.setRange(cr.getValidRange());
              v.setIsRequired(cr.required);
              v.setMustBeUnique(cr.unique);
              v.setExcludeId(intId);

            // Do the limbo
              v.validate((String) cr.getValue(), ceb);
             
              // <todo>
              // Note: the actual value validated should be extracted
              // from the vo using the fieldname with reflection.
              // </todo>
             
          }             
            break;
          }
        case Constants.STRING:
          {
          if (cr.getValue() != null)
          {           
              StringValidator v = new StringValidator(cr.getFieldName());
              v.setObjectClass(vo.getConstraintRuleList().getEntityClass());
              v.setRange(cr.getValidRange());
              v.setIsRequired(cr.required);
              v.setMustBeUnique(cr.unique);
              v.setExcludeId(intId);

              v.validate((String) cr.getValue(), ceb);
          }             
            break;
          }
          case Constants.FLOAT:
          {
View Full Code Here

    // construction).
    rules.setEntityClass(PublicationImpl.class);

    // Create a new constraintrule, supply constraint type, and field that this rule
    // applies to.
     ConstraintRule cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "Publication.name");

     // Set the constraints
     cr.setValidRange(new Range(2, 50) );
     cr.unique=false// public variabel will be changed to setter later
     cr.required=true; // public variabel will be changed to setter later
     cr.setValue(name);

     // Add this rule to the rulelist
     rules.addRule(cr);

    // Create a new constraintrule, supply constraint type, and field that this rule
    // applies to.
     cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "Publication.description");

     // Set the constraints
     cr.setValidRange(new Range(2, 50) );
     cr.unique=false// public variabel will be changed to setter later
     cr.required=true; // public variabel will be changed to setter later
     cr.setValue(description);

     // Add this rule to the rulelist
     rules.addRule(cr);
  }
View Full Code Here

    // construction).
    rules.setEntityClass(SystemUserImpl.class);
   
    // Create a new constraintrule, supply constraint type, and field that this rule
    // applies to.
     ConstraintRule cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "SystemUser.userName");
    
     // Set the constraints
     cr.setValidRange(new Range(2, 60) );
     cr.unique=true// public variabel will be changed to setter later
     cr.required=true; // public variabel will be changed to setter later
     cr.setValue(userName);
    
     // Add this rule to the rulelist
     rules.addRule(cr);   

    // Set the rest of the rules
     cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "SystemUser.password");
     cr.setValidRange(new Range(4, 15));
     cr.required = true;
     cr.setValue(password);
    rules.addRule(cr);
   
     cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "SystemUser.firstName");
     cr.setValidRange(new Range(1, 30));
     cr.required = true;
     cr.setValue(firstName);
    rules.addRule(cr);
   
     cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "SystemUser.lastName");
     cr.setValidRange(new Range(1, 30));
     cr.required = true;
     cr.setValue(lastName);
    rules.addRule(cr);

     cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.EMAIL, "SystemUser.email");
     cr.setValidRange(new Range(50));
     cr.required = true;
     cr.setValue(email);
    rules.addRule(cr);
  }
View Full Code Here

   
    // Loop through rules and create validators
    Iterator iterator = vo.getConstraintRules().iterator();
    while (iterator.hasNext())
    {
      ConstraintRule cr = (ConstraintRule) iterator.next();
      String userName = ((SystemUserVO)vo).getUserName();
     
      // an ugly switch for now.       
      switch (cr.getConstraintType())
      {
        case Constants.EMAIL:
        {
          if (cr.getValue() != null)
          {
            // Create validator
            EmailValidator v = new EmailValidator(cr.getFieldName());
             
            // Set properties
            v.setObjectClass(vo.getConstraintRuleList().getEntityClass());
            v.setRange(cr.getValidRange());
            v.setIsRequired(cr.required);
            v.setMustBeUnique(cr.unique);
            v.setExcludeId(null);
            v.setExcludeObject(userName);

            // Do the limbo
            v.validate((String) cr.getValue(), ceb);
             
            // <todo>
            // Note: the actual value validated should be extracted
            // from the vo using the fieldname with reflection.
            // </todo>
             
          }             
          break;
        }
        case Constants.STRING:
        {
          if (cr.getValue() != null)
          {           
            StringValidator v = new StringValidator(cr.getFieldName());
            v.setObjectClass(vo.getConstraintRuleList().getEntityClass());
            v.setRange(cr.getValidRange());
            v.setIsRequired(cr.required);
            v.setMustBeUnique(cr.unique);
            v.setExcludeId(null);
            v.setExcludeObject(userName);

            v.validate((String) cr.getValue(), ceb);
          }             
          break;
        }
        case Constants.FLOAT:
        {
View Full Code Here

TOP

Related Classes of org.infoglue.cms.util.validators.ConstraintRule

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.