@Override public void setInputType(DecisionTableInputType inputType) { delegate.setInputType( inputType == DecisionTableInputType.CSV ? org.drools.builder.DecisionTableInputType.CSV : org.drools.builder.DecisionTableInputType.XLS); }
public DecisionTableInputType getInputType() { return delegate.getInputType() == org.drools.builder.DecisionTableInputType.CSV ? DecisionTableInputType.CSV : DecisionTableInputType.XLS; }
public String getWorksheetName() { return delegate.getWorksheetName(); }
private String compileStream(InputStream is, DecisionTableConfiguration configuration) { SpreadsheetCompiler compiler = new SpreadsheetCompiler(); //JBRULES-3005: Sensible default when DecisionTableConfiguration is not provided if ( configuration == null ) { configuration = KnowledgeBuilderFactory.newDecisionTableConfiguration(); configuration.setInputType( DecisionTableInputType.XLS ); } switch ( configuration.getInputType() ) { case XLS : { if ( StringUtils.isEmpty( configuration.getWorksheetName() ) ) { return compiler.compile( is, InputType.XLS ); } else { return compiler.compile( is, configuration.getWorksheetName() ); } } case CSV : { return compiler.compile( is, InputType.CSV ); } } return null; }
public Object start(String uri, String localName, Attributes attrs, ExtensibleXmlParser parser) throws SAXException { parser.startElementBuilder( localName, attrs ); String type = attrs.getValue( "input-type" ); String worksheetName = attrs.getValue( "worksheet-name" ); emptyAttributeCheck( localName, "input-type", type, parser ); DecisionTableConfiguration dtConf = new DecisionTableConfigurationImpl(); dtConf.setInputType( DecisionTableInputType.valueOf( type ) ); if ( !StringUtils.isEmpty( worksheetName ) ) { dtConf.setWorksheetName( worksheetName ); } return dtConf; }
public void setWorksheetName(String name) { delegate.setWorksheetName(name); }
public void setInputType(org.drools.builder.DecisionTableInputType inputType) { delegate.setInputType(inputType); }
@Test public void testDecisionTableCsv() { DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration(); dtconf.setInputType(DecisionTableInputType.CSV); KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newClassPathResource("sample.csv", getClass()), ResourceType.DTABLE, dtconf); if (kbuilder.hasErrors()) { throw new RuntimeException("Drools compile errors: " + kbuilder.getErrors().toString()); } }
@Test public void testDecisionTableXls() { DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration(); dtconf.setInputType(DecisionTableInputType.XLS); KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newClassPathResource("sample.xls", getClass()), ResourceType.DTABLE, dtconf); if (kbuilder.hasErrors()) { throw new RuntimeException("Drools compile errors: " + kbuilder.getErrors().toString()); } }