use of com.genericworkflownodes.knime.relocator.Relocator in project GenericKnimeNodes by genericworkflownodes.
the class CTDConfigurationReader method read.
@Override
public INodeConfiguration read(InputStream in) throws InvalidCTDFileException {
try {
// create schema and parser for validation and parsing
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema ctdSchema = schemaFactory.newSchema(SchemaProvider.class.getResource("CTD.xsd"));
SAXParserFactory spfac = SAXParserFactory.newInstance();
spfac.setValidating(false);
spfac.setSchema(ctdSchema);
SAXParser sp = spfac.newSAXParser();
CTDHandler handler = new CTDHandler(sp.getXMLReader());
sp.parse(in, handler);
m_config = handler.getNodeConfiguration();
} catch (Exception e) {
throw new InvalidCTDFileException("Failed to parse CTD file.", e);
}
// validate mappings of CLI config
for (CLIElement cliElement : m_config.getCLI().getCLIElement()) {
validateCLIElement(cliElement);
}
// validate mappings in OutputConverter
for (Relocator relocator : m_config.getRelocators()) {
validateRelocator(relocator);
}
// validate ports
for (Port port : m_config.getInputPorts()) {
validatePort(port);
}
for (Port port : m_config.getOutputPorts()) {
validatePort(port);
}
// return parsed and validated config
return m_config;
}
use of com.genericworkflownodes.knime.relocator.Relocator in project GenericKnimeNodes by genericworkflownodes.
the class RelocatorHandler method startElement.
@Override
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException {
// only relocator can occur
String reference = attributes.getValue(ATTR_REFERENCE);
String pattern = attributes.getValue(ATTR_PATTERN);
m_config.getRelocators().add(new Relocator(reference, pattern));
}
use of com.genericworkflownodes.knime.relocator.Relocator in project GenericKnimeNodes by genericworkflownodes.
the class CTDConfigurationWriter method writeRelocators.
private void writeRelocators() throws IOException {
streamPut("<relocators>");
indent();
for (Relocator rel : currentConfig.getRelocators()) {
streamPut(String.format("<relocator reference=\"%s\" locations=\"%s\" />", rel.getReferencedParamter(), rel.getLocation()));
}
outdent();
streamPut("</relocators>");
}
Aggregations