Package org.drools.verifier.components

Examples of org.drools.verifier.components.LiteralRestriction


     *
     * @param descr
     */
    private void visit(LiteralRestrictionDescr descr) {

        LiteralRestriction restriction = LiteralRestriction.createRestriction( pattern,
                                                                               descr.getText() );

        restriction.setPatternIsNot( pattern.isPatternNot() );
        restriction.setConstraintPath( constraint.getPath() );
        restriction.setFieldPath( constraint.getFieldPath() );
        restriction.setOperator( Operator.determineOperator( descr.getEvaluator(),
                                                             descr.isNegated() ) );
        restriction.setOrderNumber( orderNumber );
        restriction.setParentPath( pattern.getPath() );
        restriction.setParentType( pattern.getVerifierComponentType() );

        // Set field value, if it is unset.
        field.setFieldType( restriction.getValueType() );

        data.add( restriction );
        solvers.addPatternComponent( restriction );
    }
View Full Code Here


   * @param descr
   */
  private void flatten(LiteralRestrictionDescr descr,
      VerifierComponent parent, int orderNumber) {

    LiteralRestriction restriction = new LiteralRestriction();

    restriction.setRuleId(currentRule.getId());
    restriction.setRuleName(currentRule.getRuleName());
    restriction.setRuleId(currentRule.getId());
    restriction.setPatternId(currentPattern.getId());
    restriction.setPatternIsNot(currentPattern.isPatternNot());
    restriction.setConstraintId(currentConstraint.getId());
    restriction.setFieldId(currentConstraint.getFieldId());
    restriction.setOperator(Operator.determineOperator(
        descr.getEvaluator(), descr.isNegated()));
    restriction.setValue(descr.getText());
    restriction.setOrderNumber(orderNumber);
    restriction.setParent(parent);

    // Set field value, if it is unset.
    currentField.setFieldType(restriction.getValueType());

    data.add(restriction);
    solvers.addRestriction(restriction);
  }
