Search in sources :

Example 1 with UnknownMimeTypeException

use of com.genericworkflownodes.knime.nodegeneration.exceptions.UnknownMimeTypeException in project GenericKnimeNodes by genericworkflownodes.

the class NodeModelTemplate method fillMimeTypes.

private void fillMimeTypes(INodeConfiguration config) throws UnknownMimeTypeException {
    String clazzez = "";
    for (Port port : config.getInputPorts()) {
        if (port.getMimeTypes().isEmpty()) {
            clazzez += "{}, ";
        } else {
            String tmp = "{";
            for (String type : port.getMimeTypes()) {
                String ext = type.toLowerCase();
                if (ext == null) {
                    throw new UnknownMimeTypeException(type);
                }
                tmp += "\"" + ext + "\" ,";
            }
            tmp = tmp.substring(0, tmp.length() - 1);
            tmp += "}, ";
            clazzez += tmp;
        }
    }
    if (!clazzez.equals("")) {
        clazzez = clazzez.substring(0, clazzez.length() - 1);
    }
    clazzez += "}";
    createInClazzezModel(clazzez);
    clazzez = "";
    for (Port port : config.getOutputPorts()) {
        if (port.getMimeTypes().isEmpty()) {
            clazzez += "{},";
        } else {
            String tmp = "{";
            for (String type : port.getMimeTypes()) {
                String ext = type.toLowerCase();
                if (ext == null) {
                    throw new UnknownMimeTypeException(type);
                }
                tmp += "\"" + ext + "\" ,";
            }
            tmp = tmp.substring(0, tmp.length() - 1);
            tmp += "}, ";
            clazzez += tmp;
        }
    }
    if (!clazzez.equals("")) {
        clazzez = clazzez.substring(0, clazzez.length() - 1);
    }
    clazzez += "}";
    createOutClazzezModel(clazzez);
}
Also used : Port(com.genericworkflownodes.knime.port.Port) UnknownMimeTypeException(com.genericworkflownodes.knime.nodegeneration.exceptions.UnknownMimeTypeException)

Aggregations

UnknownMimeTypeException (com.genericworkflownodes.knime.nodegeneration.exceptions.UnknownMimeTypeException)1 Port (com.genericworkflownodes.knime.port.Port)1