Package org.dmd.dmc.rules

Examples of org.dmd.dmc.rules.DmcRuleException


                  for(URL url: urls){
                    sb.append(url.getFile() + "\n");
                  }
                  sb.append("\nwith the classpath info for the missing class.");

              DmcRuleException ex = new DmcRuleException(sb.toString(), null);
              ex.source(source);
             
              if (rc == null)
                rc = new DmcRuleExceptionSet();
              rc.add(ex);
             
              // This is a show stopper, so just fire it now.
              throw(rc);
            }
            catch(DmcValueException dve){
              // If a value for an attribute doesn't pass the basic tests, we'll
              // get one of these, just repackage it as a rule exception
              DmcRuleException ex = new DmcRuleException(dve.getMessage(), null);
              ex.source(source);

              if (rc == null)
                rc = new DmcRuleExceptionSet();
              rc.add(ex);             
            }
            catch(ResultException rex){
              // If we can't find a class or attribute, we'll get one of these
              DmcRuleException ex = new DmcRuleException(rex.getMessage(), null);
              ex.source(source);

              if (rc == null)
                rc = new DmcRuleExceptionSet();
              rc.add(ex)
             
//              System.err.println(ex.toString());
            }
           
            if (ruledata == null)
              continue;
           
            try{
              ruledata.resolveReferences(sm);
            }
            catch(DmcValueExceptionSet ex){
              System.err.println(ex.toString() + "\nFile: " + ruledata.getFile() + "  Line: " + ruledata.getLineNumber());
            }
             
            try{
              DynamicInitIF rule = (DynamicInitIF) ruleDEF.newRuleInstance();
              rule.setRuleData(ruledata);
             
              allRuleData.add(ruledata);
             
//              addThisRule((RuleIF) rule);
              allRules.add((RuleIF) rule);
            }
            catch(Exception ex){
              System.err.println(ex.toString());
            }
          }
            }
      }
     
View Full Code Here


          while(refs.hasNext()){
            DmcAttributeInfo ai = DmcOmni.instance().getAttributeInfo(refs.next().getObjectName().getNameString());
            if (obj.get(ai) != null){
              if (rc == null)
                rc = new DmcRuleExceptionSet();
              rc.add(new DmcRuleException(ruleDMO.getRuleTitle() + "\nCan't have: " + ai.name, this));
            }
          }
        }
        if (ruleDMO.getIncludeThisAttributeSize() > 0){
          Iterator<AttributeDefinitionREF> refs = ruleDMO.getIncludeThisAttributeREFs();
          while(refs.hasNext()){
            DmcAttributeInfo ai = DmcOmni.instance().getAttributeInfo(refs.next().getObjectName().getNameString());
            if (obj.get(ai) == null){
              if (rc == null)
                rc = new DmcRuleExceptionSet();
              rc.add(new DmcRuleException(ruleDMO.getRuleTitle() + "\nMust have: " + ai.name, this));
            }
          }
         
        }
      }
View Full Code Here

   
    // First, we try to find the definition of the attribute in question
    DmcAttributeInfo ai = DmcOmni.instance().getAttributeInfo(attrName);
   
    if (ai == null)
      throw(new DmcRuleException("Unknown attribute: " + attrName + " referred to via attribute: " + attribute.getName() + " in object: \n" + obj.toOIF(), this));
     
    if (ruleDMO.getAllowedValueType() != null){
      // Check the value type if it was specified
      if (ruleDMO.getAllowedValueType() != ai.valueType){
        throw(new DmcRuleException(this.getRuleTitle() + "\n" + "Expected valueType: " + ruleDMO.getAllowedValueType() + " but " + attrName + " has valueType: " + ai.valueType, this));
      }
    }
   
    if (ruleDMO.getAllowedTypeSize() > 0){
      boolean typeOkay = false;
      Iterator<TypeDefinitionREF> types = ruleDMO.getAllowedType();
      while(types.hasNext()){
        TypeDefinitionREF type = types.next();
        if (type.getObjectName().getNameString().equals(ai.type)){
          typeOkay = true;
          break;
        }
      }
     
      if (!typeOkay)
        throw(new DmcRuleException(this.getRuleTitle() + "\n" + attrName + " isn't one of the expected types, it's of type: " + ai.type, this));
    }
   
  }
View Full Code Here

    if (found == 0){
      // We haven't found any of the attributes - complain
      DmcRuleExceptionSet ex = new DmcRuleExceptionSet();
      possibilities = ruleDMO.getOnePossibility();
     
      ex.add(new DmcRuleException("The object must include at least one of these attributes: " + getPossibilities(), this));
      throw(ex);
    }
    else{
      // We've found at least one, but check if we only want one.
      if (ruleDMO.isAndOnlyOne() && (found>1)){
        DmcRuleExceptionSet ex = new DmcRuleExceptionSet();
        possibilities = ruleDMO.getOnePossibility();
       
        ex.add(new DmcRuleException("The object must include only one of these attributes: " + getPossibilities(), this));
        throw(ex);
      }
    }
  }
View Full Code Here

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

    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

        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

    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.DmcRuleException

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.