Package org.drools.factconstraints.client

Examples of org.drools.factconstraints.client.ConstraintConfiguration


    return table;
  }

  protected void removeConstraint() {
    if (constraintsCombo.getSelectedIndex() != -1) {
      ConstraintConfiguration c = contraintsMap.get(constraintsCombo.getValue(constraintsCombo.getSelectedIndex()));
      ((WorkingSetConfigData) workingSet.content).constraints = getConstraintsConstrainer().removeConstraint(c);
    }
    fillFieldConstrains();
  }
View Full Code Here


      vpConstraintConf.remove(vpConstraintConf.getWidgetCount() - 1);
      vpConstraintConf.add(new SmallLabel());
      return;
    }
    if (constraintsCombo.getSelectedIndex() != -1) {
      ConstraintConfiguration c = contraintsMap.get(constraintsCombo.getValue(constraintsCombo.getSelectedIndex()));
      ConstraintEditor editor = new ConstraintEditor(c);
      vpConstraintConf.remove(vpConstraintConf.getWidgetCount() - 1);
      vpConstraintConf.add(editor);
    }
  }
View Full Code Here

    }
       
        addbutton.addClickListener( new ClickListener() {
            public void onClick(Widget w) {
              String name = consDefsCombo.getItemText(consDefsCombo.getSelectedIndex());
              ConstraintConfiguration config = ConstraintsContainer.getEmptyConfiguration(name);
              if (config != null) {
               
                String factName = factsCombo.getItemText(factsCombo.getSelectedIndex());
                String fieldName = fieldsCombo.getItemText(fieldsCombo.getSelectedIndex());
                config.setFactType(factName);
                config.setFieldName(fieldName);
                if (((WorkingSetConfigData) workingSet.content).constraints == null) {
                  ((WorkingSetConfigData) workingSet.content).constraints = new ArrayList<ConstraintConfiguration>();
                }
                ((WorkingSetConfigData) workingSet.content).constraints.add(config);
                constraintsCombo.addItem(config.getConstraintName(), addContrainsMap(config));
                getConstraintsConstrainer().addConstraint(config);
               
              }
              pop.hide();
View Full Code Here

        return constraintId;
    }

    protected void removeConstraint() {
        if (constraintsCombo.getSelectedIndex() != -1) {
            ConstraintConfiguration c = contraintsMap.get(constraintsCombo.getValue(constraintsCombo.getSelectedIndex()));
            ((WorkingSetConfigData) workingSet.content).constraints = this.workingSetEditor.getConstraintsConstrainer().removeConstraint(c);
        }
        fillFieldConstrains();
    }
View Full Code Here

            vpConstraintConf.remove(vpConstraintConf.getWidgetCount() - 1);
            vpConstraintConf.add(new SmallLabel());
            return;
        }
        if (constraintsCombo.getSelectedIndex() != -1) {
            ConstraintConfiguration c = contraintsMap.get(constraintsCombo.getValue(constraintsCombo.getSelectedIndex()));
            ConstraintEditor editor = new ConstraintEditor(c);
            vpConstraintConf.remove(vpConstraintConf.getWidgetCount() - 1);
            vpConstraintConf.add(editor);
        }
    }
View Full Code Here

        addbutton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                String name = consDefsCombo.getItemText(consDefsCombo.getSelectedIndex());
                ConstraintConfiguration config = ConstraintsContainer.getEmptyConfiguration(name);
                if (config != null) {

                    String factName = factsCombo.getItemText(factsCombo.getSelectedIndex());
                    String fieldName = fieldsCombo.getItemText(fieldsCombo.getSelectedIndex());
                    config.setFactType(factName);
                    config.setFieldName(fieldName);
                    if (((WorkingSetConfigData) workingSet.content).constraints == null) {
                        ((WorkingSetConfigData) workingSet.content).constraints = new ArrayList<ConstraintConfiguration>();
                    }
                    ((WorkingSetConfigData) workingSet.content).constraints.add(config);
                    constraintsCombo.addItem(config.getConstraintName(), addContrainsMap(config));
                    workingSetEditor.getConstraintsConstrainer().addConstraint(config);

                }
                pop.hide();
            }
View Full Code Here

public class ConstraintsConstrainerTest {

    @Test
    public void test() {
    LinkedList<ConstraintConfiguration> list = new LinkedList<ConstraintConfiguration>();
    ConstraintConfiguration conf = new SimpleConstraintConfigurationImpl();
        conf.setFactType("Person");
        conf.setFieldName("age");
       
        list.add(conf);
    ConstraintsContainer cc = new ConstraintsContainer(list);
    assertTrue(cc.hasConstraints("Person"));
    assertFalse(cc.hasConstraints("Person3"));
   
    assertEquals(1, cc.getConstraints("Person").size());
   
    conf = new SimpleConstraintConfigurationImpl();
        conf.setFactType("Person");
        conf.setFieldName("name");
       
        cc.addConstraint(conf);
        assertEquals(2, cc.getConstraints("Person").size());
        assertEquals(1, cc.getConstraints("Person", "age").size());
        assertSame(conf, cc.getConstraints("Person", "name").get(0));
        assertEquals(0, cc.getConstraints("Person", "toothCount").size());
       
        conf = new SimpleConstraintConfigurationImpl();
        conf.setFactType("Pet");
        conf.setFieldName("name");
   
        cc.addConstraint(conf);
       
        assertEquals(1, cc.getConstraints("Pet").size());
       
View Full Code Here

  }
 
  @Test
  public void newConfig() {
    for (String confName : new String[] {"NotNull", "IntegerConstraint", "RangeConstraint", "NotMatches", "Matches"}) {
      ConstraintConfiguration conf1 = ConstraintsContainer.getEmptyConfiguration(confName);
      ConstraintConfiguration conf2 = ConstraintsContainer.getEmptyConfiguration(confName);
      assertFalse(conf1.equals(conf2));
     
      assertEquals(conf1.getArgumentKeys(), conf2.getArgumentKeys());
    }
   
  }
View Full Code Here

        conf.setArgumentValue(RangeConstraint.RANGE_CONSTRAINT_MIN, "0");
        conf.setArgumentValue(RangeConstraint.RANGE_CONSTRAINT_MAX, "120");
        System.out.println("Validation Rule:\n" + cons.getVerifierRule(conf) + "\n\n");

        //salary constraint
        ConstraintConfiguration salaryCons = new SimpleConstraintConfigurationImpl();
        salaryCons.setFactType("Person");
        salaryCons.setFieldName("salary");
        salaryCons.setArgumentValue(RangeConstraint.RANGE_CONSTRAINT_MIN, "0");
        salaryCons.setArgumentValue(RangeConstraint.RANGE_CONSTRAINT_MAX, "1000.6");

        System.out.println("Validation Rule:\n" + cons.getVerifierRule(salaryCons) + "\n\n");


        String ruleToVerify = "";
View Full Code Here

        return constraintId;
    }

    protected void removeConstraint() {
        if ( constraintsCombo.getSelectedIndex() != -1 ) {
            ConstraintConfiguration c = contraintsMap.get( constraintsCombo.getValue( constraintsCombo.getSelectedIndex() ) );
            ((WorkingSetConfigData) workingSet.content).constraints = this.workingSetEditor.getConstraintsConstrainer().removeConstraint( c );
        }
        fillFieldConstrains();
    }
View Full Code Here

TOP

Related Classes of org.drools.factconstraints.client.ConstraintConfiguration

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.