use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class ResultSetCrawler method main.
public static void main(String[] args) {
ConnectionFactory conFactory = null;
try {
boolean SCAN_ONLY = true;
String singleUsername = null;
String startingUsername = null;
String outputDirName = ".";
String ampliCredName = null;
String ampliCredPassword = null;
int count = 0;
while (count < args.length) {
if (args[count].equals("-h")) {
printUsage();
System.exit(0);
} else if (args[count].equals("-u")) {
count++;
singleUsername = args[count];
} else if (args[count].equals("-c")) {
count++;
startingUsername = args[count];
} else if (args[count].equals("-o")) {
count++;
outputDirName = args[count];
} else if (args[count].equals("-d")) {
SCAN_ONLY = false;
} else if (args[count].equals("-s")) {
SCAN_ONLY = true;
} else if (args[count].equals("-y")) {
count++;
ampliCredName = args[count];
} else if (args[count].equals("-z")) {
count++;
ampliCredPassword = args[count];
} else {
System.out.println("Wrong arguments, see usage below.");
printUsage();
System.exit(1);
}
count++;
}
File outputDir = null;
if (outputDirName == null) {
outputDir = new File(".");
} else {
outputDir = new File(outputDirName);
if (!outputDir.exists()) {
throw new RuntimeException("Outuput directory doesn't exist!");
}
}
PropertyLoader.loadProperties();
File primaryDataRootDir = new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty));
File secondaryDataRootDir = new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty));
if (primaryDataRootDir.equals(secondaryDataRootDir)) {
secondaryDataRootDir = null;
}
// initialize database
conFactory = DatabaseService.getInstance().createConnectionFactory();
KeyFactory keyFactory = conFactory.getKeyFactory();
AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
DatabaseServerImpl dbServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
//
// determine the list of users to scan
//
UserInfo[] allUserInfos = adminDbTopLevel.getUserInfos(true);
HashMap<String, User> usersToScan = new HashMap<String, User>();
for (UserInfo userInfo : allUserInfos) {
if (singleUsername != null) {
// accept only the "singleUser"
if (userInfo.userid.equals(singleUsername)) {
usersToScan.put(userInfo.userid, new User(userInfo.userid, userInfo.id));
break;
}
} else if (startingUsername != null) {
// accept all users starting with the "startingUser"
if (userInfo.userid.compareToIgnoreCase(startingUsername) >= 0) {
usersToScan.put(userInfo.userid, new User(userInfo.userid, userInfo.id));
}
} else {
// all users
usersToScan.put(userInfo.userid, new User(userInfo.userid, userInfo.id));
}
}
//
// get list of directories to scan (for selected users on both user data directories)
//
List<File> useDirectoriesToScan = getDirectoriesToScan(usersToScan, primaryDataRootDir, secondaryDataRootDir);
for (File userDir : useDirectoriesToScan) {
try {
if (lg.isTraceEnabled())
lg.trace("USER: " + userDir.getName());
User user = usersToScan.get(userDir.getName());
// find all the user simulations and external data sets (field data)
SimulationInfo[] simulationInfos = dbServerImpl.getSimulationInfos(user, false);
ExternalDataIdentifier[] extDataIDArr = adminDbTopLevel.getExternalDataIdentifiers(user, true);
// scan this user directory
scanUserDirectory(userDir, extDataIDArr, simulationInfos, outputDir, SCAN_ONLY, (ampliCredName == null || ampliCredPassword == null ? null : new AmplistorUtils.AmplistorCredential(ampliCredName, ampliCredPassword)));
} catch (Exception ex) {
lg.error(ex.getMessage(), ex);
}
}
} catch (Exception ex) {
ex.printStackTrace(System.out);
} finally {
try {
if (conFactory != null) {
conFactory.close();
}
} catch (Throwable ex) {
ex.printStackTrace();
}
System.exit(0);
}
}
Aggregations