Package org.drools.guvnor.client.modeldriven.brl

Examples of org.drools.guvnor.client.modeldriven.brl.SingleFieldConstraint


        //now add the constraint from this cell
        switch (c.constraintValueType) {
          case ISingleFieldConstraint.TYPE_LITERAL:
          case ISingleFieldConstraint.TYPE_RET_VALUE:
            SingleFieldConstraint sfc = new SingleFieldConstraint(c.factField);
            if (no(c.operator)) {

              String[] a = cell.split("\\s");
              if (a.length > 1) {
                sfc.operator = a[0];
                sfc.value = a[1];
              } else {
                sfc.value = cell;
              }
            } else {
              sfc.operator = c.operator;
              sfc.value = cell;
            }
            sfc.constraintValueType = c.constraintValueType;
            fp.addConstraint(sfc);
            break;
          case ISingleFieldConstraint.TYPE_PREDICATE:
            SingleFieldConstraint pred = new SingleFieldConstraint();
            pred.constraintValueType = c.constraintValueType;
            pred.value = cell;
            fp.addConstraint(pred);
            break;
        default:
View Full Code Here


    assertEquals("c", ((FactPattern)rm.lhs[1]).boundName);

    //examine the first pattern
    FactPattern person = (FactPattern) rm.lhs[0];
    assertEquals(3, person.constraintList.constraints.length);
    SingleFieldConstraint cons = (SingleFieldConstraint) person.constraintList.constraints[0];
    assertEquals(ISingleFieldConstraint.TYPE_LITERAL, cons.constraintValueType);
    assertEquals("name", cons.fieldName);
    assertEquals("==", cons.operator);
    assertEquals("mike", cons.value);
View Full Code Here

                String typeField = (String) _typeField;
                FieldConstraint[] cons = pat.constraintList.constraints;
                for ( int i = 0; i < cons.length; i++ ) {
                    FieldConstraint con = cons[i];
                    if ( con instanceof SingleFieldConstraint ) {
                        SingleFieldConstraint sfc = (SingleFieldConstraint) con;
                        if ( sfc.fieldName.equals( typeField ) ) {
                            String key = pat.factType + "." + field + "[" + typeField + "=" + sfc.value + "]";
                            return DropDownData.create( (String[]) this.dataEnumLists.get( key ) );
                        }
                    }
                }
            } else if ( _typeField != null ) {
                // these enums are calculated on demand, server side...
                String[] fieldsNeeded = (String[]) _typeField;
                String queryString = getQueryString( pat.factType,
                                                     field,
                                                     this.dataEnumLists );

                String[] valuePairs = new String[fieldsNeeded.length];

                // collect all the values of the fields needed, then return it
                // as a string...
                for ( int i = 0; i < fieldsNeeded.length; i++ ) {
                    for ( int j = 0; j < pat.constraintList.constraints.length; j++ ) {
                        FieldConstraint con = pat.constraintList.constraints[j];
                        if ( con instanceof SingleFieldConstraint ) {
                            SingleFieldConstraint sfc = (SingleFieldConstraint) con;
                            if ( sfc.fieldName.equals( fieldsNeeded[i] ) ) {
                                valuePairs[i] = fieldsNeeded[i] + "=" + sfc.value;
                            }
                        }
                    }
View Full Code Here

        //now add the constraint from this cell
        switch (c.constraintValueType) {
          case ISingleFieldConstraint.TYPE_LITERAL:
          case ISingleFieldConstraint.TYPE_RET_VALUE:
            SingleFieldConstraint sfc = new SingleFieldConstraint(c.factField);
            if (no(c.operator)) {

              String[] a = cell.split("\\s");
              if (a.length > 1) {
                sfc.operator = a[0];
                sfc.value = a[1];
              } else {
                sfc.value = cell;
              }
            } else {
              sfc.operator = c.operator;
              sfc.value = cell;
            }
            sfc.constraintValueType = c.constraintValueType;
            fp.addConstraint(sfc);
            break;
          case ISingleFieldConstraint.TYPE_PREDICATE:
            SingleFieldConstraint pred = new SingleFieldConstraint();
            pred.constraintValueType = c.constraintValueType;
            pred.value = cell;
            fp.addConstraint(pred);
            break;
        default:
View Full Code Here

                    String typeField = splitTypeFields[j];

                    for ( int i = 0; i < cons.length; i++ ) {
                        FieldConstraint con = cons[i];
                        if ( con instanceof SingleFieldConstraint ) {
                            SingleFieldConstraint sfc = (SingleFieldConstraint) con;

                            if ( sfc.fieldName.trim().equals( typeField.trim() ) ) {
                                if ( addOpeninColumn ) {
                                    key += "[";
                                    addOpeninColumn = false;
                                }
                                key += typeField + "=" + sfc.value;

                                if ( j != (splitTypeFields.length - 1) ) {
                                    key += ",";
                                }
                            }
                        }
                    }
                }

                if ( !addOpeninColumn ) {
                    key += "]";
                }

                return DropDownData.create( (String[]) this.dataEnumLists.get( key ) );

            } else if ( _typeFields != null ) {
                // these enums are calculated on demand, server side...
                String[] fieldsNeeded = (String[]) _typeFields;
                String queryString = getQueryString( pat.factType,
                                                     field,
                                                     this.dataEnumLists );

                String[] valuePairs = new String[fieldsNeeded.length];

                // collect all the values of the fields needed, then return it
                // as a string...
                for ( int i = 0; i < fieldsNeeded.length; i++ ) {
                    for ( int j = 0; j < pat.constraintList.constraints.length; j++ ) {
                        FieldConstraint con = pat.constraintList.constraints[j];
                        if ( con instanceof SingleFieldConstraint ) {
                            SingleFieldConstraint sfc = (SingleFieldConstraint) con;
                            if ( sfc.fieldName.equals( fieldsNeeded[i] ) ) {
                                valuePairs[i] = fieldsNeeded[i] + "=" + sfc.value;
                            }
                        }
                    }
View Full Code Here

        //now add the constraint from this cell
        switch (c.constraintValueType) {
          case ISingleFieldConstraint.TYPE_LITERAL:
          case ISingleFieldConstraint.TYPE_RET_VALUE:
            SingleFieldConstraint sfc = new SingleFieldConstraint(c.factField);
            if (no(c.operator)) {

              String[] a = cell.split("\\s");
              if (a.length > 1) {
                sfc.operator = a[0];
                sfc.value = a[1];
              } else {
                sfc.value = cell;
              }
            } else {
              sfc.operator = c.operator;
                            if (c.operator.equals("in")) {
                                sfc.value = makeInList(cell);
                            } else {
                                sfc.value = cell;
                            }

            }
            sfc.constraintValueType = c.constraintValueType;
            fp.addConstraint(sfc);
            break;
          case ISingleFieldConstraint.TYPE_PREDICATE:
            SingleFieldConstraint pred = new SingleFieldConstraint();
            pred.constraintValueType = c.constraintValueType;
                        if (c.factField != null && c.factField.indexOf("$param") > -1) {
                            //handle interpolation
                            pred.value = c.factField.replace("$param", cell)
                        } else {
View Full Code Here

        String typeField = (String) _typeField;
        FieldConstraint[] cons = pat.constraintList.constraints;
        for (int i = 0; i < cons.length; i++) {
          FieldConstraint con = cons[i];
          if (con instanceof SingleFieldConstraint) {
            SingleFieldConstraint sfc = (SingleFieldConstraint) con;
            if ( sfc.fieldName.equals(typeField)) {
              String key = pat.factType + "." + field + "[" + typeField + "=" + sfc.value + "]";
              return DropDownData.create((String[]) this.dataEnumLists.get(key));
            }
          }
        }
      } else if (_typeField != null ){
        //these enums are calculated on demand, server side...
        String[] fieldsNeeded = (String[]) _typeField;
        String queryString = getQueryString(pat.factType, field, this.dataEnumLists);

        String[] valuePairs = new String[fieldsNeeded.length];

        //collect all the values of the fields needed, then return it as a string...
        for (int i = 0; i < fieldsNeeded.length; i++) {
          for (int j = 0; j < pat.constraintList.constraints.length; j++) {
            FieldConstraint con = pat.constraintList.constraints[j];
            if (con instanceof SingleFieldConstraint) {
              SingleFieldConstraint sfc = (SingleFieldConstraint) con;
              if (sfc.fieldName.equals(fieldsNeeded[i])) {
                valuePairs[i] = fieldsNeeded[i] + "=" + sfc.value;
              }
            }
          }
View Full Code Here

        //now add the constraint from this cell
        switch (c.constraintValueType) {
          case ISingleFieldConstraint.TYPE_LITERAL:
          case ISingleFieldConstraint.TYPE_RET_VALUE:
            SingleFieldConstraint sfc = new SingleFieldConstraint(c.factField);
            if (no(c.operator)) {

              String[] a = cell.split("\\s");
              if (a.length > 1) {
                sfc.operator = a[0];
                sfc.value = a[1];
              } else {
                sfc.value = cell;
              }
            } else {
              sfc.operator = c.operator;
              sfc.value = cell;
            }
            sfc.constraintValueType = c.constraintValueType;
            fp.addConstraint(sfc);
            break;
          case ISingleFieldConstraint.TYPE_PREDICATE:
            SingleFieldConstraint pred = new SingleFieldConstraint();
            pred.constraintValueType = c.constraintValueType;
            pred.value = cell;
            fp.addConstraint(pred);
            break;
        default:
View Full Code Here

      sce.dataEnumLists.put("Fact.type", new String[] {"sex", "colour"});
      sce.dataEnumLists.put("Fact.value[type=sex]", new String[] {"M", "F"});
      sce.dataEnumLists.put("Fact.value[type=colour]", new String[] {"RED", "WHITE", "BLUE"});

      FactPattern pat = new FactPattern("Fact");
      SingleFieldConstraint sfc = new SingleFieldConstraint("type");
      sfc.value = "sex";
      pat.addConstraint(sfc);
      String[] result = sce.getEnums(pat, "value").fixedList;
      assertEquals(2, result.length);
      assertEquals("M", result[0]);
      assertEquals("F", result[1]);


      pat = new FactPattern("Fact");
      sfc = new SingleFieldConstraint("type");
      sfc.value = "colour";
      pat.addConstraint(sfc);

      result = sce.getEnums(pat, "value").fixedList;
      assertEquals(3, result.length);
View Full Code Here

      assertEquals("f1", flds[0]);
      assertEquals("f2", flds[1]);


      FactPattern pat = new FactPattern("Fact");
      SingleFieldConstraint sfc = new SingleFieldConstraint("f1");
      sfc.value = "f1val";
      pat.addConstraint(sfc);
      sfc = new SingleFieldConstraint("f2");
      sfc.value = "f2val";
      pat.addConstraint(sfc);


      DropDownData dd = sce.getEnums(pat, "value");
View Full Code Here

TOP

Related Classes of org.drools.guvnor.client.modeldriven.brl.SingleFieldConstraint

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.