/** * {@inheritDoc} */ public SingletonResults executeSingleton(Query q) { return osw.executeSingleton(q); }
/** * {@inheritDoc} */ public SingletonResults executeSingleton(Query q, int batchSize, boolean optimise, boolean explain, boolean prefetch) { return osw.executeSingleton(q, batchSize, optimise, explain, prefetch); }
/** * {@inheritDoc} */ public SingletonResults executeSingleton(Query q) { return osw.executeSingleton(q); }
/** * {@inheritDoc} */ public SingletonResults executeSingleton(Query q, int batchSize, boolean optimise, boolean explain, boolean prefetch) { return osw.executeSingleton(q, batchSize, optimise, explain, prefetch); }
/** * Return a list of users with 'superuser' role * @return the user list */ public List<String> getSuperUsers() { Query q = getSuperUserQuery(); // Multiple concurrent attempts to access the userprofile (creating/deleting bags, // for instance) will cause this to fail. Allow three retries. ConcurrentModificationException lastError = null; for (int attemptsRemaining = 3; attemptsRemaining >= 0; attemptsRemaining--) { List<String> superusers = new ArrayList<String>(); try { for (Object o: uosw.executeSingleton(q)) { superusers.add(String.valueOf(o)); } return superusers; } catch (ConcurrentModificationException e) { lastError = e; } } throw lastError; }
/** * Return a list of users with 'superuser' role * @return the user list */ public List<String> getSuperUsers() { Query q = getSuperUserQuery(); // Multiple concurrent attempts to access the userprofile (creating/deleting bags, // for instance) will cause this to fail. Allow three retries. ConcurrentModificationException lastError = null; for (int attemptsRemaining = 3; attemptsRemaining >= 0; attemptsRemaining--) { List<String> superusers = new ArrayList<String>(); try { for (Object o: uosw.executeSingleton(q)) { superusers.add(String.valueOf(o)); } return superusers; } catch (ConcurrentModificationException e) { lastError = e; } } throw lastError; }
private Map<UUID, PermanentToken> loadPermanentTokens() { Map<UUID, PermanentToken> map = new HashMap<UUID, PermanentToken>(); try { // Get the current set of permanent tokens from the database. Query q = new Query(); QueryClass tokens = new QueryClass(PermanentToken.class); q.addFrom(tokens); q.addToSelect(tokens); List<?> results = uosw.executeSingleton(q); Set<PermanentToken> badTokens = new HashSet<PermanentToken>(); for (Object o: results) { PermanentToken token = (PermanentToken) o; try { UUID key = UUID.fromString(token.getToken()); map.put(key, token); } catch (IllegalArgumentException e) { badTokens.add(token); } } for (PermanentToken t: badTokens) { LOG.info("Removing bad token: " + t); uosw.delete(t); } } catch (Exception e) { LOG.error("Could not load permanent tokens", e); throw new IllegalStateException("Error loading permanent tokens", e); } return map; }
private Map<UUID, PermanentToken> loadPermanentTokens() { Map<UUID, PermanentToken> map = new HashMap<UUID, PermanentToken>(); try { // Get the current set of permanent tokens from the database. Query q = new Query(); QueryClass tokens = new QueryClass(PermanentToken.class); q.addFrom(tokens); q.addToSelect(tokens); List<?> results = uosw.executeSingleton(q); Set<PermanentToken> badTokens = new HashSet<PermanentToken>(); for (Object o: results) { PermanentToken token = (PermanentToken) o; try { UUID key = UUID.fromString(token.getToken()); map.put(key, token); } catch (IllegalArgumentException e) { badTokens.add(token); } } for (PermanentToken t: badTokens) { LOG.info("Removing bad token: " + t); uosw.delete(t); } } catch (Exception e) { LOG.error("Could not load permanent tokens", e); throw new IllegalStateException("Error loading permanent tokens", e); } return map; }
/** * Return a List of the usernames in all of the stored profiles. * * @return the usernames */ public synchronized List<String> getProfileUserNames() { Query q = new Query(); QueryClass qcUserProfile = new QueryClass(UserProfile.class); QueryField qfUserName = new QueryField(qcUserProfile, "username"); q.addFrom(qcUserProfile); q.addToSelect(qfUserName); SingletonResults res = uosw.executeSingleton(q); // TODO: We copy the data here in order to avoid any future ConcurrentModificationException // in the SingletonResults List<String> userNames = new ArrayList<String>(); for (Object userName : res) { userNames.add((String) userName); } return userNames; }
/** * Return a List of the usernames in all of the stored profiles. * * @return the usernames */ public synchronized List<String> getProfileUserNames() { Query q = new Query(); QueryClass qcUserProfile = new QueryClass(UserProfile.class); QueryField qfUserName = new QueryField(qcUserProfile, "username"); q.addFrom(qcUserProfile); q.addToSelect(qfUserName); SingletonResults res = uosw.executeSingleton(q); // TODO: We copy the data here in order to avoid any future ConcurrentModificationException // in the SingletonResults List<String> userNames = new ArrayList<String>(); for (Object userName : res) { userNames.add((String) userName); } return userNames; }
List<Object> res; try { res = osw.executeSingleton(q); } catch (Exception e) { throw new BuildException("Could not retrieve any tags", e);
List<Object> res; try { res = osw.executeSingleton(q); } catch (Exception e) { throw new BuildException("Could not retrieve any tags", e);
public void testGetItems() throws Exception { Query q = new Query(); QueryClass qc = new QueryClass(Item.class); q.addToSelect(qc); q.addFrom(qc); Collection results = osw.executeSingleton(q); //assertEquals(items.size(), results.size()); assertEquals(items, results); } }
private void removeUserProfile(String username) throws ObjectStoreException { Query q = new Query(); QueryClass qc = new QueryClass(UserProfile.class); q.addFrom(qc); q.addToSelect(qc); QueryField qf = new QueryField(qc, "username"); SimpleConstraint sc = new SimpleConstraint(qf, ConstraintOp.EQUALS, new QueryValue(username)); q.setConstraint(sc); SingletonResults res = uosw.executeSingleton(q); Iterator<?> resIter = res.iterator(); while (resIter.hasNext()) { InterMineObject o = (InterMineObject) resIter.next(); uosw.delete(o); } }
private void removeUserProfile(String username) throws ObjectStoreException { Query q = new Query(); QueryClass qc = new QueryClass(UserProfile.class); q.addFrom(qc); q.addToSelect(qc); QueryField qf = new QueryField(qc, "username"); SimpleConstraint sc = new SimpleConstraint(qf, ConstraintOp.EQUALS, new QueryValue(username)); q.setConstraint(sc); SingletonResults res = uosw.executeSingleton(q); Iterator resIter = res.iterator(); while (resIter.hasNext()) { InterMineObject o = (InterMineObject) resIter.next(); uosw.delete(o); } }