/** Returns profile format version from database. Version 0 corresponds to * situation when constraint values are saved in the internal format. Internal * format is format where '*' are replaced with % and other changes. * @see #Util.wildcardSqlToUser() * @return saved format version or "0" if not saved in database */ private static String getProfileVersion(ObjectStore os) { Database database = ((ObjectStoreInterMineImpl) os).getDatabase(); try { String ret = MetadataManager.retrieve(database, MetadataManager.PROFILE_FORMAT_VERSION); LOG.info("Userprofile database has version \"" + ret + "\""); if (ret == null) { ret = ZERO_PROFILE_VERSION; } return ret; } catch (SQLException e) { throw new RuntimeException("Error during retrieving profile version from database.", e); } }
/** Returns profile format version from database. Version 0 corresponds to * situation when constraint values are saved in the internal format. Internal * format is format where '*' are replaced with % and other changes. * @see #Util.wildcardSqlToUser() * @return saved format version or "0" if not saved in database */ private static String getProfileVersion(ObjectStore os) { Database database = ((ObjectStoreInterMineImpl) os).getDatabase(); try { String ret = MetadataManager.retrieve(database, MetadataManager.PROFILE_FORMAT_VERSION); LOG.info("Userprofile database has version \"" + ret + "\""); if (ret == null) { ret = ZERO_PROFILE_VERSION; } return ret; } catch (SQLException e) { throw new RuntimeException("Error during retrieving profile version from database.", e); } }
/** * Called by the ShutdownHook on shutdown. */ public synchronized void shutdown() { LOG.info("Shutting down open ObjectStoreInterMineImpl with sequence = " + sequenceNumber + " and Database " + getDatabase().getURL()); try { close(); } catch (ObjectStoreException e) { LOG.warn("Exception caught while shutting down ObjectStoreInterMineImpl: " + e); } }
/** * Finalise this object. */ protected synchronized void doFinalise() { LOG.error("Garbage collecting ObjectStoreInterMineImpl with sequence = " + sequenceNumber + " and Database " + getDatabase().getURL()); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception while garbage-collecting ObjectStoreInterMineImpl: " + e); } }
/** * Finalise this object. */ protected synchronized void doFinalise() { LOG.error("Garbage collecting ObjectStoreInterMineImpl with sequence = " + sequenceNumber + " and Database " + getDatabase().getURL()); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception while garbage-collecting ObjectStoreInterMineImpl: " + e); } }
/** * Called by the ShutdownHook on shutdown. */ public synchronized void shutdown() { LOG.info("Shutting down open ObjectStoreInterMineImpl with sequence = " + sequenceNumber + " and Database " + getDatabase().getURL()); try { close(); } catch (ObjectStoreException e) { LOG.warn("Exception caught while shutting down ObjectStoreInterMineImpl: " + e); } }
/** * Called by the StatsShutdownHook on shutdown */ @Override public synchronized void shutdown() { if (conn != null) { LOG.error("Shutting down open ObjectStoreWriterInterMineImpl with sequence = " + sequenceNumber + " and Database " + os.getDatabase().getURL() + ", createSituation = " + createSituation); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception caught while shutting down ObjectStoreWriterInterMineImpl: " + e); } } }
/** * Overrides Object.finalize - release the connection back to the objectstore. */ @Override protected synchronized void doFinalise() { if (conn != null) { LOG.error("Garbage collecting open ObjectStoreWriterInterMineImpl with sequence = " + sequenceNumber + " and Database " + os.getDatabase().getURL() + ", createSituation: " + createSituation); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception while garbage-collecting ObjectStoreWriterInterMineImpl: " + e); } } }
/** * Called by the StatsShutdownHook on shutdown */ @Override public synchronized void shutdown() { if (conn != null) { LOG.error("Shutting down open ObjectStoreWriterInterMineImpl with sequence = " + sequenceNumber + " and Database " + os.getDatabase().getURL() + ", createSituation = " + createSituation); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception caught while shutting down ObjectStoreWriterInterMineImpl: " + e); } } }
/** * Overrides Object.finalize - release the connection back to the objectstore. */ @Override protected synchronized void doFinalise() { if (conn != null) { LOG.error("Garbage collecting open ObjectStoreWriterInterMineImpl with sequence = " + sequenceNumber + " and Database " + os.getDatabase().getURL() + ", createSituation: " + createSituation); try { close(); } catch (ObjectStoreException e) { LOG.error("Exception while garbage-collecting ObjectStoreWriterInterMineImpl: " + e); } } }
/** * Sets up the instance variables * * @throws BuildException if something is wrong */ public void setUp() { if (alias == null && objectStore == null) { throw new BuildException("exactly one of alias and objectStore must be set"); } if (objectStore == null) { try { objectStore = ObjectStoreFactory.getObjectStore(alias); } catch (Exception e) { throw new BuildException("Exception while creating ObjectStore", e); } } if (objectStore instanceof ObjectStoreInterMineImpl) { ObjectStoreInterMineImpl osii = ((ObjectStoreInterMineImpl) objectStore); database = osii.getDatabase(); schema = osii.getSchema(); } else { // change comment on setAlias() when this changes throw new BuildException("the alias (" + alias + ") does not refer to an " + "ObjectStoreInterMineImpl"); } }
/** * Sets up the instance variables * * @throws BuildException if something is wrong */ public void setUp() { if (alias == null && objectStore == null) { throw new BuildException("exactly one of alias and objectStore must be set"); } if (objectStore == null) { try { objectStore = ObjectStoreFactory.getObjectStore(alias); } catch (Exception e) { throw new BuildException("Exception while creating ObjectStore", e); } } if (objectStore instanceof ObjectStoreInterMineImpl) { ObjectStoreInterMineImpl osii = ((ObjectStoreInterMineImpl) objectStore); database = osii.getDatabase(); schema = osii.getSchema(); } else { // change comment on setAlias() when this changes throw new BuildException("the alias (" + alias + ") does not refer to an " + "ObjectStoreInterMineImpl"); } }
/** * Run an IQL query in the objectstore and print the first results to the console. * @param os the objectstore * @param iql and IQL query string */ private static void runIqlQuery(ObjectStoreInterMineImpl os, String iql) { System.out .println("Running query in database " + os.getDatabase().getName() + " - " + iql); System.out .println("See intermine.log for query execution details."); Query q = parseIqlQuery(os.getModel(), iql); Results results = os.execute(q); Iterator<?> resIter = results.iterator(); int count = 0; while (resIter.hasNext() && count < MAX_ROWS) { ResultsRow<?> rr = (ResultsRow<?>) resIter.next(); System.out .println(count + " - " + rr); count += 1; } if (resIter.hasNext()) { System.out .println("Only fetching first " + MAX_ROWS + " rows."); } }
Database db = ((ObjectStoreInterMineImpl) objectStore).getDatabase();
Database db = ((ObjectStoreInterMineImpl) objectStore).getDatabase();
/** * Run an IQL query in the objectstore and print the first results to the console. * @param os the objectstore * @param iql and IQL query string */ private static void runIqlQuery(ObjectStoreInterMineImpl os, String iql) { System.out .println("Running query in database " + os.getDatabase().getName() + " - " + iql); System.out .println("See intermine.log for query execution details."); Query q = parseIqlQuery(os.getModel(), iql); Results results = os.execute(q); Iterator<?> resIter = results.iterator(); int count = 0; while (resIter.hasNext() && count < MAX_ROWS) { ResultsRow<?> rr = (ResultsRow<?>) resIter.next(); System.out .println(count + " - " + rr); count += 1; } if (resIter.hasNext()) { System.out .println("Only fetching first " + MAX_ROWS + " rows."); } }
/** * A testing method - converts the argument into a Query object, and then converts it back to * a String again. * * @param args command-line arguments * @throws Exception anytime */ public static void main(String args[]) throws Exception { PrintStream out = System.out; if (args.length > 1) { out.println("Usage: java org.intermine.objectstore.query.iql.IqlShell " + "<objectstore alias> - to enter shell-mode"); } else { try { ObjectStore os = ObjectStoreFactory.getObjectStore(args[0]); if (os instanceof ObjectStoreInterMineImpl) { out.println("Using database " + ((ObjectStoreInterMineImpl) os).getDatabase()); } doShell(os); } catch (Exception e) { out.println("Exception caught: " + e); e.printStackTrace(out); } } }
Connection conn = null; PrintStream out = System.out; Database db = ((ObjectStoreInterMineImpl) uos).getDatabase(); try { conn = ((ObjectStoreInterMineImpl) uos).getConnection();
Connection conn = null; PrintStream out = System.out; Database db = ((ObjectStoreInterMineImpl) uos).getDatabase(); try { conn = ((ObjectStoreInterMineImpl) uos).getConnection();
Database db = ((ObjectStoreInterMineImpl) os).getDatabase(); InputStream inputStream = getClass().getClassLoader().getResourceAsStream(configFile);