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

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


        "  dialect \"mvel\"\n" +
        "  when\n" +
        "  then\n" +
        "end";

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

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


        "  dialect \"mvel\"\n" +
        "  when\n" +
        "    $p : Person( name == name_na )\n" +
        "  then\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

      "    Person fact0 = new Person();\n" +
      "    fact0.setAge( 34 );\n" +
      "    insert(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.boundName = "$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 = ActionFieldValue.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

        "    Person fact0 = new Person();\n" +
        "    fact0.setAge( 34 );\n" +
        "    insert(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.boundName = "$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 = ActionFieldValue.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

        "  when\n" +
        "    $p : Person( name == \"baunax\" )\n" +
        "  then\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.boundName = "$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

        "  when\n" +
        "    $p : Person( name == \"baunax\" )\n" +
        "  then\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.boundName = "$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

        assertEquals(expected, drl);

  }
 
  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.boundName = "$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

        return INSTANCE;
    }
   
    @Override
    public String marshal(RuleModel model) {
      TemplateModel tplModel = (TemplateModel) model;
      String ruleTemplate = super.marshalRule(model);
      log.debug("ruleTemplate:\n{}", ruleTemplate);
      DataProviderCompiler tplCompiler = new DataProviderCompiler();
      DataProvider dataProvider;
      if (tplModel.getRowsCount() > 0) {
        dataProvider = new ArrayDataProvider(tplModel.getTableAsArray());
      } else {
        dataProvider = new ArrayDataProvider(generateEmptyIterator(tplModel));
      }
     
      String generatedDRl = tplCompiler.compile(dataProvider, new ByteArrayInputStream(ruleTemplate.getBytes()))
View Full Code Here

    return rows;
  }

  @Override
    protected void marshalHeader(RuleModel model, StringBuilder buf) {
      TemplateModel tplModel = (TemplateModel) model;
      buf.append("template header\n");
     
      String[] interpolationVariables = tplModel.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

    return super.marshal(model);
  }
 
  @Override
  public TemplateModel unmarshal(String xml) {
    TemplateModel model = (TemplateModel) super.unmarshal(xml);
    model.putInSync();
    return model;
  }
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.