use of org.vcell.cli.CLIHandler in project vcell by virtualcell.
the class VcmlOmexConverter method parseArgsAndConvert.
public static void parseArgsAndConvert(String[] args) throws IOException {
File input = null;
try {
// TODO: handle if it's not valid PATH
input = new File(args[1]);
} catch (Exception e1) {
e1.printStackTrace();
}
args = parseArgs(args);
// if (bHasDataOnly) {
try {
conFactory = DatabaseService.getInstance().createConnectionFactory();
adminDbTopLevel = new AdminDBTopLevel(conFactory);
} catch (SQLException e) {
System.err.println("\n\n\n=====>>>>EXPORT FAILED: connection to database failed");
e.printStackTrace();
}
// }
VCInfoContainer vcic;
try {
vcic = adminDbTopLevel.getPublicOracleVCInfoContainer(false);
if (vcic != null) {
User user = vcic.getUser();
BioModelInfo[] bioModelInfos = vcic.getBioModelInfos();
// int count = 0;
for (BioModelInfo bi : bioModelInfos) {
// if(bi.getPublicationInfos() != null && bi.getPublicationInfos().length > 0) {
// // let's see what has PublicationInfo
// System.out.println(bi.getVersion().getName());
// count++;
// }
// build the biomodel id / biomodel info map
String biomodelId = "biomodel_" + bi.getVersion().getVersionKey();
String biomodelName = bi.getVersion().getName();
// String biomodelId2 = "biomodel_" + bi.getModelKey();
bioModelInfoMap.put(biomodelId, bi);
bioModelInfoMap2.put(biomodelName, bi);
}
// System.out.println("User: " + user.getName() + " count published biomodels: " + count);
}
} catch (SQLException | DataAccessException e1) {
System.err.println("\n\n\n=====>>>>EXPORT FAILED: failed to retrieve metadata");
e1.printStackTrace();
}
System.out.println("Found " + bioModelInfoMap.size() + " public BioNodelInfo objects");
if (input != null && input.isDirectory()) {
FilenameFilter filterVcmlFiles = (f, name) -> name.endsWith(".vcml");
// jusr a list of vcml names, like biomodel-185577495.vcml, ...
String[] inputFiles = input.list(filterVcmlFiles);
if (inputFiles == null) {
System.err.println("No VCML files found in the directory `" + input + "`");
}
// full directory name, like C:\TEMP\biomodel\omex\native
String outputDir = args[3];
CLIStandalone.writeSimErrorList(outputDir, "hasDataOnly is " + bHasDataOnly);
CLIStandalone.writeSimErrorList(outputDir, "makeLogsOnly is " + bMakeLogsOnly);
// assert inputFiles != null;
for (String inputFile : inputFiles) {
File file = new File(input, inputFile);
System.out.println(" ============== start: " + inputFile);
args[1] = file.toString();
cliHandler = new CLIHandler(args);
try {
if (inputFile.endsWith(".vcml")) {
boolean isCreated = vcmlToOmexConversion(outputDir);
if (isCreated) {
System.out.println("Combine archive created for file(s) `" + input + "`");
} else {
System.err.println("Failed converting VCML to OMEX archive for `" + input + "`");
}
} else {
System.err.println("No VCML files found in the directory `" + input + "`");
}
} catch (Exception e) {
// e.printStackTrace(System.err);
System.out.println("\n\n\n=====>>>>EXPORT FAILED: " + inputFile + "\n\n\n");
CLIStandalone.writeDetailedErrorList(outputDir, inputFile + ", " + e.getMessage());
// System.exit(1);
}
}
} else {
try {
assert input != null;
if (input.toString().endsWith(".vcml")) {
cliHandler = new CLIHandler(args);
boolean isCreated = vcmlToOmexConversion(null);
if (isCreated)
System.out.println("Combine archive created for `" + input + "`");
else
System.err.println("Failed converting VCML to OMEX archive for `" + input + "`");
} else
System.err.println("No input files found in the directory `" + input + "`");
} catch (Exception e) {
// e.printStackTrace();
System.out.println("\n\n\n=====>>>>EXPORT FAILED: " + input + "\n\n\n");
// System.exit(1);
}
}
}
Aggregations