Package org.drools.workbench.models.datamodel.rule

Examples of org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint


        m.name = "t1";

        FactPattern p1 = new FactPattern( "Person" );
        m.addLhsItem( p1 );

        CompositeFieldConstraint comp = new CompositeFieldConstraint();
        comp.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p1.addConstraint( comp );

        final SingleFieldConstraint X = new SingleFieldConstraint();
        X.setFieldName( "field1" );
        X.setFieldType( DataType.TYPE_STRING );
        X.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        X.setValue( "$f1" );
        X.setOperator( "==" );
        comp.addConstraint( X );

        final SingleFieldConstraint Y = new SingleFieldConstraint();
        Y.setFieldName( "field2" );
        Y.setFieldType( DataType.TYPE_STRING );
        Y.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        Y.setValue( "$f2" );
        Y.setOperator( "==" );
        comp.addConstraint( Y );

        String expected = "rule \"t1_0\"\n" +
                "dialect \"mvel\"\n" +
                "when\n" +
                "Person( field2 == \"bar\" )\n" +
View Full Code Here


            preGenerateNestedConnector( gctx );
            if ( gctx.getDepth() == 0 ) {
                buf.append( ", " );
            } else {
                CompositeFieldConstraint cconstr = (CompositeFieldConstraint) gctx.getParent().getFieldConstraint();
                buf.append( cconstr.getCompositeJunctionType() + " " );
            }
            postGenerateNestedConnector( gctx );
            if ( generateTemplateCheck ) {
                buf.append( "@end{}" );
            }
View Full Code Here

        FactPattern p = new FactPattern( "Person" );

        m.addLhsItem( p );

        final CompositeFieldConstraint cfc1 = new CompositeFieldConstraint();
        cfc1.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc1 );
        final SingleFieldConstraint cfc1sfc1 = new SingleFieldConstraint();
        cfc1sfc1.setFieldName( "field1" );
        cfc1sfc1.setFieldType( DataType.TYPE_STRING );
        cfc1sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc1sfc1.setValue( "$f1" );
        cfc1sfc1.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc1 );
        final SingleFieldConstraint cfc1sfc2 = new SingleFieldConstraint();
        cfc1sfc2.setFieldName( "field2" );
        cfc1sfc2.setFieldType( DataType.TYPE_STRING );
        cfc1sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc1sfc2.setValue( "$f2" );
        cfc1sfc2.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc2 );

        final CompositeFieldConstraint cfc2 = new CompositeFieldConstraint();
        cfc2.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc2 );
        final SingleFieldConstraint cfc2sfc1 = new SingleFieldConstraint();
        cfc2sfc1.setFieldName( "field3" );
        cfc2sfc1.setFieldType( DataType.TYPE_STRING );
        cfc2sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc2sfc1.setValue( "$f3" );
        cfc2sfc1.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc1 );
        final SingleFieldConstraint cfc2sfc2 = new SingleFieldConstraint();
        cfc2sfc2.setFieldName( "field4" );
        cfc2sfc2.setFieldType( DataType.TYPE_STRING );
        cfc2sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc2sfc2.setValue( "$f4" );
        cfc2sfc2.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc2 );

        final CompositeFieldConstraint cfc3 = new CompositeFieldConstraint();
        cfc3.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc3 );
        final SingleFieldConstraint cfc3sfc1 = new SingleFieldConstraint();
        cfc3sfc1.setFieldName( "field5" );
        cfc3sfc1.setFieldType( DataType.TYPE_STRING );
        cfc3sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc3sfc1.setValue( "$f5" );
        cfc3sfc1.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc1 );
        final SingleFieldConstraint cfc3sfc2 = new SingleFieldConstraint();
        cfc3sfc2.setFieldName( "field6" );
        cfc3sfc2.setFieldType( DataType.TYPE_STRING );
        cfc3sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc3sfc2.setValue( "$f6" );
        cfc3sfc2.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc2 );

        String expected = "rule \"t1_0\"\n" +
                "dialect \"mvel\"\n" +
                "when\n" +
                "then\n" +
