本文整理汇总了Java中org.drools.decisiontable.parser.xls.ExcelParser类的典型用法代码示例。如果您正苦于以下问题:Java ExcelParser类的具体用法?Java ExcelParser怎么用?Java ExcelParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExcelParser类属于org.drools.decisiontable.parser.xls包,在下文中一共展示了ExcelParser类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseAssets
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
private GuidedDecisionTableGeneratorListener parseAssets(final Path path,
final ConversionResult result,
final PackageDataModelOracle dmo) {
final List<DataListener> listeners = new ArrayList<DataListener>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
final ExcelParser parser = new ExcelParser(listeners);
final InputStream stream = ioService.newInputStream(Paths.convert(path));
try {
parser.parseFile(stream);
} finally {
try {
stream.close();
} catch (IOException ioe) {
result.addMessage(ioe.getMessage(),
ConversionMessageType.ERROR);
}
}
return listener;
}
示例2: testGlobalsConversion
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
//https://bugzilla.redhat.com/show_bug.cgi?id=1310208
public void testGlobalsConversion() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<DataListener>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("BZ1310208.xls");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
//Check conversion results
assertEquals(0,
result.getMessages().size());
//Check basics
final List<Global> globals = listener.getGlobals();
assertNotNull(globals);
assertEquals(1,
globals.size());
final Global global = globals.get(0);
assertEquals("list",
global.getIdentifier());
assertEquals("List",
global.getClassName());
}
示例3: conversionWithBigDecimalsWithoutDMO
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
//https://issues.jboss.org/browse/RHBPMS-4737
public void conversionWithBigDecimalsWithoutDMO() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("RHBPMS-4737 (No DMO).xlsx");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
checkConversionWithBigMaths(result,
listener,
() -> DataType.TYPE_NUMERIC,
() -> new BigDecimal("10.00"),
() -> new BigDecimal("20.00"));
}
示例4: testSequentialSalience
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
public void testSequentialSalience() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<DataListener>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("SequentialSalience.xls");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
//Check conversion results
assertEquals(0,
result.getMessages().size());
//Check basics
List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
assertNotNull(dtables);
assertEquals(1,
dtables.size());
GuidedDecisionTable52 dtable = dtables.get(0);
assertEquals("SequentialSalienceTest",
dtable.getTableName());
assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
dtable.getTableFormat());
//Check expanded columns
List<BaseColumn> columns = dtable.getExpandedColumns();
assertNotNull(columns);
assertEquals(3,
columns.size());
assertTrue(columns.get(0) instanceof RowNumberCol52);
assertTrue(columns.get(1) instanceof DescriptionCol52);
assertTrue(columns.get(2) instanceof AttributeCol52);
//Check attribute column
AttributeCol52 attrCol2 = ((AttributeCol52) columns.get(2));
assertEquals(GuidedDecisionTable52.SALIENCE_ATTR,
attrCol2.getAttribute());
assertTrue(attrCol2.isUseRowNumber());
assertTrue(attrCol2.isReverseOrder());
//Check data
assertEquals(2,
dtable.getData().size());
assertTrue(isRowEquivalent(new Object[]{1, "Rule 1", 2},
dtable.getData().get(0)));
assertTrue(isRowEquivalent(new Object[]{2, "Rule 2", 1},
dtable.getData().get(1)));
}
示例5: testSalienceWarnings
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
public void testSalienceWarnings() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<DataListener>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("SalienceWarnings.xls");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
//Check conversion results
assertEquals(2,
result.getMessages().size());
assertEquals(ConversionMessageType.WARNING,
result.getMessages().get(0).getMessageType());
assertFalse(result.getMessages().get(0).getMessage().indexOf("Priority is not an integer literal, in cell C7") == -1);
assertEquals(ConversionMessageType.WARNING,
result.getMessages().get(1).getMessageType());
assertFalse(result.getMessages().get(1).getMessage().indexOf("Priority is not an integer literal, in cell C8") == -1);
//Check basics
List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
assertNotNull(dtables);
assertEquals(1,
dtables.size());
GuidedDecisionTable52 dtable = dtables.get(0);
assertEquals("SalienceWarningsTest",
dtable.getTableName());
assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
dtable.getTableFormat());
//Check expanded columns
List<BaseColumn> columns = dtable.getExpandedColumns();
assertNotNull(columns);
assertEquals(3,
columns.size());
assertTrue(columns.get(0) instanceof RowNumberCol52);
assertTrue(columns.get(1) instanceof DescriptionCol52);
assertTrue(columns.get(2) instanceof AttributeCol52);
//Check attribute column
AttributeCol52 attrCol2 = ((AttributeCol52) columns.get(2));
assertEquals(GuidedDecisionTable52.SALIENCE_ATTR,
attrCol2.getAttribute());
assertFalse(attrCol2.isUseRowNumber());
assertFalse(attrCol2.isReverseOrder());
//Check data
assertEquals(2,
dtable.getData().size());
assertTrue(isRowEquivalent(new Object[]{1, "Rule 1", 0},
dtable.getData().get(0)));
assertTrue(isRowEquivalent(new Object[]{2, "Rule 2", 0},
dtable.getData().get(1)));
}
示例6: testDurationWarnings
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
public void testDurationWarnings() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<DataListener>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("DurationWarnings.xls");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
//Check conversion results
assertEquals(2,
result.getMessages().size());
assertEquals(ConversionMessageType.WARNING,
result.getMessages().get(0).getMessageType());
assertFalse(result.getMessages().get(0).getMessage().indexOf("Duration is not an long literal, in cell C7") == -1);
assertEquals(ConversionMessageType.WARNING,
result.getMessages().get(1).getMessageType());
assertFalse(result.getMessages().get(1).getMessage().indexOf("Duration is not an long literal, in cell C8") == -1);
//Check basics
List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
assertNotNull(dtables);
assertEquals(1,
dtables.size());
GuidedDecisionTable52 dtable = dtables.get(0);
assertEquals("DurationWarningsTest",
dtable.getTableName());
assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
dtable.getTableFormat());
//Check expanded columns
List<BaseColumn> columns = dtable.getExpandedColumns();
assertNotNull(columns);
assertEquals(3,
columns.size());
assertTrue(columns.get(0) instanceof RowNumberCol52);
assertTrue(columns.get(1) instanceof DescriptionCol52);
assertTrue(columns.get(2) instanceof AttributeCol52);
//Check attribute column
AttributeCol52 attrCol2 = ((AttributeCol52) columns.get(2));
assertEquals(GuidedDecisionTable52.DURATION_ATTR,
attrCol2.getAttribute());
assertFalse(attrCol2.isUseRowNumber());
assertFalse(attrCol2.isReverseOrder());
//Check data
assertEquals(2,
dtable.getData().size());
assertTrue(isRowEquivalent(new Object[]{1, "Rule 1", 0},
dtable.getData().get(0)));
assertTrue(isRowEquivalent(new Object[]{2, "Rule 2", 0},
dtable.getData().get(1)));
}
示例7: testMetadata
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
public void testMetadata() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<DataListener>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("Metadata.xls");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
//Check conversion results
assertEquals(0,
result.getMessages().size());
//Check basics
List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
assertNotNull(dtables);
assertEquals(1,
dtables.size());
GuidedDecisionTable52 dtable = dtables.get(0);
assertEquals("MetadataTest",
dtable.getTableName());
assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
dtable.getTableFormat());
//Check expanded columns
List<BaseColumn> columns = dtable.getExpandedColumns();
assertNotNull(columns);
assertEquals(3,
columns.size());
assertTrue(columns.get(0) instanceof RowNumberCol52);
assertTrue(columns.get(1) instanceof DescriptionCol52);
assertTrue(columns.get(2) instanceof MetadataCol52);
//Check metadata column
MetadataCol52 mdCol2 = ((MetadataCol52) columns.get(2));
assertEquals("cheese",
mdCol2.getMetadata());
//Check data
assertEquals(2,
dtable.getData().size());
assertTrue(isRowEquivalent(new Object[]{1, "Rule 1", "cheddar"},
dtable.getData().get(0)));
assertTrue(isRowEquivalent(new Object[]{2, "Rule 2", "edam"},
dtable.getData().get(1)));
}
示例8: testProperties
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
public void testProperties() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<DataListener>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("Properties.xls");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
//Check conversion results
assertEquals(0,
result.getMessages().size());
//Check properties
List<String> functions = listener.getFunctions();
assertNotNull(functions);
assertEquals(1,
functions.size());
assertEquals("function a() { }",
functions.get(0));
List<Global> globals = listener.getGlobals();
assertNotNull(globals);
assertEquals(1,
globals.size());
assertEquals("java.util.List",
globals.get(0).getClassName());
assertEquals("list",
globals.get(0).getIdentifier());
List<Import> imports = listener.getImports();
assertNotNull(imports);
assertEquals(2,
imports.size());
assertEquals("org.yourco.model.*",
imports.get(0).getClassName());
assertEquals("java.util.Date",
imports.get(1).getClassName());
List<String> queries = listener.getQueries();
assertNotNull(queries);
assertEquals(1,
queries.size());
assertEquals("A query",
queries.get(0));
List<String> types = listener.getTypeDeclarations();
assertNotNull(types);
assertEquals(1,
types.size());
assertEquals("declare Smurf name : String end",
types.get(0));
}
示例9: testRowDescriptions
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
public void testRowDescriptions() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<DataListener>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("MultipleRuleTables.xls");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
//Check conversion results
assertEquals(0,
result.getMessages().size());
//Check basics
final List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
assertNotNull(dtables);
assertEquals(2,
dtables.size());
GuidedDecisionTable52 dtable = dtables.get(0);
assertEquals(2,
dtable.getData().size());
assertEquals("Created from row 7",
dtable.getData().get(0).get(1).getStringValue());
assertEquals("Row 2",
dtable.getData().get(1).get(1).getStringValue());
dtable = dtables.get(1);
assertEquals(2,
dtable.getData().size());
assertEquals("Row 1",
dtable.getData().get(0).get(1).getStringValue());
assertEquals("Created from row 16",
dtable.getData().get(1).get(1).getStringValue());
}
示例10: testEmptyCells
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
//https://bugzilla.redhat.com/show_bug.cgi?id=1256623
public void testEmptyCells() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<DataListener>();
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("EmptySpreadsheetCells.xls");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
//Check conversion results
assertEquals(0,
result.getMessages().size());
//Check basics
List<GuidedDecisionTable52> dtables = listener.getGuidedDecisionTables();
assertNotNull(dtables);
assertEquals(1,
dtables.size());
final GuidedDecisionTable52 dtable = dtables.get(0);
assertEquals("ExceptionPrivateCar",
dtable.getTableName());
assertEquals(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
dtable.getTableFormat());
//Check expanded columns
List<BaseColumn> columns = dtable.getExpandedColumns();
assertNotNull(columns);
assertEquals(20,
columns.size());
assertTrue(columns.get(0) instanceof RowNumberCol52);
assertTrue(columns.get(1) instanceof DescriptionCol52);
assertTrue(columns.get(2) instanceof AttributeCol52);
assertTrue(columns.get(3) instanceof AttributeCol52);
assertTrue(columns.get(4) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(5) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(6) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(7) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(8) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(9) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(10) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(11) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(12) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(13) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(14) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(15) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(16) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(17) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(18) instanceof BRLConditionVariableColumn);
assertTrue(columns.get(19) instanceof BRLActionVariableColumn);
}
示例11: conversionWithBigDecimals
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
//https://issues.jboss.org/browse/RHBPMS-4737
public void conversionWithBigDecimals() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<>();
addModelField("org.test.Message",
"this",
"org.test.Message",
DataType.TYPE_THIS);
addModelField("org.test.Message",
"status",
String.class.getName(),
DataType.TYPE_STRING);
addModelField("org.test.Message",
"message",
String.class.getName(),
DataType.TYPE_STRING);
addModelField("org.test.Message",
"rate",
BigDecimal.class.getName(),
DataType.TYPE_NUMERIC_BIGDECIMAL);
addModelField("org.test.Reply",
"this",
"org.test.Reply",
DataType.TYPE_THIS);
addModelField("org.test.Reply",
"message",
String.class.getName(),
DataType.TYPE_STRING);
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("RHBPMS-4737 (BigDecimal).xlsx");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
checkConversionWithBigMaths(result,
listener,
() -> DataType.TYPE_NUMERIC_BIGDECIMAL,
() -> new BigDecimal("10.00"),
() -> new BigDecimal("20.00"));
}
示例12: conversionWithBigIntegers
import org.drools.decisiontable.parser.xls.ExcelParser; //导入依赖的package包/类
@Test
//https://issues.jboss.org/browse/RHBPMS-4737
public void conversionWithBigIntegers() {
final ConversionResult result = new ConversionResult();
final List<DataListener> listeners = new ArrayList<>();
addModelField("org.test.Message",
"this",
"org.test.Message",
DataType.TYPE_THIS);
addModelField("org.test.Message",
"status",
String.class.getName(),
DataType.TYPE_STRING);
addModelField("org.test.Message",
"message",
String.class.getName(),
DataType.TYPE_STRING);
addModelField("org.test.Message",
"rate",
BigDecimal.class.getName(),
DataType.TYPE_NUMERIC_BIGINTEGER);
addModelField("org.test.Reply",
"this",
"org.test.Reply",
DataType.TYPE_THIS);
addModelField("org.test.Reply",
"message",
String.class.getName(),
DataType.TYPE_STRING);
final GuidedDecisionTableGeneratorListener listener = new GuidedDecisionTableGeneratorListener(result,
dmo);
listeners.add(listener);
//Convert
final ExcelParser parser = new ExcelParser(listeners);
final InputStream is = this.getClass().getResourceAsStream("RHBPMS-4737 (BigInteger).xlsx");
try {
parser.parseFile(is);
} finally {
try {
is.close();
} catch (IOException ioe) {
fail(ioe.getMessage());
}
}
checkConversionWithBigMaths(result,
listener,
() -> DataType.TYPE_NUMERIC_BIGINTEGER,
() -> new BigInteger("10"),
() -> new BigInteger("20"));
}