Search in sources :

Example 6 with DefaultTemplateContainer

use of org.drools.template.parser.DefaultTemplateContainer in project drools by kiegroup.

the class RuleTemplateModelDRLPersistenceImpl method marshal.

@Override
public String marshal(final RuleModel model) {
    // Build rule
    final String ruleTemplate = marshalRule(model);
    log.debug("ruleTemplate:\n{}", ruleTemplate);
    log.debug("generated template:\n{}", ruleTemplate);
    final DataProvider dataProvider = chooseDataProvider(model);
    final DataProviderCompiler tplCompiler = new DataProviderCompiler();
    final InputStream templateStream = new ByteArrayInputStream(ruleTemplate.getBytes(IoUtils.UTF8_CHARSET));
    final DefaultTemplateContainer tc = new DefaultTemplateContainer(templateStream, false);
    final TemplateDataListener listener = new TemplateDataListener(tc, false);
    final String generatedDrl = tplCompiler.compile(dataProvider, listener);
    log.debug("generated drl:\n{}", generatedDrl);
    return generatedDrl;
}
Also used : DataProvider(org.drools.template.DataProvider) ArrayDataProvider(org.drools.template.objects.ArrayDataProvider) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DataProviderCompiler(org.drools.template.DataProviderCompiler) DefaultTemplateContainer(org.drools.template.parser.DefaultTemplateContainer) TemplateDataListener(org.drools.template.parser.TemplateDataListener)

Example 7 with DefaultTemplateContainer

use of org.drools.template.parser.DefaultTemplateContainer in project drools by kiegroup.

the class ExternalSpreadsheetCompiler method compile.

public String compile(final InputStream xlsStream, final InputStream templateStream, InputType type, int startRow, int startCol) {
    TemplateContainer tc = new DefaultTemplateContainer(templateStream);
    closeStream(templateStream);
    return compile(xlsStream, type, new TemplateDataListener(startRow, startCol, tc));
}
Also used : TemplateContainer(org.drools.template.parser.TemplateContainer) DefaultTemplateContainer(org.drools.template.parser.DefaultTemplateContainer) DefaultTemplateContainer(org.drools.template.parser.DefaultTemplateContainer) TemplateDataListener(org.drools.template.parser.TemplateDataListener)

Aggregations

DefaultTemplateContainer (org.drools.template.parser.DefaultTemplateContainer)7 TemplateDataListener (org.drools.template.parser.TemplateDataListener)6 TemplateContainer (org.drools.template.parser.TemplateContainer)5 InputStream (java.io.InputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataProvider (org.drools.template.DataProvider)1 DataProviderCompiler (org.drools.template.DataProviderCompiler)1 ArrayDataProvider (org.drools.template.objects.ArrayDataProvider)1 ObjectDataProvider (org.drools.template.objects.ObjectDataProvider)1 Column (org.drools.template.parser.Column)1 Test (org.junit.Test)1