List of usage examples for org.springframework.dao EmptyResultDataAccessException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public Set<String> getSakaiIdsForUserWithNewsLinks(String entityReference) { if (log.isDebugEnabled()) { log.debug("getSakaIdsForUserWithNewsLinks(" + entityReference + ")"); }// w w w.j av a2 s . co m String sql = getStatement("select.sakaiUserIds.in.newsLinks.by.entityReference"); Object[] params = new Object[] { entityReference }; try { List<String> userIds = getJdbcTemplate().query(sql, params, new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { return rs.getString(1); } }); return new HashSet<String>(userIds); } catch (EmptyResultDataAccessException ex) { log.debug("getSakaIdsForUserWithNewsLinks: Empty result executing query: " + ex.getClass() + ":" + ex.getMessage()); return new HashSet<String>(); } catch (DataAccessException ex) { log.warn("getSakaIdsForUserWithNewsLinks: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return new HashSet<String>(); } }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public Set<String> listUsersWithLinks(CalendarItem calendarItem) { if (log.isDebugEnabled()) { log.debug("listUsersWithAccess(" + calendarItem + ")"); }//w w w . ja v a 2 s .c om try { String sql = getStatement("select.Person.sakaiId.by.calendarLink"); Object[] args = new Object[] { calendarItem.getId() }; List items = getJdbcTemplate().queryForList(sql, args, String.class); if (items == null || items.isEmpty()) { return new TreeSet<String>(); } return new TreeSet<String>(items); } catch (EmptyResultDataAccessException ex) { log.debug( "listUsersWithAccess: Empty result executing query: " + ex.getClass() + ":" + ex.getMessage()); return new TreeSet<String>(); } catch (DataAccessException ex) { log.warn("listUsersWithAccess: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return new TreeSet<String>(); } }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public Integer getConfigProperty(String propertyName) { if (log.isDebugEnabled()) { log.debug("getConfigProperty( " + propertyName + ")"); }/*from ww w .ja v a2s .c om*/ Integer value = null; String sql = getStatement("select.Config.by.propertyName"); Object[] params = new Object[] { propertyName }; JdbcTemplate jdbcTemplate = getJdbcTemplate(); try { value = jdbcTemplate.queryForInt(sql, params); } catch (EmptyResultDataAccessException ex) { // do nothing. This means no value is set for this property, an expected condition in some cases. // log.warn("getConfigProperty: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); } catch (DataAccessException ex) { log.warn("getConfigProperty: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); } catch (Exception ex) { log.warn("getConfigProperty: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); } return value; }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
/** * construct HashMap, /*from w w w.j a v a2s . c o m*/ * keyed with context id, * value is set of user ids that has links(calendarlink, newslink) in dashboard * @param the sql name * @return HashMap object */ private HashMap<String, Set<String>> getDashboardContextUserMap(String sqlName) { HashMap<String, Set<String>> dashboardUserMap = new HashMap<String, Set<String>>(); String sql = getStatement(sqlName); try { List<String> contextUsersList = (List<String>) getJdbcTemplate().query(sql, new ContextUserMapper()); if (contextUsersList != null) { for (String contextUser : contextUsersList) { // the string returned from db query is of format context id + " " + user id // need to parse it out and form HashMap String[] parts = contextUser.split(" "); if (parts.length == 2) { // parts: context id (site id) and user id String context_id = parts[0]; String user_id = parts[1]; if (dashboardUserMap.containsKey(context_id)) { // get the current set and add user id into it Set<String> current = dashboardUserMap.get(context_id); current.add(user_id); dashboardUserMap.put(context_id, current); } else { // add the new key Set<String> current = new HashSet<String>(); current.add(user_id); dashboardUserMap.put(context_id, current); } } } } } catch (EmptyResultDataAccessException ex) { log.debug("getDashboardContextUserMap: Empty result executing query: " + sqlName + " " + ex.getClass() + ":" + ex.getMessage()); } catch (DataAccessException ex) { log.warn("getDashboardContextUserMap: Error executing query: " + sqlName + " " + ex.getClass() + ":" + ex.getMessage()); } return dashboardUserMap; }