Examples of FactPattern


Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

        sce.putDataEnumList( "Fact.field5",
                               new String[]{"e1", "e2"} );
        sce.putDataEnumList( "Fact.field6[field1=a1, field2=b2, field3=c3,longerField4=d1,field5=e2]",
                               new String[]{"f1", "f2"} );

        FactPattern pat = new FactPattern( "Fact" );
        SingleFieldConstraint sfc = new SingleFieldConstraint( "field1" );
        sfc.setValue( "a1" );
        pat.addConstraint( sfc );
        SingleFieldConstraint sfc2 = new SingleFieldConstraint( "field2" );
        sfc2.setValue( "b2" );
        pat.addConstraint( sfc2 );
        SingleFieldConstraint sfc3 = new SingleFieldConstraint( "field3" );
        sfc3.setValue( "c3" );
        pat.addConstraint( sfc3 );
        SingleFieldConstraint sfc4 = new SingleFieldConstraint( "longerField4" );
        sfc4.setValue( "d1" );
        pat.addConstraint( sfc4 );

        assertNull( sce.getEnums( pat,
                                  "field6" ) );

        SingleFieldConstraint sfc5 = new SingleFieldConstraint( "field5" );
        sfc5.setValue( "e2" );
        pat.addConstraint( sfc5 );

        String[] result2 = sce.getEnums( pat,
                                         "field6" ).fixedList;
        assertEquals( 2,
                      result2.length );
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

        sce.putDataEnumList( "Fact.type",
                               new String[]{"sex", "colour"} );
        sce.putDataEnumList( "Fact.value[f1, f2]",
                               new String[]{"select something from database where x=@{f1} and y=@{f2}"} );

        FactPattern fp = new FactPattern( "Fact" );
        String[] drops = sce.getEnums( fp,
                                       "type" ).fixedList;
        assertEquals( 2,
                      drops.length );
        assertEquals( "sex",
                      drops[0] );
        assertEquals( "colour",
                      drops[1] );

        Map<String, Object> lookupFields = sce.loadDataEnumLookupFields();
        assertEquals( 1,
                      lookupFields.size() );
        String[] flds = (String[]) lookupFields.get( "Fact.value" );
        assertEquals( 2,
                      flds.length );
        assertEquals( "f1",
                      flds[0] );
        assertEquals( "f2",
                      flds[1] );

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

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

Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

        sce.putDataEnumList( "Fact.value[e1, e2]",
                               new String[]{"select something from database where x=@{e1} and y=@{e2}"} );
        sce.putDataEnumList( "Fact.value[f1, f2]",
                               new String[]{"select something from database where x=@{f1} and y=@{f2}"} );

        FactPattern fp = new FactPattern( "Fact" );
        String[] drops = sce.getEnums( fp,
                                       "type" ).fixedList;
        assertEquals( 2,
                      drops.length );
        assertEquals( "sex",
                      drops[0] );
        assertEquals( "colour",
                      drops[1] );

        Map<String, Object> lookupFields = sce.loadDataEnumLookupFields();
        assertEquals( 1,
                      lookupFields.size() );
        String[] flds = (String[]) lookupFields.get( "Fact.value" );
        assertEquals( 2,
                      flds.length );
        assertEquals( "f1",
                      flds[0] );
        assertEquals( "f2",
                      flds[1] );

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

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

Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

    @Test
    public void testFactPattern_Basics() {
        RuleModel model = new RuleModel();

        model.lhs = new IPattern[1];
        FactPattern fp0 = new FactPattern();
        fp0.setBoundName( "$t0" );
        fp0.setFactType( "FT0" );
        fp0.setNegated( true );
        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FactPattern );
        FactPattern fp0Clone = (FactPattern) clone.lhs[0];
        assertEquals( fp0.getBoundName(),
                      fp0Clone.getBoundName() );
        assertEquals( fp0.getFactType(),
                      fp0Clone.getFactType() );
        assertEquals( fp0.isNegated(),
                      fp0Clone.isNegated() );
    }
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

    @Test
    public void testFactPattern_CEPWindow() {
        RuleModel model = new RuleModel();

        model.lhs = new IPattern[1];
        FactPattern fp0 = new FactPattern();
        fp0.setBoundName( "$t0" );
        fp0.setFactType( "FT0" );
        fp0.setNegated( true );
        CEPWindow cepWindow0 = new CEPWindow();
        cepWindow0.setOperator( SuggestionCompletionEngine.getCEPWindowOperators().get( 0 ) );
        cepWindow0.setParameter( "cepWindow0P0",
                                 "cepWindow0P0Value" );
        cepWindow0.setParameter( "cepWindow0P1",
                                 "cepWindow0P1Value" );
        fp0.setWindow( cepWindow0 );
        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FactPattern );
        FactPattern fp0Clone = (FactPattern) clone.lhs[0];
        assertEquals( fp0.getBoundName(),
                      fp0Clone.getBoundName() );
        assertEquals( fp0.getFactType(),
                      fp0Clone.getFactType() );
        assertEquals( fp0.isNegated(),
                      fp0Clone.isNegated() );

        assertNotSame( fp0.getWindow(),
                       fp0Clone.getWindow() );
        assertNotNull( fp0Clone.getWindow() );
        assertTrue( fp0Clone.getWindow() instanceof CEPWindow );
        CEPWindow cepWindow0Clone = (CEPWindow) fp0Clone.getWindow();
        assertEquals( cepWindow0.getOperator(),
                      cepWindow0Clone.getOperator() );
        assertEquals( cepWindow0.getParameters().size(),
                      cepWindow0Clone.getParameters().size() );
        assertNotNull( cepWindow0Clone.getParameter( "cepWindow0P0" ) );
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

    @Test
    public void testFactPattern_SingleFieldConstraints() {
        RuleModel model = new RuleModel();

        model.lhs = new IPattern[1];
        FactPattern fp0 = new FactPattern();
        fp0.setBoundName( "$t0" );
        fp0.setFactType( "FT0" );

        SingleFieldConstraint sfc0 = new SingleFieldConstraint();
        sfc0.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        sfc0.setFieldBinding( "$sfc0" );
        sfc0.setFieldName( "sfc0" );
        sfc0.setFieldType( SuggestionCompletionEngine.TYPE_STRING );
        sfc0.setOperator( "==" );
        sfc0.setParameter( "sfc0p0",
                           "sfc0p0Value" );
        sfc0.setValue( "sfc0Value" );
        fp0.addConstraint( sfc0 );

        SingleFieldConstraint sfc1 = new SingleFieldConstraint();
        sfc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        sfc1.setFieldBinding( "$sfc1" );
        sfc1.setFieldName( "sfc1" );
        sfc1.setFieldType( SuggestionCompletionEngine.TYPE_STRING );
        sfc1.setOperator( "==" );
        sfc1.setParameter( "sfc1p0",
                           "sfc1p0Value" );
        sfc1.setValue( "sfc1Value" );
        fp0.addConstraint( sfc1 );

        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FactPattern );
        FactPattern fp0Clone = (FactPattern) clone.lhs[0];
        assertEquals( fp0.getBoundName(),
                      fp0Clone.getBoundName() );
        assertEquals( fp0.getFactType(),
                      fp0Clone.getFactType() );

        assertEquals( 2,
                      fp0Clone.constraintList.constraints.length );

        assertNotSame( fp0.constraintList.constraints[0],
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

    @Test
    public void testFactPattern_ConnectiveConstraints() {
        RuleModel model = new RuleModel();

        model.lhs = new IPattern[1];
        FactPattern fp0 = new FactPattern();
        fp0.setBoundName( "$t0" );
        fp0.setFactType( "FT0" );

        SingleFieldConstraint sfc0 = new SingleFieldConstraint();
        sfc0.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        sfc0.setFieldBinding( "$sfc0" );
        sfc0.setFieldName( "sfc0" );
        sfc0.setFieldType( SuggestionCompletionEngine.TYPE_STRING );
        sfc0.setOperator( "==" );
        sfc0.setParameter( "sfc0p0",
                           "sfc0p0Value" );
        sfc0.setValue( "sfc0Value" );
        fp0.addConstraint( sfc0 );

        sfc0.addNewConnective();
        ConnectiveConstraint sfc0cc0 = sfc0.connectives[0];
        sfc0cc0.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        sfc0cc0.setFieldName( "sfc0" );
        sfc0cc0.setFieldType( SuggestionCompletionEngine.TYPE_STRING );
        sfc0cc0.setOperator( "|| ==" );
        sfc0cc0.setParameter( "sfc0cc0p0",
                              "sfc0cc0p0Value" );
        sfc0cc0.setValue( "sfc0cc0Value" );

        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FactPattern );
        FactPattern fp0Clone = (FactPattern) clone.lhs[0];
        assertEquals( fp0.getBoundName(),
                      fp0Clone.getBoundName() );
        assertEquals( fp0.getFactType(),
                      fp0Clone.getFactType() );

        assertEquals( 1,
                      fp0Clone.constraintList.constraints.length );

        assertNotSame( fp0.constraintList.constraints[0],
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

    @Test
    public void testFactPattern_CompositeFieldConstraints() {
        RuleModel model = new RuleModel();

        model.lhs = new IPattern[1];
        FactPattern fp0 = new FactPattern();
        fp0.setBoundName( "$t0" );
        fp0.setFactType( "FT0" );

        CompositeFieldConstraint cfc0 = new CompositeFieldConstraint();
        cfc0.compositeJunctionType = CompositeFieldConstraint.COMPOSITE_TYPE_OR;

        SingleFieldConstraint sfc0 = new SingleFieldConstraint();
        sfc0.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        sfc0.setFieldBinding( "$sfc0" );
        sfc0.setFieldName( "sfc0" );
        sfc0.setFieldType( SuggestionCompletionEngine.TYPE_STRING );
        sfc0.setOperator( "==" );
        sfc0.setParameter( "sfc0p0",
                           "sfc0p0Value" );
        sfc0.setValue( "sfc0Value" );
        cfc0.addConstraint( sfc0 );

        SingleFieldConstraint sfc1 = new SingleFieldConstraint();
        sfc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_LITERAL );
        sfc1.setFieldBinding( "$sfc1" );
        sfc1.setFieldName( "sfc1" );
        sfc1.setFieldType( SuggestionCompletionEngine.TYPE_STRING );
        sfc1.setOperator( "==" );
        sfc1.setParameter( "sfc1p0",
                           "sfc1p0Value" );
        sfc1.setValue( "sfc1Value" );
        cfc0.addConstraint( sfc1 );

        fp0.addConstraint( cfc0 );

        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FactPattern );
        FactPattern fp0Clone = (FactPattern) clone.lhs[0];
        assertEquals( fp0.getBoundName(),
                      fp0Clone.getBoundName() );
        assertEquals( fp0.getFactType(),
                      fp0Clone.getFactType() );

        assertEquals( 1,
                      fp0Clone.constraintList.constraints.length );

        assertNotSame( fp0.constraintList.constraints[0],
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

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

        // examine the first pattern
        FactPattern person = (FactPattern) rm.lhs[0];
        assertEquals( 3,
                      person.constraintList.constraints.length );
        SingleFieldConstraint cons = (SingleFieldConstraint) person.constraintList.constraints[0];
        assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL,
                      cons.getConstraintValueType() );
        assertEquals( "name",
                      cons.getFieldName() );
        assertEquals( "==",
                      cons.getOperator() );
        assertEquals( "mike",
                      cons.getValue() );

        cons = (SingleFieldConstraint) person.constraintList.constraints[1];
        assertEquals( BaseSingleFieldConstraint.TYPE_RET_VALUE,
                      cons.getConstraintValueType() );
        assertEquals( "age",
                      cons.getFieldName() );
        assertEquals( "<",
                      cons.getOperator() );
        assertEquals( "33 + 1",
                      cons.getValue() );

        cons = (SingleFieldConstraint) person.constraintList.constraints[2];
        assertEquals( BaseSingleFieldConstraint.TYPE_PREDICATE,
                      cons.getConstraintValueType() );
        assertEquals( "age > 6",
                      cons.getValue() );

        // examine the second pattern
        FactPattern cheese = (FactPattern) rm.lhs[1];
        assertEquals( 1,
                      cheese.constraintList.constraints.length );
        cons = (SingleFieldConstraint) cheese.constraintList.constraints[0];
        assertEquals( "type",
                      cons.getFieldName() );
View Full Code Here

Examples of org.drools.ide.common.client.modeldriven.brl.FactPattern

                      ((FactPattern) rm.lhs[0]).getFactType() );
        assertEquals( "p1",
                      ((FactPattern) rm.lhs[0]).getBoundName() );

        // examine the first pattern
        FactPattern person = (FactPattern) rm.lhs[0];
        assertEquals( 3,
                      person.constraintList.constraints.length );

        SingleFieldConstraint cons = (SingleFieldConstraint) person.constraintList.constraints[0];
        assertEquals( BaseSingleFieldConstraint.TYPE_LITERAL,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.