Package org.drools.ide.common.client.modeldriven.brl

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


        p1.getChildColumns().add( c1 );
        dt.getConditions().add( p1 );

        BRLConditionColumn brlCondition = new BRLConditionColumn();
        FactPattern fp = new FactPattern( "Driver" );
        fp.setBoundName( "$brl1" );

        SingleFieldConstraint sfc1 = new SingleFieldConstraint();
        sfc1.setFieldBinding( "$sfc1" );
        sfc1.setOperator( "==" );
        sfc1.setFieldName( "name" );
        sfc1.setFieldType( SuggestionCompletionEngine.TYPE_STRING );

        fp.addConstraint( sfc1 );
        brlCondition.getDefinition().add( fp );
        dt.getConditions().add( brlCondition );

        ActionInsertFactCol52 ins = new ActionInsertFactCol52();
        ins.setBoundName( "$ins" );
        ins.setFactField( "rating" );
        ins.setFactType( "Person" );
        ins.setType( SuggestionCompletionEngine.TYPE_STRING );
        dt.getActionCols().add( ins );

        BRLRuleModel model = new BRLRuleModel( dt );

        assertNotNull( model.getLHSBoundFacts() );
        assertEquals( 2,
                      model.getLHSBoundFacts().size() );
        assertTrue( model.getLHSBoundFacts().contains( "$p1" ) );
        assertTrue( model.getLHSBoundFacts().contains( "$brl1" ) );

        assertNotNull( model.getLHSBindingType( "$p1" ) );
        assertEquals( "Driver",
                      model.getLHSBindingType( "$p1" ) );
        assertNotNull( model.getLHSBindingType( "$brl1" ) );
        assertEquals( "Driver",
                      model.getLHSBindingType( "$brl1" ) );

        FactPattern r1 = model.getLHSBoundFact( "$p1" );
        assertNotNull( r1 );
        assertTrue( r1 instanceof BRLRuleModel.Pattern52FactPatternAdaptor );
        BRLRuleModel.Pattern52FactPatternAdaptor raif1 = (BRLRuleModel.Pattern52FactPatternAdaptor) r1;
        assertEquals( "Driver",
                      raif1.getFactType() );

        FactPattern r2 = model.getLHSBoundFact( "$brl1" );
        assertNotNull( r2 );
        assertEquals( "Driver",
                      r2.getFactType() );
    }
View Full Code Here


        p1.getChildColumns().add( c1 );
        dt.getConditions().add( p1 );

        BRLConditionColumn brlCondition = new BRLConditionColumn();
        FactPattern fp = new FactPattern( "Driver" );
        fp.setBoundName( "$brl1" );

        SingleFieldConstraint sfc1 = new SingleFieldConstraint();
        sfc1.setFieldBinding( "$sfc1" );
        sfc1.setOperator( "==" );
        sfc1.setFieldName( "name" );
        sfc1.setFieldType( SuggestionCompletionEngine.TYPE_STRING );

        fp.addConstraint( sfc1 );
        brlCondition.getDefinition().add( fp );
        dt.getConditions().add( brlCondition );

        ActionInsertFactCol52 ins = new ActionInsertFactCol52();
        ins.setBoundName( "$ins" );
View Full Code Here

        assertEquals( "42",
                      items[0] );
        assertEquals( "43",
                      items[1] );

        items = engine.getEnums( new FactPattern( "Person" ),
                                 "age" ).fixedList;
        assertEquals( 2,
                      items.length );
        assertEquals( "42",
                      items[0] );
        assertEquals( "43",
                      items[1] );

        assertNull( engine.getEnums( new FactPattern( "Nothing" ),
                                     "age" ) );

        assertEquals( null,
                      engine.getEnums( new FactPattern( "Something" ),
                                       "else" ) );

    }
View Full Code Here

                                                                        enums );
        assertEquals( "String",
                      engine.getFieldType( "SuggestionCompletionEngineTest$NestedClass",
                                           "name" ) );

        FactPattern pat = new FactPattern( "Fact" );
        SingleFieldConstraint f1 = new SingleFieldConstraint( "f1" );
        f1.setValue( "a1" );
        pat.addConstraint( f1 );
        pat.addConstraint( new SingleFieldConstraint( "f2" ) );

        DropDownData data = engine.getEnums( pat,
                                             "f2" );

        assertNotNull( data );
View Full Code Here

        assertEquals( "val3",
                      items[0] );
        assertEquals( "val4",
                      items[1] );

        FactPattern pat = new FactPattern( "Fact" );
        SingleFieldConstraint sfc = new SingleFieldConstraint( "field2" );
        pat.addConstraint( sfc );
        items = engine.getEnums( pat,
                                 "field2" ).fixedList;
        assertEquals( 2,
                      items.length );
        assertEquals( "val3",
                      items[0] );
        assertEquals( "val4",
                      items[1] );

        items = engine.getDataEnumList( "Fact.field1" );
        assertEquals( 2,
                      items.length );
        assertEquals( "val1",
                      items[0] );
        assertEquals( "val2",
                      items[1] );

        items = engine.getEnums( new FactPattern( "Fact" ),
                                 "field1" ).fixedList;
        assertEquals( 2,
                      items.length );
        assertEquals( "val1",
                      items[0] );
View Full Code Here

        sce.putDataEnumList( "Fact.value[type=sex]",
                               new String[]{"M", "F"} );
        sce.putDataEnumList( "Fact.value[type=colour]",
                               new String[]{"RED", "WHITE", "BLUE"} );

        FactPattern pat = new FactPattern( "Fact" );
        SingleFieldConstraint sfc = new SingleFieldConstraint( "type" );
        sfc.setValue( "sex" );
        pat.addConstraint( sfc );
        String[] result = sce.getEnums( pat,
                                        "value" ).fixedList;
        assertEquals( 2,
                      result.length );
        assertEquals( "M",
                      result[0] );
        assertEquals( "F",
                      result[1] );

        pat = new FactPattern( "Fact" );
        sfc = new SingleFieldConstraint( "type" );
        sfc.setValue( "colour" );
        pat.addConstraint( sfc );

        result = sce.getEnums( pat,
                               "value" ).fixedList;
        assertEquals( 3,
                      result.length );
View Full Code Here

        sce.putDataEnumList( "Fact.field3[field1=a1,field2=b1]",
                               new String[]{"c1", "c2", "c3"} );
        sce.putDataEnumList( "Fact.field4[field1=a1]",
                               new String[]{"d1", "d2"} );

        FactPattern pat = new FactPattern( "Fact" );
        SingleFieldConstraint sfc = new SingleFieldConstraint( "field1" );
        sfc.setValue( "a1" );
        pat.addConstraint( sfc );
        SingleFieldConstraint sfc2 = new SingleFieldConstraint( "field2" );
        sfc2.setValue( "b1" );
        pat.addConstraint( sfc2 );

        String[] result = sce.getEnums( pat,
                                        "field3" ).fixedList;
        assertEquals( 3,
                      result.length );
View Full Code Here

        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

        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

        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

TOP

Related Classes of org.drools.ide.common.client.modeldriven.brl.FactPattern

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.