Search in sources :

Example 6 with KeyFactory

use of org.vcell.db.KeyFactory in project vcell by virtualcell.

the class SQLCreateAllTables method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    // 
    try {
        final String oracle = "oracle";
        final String postgres = "postgres";
        final String usage = "\nUsage: (" + oracle + "|" + postgres + ") connectUrl schemaUser schemaUserPassword\n";
        if (args.length != 4) {
            System.out.println(usage);
            System.exit(1);
        }
        String connectURL = args[1];
        String dbSchemaUser = args[2];
        String dbPassword = args[3];
        // 
        int ok = javax.swing.JOptionPane.showConfirmDialog(new JFrame(), "EXTREME DANGER!!!!\nAll Tables in Schema below will be DESTROYED and re-created" + "connectURL=" + connectURL + "\nUser=" + dbSchemaUser + "\npassword=" + dbPassword, "Confirm", javax.swing.JOptionPane.OK_CANCEL_OPTION, javax.swing.JOptionPane.WARNING_MESSAGE);
        if (ok != javax.swing.JOptionPane.OK_OPTION) {
            throw new RuntimeException("Aborted by user");
        }
        ConnectionFactory conFactory = null;
        KeyFactory keyFactory = null;
        new cbit.vcell.resource.PropertyLoader();
        if (args[0].equalsIgnoreCase(oracle)) {
            String driverName = "oracle.jdbc.driver.OracleDriver";
            conFactory = DatabaseService.getInstance().createConnectionFactory(driverName, connectURL, dbSchemaUser, dbPassword);
        } else if (args[0].equalsIgnoreCase(postgres)) {
            String driverName = "org.postgresql.Driver";
            conFactory = DatabaseService.getInstance().createConnectionFactory(driverName, connectURL, dbSchemaUser, dbPassword);
        } else {
            System.out.println(usage);
            System.exit(1);
        }
        destroyAndRecreateTables(conFactory, conFactory.getKeyFactory(), conFactory.getDatabaseSyntax());
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    System.exit(0);
}
Also used : ConnectionFactory(org.vcell.db.ConnectionFactory) JFrame(javax.swing.JFrame) KeyFactory(org.vcell.db.KeyFactory)

Example 7 with KeyFactory

use of org.vcell.db.KeyFactory in project vcell by virtualcell.

the class FunctionFileCrawler method main.

/**
 * Insert the method's description here.
 * Creation date: (6/27/2006 1:33:58 PM)
 * @param args java.lang.String[]
 */