View Full Code Here

        FactPattern p = new FactPattern( "Person" );

        m.addLhsItem( p );

        final CompositeFieldConstraint cfc1 = new CompositeFieldConstraint();
        cfc1.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc1 );
        final SingleFieldConstraint cfc1sfc1 = new SingleFieldConstraint();
        cfc1sfc1.setFieldName( "field1" );
        cfc1sfc1.setFieldType( DataType.TYPE_STRING );
        cfc1sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc1sfc1.setValue( "$f1" );
        cfc1sfc1.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc1 );
        final SingleFieldConstraint cfc1sfc2 = new SingleFieldConstraint();
        cfc1sfc2.setFieldName( "field2" );
        cfc1sfc2.setFieldType( DataType.TYPE_STRING );
        cfc1sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc1sfc2.setValue( "v2" );
        cfc1sfc2.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc2 );

        final CompositeFieldConstraint cfc2 = new CompositeFieldConstraint();
        cfc2.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc2 );
        final SingleFieldConstraint cfc2sfc1 = new SingleFieldConstraint();
        cfc2sfc1.setFieldName( "field3" );
        cfc2sfc1.setFieldType( DataType.TYPE_STRING );
        cfc2sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc2sfc1.setValue( "$f3" );
        cfc2sfc1.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc1 );
        final SingleFieldConstraint cfc2sfc2 = new SingleFieldConstraint();
        cfc2sfc2.setFieldName( "field4" );
        cfc2sfc2.setFieldType( DataType.TYPE_STRING );
        cfc2sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc2sfc2.setValue( "v4" );
        cfc2sfc2.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc2 );

        final CompositeFieldConstraint cfc3 = new CompositeFieldConstraint();
        cfc3.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc3 );
        final SingleFieldConstraint cfc3sfc1 = new SingleFieldConstraint();
        cfc3sfc1.setFieldName( "field5" );
        cfc3sfc1.setFieldType( DataType.TYPE_STRING );
        cfc3sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc3sfc1.setValue( "$f5" );
        cfc3sfc1.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc1 );
        final SingleFieldConstraint cfc3sfc2 = new SingleFieldConstraint();
        cfc3sfc2.setFieldName( "field6" );
        cfc3sfc2.setFieldType( DataType.TYPE_STRING );
        cfc3sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc3sfc2.setValue( "v6" );
        cfc3sfc2.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc2 );

        String expected = "rule \"t1_0\"\n" +
                "dialect \"mvel\"\n" +
                "when\n" +
                "Person( field1 == \"v1\" || field2 == \"v2\", field3 == \"v3\" || field4 == \"v4\", field5 == \"v5\" || field6 == \"v6\" )\n" +
View Full Code Here

        FactPattern p = new FactPattern( "Person" );

        m.addLhsItem( p );

        final CompositeFieldConstraint cfc1 = new CompositeFieldConstraint();
        cfc1.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc1 );
        final SingleFieldConstraint cfc1sfc1 = new SingleFieldConstraint();
        cfc1sfc1.setFieldName( "field1" );
        cfc1sfc1.setFieldType( DataType.TYPE_STRING );
        cfc1sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc1sfc1.setValue( "$f1" );
        cfc1sfc1.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc1 );
        final SingleFieldConstraint cfc1sfc2 = new SingleFieldConstraint();
        cfc1sfc2.setFieldName( "field2" );
        cfc1sfc2.setFieldType( DataType.TYPE_STRING );
        cfc1sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc1sfc2.setValue( "v2" );
        cfc1sfc2.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc2 );

        final CompositeFieldConstraint cfc2 = new CompositeFieldConstraint();
        cfc2.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc2 );
        final SingleFieldConstraint cfc2sfc1 = new SingleFieldConstraint();
        cfc2sfc1.setFieldName( "field3" );
        cfc2sfc1.setFieldType( DataType.TYPE_STRING );
        cfc2sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc2sfc1.setValue( "$f3" );
        cfc2sfc1.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc1 );
        final SingleFieldConstraint cfc2sfc2 = new SingleFieldConstraint();
        cfc2sfc2.setFieldName( "field4" );
        cfc2sfc2.setFieldType( DataType.TYPE_STRING );
        cfc2sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc2sfc2.setValue( "v4" );
        cfc2sfc2.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc2 );

        final CompositeFieldConstraint cfc3 = new CompositeFieldConstraint();
        cfc3.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc3 );
        final SingleFieldConstraint cfc3sfc1 = new SingleFieldConstraint();
        cfc3sfc1.setFieldName( "field5" );
        cfc3sfc1.setFieldType( DataType.TYPE_STRING );
        cfc3sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc3sfc1.setValue( "$f5" );
        cfc3sfc1.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc1 );
        final SingleFieldConstraint cfc3sfc2 = new SingleFieldConstraint();
        cfc3sfc2.setFieldName( "field6" );
        cfc3sfc2.setFieldType( DataType.TYPE_STRING );
        cfc3sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc3sfc2.setValue( "v6" );
        cfc3sfc2.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc2 );

        String expected = "rule \"t1_0\"\n" +
                "dialect \"mvel\"\n" +
                "when\n" +
                "Person( field2 == \"v2\", field4 == \"v4\", field6 == \"v6\" )\n" +
