use of org.jpmml.model.inlinetable.InputCell in project drools by kiegroup.
the class ModelUtilsTest method getRowDataMap.
@Test
public void getRowDataMap() {
Row source = getRandomRowWithCells();
Map<String, Object> retrieved = ModelUtils.getRowDataMap(source);
InputCell inputCell = source.getContent().stream().filter(InputCell.class::isInstance).map(InputCell.class::cast).findFirst().get();
OutputCell outputCell = source.getContent().stream().filter(OutputCell.class::isInstance).map(OutputCell.class::cast).findFirst().get();
assertEquals(2, retrieved.size());
String expected = getPrefixedName(inputCell.getName());
assertTrue(retrieved.containsKey(expected));
assertEquals(inputCell.getValue(), retrieved.get(expected));
expected = getPrefixedName(outputCell.getName());
assertTrue(retrieved.containsKey(expected));
assertEquals(outputCell.getValue(), retrieved.get(expected));
}
use of org.jpmml.model.inlinetable.InputCell in project drools by kiegroup.
the class ModelUtils method getRowDataMap.
public static Map<String, Object> getRowDataMap(Row source) {
Map<String, Object> toReturn = new HashMap<>();
List<Element> elements = source.getContent().stream().filter(Element.class::isInstance).map(Element.class::cast).collect(Collectors.toList());
if (!elements.isEmpty()) {
elements.forEach(el -> populateWithElement(toReturn, el));
} else {
InputCell inputCell = source.getContent().stream().filter(InputCell.class::isInstance).map(InputCell.class::cast).findFirst().orElse(null);
OutputCell outputCell = source.getContent().stream().filter(OutputCell.class::isInstance).map(OutputCell.class::cast).findFirst().orElse(null);
populateWithCells(toReturn, inputCell, outputCell);
}
return toReturn;
}
use of org.jpmml.model.inlinetable.InputCell in project drools by kiegroup.
the class PMMLModelTestUtils method getRandomRowWithCells.
public static Row getRandomRowWithCells() {
Row toReturn = new Row();
toReturn.addContent(new InputCell(RandomStringUtils.random(6, true, false)));
toReturn.addContent(new OutputCell(RandomStringUtils.random(6, true, false)));
return toReturn;
}
Aggregations