Package org.drools.workbench.models.guided.template.shared

Examples of org.drools.workbench.models.guided.template.shared.TemplateModel


        fp.addConstraint( sfc1 );
        fp.addConstraint( sfc2 );

        //Test 1
        TemplateModel m1 = new TemplateModel();
        m1.addLhsItem( fp );
        m1.name = "r1";

        m1.addRow( new String[]{ null, null } );

        final String expected1 = "rule \"r1_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "  then\n" +
                "end";

        checkMarshall( expected1,
                       m1 );

        //Test 2
        TemplateModel m2 = new TemplateModel();
        m2.addLhsItem( fp );
        m2.name = "r2";

        m2.addRow( new String[]{ "   ", "35" } );

        final String expected2 = "rule \"r2_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf( age == 35 )\n" +
                "  then\n" +
                "end";

        checkMarshall( expected2,
                       m2 );

        //Test 3
        TemplateModel m3 = new TemplateModel();
        m3.addLhsItem( fp );
        m3.name = "r3";

        m3.addRow( new String[]{ "", null } );

        final String expected3 = "rule \"r3_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "  then\n" +
                "end";

        checkMarshall( expected3,
                       m3 );

        //Test 4
        TemplateModel m4 = new TemplateModel();
        m4.addLhsItem( fp );
        m4.name = "r4";

        m4.addRow( new String[]{ "", "35" } );

        final String expected4 = "rule \"r4_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf( age == 35 )\n" +
View Full Code Here


        fp.addConstraint( sfc1 );
        fp.addConstraint( sfc2 );

        //Test 1
        TemplateModel m1 = new TemplateModel();
        m1.addLhsItem( fp );
        m1.name = "r1";

        m1.addRow( new String[]{ null, null } );

        final String expected1 = "rule \"r1_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "  then\n" +
                "end";

        checkMarshall( expected1,
                       m1 );

        //Test 2
        TemplateModel m2 = new TemplateModel();
        m2.addLhsItem( fp );
        m2.name = "r2";

        m2.addRow( new String[]{ "\"   \"", "35" } );

        final String expected2 = "rule \"r2_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf( name == \"   \", age == 35 )\n" +
                "  then\n" +
                "end";

        checkMarshall( expected2,
                       m2 );

        //Test 3
        TemplateModel m3 = new TemplateModel();
        m3.addLhsItem( fp );
        m3.name = "r3";

        m3.addRow( new String[]{ "\"\"", null } );

        final String expected3 = "rule \"r3_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf( name == \"\" )\n" +
                "  then\n" +
                "end";

        checkMarshall( expected3,
                       m3 );

        //Test 4
        TemplateModel m4 = new TemplateModel();
        m4.addLhsItem( fp );
        m4.name = "r4";

        m4.addRow( new String[]{ "\"\"", "35" } );

        final String expected4 = "rule \"r4_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf( name == \"\", age == 35 )\n" +
View Full Code Here

                                                  "$age",
                                                  DataType.TYPE_NUMERIC_INTEGER ) );
        auf2.getFieldValues()[ 0 ].setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );

        //Test 1
        TemplateModel m1 = new TemplateModel();
        m1.addLhsItem( fp );
        m1.addRhsItem( auf1 );
        m1.addRhsItem( auf2 );
        m1.name = "r1";

        m1.addRow( new String[]{ null, null } );

        final String expected1 = "rule \"r1_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf()\n" +
                "  then\n" +
                "end";

        checkMarshall( expected1,
                       m1 );

        //Test 2
        TemplateModel m2 = new TemplateModel();
        m2.addLhsItem( fp );
        m2.addRhsItem( auf1 );
        m2.addRhsItem( auf2 );
        m2.name = "r2";

        m2.addRow( new String[]{ "   ", "35" } );

        final String expected2 = "rule \"r2_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf()\n" +
                "  then\n" +
                "    modify( p1 ) {\n" +
                "      setAge( 35 )\n" +
                "    }\n" +
                "end";

        checkMarshall( expected2,
                       m2 );

        //Test 3
        TemplateModel m3 = new TemplateModel();
        m3.addLhsItem( fp );
        m3.addRhsItem( auf1 );
        m3.addRhsItem( auf2 );
        m3.name = "r3";

        m3.addRow( new String[]{ "", null } );

        final String expected3 = "rule \"r3_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf()\n" +
                "  then\n" +
                "end";

        checkMarshall( expected3,
                       m3 );

        //Test 4
        TemplateModel m4 = new TemplateModel();
        m4.addLhsItem( fp );
        m4.addRhsItem( auf1 );
        m4.addRhsItem( auf2 );
        m4.name = "r4";

        m4.addRow( new String[]{ "", "35" } );

        final String expected4 = "rule \"r4_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf()\n" +