View Full Code Here

        FactPattern p = new FactPattern( "Person" );

        m.addLhsItem( p );

        final CompositeFieldConstraint cfc1 = new CompositeFieldConstraint();
        cfc1.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc1 );
        final SingleFieldConstraint cfc1sfc1 = new SingleFieldConstraint();
        cfc1sfc1.setFieldName( "field1" );
        cfc1sfc1.setFieldType( DataType.TYPE_STRING );
        cfc1sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc1sfc1.setValue( "$f1" );
        cfc1sfc1.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc1 );
        final SingleFieldConstraint cfc1sfc2 = new SingleFieldConstraint();
        cfc1sfc2.setFieldName( "field2" );
        cfc1sfc2.setFieldType( DataType.TYPE_STRING );
        cfc1sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc1sfc2.setValue( "v2" );
        cfc1sfc2.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc2 );

        final CompositeFieldConstraint cfc2 = new CompositeFieldConstraint();
        cfc2.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc2 );
        final SingleFieldConstraint cfc2sfc1 = new SingleFieldConstraint();
        cfc2sfc1.setFieldName( "field3" );
        cfc2sfc1.setFieldType( DataType.TYPE_STRING );
        cfc2sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc2sfc1.setValue( "$f3" );
        cfc2sfc1.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc1 );
        final SingleFieldConstraint cfc2sfc2 = new SingleFieldConstraint();
        cfc2sfc2.setFieldName( "field4" );
        cfc2sfc2.setFieldType( DataType.TYPE_STRING );
        cfc2sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc2sfc2.setValue( "v4" );
        cfc2sfc2.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc2 );

        final CompositeFieldConstraint cfc3 = new CompositeFieldConstraint();
        cfc3.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc3 );
        final SingleFieldConstraint cfc3sfc1 = new SingleFieldConstraint();
        cfc3sfc1.setFieldName( "field5" );
        cfc3sfc1.setFieldType( DataType.TYPE_STRING );
        cfc3sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc3sfc1.setValue( "$f5" );
        cfc3sfc1.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc1 );
        final SingleFieldConstraint cfc3sfc2 = new SingleFieldConstraint();
        cfc3sfc2.setFieldName( "field6" );
        cfc3sfc2.setFieldType( DataType.TYPE_STRING );
        cfc3sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc3sfc2.setValue( "v6" );
        cfc3sfc2.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc2 );

        String expected = "rule \"t1_0\"\n" +
                "dialect \"mvel\"\n" +
                "when\n" +
                "Person( field1 == \"v1\" || field2 == \"v2\", field3 == \"v3\" || field4 == \"v4\", field5 == \"v5\" || field6 == \"v6\" )\n" +
