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

Examples of org.drools.ide.common.client.modeldriven.dt.TemplateModel


        return rows;
    }

    @Override
    protected void marshalHeader(RuleModel model, StringBuilder buf) {
        TemplateModel templateModel = (TemplateModel) model;
        buf.append( "template header\n" );

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


                "\tdialect \"mvel\"\n" +
                "\twhen\n" +
                "\tthen\n" +
                "end";

        final String drl = p.marshal(new TemplateModel());
        log.info("drl :\n{}", drl);

        assertNotNull(drl);
        assertEquals(expected, drl);
    }
View Full Code Here

                "\tdialect \"mvel\"\n" +
                "\twhen\n" +
                "\t\t$p : Person( name == \"name_na\" )\n" +
                "\tthen\n" +
                "end";
        TemplateModel m = new TemplateModel();
        m.name = "with composite";
        m.lhs = new IPattern[1];
        m.rhs = new IAction[0];

        FactPattern fp = new FactPattern("Person");
View Full Code Here

            "\t\tPerson fact0 = new Person();\n" +
            "\t\tfact0.setAge( \"34\" );\n" +
            "\t\tinsert(fact0 );\n" +
            "end";

        TemplateModel m = new TemplateModel();
        m.name = "with composite";
        m.lhs = new IPattern[2];
        m.rhs = new IAction[1];

        FactPattern fp = new FactPattern("Person");
        fp.setBoundName("$p");

        SingleFieldConstraint sfc = new SingleFieldConstraint("name");
        sfc.setFieldName("name");
        sfc.setValue("name");
        sfc.setOperator("==");

        sfc.setConstraintValueType(BaseSingleFieldConstraint.TYPE_TEMPLATE);
        fp.addConstraint(sfc);

        m.lhs[0] = fp;

        FreeFormLine ffl = new FreeFormLine();
        ffl.text = "Cheese(type == \"@{type}\", price < @{price})";

        m.lhs[1] = ffl;

        ActionInsertFact aif = new ActionInsertFact("Person");
        ActionFieldValue afv = new ActionFieldValue("age", "age", "");
        afv.nature = FieldNature.TYPE_TEMPLATE;

        aif.addFieldValue(afv);
        m.rhs[0] = aif;

        m.addRow(new String[] {"baunax", "Cheddar", "23", "34"});
        m.addRow(new String[] {"diegoll", "Gouda", "17", "87"});
        final String drl = p.marshal(m);
        log.info("drl :\n{}", drl);

        assertNotNull(drl);
        assertEquals(expected, drl);
View Full Code Here

                "\t\tPerson fact0 = new Person();\n" +
                "\t\tfact0.setAge( \"34\" );\n" +
                "\t\tinsert(fact0 );\n" +
                "end";

        TemplateModel m = new TemplateModel();
        m.name = "with composite";
        m.lhs = new IPattern[1];
        m.rhs = new IAction[1];

        FactPattern fp = new FactPattern("Person");
        fp.setBoundName("$p");
       
        SingleFieldConstraint sfc = new SingleFieldConstraint("name");
        sfc.setFieldName("name");
        sfc.setValue("name");
        sfc.setOperator("==");

        sfc.setConstraintValueType(BaseSingleFieldConstraint.TYPE_TEMPLATE);
        fp.addConstraint(sfc);
       
        m.lhs[0] = fp;
       
        ActionInsertFact aif = new ActionInsertFact("Person");
        ActionFieldValue afv = new ActionFieldValue("age", "age", "");
        afv.nature = FieldNature.TYPE_TEMPLATE;
       
        aif.addFieldValue(afv);
        m.rhs[0] = aif;
       
        m.addRow(new String[] {"baunax", "34"});
        m.addRow(new String[] {"diegoll", "87"});
        final String drl = p.marshal(m);
        log.info("drl :\n{}", drl);

        assertNotNull(drl);
        assertEquals(expected, drl);
