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

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


    public static class NotEqualsOtherwiseBuilder extends AbstractOtherwiseBuilder {

        @Override
        SingleFieldConstraint constructSingleFieldConstraint(ConditionCol52 c,
                                                             List<DTCellValue52> columnData) {
            SingleFieldConstraint sfc = new SingleFieldConstraint( c.getFactField() );
            sfc.setConstraintValueType( c.getConstraintValueType() );

            sfc.setOperator( "in" );

            List<String> consumedValues = new ArrayList<String>();
            StringBuilder value = new StringBuilder();
            value.append( "( " );
            for ( DTCellValue52 cv : columnData ) {

                //Ensure cell values start and end with quotes
                String scv = GuidedDTDRLUtilities.convertDTCellValueToString( cv );
                if ( scv != null ) {
                    if ( !consumedValues.contains( scv ) ) {
                        DRLConstraintValueBuilder.buildLHSFieldValue( value,
                                                                      c.getConstraintValueType(),
                                                                      c.getFieldType(),
                                                                      scv );
                        value.append( ", " );
                    }
                    consumedValues.add( scv );
                }
            }
            value.delete( value.lastIndexOf( "," ),
                          value.length() - 1 );
            value.append( ")" );
            sfc.setValue( value.toString() );
            return sfc;
        }
View Full Code Here


        Map<String, String> currentValueMap = new HashMap<String, String>();

        if ( pattern.constraintList != null && pattern.constraintList.constraints != null ) {
            for ( FieldConstraint con : pattern.constraintList.constraints ) {
                if ( con instanceof SingleFieldConstraint ) {
                    SingleFieldConstraint sfc = (SingleFieldConstraint) con;
                    String fieldName = sfc.getFieldName();
                    if ( fieldName != null && fieldName.contains( "." ) ) {
                        fieldName = fieldName.substring( fieldName.indexOf( "." ) + 1 );
                    }
                    currentValueMap.put( fieldName,
                                         sfc.getValue() );
                }
            }
        }
        return getEnums( type,
                         field,
View Full Code Here

        }
        return clone;
    }

    private SingleFieldConstraint visitSingleFieldConstraint(SingleFieldConstraint sfc) {
        SingleFieldConstraint clone = new SingleFieldConstraint();
        clone.setConstraintValueType( sfc.getConstraintValueType() );
        clone.setExpressionValue( (ExpressionFormLine) visit( sfc.getExpressionValue() ) );
        clone.setFieldBinding( sfc.getFieldBinding() );
        clone.setFieldName( sfc.getFieldName() );
        clone.setFieldType( sfc.getFieldType() );
        clone.setOperator( sfc.getOperator() );
        for ( Map.Entry<String, String> entry : sfc.getParameters().entrySet() ) {
            clone.setParameter( entry.getKey(),
                                entry.getValue() );
        }
        clone.setValue( sfc.getValue() );

        if ( sfc.connectives != null ) {
            clone.connectives = new ConnectiveConstraint[sfc.connectives.length];
            for ( int i = 0; i < sfc.connectives.length; i++ ) {
                clone.connectives[i] = (ConnectiveConstraint) visit( sfc.connectives[i] );
View Full Code Here

        assertNotNull( m );
        m.name = "testBRL";

        FactPattern p = new FactPattern( "Person" );
        p.setBoundName( "p" );
        SingleFieldConstraint con = new SingleFieldConstraint();
        con.setFieldName( "name" );
        con.setValue( "mark" );
        con.setOperator( "==" );
        con.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        con.setFieldType( SuggestionCompletionEngine.TYPE_STRING );

        p.addConstraint( con );

        m.addLhsItem( p );
View Full Code Here

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

        FactPattern pat = new FactPattern( "Fact" );
        SingleFieldConstraint sfc = new SingleFieldConstraint( "field2" );
        pat.addConstraint( sfc );
        items = engine.getEnums( pat.getFactType(),
                                 pat.constraintList,
                                 "field2" ).fixedList;
        assertEquals( 2,
View Full Code Here

        assertEquals( "String",
                      engine.getFieldType( "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.getFactType(),
                                             pat.constraintList,
                                             "f2" );
View Full Code Here

                               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.getFactType(),
                                        pat.constraintList,
                                        "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.getFactType(),
                               pat.constraintList,
                               "value" ).fixedList;
View Full Code Here

                               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.getFactType(),
                                        pat.constraintList,
                                        "field3" ).fixedList;
View Full Code Here

                               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.getFactType(),
                                  pat.constraintList,
                                  "field6" ) );

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

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

                      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.getFactType(),
                                        pat.constraintList,
                                        "value" );
View Full Code Here

TOP

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

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.