View Full Code Here

    }

    for (Restriction r : restrictions) {
      if (r instanceof LiteralRestriction) {
        try {
          LiteralRestriction restriction = (LiteralRestriction) r;

          dt.put(restriction.getValueAsObject(), new DataRow(
              restriction.getRuleId(), restriction.getRuleName(),
              restriction.getOperator(), restriction
                  .getValueAsString()));
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
View Full Code Here

     *
     * @param descr
     */
    private void visit(LiteralRestrictionDescr descr) {

        LiteralRestriction restriction = LiteralRestriction.createRestriction(pattern,
                descr.getText());

        restriction.setPatternIsNot(pattern.isPatternNot());
        restriction.setFieldPath(field.getPath());
        restriction.setOperator(Operator.determineOperator(descr.getEvaluator(),
                descr.isNegated()));
        restriction.setOrderNumber(orderNumber);
        restriction.setParentPath(pattern.getPath());
        restriction.setParentType(pattern.getVerifierComponentType());

        // Set field value, if it is unset.
        field.setFieldType(restriction.getValueType());

        data.add(restriction);
        solvers.addPatternComponent(restriction);
    }
View Full Code Here

            createRestriction(currentOrderNumber, value, operator);
        }
    }

    private void createRestriction(int currentOrderNumber, String value, Operator operator) {
        LiteralRestriction restriction = LiteralRestriction.createRestriction(pattern, value);
        restriction.setFieldPath(field.getPath());
        restriction.setPatternIsNot(pattern.isPatternNot());
        restriction.setParentPath(pattern.getPath());
        restriction.setParentType(pattern.getVerifierComponentType());
        restriction.setOrderNumber(currentOrderNumber);
        restriction.setOperator(operator);
        field.setFieldType(restriction.getValueType());
        data.add(restriction);
        solvers.addPatternComponent(restriction);
    }
View Full Code Here

        Collection<Object> data = new ArrayList<Object>();

        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        LiteralRestriction r1 = LiteralRestriction.createRestriction( pattern,
                                                                      "1" );
        r1.setFieldPath( "0" );
        r1.setOperator( Operator.EQUAL );
        r1.setOrderNumber( 0 );

        LiteralRestriction r2 = LiteralRestriction.createRestriction( pattern,
                                                                      "1" );
        r2.setFieldPath( "0" );
        r2.setOperator( Operator.NOT_EQUAL );
        r2.setOrderNumber( 1 );

        LiteralRestriction r3 = LiteralRestriction.createRestriction( pattern,
                                                                      "1.0" );
        r3.setFieldPath( "0" );
        r3.setOperator( Operator.EQUAL );
        r3.setOrderNumber( 2 );

        LiteralRestriction r4 = LiteralRestriction.createRestriction( pattern,
                                                                      "1.0" );
        r4.setFieldPath( "0" );
        r4.setOperator( Operator.NOT_EQUAL );
        r4.setOrderNumber( 3 );

        LiteralRestriction r5 = LiteralRestriction.createRestriction( pattern,
                                                                      "foo" );
        r5.setFieldPath( "0" );
        r5.setOperator( MatchesEvaluatorsDefinition.MATCHES );
        r5.setOrderNumber( 4 );

        LiteralRestriction r6 = LiteralRestriction.createRestriction( pattern,
                                                                      "foo" );
        r6.setFieldPath( "0" );
        r6.setOperator( MatchesEvaluatorsDefinition.NOT_MATCHES );
        r6.setOrderNumber( 5 );

        data.add( r1 );
        data.add( r2 );
        data.add( r3 );
        data.add( r4 );
View Full Code Here

        Collection<Object> data = new ArrayList<Object>();

        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        LiteralRestriction r1 = LiteralRestriction.createRestriction( pattern,
                                                                      "1" );
        r1.setFieldPath( "0" );
        r1.setOperator( Operator.GREATER_OR_EQUAL );
        r1.setOrderNumber( 0 );

        LiteralRestriction r2 = LiteralRestriction.createRestriction( pattern,
                                                                      "1" );
        r2.setFieldPath( "0" );
        r2.setOperator( Operator.LESS );
        r2.setOrderNumber( 1 );

        data.add( r1 );
        data.add( r2 );

        StatelessSessionResult sessionResult = session.executeWithResults( data );
View Full Code Here

        session.setAgendaFilter( new RuleNameMatchesAgendaFilter( "Opposite LiteralRestrictions with ranges, greater - less or equal" ) );

        Collection<Object> data = new ArrayList<Object>();

        Pattern pattern = VerifierComponentMockFactory.createPattern1();
        LiteralRestriction r1 = LiteralRestriction.createRestriction( pattern,
                                                                      "1" );
        r1.setFieldPath( "0" );
        r1.setOperator( Operator.GREATER );
        r1.setOrderNumber( 0 );

        LiteralRestriction r2 = LiteralRestriction.createRestriction( pattern,
                                                                      "1" );
        r2.setFieldPath( "0" );
        r2.setOperator( Operator.LESS_OR_EQUAL );
        r2.setOrderNumber( 1 );

        data.add( r1 );
        data.add( r2 );

        StatelessSessionResult sessionResult = session.executeWithResults( data );
View Full Code Here

        session.setAgendaFilter( new RuleNameMatchesAgendaFilter( "Find redundant restrictions from pattern possibilities" ) );

        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        Collection<Object> objects = new ArrayList<Object>();
        LiteralRestriction left = LiteralRestriction.createRestriction( pattern,
                                                                        "" );

        LiteralRestriction right = LiteralRestriction.createRestriction( pattern,
                                                                         "" );

        Redundancy redundancy = new Redundancy( left,
                                                right );
View Full Code Here

        Collection<Object> data = new ArrayList<Object>();

        Pattern pattern = VerifierComponentMockFactory.createPattern1();

        LiteralRestriction r1 = LiteralRestriction.createRestriction( pattern,
                                                                      "1" );
        r1.setFieldPath( "0" );
        r1.setOperator( Operator.GREATER_OR_EQUAL );
        r1.setOrderNumber( 0 );

        LiteralRestriction r2 = LiteralRestriction.createRestriction( pattern,
                                                                      "0" );
        r2.setFieldPath( "0" );
        r2.setOperator( Operator.LESS_OR_EQUAL );
        r2.setOrderNumber( 1 );

        data.add( r1 );
        data.add( r2 );

        StatelessSessionResult sessionResult = session.executeWithResults( data );
View Full Code Here

TOP

Related Classes of org.drools.verifier.components.LiteralRestriction

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.