View Full Code Here

                "\twhen\n" +
                "\t\t$p : Person( name == \"baunax\" )\n" +
                "\tthen\n" +
                "end";

        TemplateModel m = new TemplateModel();
        m.name = "with composite";
        m.lhs = new IPattern[1];
        m.rhs = new IAction[0];

        FactPattern fp = new FactPattern("Person");
        fp.setBoundName("$p");
       
        SingleFieldConstraint sfc = new SingleFieldConstraint("name");
        sfc.setFieldName("name");
        sfc.setValue("name");
        sfc.setOperator("==");

        sfc.setConstraintValueType(BaseSingleFieldConstraint.TYPE_TEMPLATE);
        fp.addConstraint(sfc);
       
        m.lhs[0] = fp;
       
        m.addRow(new String[] {"baunax"});
        m.addRow(new String[] {"diegoll"});
       
        final String drl = p.marshal(m);
        log.info("drl :\n{}", drl);
        assertNotNull(drl);
        assertEquals(expected, drl);
View Full Code Here

                "\twhen\n" +
                "\t\t$p : Person( name == \"baunax\" )\n" +
                "\tthen\n" +
                "end";

        TemplateModel m = new TemplateModel();
        m.name = "with composite";
        m.lhs = new IPattern[1];
        m.rhs = new IAction[0];

        FactPattern fp = new FactPattern("Person");
        fp.setBoundName("$p");
       
        SingleFieldConstraint sfc = new SingleFieldConstraint("name");
        sfc.setFieldName("name");
        sfc.setValue("name");
        sfc.setOperator("==");

        sfc.setConstraintValueType(BaseSingleFieldConstraint.TYPE_TEMPLATE);
        fp.addConstraint(sfc);
       
        m.lhs[0] = fp;
       
        m.addRow(new String[] {"baunax"});
        m.addRow(new String[] {"diegoll"});
        String id1 = m.addRow(new String[] {"diegoll1"});
        String id2 = m.addRow(new String[] {"diegoll2"});
       
        m.removeRowById(id1);
        m.removeRowById(id2);
       
        final String drl = p.marshal(m);
        log.info("drl :\n{}", drl);
        assertNotNull(drl);
        assertEquals(expected, drl);
View Full Code Here

    }

    @Test
    public void testWithDataAndSync() {
        TemplateModel m = new TemplateModel();
        m.name = "with composite";
        m.lhs = new IPattern[1];
        m.rhs = new IAction[0];

        FactPattern fp = new FactPattern("Person");
        fp.setBoundName("$p");
       
        SingleFieldConstraint sfc = new SingleFieldConstraint("name");
        sfc.setFieldName("name");
        sfc.setValue("name");
        sfc.setOperator("==");
        sfc.setConstraintValueType(BaseSingleFieldConstraint.TYPE_TEMPLATE);
       
        fp.addConstraint(sfc);
       
        sfc = new SingleFieldConstraint("age");
        sfc.setFieldName("age");
        sfc.setValue("age");
        sfc.setOperator("==");
        sfc.setConstraintValueType(BaseSingleFieldConstraint.TYPE_TEMPLATE);
       
        fp.addConstraint(sfc);
       
        m.lhs[0] = fp;

        m.putInSync();
        HashSet<String> expected = new HashSet<String>();
        expected.add("name");
        expected.add("age");
        expected.add(TemplateModel.ID_COLUMN_NAME);
        assertEquals(expected, m.getTable().keySet());
       
        fp.removeConstraint(1);
        m.putInSync();
       
        expected.remove("age");
        expected.add(TemplateModel.ID_COLUMN_NAME);
        assertEquals(expected, m.getTable().keySet());
       
        fp.addConstraint(sfc);
        m.putInSync();
       
        expected.add("age");
        expected.add(TemplateModel.ID_COLUMN_NAME);
        assertEquals(expected, m.getTable().keySet());
       
    }
View Full Code Here

                "\tdialect \"mvel\"\n" +
                "\twhen\n" +
                "\tthen\n" +
                "end";

        final String drl = p.marshal(new TemplateModel());
        log.info("drl :\n{}", drl);

        assertNotNull(drl);
        assertEquals(expected, drl);
    }
View Full Code Here

                "\tdialect \"mvel\"\n" +
                "\twhen\n" +
                "\t\t$p : Person( name == \"name_na\" )\n" +
                "\tthen\n" +
                "end";
        TemplateModel m = new TemplateModel();
        m.name = "with composite";
        m.lhs = new IPattern[1];
        m.rhs = new IAction[0];

        FactPattern fp = new FactPattern("Person");
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.dt.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.