/** * @return if the database adjustment is not yet performed */ private boolean isCheckRequired() { return (Boolean) executor.executeSql( new Executor.SimpleSqlWork(this, "BaseDBCheck") { @Transactional(readOnly = true) public Boolean doWork(SqlAction sql) { return !configValue.equals(sql.configValue(configKey)); } }); }
@SuppressWarnings("unchecked") public List<Long> idsInDb() { return (List<Long>) ex .executeSql(new Executor.SimpleSqlWork(this, "idsInDb") { @Transactional(readOnly = true) public Object doWork(SqlAction sql) { return idsInDb(sql); } }); }
public boolean isInRepo(final long id) { return (Boolean) ex.executeSql(new Executor.SimpleSqlWork( this, "isInRepo", id) { @Transactional(readOnly = true) public Object doWork(SqlAction sql) { return isInRepo(sql, id); } }); }
@Override public long executeNextSessionId() { return (Long) executor .executeSql(new Executor.SimpleSqlWork(this, "executeNextSessionId") { @Transactional(readOnly = false) public Object doWork(SqlAction sql) { return sql.nextSessionId(); } }); }
public int countInDb() { return (Integer) ex.executeSql(new Executor.SimpleSqlWork( this, "countInDb") { @Transactional(readOnly = true) public Object doWork(SqlAction sql) { return countInDb(sql); } }); }
public Long findInDb(final RepoFile file, final boolean scriptsOnly) { return (Long) ex.executeSql(new Executor.SimpleSqlWork( this, "findInDb", file, scriptsOnly) { @Transactional(readOnly = true) public Object doWork(SqlAction sql) { return findInDb(sql, file, scriptsOnly); } }); }
/** * The database adjustment is to be performed. */ private void checkIsStarting() { executor.executeSql( new Executor.SimpleSqlWork(this, "BaseDBCheck") { @Transactional(readOnly = false) public Object doWork(SqlAction sql) { sql.addMessageWithinDbPatchStart(version, patch, configKeyValue); return null; } }); }
/** * Currently only returns false since if the regular password check * performed by {@link ome.services.sessions.SessionManager} cannot find the * session, then the cluster has no extra information. */ public boolean checkPassword(final String userId) { return (Boolean) executor.executeSql(new Executor.SimpleSqlWork(this, "checkPassword") { @Transactional(readOnly = true) public Object doWork(SqlAction sql) { return sql.activeSession(userId); } }); }
@Override public Long findSessionIdByUuid(final String uuid) { return (Long) executor.executeSql(new Executor.SimpleSqlWork(this, "getSessionId") { @Override @Transactional(readOnly = true) public Object doWork(SqlAction sql) { try { return sql.sessionId(uuid); } catch (EmptyResultDataAccessException erdae) { return null; } } }); }
/** * The database adjustment is now performed. * Hereafter {@link #isCheckRequired()} should return {@code false}. */ private void checkIsDone() { executor.executeSql( new Executor.SimpleSqlWork(this, "BaseDBCheck") { @Transactional(readOnly = false) public Object doWork(SqlAction sql) { sql.addMessageWithinDbPatchEnd(version, patch, configKeyValue); sql.updateOrInsertConfigValue(configKey, configValue); return null; } }); }
@Override public void executeCloseSession(final String uuid) { executor.executeSql(new Executor.SimpleSqlWork(this, "executeCloseSession") { @Transactional(readOnly = false) public Object doWork(SqlAction sql) { try { final int count = sql.closeSessions(uuid); if (count == 0) { log.warn("No session updated on closeSession: {}", uuid); } else { log.debug("Session.closed set to now() for {}", uuid); } } catch (Exception e) { log.error("FAILED TO CLOSE SESSION IN DATABASE: {}", uuid, e); } return null; } }); }
@SuppressWarnings("unchecked") private void loadFromAction(Set<String> addresses) { Collection<String> rv = (Collection<String>) executor.executeSql(new Executor.SimpleSqlWork(this, "loadAdminEmails") { @Override @Transactional(readOnly=true) public Collection<String> doWork(SqlAction sql) { return sql.getUserEmailsByGroup(roles.getSystemGroupId()); } }); for (String email : rv) { if (!email.isEmpty()) { addresses.add(email); } } }
@Override protected void doCheck() { final boolean hasUnicodeUnits; try { hasUnicodeUnits = (Boolean) executor.executeSql(new Executor.SimpleSqlWork(this, "DBUnicodeUnitsCheck") { @Transactional(readOnly = true) public Boolean doWork(SqlAction sql) { return sql.hasUnicodeUnits(); } }); } catch (Exception e) { final String message = "Error while checking the encoding of units of measure."; LOGGER.error(message, e); throw new InternalException(message); } if (hasUnicodeUnits) { LOGGER.info("Database has the correctly encoded units of measure."); } else { final String message = "Database does not contain correctly encoded units of measure."; LOGGER.error(message); throw new InternalException(message); } } }
public void synchronizeJobs() { final Callback cb = (Callback) oa.find(id); final List<Long> ids = new ArrayList<Long>(); synchronized (cb.openJobs) { ids.addAll(cb.openJobs); } try { ex.executeSql(new Executor.SimpleSqlWork(this, "synchronizeJobs") { @Transactional(readOnly = false) public Object doWork(SqlAction sql) { int count = sql.synchronizeJobs(ids); if (count > 0) { log.warn("Forcibly closed " + count + " abandoned job(s)."); } return null; } }); } finally { oa.remove(id); // OK ADAPTER USAGE } }
final Long sessionId = executeNextSessionId(); return (Session) executor .executeSql(new Executor.SimpleSqlWork(this, "executeInternalSession") { @Transactional(readOnly = false)
@SuppressWarnings("unchecked") protected String getFileRepo(final OriginalFile file) throws ServerError { if (file == null || file.getId() == null) { throw new omero.ValidationException(null, null, "Unmanaged file"); } Map<String, Object> map = (Map<String, Object>) ex .executeSql(new Executor.SimpleSqlWork(this, "getFileRepo") { @Transactional(readOnly = true) public Object doWork(SqlAction sql) { return sql.repoFile(file.getId().getValue()); } }); if (map.size() == 0) { throw new omero.ValidationException(null, null, "Unknown file: " + file.getId().getValue()); } return (String) map.get("repo"); }
@Override public Session executeInternalSession(final String uuid, Session session) { Node node = (Node) executor.executeSql(new Executor.SimpleSqlWork(this, "executeInternalSession") { @Transactional(readOnly = true) public Object doWork(SqlAction sql) { final Long nodeId = nodeProvider.getManagerIdByUuid(uuid, sql); return nodeId == null ? null : new Node(nodeId, false); } }); session.setId(executeNextSessionId()); log.debug("Created session: {}", session); log.debug("Setting node: {}", node); session.setNode(node); session.setOwner(new Experimenter(roles.getRootId(), false)); openSessions.put(session.getUuid(), session); return session; }
.executeSql(new Executor.SimpleSqlWork(this, "__redirect", fileId) { @Transactional(readOnly = true)