Package org.openbel.framework.core.df

Examples of org.openbel.framework.core.df.DBConnection


     * @return a test {@link KamInfo}
     * @throws SQLException Thrown if a SQL error occurred accessing the KAM
     * catalog
     */
    public static KamInfo createKamInfo() throws SQLException {
        DBConnection dbc =
                new DBConnection(mockConn, DatabaseType.DERBY, "", "", "");
        KAMCatalogDao kcdao = new KAMCatalogDao(dbc, "foo", "bar");
        return kcdao.getKamInfoByName("test");
    }
View Full Code Here


            pkw = new PKAMWriter(filePath);
            tabbedWriter = new CSVWriter(pkw, FIELD_SEPARATOR,
                    CSVParser.DEFAULT_QUOTE_CHARACTER,
                    CSVParser.DEFAULT_ESCAPE_CHARACTER);

            final DBConnection kcc = createKAMConnection(kamName, cfg);
            kdao = new KAMExportDAO(kcc, kamInfo.getSchemaName());
            for (KAMStoreTables1_0 kamTable : KAMStoreTables1_0.values()) {
                tabbedWriter.writeNext(new String[] { "["
                        + kamTable.getTableName() + "]" });
View Full Code Here

        }
    }

    private DBConnection createKAMConnection(final String kamName,
            final SystemConfiguration cfg) throws PKAMSerializationFailure {
        final DBConnection kcc;
        try {
            kcc = databaseService.dbConnection(
                    cfg.getKamURL(),
                    cfg.getKamUser(),
                    cfg.getKamPassword());
View Full Code Here

                        String[] kcRowData = tabbedReader.readNext();

                        final String newKAMSchema = createKAMSchema(cfg,
                                kamName, kcRowData, filePath, noPreserve);

                        final DBConnection kcc =
                                createKAMConnection(filePath, cfg);
                        kamImportDAO = new KAMImportDAO(kcc, newKAMSchema);
                        continue;
                    }
View Full Code Here

        } catch (SQLException e) {
            throw new PKAMSerializationFailure(filePath, e.getMessage());
        }

        // setup KamStore schema
        DBConnection kcc = null;
        try {
            kcc = createKAMConnection(kamName, cfg);
            schemaService.setupKAMStoreSchema(kcc, kamSchema);
        } catch (SQLException e) {
            throw new PKAMSerializationFailure(filePath, e.getMessage());
        } catch (IOException e) {
            throw new PKAMSerializationFailure(filePath, e.getMessage());
        } finally {
            if (kcc != null) {
                kcc.close();
            }
        }

        return kamSchema;
    }