View Full Code Here

        FactPattern p = new FactPattern( "Person" );

        m.addLhsItem( p );

        final CompositeFieldConstraint cfc1 = new CompositeFieldConstraint();
        cfc1.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc1 );
        final SingleFieldConstraint cfc1sfc1 = new SingleFieldConstraint();
        cfc1sfc1.setFieldName( "field1" );
        cfc1sfc1.setFieldType( DataType.TYPE_STRING );
        cfc1sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc1sfc1.setValue( "v1" );
        cfc1sfc1.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc1 );
        final SingleFieldConstraint cfc1sfc2 = new SingleFieldConstraint();
        cfc1sfc2.setFieldName( "field2" );
        cfc1sfc2.setFieldType( DataType.TYPE_STRING );
        cfc1sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc1sfc2.setValue( "$f2" );
        cfc1sfc2.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc2 );

        final CompositeFieldConstraint cfc2 = new CompositeFieldConstraint();
        cfc2.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc2 );
        final SingleFieldConstraint cfc2sfc1 = new SingleFieldConstraint();
        cfc2sfc1.setFieldName( "field3" );
        cfc2sfc1.setFieldType( DataType.TYPE_STRING );
        cfc2sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc2sfc1.setValue( "v3" );
        cfc2sfc1.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc1 );
        final SingleFieldConstraint cfc2sfc2 = new SingleFieldConstraint();
        cfc2sfc2.setFieldName( "field4" );
        cfc2sfc2.setFieldType( DataType.TYPE_STRING );
        cfc2sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc2sfc2.setValue( "$f4" );
        cfc2sfc2.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc2 );

        final CompositeFieldConstraint cfc3 = new CompositeFieldConstraint();
        cfc3.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc3 );
        final SingleFieldConstraint cfc3sfc1 = new SingleFieldConstraint();
        cfc3sfc1.setFieldName( "field5" );
        cfc3sfc1.setFieldType( DataType.TYPE_STRING );
        cfc3sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc3sfc1.setValue( "v5" );
        cfc3sfc1.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc1 );
        final SingleFieldConstraint cfc3sfc2 = new SingleFieldConstraint();
        cfc3sfc2.setFieldName( "field6" );
        cfc3sfc2.setFieldType( DataType.TYPE_STRING );
        cfc3sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc3sfc2.setValue( "$f6" );
        cfc3sfc2.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc2 );

        String expected = "rule \"t1_0\"\n" +
                "dialect \"mvel\"\n" +
                "when\n" +
                "Person( field1 == \"v1\", field3 == \"v3\", field5 == \"v5\" )\n" +
View Full Code Here

        FactPattern p = new FactPattern( "Person" );

        m.addLhsItem( p );

        final CompositeFieldConstraint cfc1 = new CompositeFieldConstraint();
        cfc1.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc1 );
        final SingleFieldConstraint cfc1sfc1 = new SingleFieldConstraint();
        cfc1sfc1.setFieldName( "field1" );
        cfc1sfc1.setFieldType( DataType.TYPE_STRING );
        cfc1sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc1sfc1.setValue( "v1" );
        cfc1sfc1.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc1 );
        final SingleFieldConstraint cfc1sfc2 = new SingleFieldConstraint();
        cfc1sfc2.setFieldName( "field2" );
        cfc1sfc2.setFieldType( DataType.TYPE_STRING );
        cfc1sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc1sfc2.setValue( "$f2" );
        cfc1sfc2.setOperator( "==" );
        cfc1.addConstraint( cfc1sfc2 );

        final CompositeFieldConstraint cfc2 = new CompositeFieldConstraint();
        cfc2.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc2 );
        final SingleFieldConstraint cfc2sfc1 = new SingleFieldConstraint();
        cfc2sfc1.setFieldName( "field3" );
        cfc2sfc1.setFieldType( DataType.TYPE_STRING );
        cfc2sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc2sfc1.setValue( "v3" );
        cfc2sfc1.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc1 );
        final SingleFieldConstraint cfc2sfc2 = new SingleFieldConstraint();
        cfc2sfc2.setFieldName( "field4" );
        cfc2sfc2.setFieldType( DataType.TYPE_STRING );
        cfc2sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc2sfc2.setValue( "$f4" );
        cfc2sfc2.setOperator( "==" );
        cfc2.addConstraint( cfc2sfc2 );

        final CompositeFieldConstraint cfc3 = new CompositeFieldConstraint();
        cfc3.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( cfc3 );
        final SingleFieldConstraint cfc3sfc1 = new SingleFieldConstraint();
        cfc3sfc1.setFieldName( "field5" );
        cfc3sfc1.setFieldType( DataType.TYPE_STRING );
        cfc3sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        cfc3sfc1.setValue( "v5" );
        cfc3sfc1.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc1 );
        final SingleFieldConstraint cfc3sfc2 = new SingleFieldConstraint();
        cfc3sfc2.setFieldName( "field6" );
        cfc3sfc2.setFieldType( DataType.TYPE_STRING );
        cfc3sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        cfc3sfc2.setValue( "$f6" );
        cfc3sfc2.setOperator( "==" );
        cfc3.addConstraint( cfc3sfc2 );

        String expected = "rule \"t1_0\"\n" +
                "dialect \"mvel\"\n" +
                "when\n" +
                "Person( field1 == \"v1\" || field2 == \"v2\", field3 == \"v3\" || field4 == \"v4\", field5 == \"v5\" || field6 == \"v6\" )\n" +
