Search in sources :

Example 31 with SimulationInfo

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);
    }
}
Also used : User(org.vcell.util.document.User) HashMap(java.util.HashMap) UserInfo(org.vcell.util.document.UserInfo) DataAccessException(org.vcell.util.DataAccessException) SQLException(java.sql.SQLException) ConnectionFactory(org.vcell.db.ConnectionFactory) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) File(java.io.File) KeyFactory(org.vcell.db.KeyFactory) SimulationInfo(cbit.vcell.solver.SimulationInfo) AmplistorUtils(cbit.vcell.util.AmplistorUtils)

Aggregations

SimulationInfo (cbit.vcell.solver.SimulationInfo)31 Simulation (cbit.vcell.solver.Simulation)12 SimulationStatus (cbit.vcell.server.SimulationStatus)8 Hashtable (java.util.Hashtable)8 BioModel (cbit.vcell.biomodel.BioModel)7 Vector (java.util.Vector)7 MathModel (cbit.vcell.mathmodel.MathModel)6 TestCriteriaNewBioModel (cbit.vcell.numericstest.TestCriteriaNewBioModel)6 DataAccessException (org.vcell.util.DataAccessException)6 BioModelInfo (org.vcell.util.document.BioModelInfo)6 MathModelInfo (org.vcell.util.document.MathModelInfo)6 TestCriteriaNewMathModel (cbit.vcell.numericstest.TestCriteriaNewMathModel)5 KeyValue (org.vcell.util.document.KeyValue)5 VCDocument (org.vcell.util.document.VCDocument)4 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)3 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 TFGenerateReport (cbit.vcell.client.task.TFGenerateReport)3 Geometry (cbit.vcell.geometry.Geometry)3 EditTestCriteriaOPBioModel (cbit.vcell.numericstest.EditTestCriteriaOPBioModel)3 TestCaseNewBioModel (cbit.vcell.numericstest.TestCaseNewBioModel)3