@SuppressWarnings("unchecked") public Entry<String, LscDatasets> getNextId() { Map<String, Object> idMap; try { idMap = (Map<String, Object>) sqlMapper.queryForObject(getRequestNameForNextId()); String key = getMapKey(idMap, count++); Map<String, LscDatasets> ret = new HashMap<String, LscDatasets>(); ret.put(key, new LscDatasets(idMap)); return ret.entrySet().iterator().next(); } catch (SQLException e) { LOGGER.warn("Error while looking for next entry ({})", e); LOGGER.debug(e.toString(), e); } return null; }
/** * The simple object getter according to its identifier. * * @param pivotName Name of the entry to be returned, which is the name returned by * {@link #getListPivots()} (used for display only) * @param pivotAttributes Map of attribute names and values, which is the data identifier in the * source such as returned by {@link #getListPivots()}. It must identify a unique * entry in the source. * @return The bean, or null if not found * @throws LscServiceException May throw a embedded {@link CommunicationException} if an SQLException is encountered */ public IBean getBean(String pivotName, LscDatasets pivotAttributes) throws LscServiceException { Map<String, Object> attributeMap = pivotAttributes.getDatasets(); try { return (IBean) sqlMapper.queryForObject(getRequestNameForObject(), attributeMap); } catch (SQLException e) { LOGGER.warn("Error while looking for a specific entry with id={} ({})", pivotName, e); LOGGER.debug(e.toString(), e); // TODO This SQLException may mean we lost the connection to the DB // This is a dirty hack to make sure we stop everything, and don't risk deleting everything... throw new LscServiceException(new CommunicationException(e.getMessage())); } }