Search in sources :

Example 6 with TemplateDataListener

use of org.drools.template.parser.TemplateDataListener 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 TemplateDataListener

use of org.drools.template.parser.TemplateDataListener 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

TemplateDataListener (org.drools.template.parser.TemplateDataListener)7 DefaultTemplateContainer (org.drools.template.parser.DefaultTemplateContainer)6 TemplateContainer (org.drools.template.parser.TemplateContainer)4 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Driver (org.acme.insurance.Driver)1 Policy (org.acme.insurance.Policy)1 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)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 DataListener (org.drools.template.parser.DataListener)1 Test (org.junit.Test)1 KieSession (org.kie.api.runtime.KieSession)1 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)1