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

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


    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


        for (int i = 0; i < sortedConst.size(); i++) {
            int tabs = -1;
            FieldConstraint current = (FieldConstraint) sortedConst.get(i);
            if (current instanceof SingleFieldConstraint) {
                SingleFieldConstraint single = (SingleFieldConstraint) current;
                FieldConstraint parent = single.parent;

                for (int j = 0; j < parents.size(); j++) {
                    FieldConstraint storedParent = (FieldConstraint) parents.get(j);
                    if (storedParent != null && storedParent.equals(parent)) {
View Full Code Here

    private ArrayList sortConstraints(FieldConstraint[] constraints) {
        ArrayList sortedConst = new ArrayList(constraints.length);
        for (int i = 0; i < constraints.length; i++) {
            FieldConstraint current = constraints[i];
            if (current instanceof SingleFieldConstraint) {
                SingleFieldConstraint single = (SingleFieldConstraint) current;
                int index = sortedConst.indexOf(single.parent);
                if (single.parent == null) {
                    sortedConst.add(single);
                } else if (index >= 0){
                    sortedConst.add(index + 1, single);
View Full Code Here

        box.setSelectedIndex( 0 );

        box.addChangeListener( new ChangeListener() {
            public void onChange(Widget w) {
                composite.addConstraint( new SingleFieldConstraint( box.getItemText( box.getSelectedIndex() ) ) );
                modeller.refreshWidget();
                popup.hide();
            }
        } );
        popup.addAttribute(constants.AddARestrictionOnAField(), box );
View Full Code Here

        box.addChangeListener( new ChangeListener() {
            public void onChange(Widget w) {
                String fieldName = box.getItemText( box.getSelectedIndex() );
                String qualifiedName = factType + "." + fieldName;
                String fieldType = (String) completions.fieldTypes.get(qualifiedName);
                pattern.addConstraint( new SingleFieldConstraint( fieldName, fieldType, con ) );
                modeller.refreshWidget();
                popup.hide();
            }
        } );
        popup.addAttribute(constants.AddARestrictionOnAField(), box );


        final ListBox composites = new ListBox();
        composites.addItem("...");
        composites.addItem(constants.AllOfAnd(), CompositeFieldConstraint.COMPOSITE_TYPE_AND );
        composites.addItem(constants.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        composites.setSelectedIndex( 0 );

        composites.addChangeListener( new ChangeListener() {
            public void onChange(Widget w) {
                CompositeFieldConstraint comp = new CompositeFieldConstraint();
                comp.compositeJunctionType = composites.getValue( composites.getSelectedIndex() );
                pattern.addConstraint( comp );
                modeller.refreshWidget();
                popup.hide();
            }
        });

        InfoPopup infoComp = new InfoPopup(constants.MultipleFieldConstraints(), constants.MultipleConstraintsTip1());

        HorizontalPanel horiz = new HorizontalPanel();

        horiz.add( composites );
        horiz.add( infoComp );
        if (con == null) {
            popup.addAttribute(constants.MultipleFieldConstraint(), horiz );
        }


        //popup.addRow( new HTML("<hr/>") );
        if (con == null) {
            popup.addRow( new SmallLabel("<i>" + constants.AdvancedOptionsColon() + "</i>") ); //NON-NLS
            final Button predicate = new Button(constants.NewFormula());
            predicate.addClickListener( new ClickListener() {
                public void onClick(Widget w) {
                    SingleFieldConstraint con = new SingleFieldConstraint();
                    con.constraintValueType = SingleFieldConstraint.TYPE_PREDICATE;
                    pattern.addConstraint( con );
                    modeller.refreshWidget();
                    popup.hide();
                }
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

                    buf.append( constr.fieldBinding );
                    buf.append( " : " );
                }
                if ((constr.operator != null && constr.value != null)
                        || constr.fieldBinding != null) {
                    SingleFieldConstraint parent = (SingleFieldConstraint) constr.parent;
                    StringBuffer parentBuf = new StringBuffer();
                    while (parent != null) {
                        parentBuf.insert(0, parent.fieldName + ".");
                        parent = (SingleFieldConstraint) parent.parent;
                    }
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

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.