View Full Code Here

                                                  "$age",
                                                  DataType.TYPE_NUMERIC_INTEGER ) );
        auf2.getFieldValues()[ 0 ].setNature( BaseSingleFieldConstraint.TYPE_TEMPLATE );

        //Test 1
        TemplateModel m1 = new TemplateModel();
        m1.addLhsItem( fp );
        m1.addRhsItem( auf1 );
        m1.addRhsItem( auf2 );
        m1.name = "r1";

        m1.addRow( new String[]{ null, null } );

        final String expected1 = "rule \"r1_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf()\n" +
                "  then\n" +
                "end";

        checkMarshall( expected1,
                       m1 );

        //Test 2
        TemplateModel m2 = new TemplateModel();
        m2.addLhsItem( fp );
        m2.addRhsItem( auf1 );
        m2.addRhsItem( auf2 );
        m2.name = "r2";

        m2.addRow( new String[]{ "\"   \"", "35" } );

        final String expected2 = "rule \"r2_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf()\n" +
                "  then\n" +
                "    modify( p1 ) {\n" +
                "      setName( \"   \" ),\n" +
                "      setAge( 35 )\n" +
                "    }\n" +
                "end";

        checkMarshall( expected2,
                       m2 );

        //Test 3
        TemplateModel m3 = new TemplateModel();
        m3.addLhsItem( fp );
        m3.addRhsItem( auf1 );
        m3.addRhsItem( auf2 );
        m3.name = "r3";

        m3.addRow( new String[]{ "\"\"", null } );

        final String expected3 = "rule \"r3_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf()\n" +
                "  then\n" +
                "    modify( p1 ) {\n" +
                "      setName( \"\" )\n" +
                "    }\n" +
                "end";

        checkMarshall( expected3,
                       m3 );

        //Test 4
        TemplateModel m4 = new TemplateModel();
        m4.addLhsItem( fp );
        m4.addRhsItem( auf1 );
        m4.addRhsItem( auf2 );
        m4.name = "r4";

        m4.addRow( new String[]{ "\"\"", "35" } );

        final String expected4 = "rule \"r4_0\"\n" +
                "  dialect \"mvel\"\n" +
                "  when\n" +
                "    p1 : Smurf()\n" +
View Full Code Here

        return header.append( buf ).toString();
    }

    private DataProvider chooseDataProvider( final RuleModel model ) {
        DataProvider dataProvider;
        TemplateModel tplModel = (TemplateModel) model;
        if ( tplModel.getRowsCount() > 0 ) {
            dataProvider = new ArrayDataProvider( tplModel.getTableAsArray() );
        } else {
            dataProvider = generateEmptyIterator();
        }
        return dataProvider;
    }
View Full Code Here

    @Override
    protected void marshalRuleHeader( final RuleModel model,
                                      final StringBuilder buf ) {
        //Append Template header
        TemplateModel templateModel = (TemplateModel) model;
        buf.append( "template header\n" );

        InterpolationVariable[] interpolationVariables = templateModel.getInterpolationVariablesList();
        if ( interpolationVariables.length == 0 ) {
            buf.append( "test_var" ).append( '\n' );
        } else {
            for ( InterpolationVariable var : interpolationVariables ) {
                buf.append( var.getVarName() ).append( '\n' );
View Full Code Here

    }

    @Override
    public GuidedTemplateEditorContent loadContent( final Path path ) {
        try {
            final TemplateModel model = load( path );
            final PackageDataModelOracle oracle = dataModelService.getDataModel( path );
            return new GuidedTemplateEditorContent( oracle,
                                                    model );

        } catch ( Exception e ) {
View Full Code Here

        return buf.toString();
    }

    private DataProvider chooseDataProvider( final RuleModel model ) {
        DataProvider dataProvider;
        TemplateModel tplModel = (TemplateModel) model;
        if ( tplModel.getRowsCount() > 0 ) {
            dataProvider = new ArrayDataProvider( tplModel.getTableAsArray() );
        } else {
            dataProvider = new ArrayDataProvider( generateEmptyIterator( tplModel ) );
        }
        return dataProvider;
    }
View Full Code Here

    @Override
    protected void marshalRuleHeader( final RuleModel model,
                                      final StringBuilder buf ) {
        //Append Template header
        TemplateModel templateModel = (TemplateModel) model;
        buf.append( "template header\n" );

        InterpolationVariable[] interpolationVariables = templateModel.getInterpolationVariablesList();
        if ( interpolationVariables.length == 0 ) {
            buf.append( "test_var" ).append( '\n' );
        } else {
            for ( InterpolationVariable var : interpolationVariables ) {
                buf.append( var.getVarName() ).append( '\n' );
View Full Code Here

    @Override
    public FormatConversionResult convert( String name,
                                           byte[] input ) {
        String xml = new String( input );
        TemplateModel model = (TemplateModel) BRDRTXMLPersistence.getInstance().unmarshal( xml );

        String drl = new StringBuilder().append( BRDRTPersistence.getInstance().marshal( model ) ).toString();

        return new FormatConversionResult( getDestinationName( name, model.hasDSLSentences() ), drl.getBytes() );
    }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.guided.template.shared.TemplateModel

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.