View Full Code Here

        return kamSchema;
    }

    private KamInfo loadKAMInfo(final String kamName, final String filePath,
            final SystemConfiguration cfg) throws PKAMSerializationFailure {
        final DBConnection kcc = createKAMConnection(kamName, cfg);

        KamInfo kamInfo;
        KAMCatalogDao kcdao = null;
        try {
            kcdao = new KAMCatalogDao(kcc,
View Full Code Here

    private static boolean kamExists(String kam) {
        DatabaseService db = new DatabaseServiceImpl();
        SystemConfiguration sc = getSystemConfiguration();

        DBConnection c = null;
        try {
            c = db.dbConnection(sc.getKamURL(), sc.getKamUser(),
                    sc.getKamPassword());
            KAMStore store = new KAMStoreImpl(c);
            return store.getKamInfo(kam) != null;
        } catch (SQLException e) {
            return false;
        } finally {
            if (c != null) {
                c.close();
            }
        }
    }
View Full Code Here

    private static Kam kam(String kam) {
        DatabaseService db = new DatabaseServiceImpl();
        SystemConfiguration sc = getSystemConfiguration();

        DBConnection c = null;
        try {
            c = db.dbConnection(sc.getKamURL(), sc.getKamUser(),
                    sc.getKamPassword());
            KAMStore store = new KAMStoreImpl(c);
            return store.getKam(kam);
        } catch (SQLException e) {
            return null;
        } finally {
            if (c != null) {
                c.close();
            }
        }
    }
View Full Code Here

    private static KAMStore kamstore() {
        DatabaseService db = new DatabaseServiceImpl();
        SystemConfiguration sc = getSystemConfiguration();

        DBConnection c = null;
        try {
            c = db.dbConnection(sc.getKamURL(), sc.getKamUser(),
                    sc.getKamPassword());
            return new KAMStoreImpl(c);
        } catch (SQLException e) {
View Full Code Here

            reportable.output("Using KAM Store URL: " + sysconfig.getKamURL());
            reportable
                    .output("Using KAM Store User: " + sysconfig.getKamUser());
        }

        DBConnection dbConnection = dbservice.dbConnection(
                sysconfig.getKamURL(),
                sysconfig.getKamUser(),
                sysconfig.getKamPassword());

        KAMStore kAMStore = new KAMStoreImpl(dbConnection);

        // See if we need to set up the KAM Store schemas
        final KAMStoreSchemaService kamSchemaService =
                new KAMStoreSchemaServiceImpl(dbservice);

        // Load the KAM catalog schema, if it doesn't exist (see #88).
        kamSchemaService.setupKAMCatalogSchema();

        try {
            if (mode == Mode.LIST) {
                List<KamInfo> kamInfos = kAMStore.getCatalog();
                printKamCatalogSummary(kamInfos);

            } else if (mode == Mode.COMPARE) {
                final KamComparisonXHTMLWriter xhtmlWriter =
                        createOutputFileWriter();

                final String[] kamNames = new String[] { kam1Name, kam2Name };

                // Get the KAM catalog information for each KAM.
                final KamInfo[] kamInfos = new KamInfo[kamNames.length];
                for (int i = 0; i < kamNames.length; ++i) {
                    final KamInfo kamInfo = kAMStore.getKamInfo(kamNames[i]);
                    if (kamInfo == null) {
                        reportable.error("No KAM found with name '"
                                + kamNames[i] + "'");
                        bail(ExitCode.GENERAL_FAILURE);
                    }
                    kamInfos[i] = kamInfo;
                }

                // Create the KamComparison that will be displayed and/or written to the
                // output file.
                final KamComparison cmp = new KamComparison(kamNames);
                for (KamInfo kamInfo : kamInfos) {
                    final String kamName = kamInfo.getName();
                    final KAMStoreStatisticsDaoImpl dao =
                            new KAMStoreStatisticsDaoImpl(
                                    kamInfo.getKamDbObject().getSchemaName(),
                                    dbConnection);

                    cmp.setKamNodeCount(kamName, dao.getKamNodeCount());
                    cmp.setKamEdgeCount(kamName, dao.getKamEdgeCount());
                    cmp.setBELDocumentCount(kamName, dao.getBELDocumentCount());
                    cmp.setNamespaceCount(kamName, dao.getNamespaceCount());
                    cmp.setAnnotationDefinitionCount(kamName,
                            dao.getAnnotationDefinitonCount());
                    cmp.setAnnotationCount(kamName, dao.getAnnotationCount());
                    cmp.setStatementCount(kamName, dao.getStatementCount());
                    cmp.setTermCount(kamName, dao.getTermCount());
                    cmp.setParameterCount(kamName, dao.getParameterCount());
                    cmp.setUniqueParameterCount(kamName,
                            dao.getUniqueParameterCount());
                }

                // Write to stdout.
                writeComparison(cmp);

                // Write the output to the output file.
                if (xhtmlWriter != null) {
                    xhtmlWriter.writeKamComparison(cmp);
                    xhtmlWriter.close();
                }
            }
        } finally {
            kAMStore.teardown();
            dbConnection.getConnection().close();
        }
    }
View Full Code Here

TOP

Related Classes of org.openbel.framework.core.df.DBConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.