コード例 #1
0
ファイル: RuleModel.java プロジェクト: jimlgx/guvnor
  protected List<String> getFieldBinding(FieldConstraint f) {
    List<String> result = new ArrayList<String>();
    if (f instanceof SingleFieldConstraint) {
      SingleFieldConstraint con = (SingleFieldConstraint) f;
      if (con.isBound()) {
        result.add(con.getFieldBinding());
      }
      if (con.getExpressionValue() != null && con.getExpressionValue().isBound()) {
        result.add(con.getExpressionValue().getBinding());
      }
      if (con instanceof SingleFieldConstraintEBLeftSide) {
        SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) con;
        if (exp.getExpressionLeftSide() != null && exp.getExpressionLeftSide().isBound()) {
          result.add(exp.getExpressionLeftSide().getBinding());
        }
      }

    } else if (f instanceof CompositeFieldConstraint) {
      CompositeFieldConstraint cfc = (CompositeFieldConstraint) f;
      if (cfc.getConstraints() != null) {
        for (FieldConstraint ss : cfc.getConstraints()) {
          List<String> t = getFieldBinding(ss);
          result.addAll(t);
        }
      }
    }
    return result;
  }
コード例 #2
0
ファイル: RuleModel.java プロジェクト: jimlgx/guvnor
  /** This will get a list of all LHS bound variables, including bound fields.. */
  public List<String> getAllLHSVariables() {
    List<String> result = new ArrayList<String>();

    for (int i = 0; i < this.lhs.length; i++) {
      IPattern pat = this.lhs[i];
      if (pat instanceof FromCompositeFactPattern) {
        pat = ((FromCompositeFactPattern) pat).getFactPattern();
      }
      if (pat instanceof FactPattern) {
        FactPattern fact = (FactPattern) pat;
        if (fact.isBound()) {
          result.add(fact.getBoundName());
        }

        for (int j = 0; j < fact.getFieldConstraints().length; j++) {
          FieldConstraint fc = fact.getFieldConstraints()[j];
          if (fc instanceof SingleFieldConstraintEBLeftSide) {
            SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fc;
            if (exp.getExpressionLeftSide() != null && exp.getExpressionLeftSide().isBound()) {
              result.add(exp.getExpressionLeftSide().getBinding());
            }
          } else if (fc instanceof SingleFieldConstraint) {
            SingleFieldConstraint con = (SingleFieldConstraint) fc;
            if (con.isBound()) {
              result.add(con.getFieldBinding());
            }
            if (con.getExpressionValue() != null && con.getExpressionValue().isBound()) {
              result.add(con.getExpressionValue().getBinding());
            }
          }
        }
      }
    }

    return result;
  }
コード例 #3
0
ファイル: RuleModel.java プロジェクト: jimlgx/guvnor
 protected String getFieldBinding(FieldConstraint fc, String var) {
   String fieldType = null;
   if (fc instanceof SingleFieldConstraint) {
     SingleFieldConstraint s = (SingleFieldConstraint) fc;
     if (s.isBound() && var.equals(s.getFieldBinding())) {
       fieldType = s.getFieldType();
     }
   }
   if (fc instanceof SingleFieldConstraintEBLeftSide) {
     SingleFieldConstraintEBLeftSide s = (SingleFieldConstraintEBLeftSide) fc;
     if (s.isBound() && var.equals(s.getFieldBinding())) {
       fieldType = s.getExpressionLeftSide().getGenericType();
     }
   }
   if (fc instanceof CompositeFieldConstraint) {
     CompositeFieldConstraint s = (CompositeFieldConstraint) fc;
     if (s.getConstraints() != null) {
       for (FieldConstraint ss : s.getConstraints()) {
         fieldType = getFieldBinding(ss, var);
       }
     }
   }
   return fieldType;
 }