/** * @param bigg * @param input * @param output * @param parameters * @throws IOException * @throws XMLStreamException */ public void batchProcess(BiGGDB bigg, File input, File output, Parameters parameters) throws IOException, XMLStreamException { // We test if non-existing path denotes a file or directory by checking if // it contains at least one period in its name. If so, we assume it is a // file. if (!output.exists() && (output.getName().lastIndexOf('.') < 0) && !(input.isFile() && input.getName().equals(output.getName()))) { logger.info(MessageFormat.format("Creating directory {0}.", output.getAbsolutePath())); output.mkdir(); } if (input.isFile()) { boolean jsonFile = SBFileFilter.hasFileType(input, SBFileFilter.FileType.JSON_FILES); boolean matFile = SBFileFilter.hasFileType(input, SBFileFilter.FileType.MAT_FILES); if (SBFileFilter.isSBMLFile(input) || matFile || jsonFile) { if (output.isDirectory()) { String fName = input.getName(); if (matFile || jsonFile) { fName = FileTools.removeFileExtension(fName) + ".xml"; } output = new File(Utils.ensureSlash(output.getAbsolutePath()) + fName); } polish(bigg, input, output, parameters); } } else { if (!output.isDirectory()) { throw new IOException( MessageFormat.format("Cannot write to file {0}.", output.getAbsolutePath())); } for (File file : input.listFiles()) { File target = new File(Utils.ensureSlash(output.getAbsolutePath()) + file.getName()); batchProcess(bigg, file, target, parameters); } } }