Search in sources :

Example 11 with ConnectionFactory

use of org.vcell.db.ConnectionFactory 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 12 with ConnectionFactory

use of org.vcell.db.ConnectionFactory 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 13 with ConnectionFactory

use of org.vcell.db.ConnectionFactory 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 14 with ConnectionFactory

use of org.vcell.db.ConnectionFactory 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)

Example 15 with ConnectionFactory

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

the class ServerManageConsole method main.

/**
 * main entrypoint - starts the part when it is run as an application
 * @param args java.lang.String[]
 */
public static void main(java.lang.String[] args) {
    try {
        if (args.length == 2 && args[0].equals("-password")) {
            ServerManageConsole.commandLineAdminPassword = args[1];
        }
        PropertyLoader.loadProperties();
        javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
        ConnectionFactory conFactory = DatabaseService.getInstance().createConnectionFactory();
        KeyFactory keyFactory = conFactory.getKeyFactory();
        DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(conFactory, keyFactory);
        AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(conFactory);
        ServerManageConsole aServerManageConsole = new ServerManageConsole(adminDbTopLevel, databaseServerImpl);
        aServerManageConsole.addWindowListener(new java.awt.event.WindowAdapter() {

            public void windowClosing(java.awt.event.WindowEvent e) {
                System.exit(0);
            }
        });
        java.awt.Insets insets = aServerManageConsole.getInsets();
        aServerManageConsole.setSize(aServerManageConsole.getWidth() + insets.left + insets.right, aServerManageConsole.getHeight() + insets.top + insets.bottom);
        aServerManageConsole.setLocation(200, 200);
        aServerManageConsole.setVisible(true);
    } catch (Throwable exception) {
        System.err.println("Exception occurred in main() of javax.swing.JFrame");
        exception.printStackTrace(System.out);
    }
}
Also used : RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) ConnectionFactory(org.vcell.db.ConnectionFactory) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) DatabaseServerImpl(cbit.vcell.modeldb.DatabaseServerImpl) KeyFactory(org.vcell.db.KeyFactory)

Aggregations

ConnectionFactory (org.vcell.db.ConnectionFactory)21 KeyFactory (org.vcell.db.KeyFactory)13 File (java.io.File)8 SQLException (java.sql.SQLException)7 DatabaseServerImpl (cbit.vcell.modeldb.DatabaseServerImpl)4 IOException (java.io.IOException)4 Connection (java.sql.Connection)4 VCMessagingService (cbit.vcell.message.VCMessagingService)3 AdminDBTopLevel (cbit.vcell.modeldb.AdminDBTopLevel)3 ZipFile (java.util.zip.ZipFile)3 ServerMessagingDelegate (cbit.vcell.message.server.ServerMessagingDelegate)2 ServiceInstanceStatus (cbit.vcell.message.server.ServiceInstanceStatus)2 RemoteProxyVCellConnectionFactory (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory)2 LocalAdminDbServer (cbit.vcell.modeldb.LocalAdminDbServer)2 PropertyLoader (cbit.vcell.resource.PropertyLoader)2 AdminDatabaseServer (cbit.vcell.server.AdminDatabaseServer)2 FileFilter (java.io.FileFilter)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 JFrame (javax.swing.JFrame)2