Package org.dmd.dmc.rules

Examples of org.dmd.dmc.rules.DmcRuleExceptionSet


          okay = true;
        break;
      }
     
      if (!okay){
        DmcRuleExceptionSet ex = new DmcRuleExceptionSet();
        ex.add(new DmcRuleException(this.getRuleTitle(), this));
        throw(ex);
      }
    }
  }
View Full Code Here


  @Override
  public void execute(DmcObject obj, DmcAttribute<?> attribute) throws DmcRuleExceptionSet {
    DebugInfo.debug("Entering >>>");
   
    DmcRuleExceptionSet rc = null;
    Double minimum = ruleDMO.getNrrMinimum();
    Double maximum = ruleDMO.getNrrMaximum();
   
    if (attribute.getAttributeInfo().valueType == ValueTypeEnum.SINGLE){
      Double value = ((Number) attribute.getSV()).doubleValue();
      if (minimum != null){
        if (value < minimum){
          rc = new DmcRuleExceptionSet();
          rc.add(new DmcRuleException(ruleDMO.getRuleTitle() + "\nThis value is less than the minimum: " + attribute.getSV(), this));
        }
      }
      if (maximum != null){
        if (value > maximum){
          rc = new DmcRuleExceptionSet();
          rc.add(new DmcRuleException(ruleDMO.getRuleTitle() + "\nThis value is more than the maximum: " + attribute.getSV(), this));
        }
      }
    }
    else{
      for(int i=0; i<attribute.getMVSize(); i++){
        Double value = ((Number) attribute.getMVnth(i)).doubleValue();
       
        if (minimum != null){
          if (value < minimum){
            if (rc == null)
              rc = new DmcRuleExceptionSet();
            rc.add(new DmcRuleException(ruleDMO.getRuleTitle() + "\nThis value is less than the minimum: " + attribute.getSV(), this));
          }
        }
        if (maximum != null){
          if (value > maximum){
            if (rc == null)
              rc = new DmcRuleExceptionSet();
            rc.add(new DmcRuleException(ruleDMO.getRuleTitle() + "\nThis value is more than the maximum: " + attribute.getSV(), this));
          }
        }
      }
    }
   
View Full Code Here

    super(dmo);
  }

  @Override
  public void execute(DmcObject obj) throws DmcRuleExceptionSet {
    DmcRuleExceptionSet exceptions = null;
   
    // Cycle through the attribute definitions associated with the object
    // and verify that any that are NOT optional, exist in the object.
    Map<Integer,DmcAttributeInfoRef> mai = obj.getConstructionClassInfo().getIdToAttr();
    if (mai != null){
      Iterator<DmcAttributeInfoRef> it = mai.values().iterator();
      while(it.hasNext()){
        DmcAttributeInfoRef air = it.next();
        if (air.mandatory){
          if (obj.get(air.info.id) == null){
            if (exceptions == null)
              exceptions = new DmcRuleExceptionSet();
            exceptions.add(new DmcRuleException("Mandatory attribute is missing: " + air.info.name, this));
          }
        }
      }
    }
   
    // And now, cycle through the attributes of the object and verify that
    // they are allowed - if the class isn't extensible
    if (obj.getConstructionClassInfo().classType != ClassTypeEnum.EXTENSIBLE){
      Iterator<DmcAttribute<?>> attrs = obj.getAttributes().values().iterator();
      while(attrs.hasNext()){
        DmcAttribute<?> attr = attrs.next();
        if (!obj.allowsAttribute(attr.getAttributeInfo())){
          if (exceptions == null)
            exceptions = new DmcRuleExceptionSet();
          exceptions.add(new DmcRuleException("Attribute: " + attr.getName() + " is not valid for an object of class: " + obj.getConstructionClassName(), this));
        }
      }
    }
   
    if (exceptions != null)
View Full Code Here

    super(dmo);
  }

  @Override
  public void execute(DmcObject obj, DmcAttribute<?> attribute) throws DmcRuleExceptionSet {
    DmcRuleExceptionSet rc = null;
   
    if ( (ruleDMO.getMinLength() != null) && (ruleDMO.getMaxLength() != null)){
      // We have both maximum and minimum
      int max = ruleDMO.getMaxLength();
      int min = ruleDMO.getMinLength();
      if (attribute.getAttributeInfo().valueType == ValueTypeEnum.SINGLE){
       
      }
      else{
        Iterator<?> it = attribute.getMV();
        while(it.hasNext()){
          Object value = it.next();
          try {
            checkMinimum(min, value.toString());
            checkMaximum(max, value.toString());
          } catch (DmcRuleException e) {
            if (rc == null)
              rc = new DmcRuleExceptionSet();
            rc.add(e);
          }
        }
      }
    }
    else if (ruleDMO.getMinLength() != null){
View Full Code Here

  public void execute(DmcObject obj, DmcAttribute<?> attribute) throws DmcRuleExceptionSet {
    if (attribute.getAttributeInfo().valueType == ValueTypeEnum.SINGLE){
      String value = attribute.getSV().toString();
     
      if (!value.matches(ruleDMO.getMatchesPattern())){
        DmcRuleExceptionSet ex = new DmcRuleExceptionSet();
        ex.add(new DmcRuleException(this.getRuleTitle() + "\n" + obj.toOIF(), this));
        throw(ex);
      }
    }
    else{
      for(int i=0; i<attribute.getMVSize(); i++){
        Object valobj = attribute.getMVnth(i);
        if (valobj != null){
          String value = valobj.toString();
         
          if (!value.matches(ruleDMO.getMatchesPattern())){
            DmcRuleExceptionSet ex = new DmcRuleExceptionSet();
            ex.add(new DmcRuleException(this.getRuleTitle() + "\n" + obj.toOIF(), this));
            throw(ex);
          }
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.dmd.dmc.rules.DmcRuleExceptionSet

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.