Package org.drools.template.model

Examples of org.drools.template.model.Rule


        if ( this._currentSequentialFlag ) {
            salience = new Integer( Rule.calcSalience( row ) );
        }
        final int spreadsheetRow = row + 1;
        final String name = this._currentRulePrefix + "_" + spreadsheetRow;
        final Rule rule = new Rule( name, salience, spreadsheetRow );
        rule.setComment( " rule values at " + ruleCell + ", header at " + headCell );

        return rule;
    }
View Full Code Here


    private void createRule(final int row,
            final int column,
            final String value) {
        final Consequence consequence = createConsequence( value );

        Rule rule = firstRule;
        if ( rule == null ) {
            rule = new Rule( "rule_" + row + "_" + column,
                    null,
                    row );
            addRule( rule );
        } else {
            firstRule = null;
            rule.setName( "rule_" + row + "_" + column );
        }
        rule.setAgendaGroup( this._currentAgendaGroup );
        rule.addCondition( this._currentPrecondition );
        rule.addCondition( _currentVerticalCondition );
        rule.addCondition( (Condition) _horizontalConditions.get( column - (ruleTableColumn + 1) ) );
        rule.addConsequence( consequence );
    }
View Full Code Here

        if ( this._currentSequentialFlag ) {
            salience = new Integer( Rule.calcSalience( row ) );
        }
        final int spreadsheetRow = row + 1;
        final String name = this._currentRulePrefix + "_" + spreadsheetRow;
        final Rule rule = new Rule( name, salience, spreadsheetRow );
        rule.setComment( " rule values at " + ruleCell + ", header at " + headCell );

        return rule;
    }
View Full Code Here

        final RuleSheetListener listener = getRuleSheetListener( stream );

        final Package ruleset = listener.getRuleSet();
        assertNotNull( ruleset );

        final Rule firstRule = (Rule) ruleset.getRules().get( 0 );
        assertNotNull( firstRule.getSalience() );
        assertTrue( firstRule.getSalience().intValue() > 0 );

        // System.out.println(ruleset.toXML());

        assertEquals( "myruleset",
                      ruleset.getName() );
        assertEquals( 2,
                      ruleset.getImports().size() );
        assertEquals( 6,
                      ruleset.getRules().size() );

        // check imports
        Import imp = (Import) ruleset.getImports().get( 0 );
        assertEquals( "blah.class1",
                      imp.getClassName() );
        imp = (Import) ruleset.getImports().get( 1 );
        assertEquals( "blah.class2",
                      imp.getClassName() );

        // check rules
        Rule rule = (Rule) ruleset.getRules().get( 0 );
        Condition cond = (Condition) rule.getConditions().get( 0 );
        assertEquals( "Foo(myObject.getColour().equals(red), myObject.size () > 1)",
                      cond.getSnippet() );

        Consequence cons = (Consequence) rule.getConsequences().get( 0 );
        assertNotNull( cons );
        assertEquals( "myObject.setIsValid(Y);",
                      cons.getSnippet() );

        rule = (Rule) ruleset.getRules().get( 5 );
        cond = (Condition) rule.getConditions().get( 1 );
        assertEquals( "myObject.size () > 7",
                      cond.getSnippet() );
        cons = (Consequence) rule.getConsequences().get( 0 );
        assertEquals( "myObject.setIsValid(10-Jul-1974)",
                      cons.getSnippet() );

    }
View Full Code Here

        return out.getDRL();

    }

    private void createTemplateRule(org.drools.template.model.Package p, int index, RuleTemplate template) {
        Rule rule = new Rule(template.getName(), null, index);
        Condition condition = new Condition();
        condition.setSnippet("r : Row()");
        rule.addCondition(condition);
        createColumnConditions(template, rule);
        rule.addConsequence(createConsequence(template));
        p.addRule(rule);
    }
View Full Code Here

  private void createRule(final int row,
      final int column,
      final String value) {
    final Consequence consequence = createConsequence( value );

    Rule rule = firstRule;
    if ( rule == null ) {
      rule = new Rule( "rule_" + row + "_" + column,
          null,
          row );
      addRule( rule );
    } else {
      firstRule = null;
      rule.setName( "rule_" + row + "_" + column );
    }
    rule.setAgendaGroup( this._currentAgendaGroup );
    rule.addCondition( this._currentPrecondition );
    rule.addCondition( _currentVerticalCondition );
    rule.addCondition( (Condition) _horizontalConditions.get( column - (ruleTableColumn + 1) ) );
    rule.addConsequence( consequence );
  }
View Full Code Here

    if ( this._currentSequentialFlag ) {
      salience = new Integer( Rule.calcSalience( row ) );
    }
    final int spreadsheetRow = row + 1;
    final String name = this._currentRulePrefix + "_" + spreadsheetRow;
    final Rule rule = new Rule( name, salience, spreadsheetRow );
    rule.setComment( " rule values at " + ruleCell + ", header at " + headCell );

    return rule;
  }
View Full Code Here

        final RuleSheetListener listener = getRuleSheetListener( stream );

        final Package ruleset = listener.getRuleSet();
        assertNotNull( ruleset );

        final Rule firstRule = (Rule) ruleset.getRules().get( 0 );
        assertNotNull( firstRule.getSalience() );
        assertTrue( firstRule.getSalience().intValue() > 0 );

        // System.out.println(ruleset.toXML());

        assertEquals( "myruleset",
                      ruleset.getName() );
        assertEquals( 2,
                      ruleset.getImports().size() );
        assertEquals( 6,
                      ruleset.getRules().size() );

        // check imports
        Import imp = (Import) ruleset.getImports().get( 0 );
        assertEquals( "blah.class1",
                      imp.getClassName() );
        imp = (Import) ruleset.getImports().get( 1 );
        assertEquals( "blah.class2",
                      imp.getClassName() );

        // check rules
        Rule rule = (Rule) ruleset.getRules().get( 0 );
        Condition cond = (Condition) rule.getConditions().get( 0 );
        assertEquals( "Foo(myObject.getColour().equals(red), myObject.size () > 12\\\")",
                      cond.getSnippet() );

        Consequence cons = (Consequence) rule.getConsequences().get( 0 );
        assertNotNull( cons );
        assertEquals( "myObject.setIsValid(Y);",
                      cons.getSnippet() );

        rule = (Rule) ruleset.getRules().get( 5 );
        cond = (Condition) rule.getConditions().get( 1 );
        assertEquals( "myObject.size () > 7",
                      cond.getSnippet() );
        cons = (Consequence) rule.getConsequences().get( 0 );
        assertEquals( "myObject.setIsValid(10-Jul-1974)",
                      cons.getSnippet() );

    }
View Full Code Here

        if ( this._currentSequentialFlag ) {
            salience = new Integer( Rule.calcSalience( row ) );
        }
        final int spreadsheetRow = row + 1;
        final String name = this._currentRulePrefix + "_" + spreadsheetRow;
        final Rule rule = new Rule( name, salience, spreadsheetRow );
        rule.setComment( " rule values at " + ruleCell + ", header at " + headCell );

        return rule;
    }
View Full Code Here

    return out.getDRL();

  }

  private void createTemplateRule(org.drools.template.model.Package p, int index, RuleTemplate template) {
    Rule rule = new Rule(template.getName(), null, index);
    Condition condition = new Condition();
    condition.setSnippet("r : Row()");
    rule.addCondition(condition);
    createColumnConditions(template, rule);
    rule.addConsequence(createConsequence(template));
    p.addRule(rule);
  }
View Full Code Here

TOP

Related Classes of org.drools.template.model.Rule

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.