use of org.knime.core.node.port.pmml.XMLTreeCreator in project knime-core by knime.
the class PMMLPreprocPortObjectView method create.
private void create() {
// serialize port object
synchronized (m_lock) {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
TransformerHandler handler = PMMLPreprocPortObject.createTransformerHandlerForSave(out);
for (PMMLPreprocOperation op : m_portObject.getOperations()) {
String writeElement = op.getClass().getName();
String locationElement = op.getTransformElement().toString();
handler.startElement(null, null, writeElement, null);
handler.startElement(null, null, locationElement, null);
op.save(handler, new ExecutionMonitor());
handler.endElement(null, null, locationElement);
handler.endElement(null, null, writeElement);
handler.endDocument();
}
out.close();
SAXParserFactory saxFac = SAXParserFactory.newInstance();
SAXParser parser = saxFac.newSAXParser();
XMLTreeCreator treeCreator = new XMLTreeCreator();
parser.parse(new InputSource(new ByteArrayInputStream(out.toByteArray())), treeCreator);
m_tree.setModel(new DefaultTreeModel(treeCreator.getTreeNode()));
add(new JScrollPane(m_tree));
revalidate();
} catch (Exception e) {
// log and return a "error during saving" component
LOGGER.error("PMML Preproc contains errors", e);
PMMLPreprocPortObjectView.this.add(new JLabel("PMML Preproc contains errors: " + e.getMessage()));
}
}
}
Aggregations