public static void main(String[] args) {
    ConnectionFactory conFactory = null;
    try {
        String username = null;
        String outputdir = ".";
        int count = 0;
        boolean SCAN_SINGLE = false;
        while (count < args.length) {
            if (args[count].equals("-h")) {
                printUsage();
                System.exit(0);
            } else if (args[count].equals("-u")) {
                count++;
                username = args[count];
                SCAN_SINGLE = true;
            } else if (args[count].equals("-o")) {
                count++;
                outputdir = args[count];
            } else {
                System.out.println("Wrong arguments, see usage below.");
                printUsage();
                System.exit(1);
            }
            count++;
        }
        PropertyLoader.loadProperties();
        conFactory = DatabaseService.getInstance().createConnectionFactory();
        KeyFactory keyFactory = conFactory.getKeyFactory();
        AdminDatabaseServer adminDbServer = new LocalAdminDbServer(conFactory, keyFactory);
        FunctionFileCrawler crawler = new FunctionFileCrawler(adminDbServer, outputdir);
        if (SCAN_SINGLE) {
            crawler.scanAUser(username);
        } else {
            crawler.scanAllUsers();
        }
        System.exit(0);
    } catch (Exception ex) {
        ex.printStackTrace(System.out);
    } finally {
        try {
            if (conFactory != null) {
                conFactory.close();
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
        }
        System.exit(0);
    }
}
Also used : ConnectionFactory(org.vcell.db.ConnectionFactory) KeyFactory(org.vcell.db.KeyFactory) AdminDatabaseServer(cbit.vcell.server.AdminDatabaseServer) DataAccessException(org.vcell.util.DataAccessException) SQLException(java.sql.SQLException)

Example 8 with KeyFactory

use of org.vcell.db.KeyFactory in project vcell by virtualcell.

the class VCDatabaseScanner method createDatabaseScanner.

/**
 * create database scanner with specified log
 * @param log
 * @return new scanner
 * @throws Exception
 */
public static VCDatabaseScanner createDatabaseScanner() throws Exception {
    new PropertyLoader();
    DatabasePolicySQL.lg.setLevel(Level.WARN);
    DatabasePolicySQL.bAllowAdministrativeAccess = true;
    ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory();
    KeyFactory keyFactory = conFactory.getKeyFactory();
    VCDatabaseScanner databaseScanner = new VCDatabaseScanner(conFactory, keyFactory);
    return databaseScanner;
}
Also used : ConnectionFactory(org.vcell.db.ConnectionFactory) PropertyLoader(cbit.vcell.resource.PropertyLoader) KeyFactory(org.vcell.db.KeyFactory)

Example 9 with KeyFactory

use of org.vcell.db.KeyFactory in project vcell by virtualcell.

the class CompareDatabaseSchema method main.

/**
 * Starts the application.
 * @param args an array of command-line arguments
 */
public static void main(java.lang.String[] args) {
    // 
    try {
        final String oracle = "oracle";
        final String postgres = "postgres";
        final String usage = "Usage: (" + oracle + "|" + postgres + ") connectURL schemaUser schemaUserPassword";
        if (args.length != 4 || (!args[0].equalsIgnoreCase(oracle) && !args[0].equalsIgnoreCase(postgres))) {
            System.out.println(usage);
            System.exit(0);
        }
        String connectURL = args[1];
        String dbSchemaUser = args[2];
        String dbPassword = args[3];
        // 
        int ok = javax.swing.JOptionPane.showConfirmDialog(new JFrame(), "Will compare VCell Software 'Tables' with Database Schema: " + "connectURL=" + connectURL + "\nUser=" + dbSchemaUser + "\npassword=" + dbPassword, "Confirm", javax.swing.JOptionPane.OK_CANCEL_OPTION, javax.swing.JOptionPane.WARNING_MESSAGE);
        if (ok != javax.swing.JOptionPane.OK_OPTION) {
            throw new RuntimeException("Aborted by user");
        }
        SessionLog log = new StdoutSessionLog("CompareDatabaseSchema");
        ConnectionFactory conFactory = null;
        KeyFactory keyFactory = null;
        new cbit.vcell.resource.PropertyLoader();
        // 
        // get appropriate database factory objects
        // 
        DatabaseSyntax dbSyntax = null;
        if (args[0].equalsIgnoreCase(oracle)) {
            dbSyntax = DatabaseSyntax.ORACLE;
            String driverName = "oracle.jdbc.driver.OracleDriver";
            conFactory = DatabaseService.getInstance().createConnectionFactory(driverName, connectURL, dbSchemaUser, dbPassword);
            keyFactory = conFactory.getKeyFactory();
        } else if (args[0].equalsIgnoreCase(postgres)) {
            dbSyntax = DatabaseSyntax.POSTGRES;
            String driverName = "org.postgresql.Driver";
            conFactory = DatabaseService.getInstance().createConnectionFactory(driverName, connectURL, dbSchemaUser, dbPassword);
            keyFactory = conFactory.getKeyFactory();
        } else {
            System.out.println(usage);
            System.exit(1);
        }
        // 
        // compare with VCell Software 'tables'
        // 
        Table[] tables = SQLCreateAllTables.getVCellTables();
        compareSchemas(log, conFactory, keyFactory, tables, dbSyntax);
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    System.exit(0);
}
Also used : DatabaseSyntax(org.vcell.db.DatabaseSyntax) StdoutSessionLog(cbit.vcell.resource.StdoutSessionLog) StdoutSessionLog(cbit.vcell.resource.StdoutSessionLog) SessionLog(org.vcell.util.SessionLog) ConnectionFactory(org.vcell.db.ConnectionFactory) JFrame(javax.swing.JFrame) KeyFactory(org.vcell.db.KeyFactory)

Example 10 with KeyFactory

use of org.vcell.db.KeyFactory in project vcell by virtualcell.

the class StochtestRunService method main.

public static void main(String[] args) {
    try {
        if (args.length != 3) {
            System.out.println("Usage:  StochtestService baseDirectory numtrials bngTimeoutMS");
            System.exit(-1);
        }
        File baseDir = new File(args[0]);
        if (!baseDir.exists()) {
            throw new RuntimeException("base directory " + baseDir.getPath() + " not found");
        }
        int numTrials = Integer.valueOf(args[1]);
        long bngTimeoutMS = Long.valueOf(args[2]);
        PropertyLoader.loadProperties();
        DatabasePolicySQL.bAllowAdministrativeAccess = true;
        String driverName = PropertyLoader.getRequiredProperty(PropertyLoader.dbDriverName);
        String connectURL = PropertyLoader.getRequiredProperty(PropertyLoader.dbConnectURL);
        String dbSchemaUser = PropertyLoader.getRequiredProperty(PropertyLoader.dbUserid);
        String dbPassword = PropertyLoader.getSecretValue(PropertyLoader.dbPasswordValue, PropertyLoader.dbPasswordFile);
        // 
        // get appropriate database factory objects
        // 
        ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory(driverName, connectURL, dbSchemaUser, dbPassword);
        KeyFactory keyFactory = conFactory.getKeyFactory();
        StochtestRunService stochtestService = new StochtestRunService(baseDir, numTrials, bngTimeoutMS, conFactory, keyFactory);
        while (true) {
            stochtestService.runOne();
        }
    } catch (Throwable e) {
        e.printStackTrace(System.out);
    }
    System.exit(0);
}
Also used : ConnectionFactory(org.vcell.db.ConnectionFactory) File(java.io.File) KeyFactory(org.vcell.db.KeyFactory)

Aggregations

KeyFactory (org.vcell.db.KeyFactory)14 ConnectionFactory (org.vcell.db.ConnectionFactory)13 File (java.io.File)6 DatabaseServerImpl (cbit.vcell.modeldb.DatabaseServerImpl)5 AdminDBTopLevel (cbit.vcell.modeldb.AdminDBTopLevel)4 VCMessagingService (cbit.vcell.message.VCMessagingService)3 SQLException (java.sql.SQLException)3 User (org.vcell.util.document.User)3 ExportServiceImpl (cbit.vcell.export.server.ExportServiceImpl)2 ServerMessagingDelegate (cbit.vcell.message.server.ServerMessagingDelegate)2 ServiceInstanceStatus (cbit.vcell.message.server.ServiceInstanceStatus)2 SimulationDatabaseDirect (cbit.vcell.message.server.dispatcher.SimulationDatabaseDirect)2 LocalAdminDbServer (cbit.vcell.modeldb.LocalAdminDbServer)2 PropertyLoader (cbit.vcell.resource.PropertyLoader)2 AdminDatabaseServer (cbit.vcell.server.AdminDatabaseServer)2 Cachetable (cbit.vcell.simdata.Cachetable)2 DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)2 Date (java.util.Date)2 JFrame (javax.swing.JFrame)2 DataAccessException (org.vcell.util.DataAccessException)2