Search in sources :

Example 1 with Relocator

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;
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) Schema(javax.xml.validation.Schema) CTDHandler(com.genericworkflownodes.knime.config.reader.handler.CTDHandler) CLIElement(com.genericworkflownodes.knime.cliwrapper.CLIElement) Port(com.genericworkflownodes.knime.port.Port) SchemaProvider(com.genericworkflownodes.knime.schemas.SchemaProvider) SAXParser(javax.xml.parsers.SAXParser) Relocator(com.genericworkflownodes.knime.relocator.Relocator) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 2 with Relocator

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));
}
Also used : Relocator(com.genericworkflownodes.knime.relocator.Relocator)

Example 3 with Relocator

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>");
}
Also used : Relocator(com.genericworkflownodes.knime.relocator.Relocator)

Aggregations

Relocator (com.genericworkflownodes.knime.relocator.Relocator)3 CLIElement (com.genericworkflownodes.knime.cliwrapper.CLIElement)1 CTDHandler (com.genericworkflownodes.knime.config.reader.handler.CTDHandler)1 Port (com.genericworkflownodes.knime.port.Port)1 SchemaProvider (com.genericworkflownodes.knime.schemas.SchemaProvider)1 SAXParser (javax.xml.parsers.SAXParser)1 SAXParserFactory (javax.xml.parsers.SAXParserFactory)1 Schema (javax.xml.validation.Schema)1 SchemaFactory (javax.xml.validation.SchemaFactory)1