View Full Code Here

    public void testNestedCompositeConstraints3FirstValue() {
        TemplateModel m = new TemplateModel();
        m.name = "t1";

        FactPattern p = new FactPattern( "Person" );
        CompositeFieldConstraint comp = new CompositeFieldConstraint();
        comp.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( comp );

        m.addLhsItem( p );

        final SingleFieldConstraint sfc1 = new SingleFieldConstraint();
        sfc1.setFieldName( "field1" );
        sfc1.setFieldType( DataType.TYPE_STRING );
        sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        sfc1.setValue( "$f1" );
        sfc1.setOperator( "==" );
        comp.addConstraint( sfc1 );

        final SingleFieldConstraint sfc2 = new SingleFieldConstraint();
        sfc2.setFieldName( "field2" );
        sfc2.setFieldType( DataType.TYPE_STRING );
        sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        sfc2.setValue( "$f2" );
        sfc2.setOperator( "==" );
        comp.addConstraint( sfc2 );

        CompositeFieldConstraint comp2 = new CompositeFieldConstraint();
        comp2.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_AND );
        final SingleFieldConstraint comp2sfc1 = new SingleFieldConstraint();
        comp2sfc1.setFieldType( DataType.TYPE_STRING );
        comp2sfc1.setFieldName( "field3" );
        comp2sfc1.setOperator( "==" );
        comp2sfc1.setValue( "$f3" );
        comp2sfc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_TEMPLATE );

        comp2.addConstraint( comp2sfc1 );

        comp.addConstraint( comp2 );

        String expected = "rule \"t1_0\"\n" +
                "dialect \"mvel\"\n" +
View Full Code Here

    public void testNestedCompositeConstraints3SecondValue() {
        TemplateModel m = new TemplateModel();
        m.name = "t1";

        FactPattern p = new FactPattern( "Person" );
        CompositeFieldConstraint comp = new CompositeFieldConstraint();
        comp.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        p.addConstraint( comp );

        m.addLhsItem( p );

        final SingleFieldConstraint sfc1 = new SingleFieldConstraint();
        sfc1.setFieldName( "field1" );
        sfc1.setFieldType( DataType.TYPE_STRING );
        sfc1.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        sfc1.setValue( "$f1" );
        sfc1.setOperator( "==" );
        comp.addConstraint( sfc1 );

        final SingleFieldConstraint sfc2 = new SingleFieldConstraint();
        sfc2.setFieldName( "field2" );
        sfc2.setFieldType( DataType.TYPE_STRING );
        sfc2.setConstraintValueType( SingleFieldConstraint.TYPE_TEMPLATE );
        sfc2.setValue( "$f2" );
        sfc2.setOperator( "==" );
        comp.addConstraint( sfc2 );

        CompositeFieldConstraint comp2 = new CompositeFieldConstraint();
        comp2.setCompositeJunctionType( CompositeFieldConstraint.COMPOSITE_TYPE_AND );
        final SingleFieldConstraint comp2sfc1 = new SingleFieldConstraint();
        comp2sfc1.setFieldType( DataType.TYPE_STRING );
        comp2sfc1.setFieldName( "field3" );
        comp2sfc1.setOperator( "==" );
        comp2sfc1.setValue( "$f3" );
        comp2sfc1.setConstraintValueType( BaseSingleFieldConstraint.TYPE_TEMPLATE );

        comp2.addConstraint( comp2sfc1 );

        comp.addConstraint( comp2 );

        String expected = "rule \"t1_0\"\n" +
                "dialect \"mvel\"\n" +
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint

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.