List of usage examples for org.springframework.dao IncorrectResultSizeDataAccessException getMessage
@Override
@Nullable
public String getMessage()
From source file:com.sfs.whichdoctor.dao.EmailDAOImpl.java
/** * Load the EmailBeans that have the supplied domain name. * * @param domainName the address domain name * @return the collection of EmailBeans/*w w w . j ava 2 s .com*/ * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<EmailBean> loadDomain(final String domainName) throws WhichDoctorDaoException { final String loadDomain = getSQL().getValue("email/load") + " " + getSQL().getValue("email/whereDomain"); String domainSearch = ""; if (StringUtils.isNotBlank(domainName)) { domainSearch = "%@" + domainName; } Collection<EmailBean> emailAddresses = new ArrayList<EmailBean>(); if (StringUtils.isNotBlank(domainSearch)) { try { emailAddresses = this.getJdbcTemplateReader().query(loadDomain, new Object[] { domainSearch, true }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadEmail(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } } return emailAddresses; }
From source file:com.sfs.whichdoctor.dao.SavedSearchDAOImpl.java
/** * Used to get a Collection of SearchBean details for a public. * * @param filter the filter/*from w w w . ja v a 2 s.c o m*/ * @param subtype the subtype * @param username the username * @return the collection * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<SearchBean> load(final String filter, final String subtype, final String username) throws WhichDoctorDaoException { final StringBuffer loadSearch = new StringBuffer(); ArrayList<Object> parameters = new ArrayList<Object>(); if (StringUtils.isNotBlank(filter)) { loadSearch.append(" AND (savedsearch.Name LIKE ? OR savedsearch.Description LIKE ?)"); parameters.add("%" + filter + "%"); parameters.add("%" + filter + "%"); } if (StringUtils.isNotBlank(subtype)) { loadSearch.append(" AND Type = ?"); parameters.add(subtype); } if (StringUtils.isNotBlank(username)) { loadSearch.append(" AND (savedsearch.UserDn = ? OR savedsearch.PublicSearch = true)"); parameters.add(username); } else { loadSearch.append(" AND savedsearch.publicSearch = true"); } if (loadSearch.length() > 0) { /* Delete the AND from the beginning of the search if defined */ final int subtract = 5; loadSearch.delete(0, subtract); loadSearch.insert(0, " WHERE "); } loadSearch.insert(0, this.getSQL().getValue("search/load")); loadSearch.append(" ORDER BY savedsearch.Name"); dataLogger.info("Retrieving saved public searches"); Collection<SearchBean> savedsearches = new ArrayList<SearchBean>(); try { savedsearches = this.getJdbcTemplateReader().query(loadSearch.toString(), parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadSearch(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } return savedsearches; }
From source file:com.sfs.whichdoctor.dao.IsbMessageDAOImpl.java
/** * Load the oldest unprocessed IsbMessage that needs publishing to an ISB. * * @param isbName the name of the ISB being published to * * @return the isb message bean/*from www.j av a 2 s. c o m*/ * * @throws WhichDoctorDaoException the which doctor dao exception */ public final IsbMessageBean loadFirstUnprocessed(final String isbName) throws WhichDoctorDaoException { dataLogger.info("Oldest unpublished ISB message requested for '" + isbName + "'"); if (isbName == null) { throw new WhichDoctorDaoException("The ISB name cannot be null"); } IsbMessageBean isbMessage = null; try { isbMessage = (IsbMessageBean) this.getIsbJdbcTemplate().queryForObject( this.getSQL().getValue("isbmessage/loadUnprocessed"), new Object[] { isbName }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadIsbMessageBean(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return isbMessage; }
From source file:com.sfs.whichdoctor.dao.ReportDAOImpl.java
/** * Used to get a ReportBean for a specified reportId. * * @param reportId the report id//from www . j a v a2 s . c om * @return the report bean * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final ReportBean load(final int reportId) throws WhichDoctorDaoException { dataLogger.info("reportId: " + reportId + " requested"); final String loadId = getSQL().getValue("report/load") + " WHERE report.reportId = ?"; ReportBean report = null; try { report = (ReportBean) this.getJdbcTemplateReader().queryForObject(loadId, new Object[] { reportId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadReport(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return report; }
From source file:com.sfs.whichdoctor.dao.ReportDAOImpl.java
/** * Used to get an Collection of ReportBeans for a specified GUID number. * * @param guid the guid//from w ww. ja v a2 s . c o m * @param fullResults the full results * @return the collection * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<ReportBean> load(final int guid, final boolean fullResults) throws WhichDoctorDaoException { dataLogger.info("Reports for GUID: " + guid + " requested"); final String loadReport = getSQL().getValue("report/load") + " WHERE report.Active = true AND report.ReferenceGUID = ?" + " ORDER BY reporttype.Value, report.AuthorOrder"; Collection<ReportBean> reports = new ArrayList<ReportBean>(); try { reports = this.getJdbcTemplateReader().query(loadReport, new Object[] { guid }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadReport(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for this search: " + ie.getMessage()); } return reports; }
From source file:com.sfs.whichdoctor.dao.TagDAOImpl.java
/** * Used to get a TagBean based on its ID. * * @param tagId the tag id/* w ww .ja va2 s . c om*/ * @return the tag bean * @throws WhichDoctorDaoException the which doctor dao exception */ public final TagBean load(final int tagId) throws WhichDoctorDaoException { dataLogger.info("TagId: " + tagId + " requested"); final String loadTag = getSQL().getValue("tag/loadId"); TagBean tag = null; try { tag = (TagBean) this.getJdbcTemplateReader().queryForObject(loadTag, new Object[] { tagId }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadTag(rs, true); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results for this search: " + ie.getMessage()); } return tag; }
From source file:com.sfs.whichdoctor.dao.TagDAOImpl.java
/** * Used to get a Collection of TagBeans for a specified GUID. * * @param guid the guid// w w w . j a v a 2s . c o m * @param username the username * @param fullResults the full results * @return the collection * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<TagBean> load(final int guid, final String username, final boolean fullResults) throws WhichDoctorDaoException { dataLogger.info("Tags for GUID: " + guid + " requested"); Collection<TagBean> tags = new ArrayList<TagBean>(); String loadTags = this.getSQL().getValue("tag/loadAnonymous"); Collection<Object> parameters = new ArrayList<Object>(); parameters.add(guid); parameters.add("Private"); if (StringUtils.isNotEmpty(username)) { loadTags = this.getSQL().getValue("tag/loadAuthenticated"); parameters.add("Private"); parameters.add(username); } try { tags = this.getJdbcTemplateReader().query(loadTags, parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadTag(rs, fullResults); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results for this search: " + ie.getMessage()); } return tags; }
From source file:com.sfs.whichdoctor.dao.EmailDAOImpl.java
/** * Used to get an Collection of EmailBean objects for a * specified GUID number.//from w w w.j a va 2s . co m * * @param guid the guid * @param allAddresses the all addresses * @param emailClass the email class * @param emailType the email type * @return the collection * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<EmailBean> load(final int guid, final boolean allAddresses, final String emailClass, final String emailType) throws WhichDoctorDaoException { dataLogger.info("Email Addresses for GUID: " + guid + " requested"); // Do check whether required results are light (only primary) // or full(all email addresses) boolean specificAddress = false; String sql = getSQL().getValue("email/load") + " WHERE email.ReferenceGUID = ? AND email.Active = true"; Collection<Object> variables = new ArrayList<Object>(); /* The GUID value is the first variable */ variables.add(guid); if (emailClass != null) { if (emailClass.compareTo("") != 0 && emailClass.compareTo("Preferred") != 0) { sql += " AND emailtype.Class = ?"; variables.add(emailClass); specificAddress = true; } } if (emailType != null) { if (emailType.compareTo("") != 0 && emailType.compareTo("Preferred") != 0) { sql += " AND emailtype.Name = ?"; variables.add(emailType); specificAddress = true; } } sql += " ORDER BY PrimaryEmail DESC"; if (!allAddresses) { sql += " LIMIT 1"; } Collection<EmailBean> emailAddresses = new ArrayList<EmailBean>(); try { emailAddresses = this.getJdbcTemplateReader().query(sql, variables.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { return loadEmail(rs); } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results found for search: " + ie.getMessage()); } if (specificAddress && emailAddresses.size() == 0) { /** * Specific email type defined but no result found * Try getting a more generic email address */ if (emailType != null) { if (emailType.compareTo("") != 0) { emailAddresses = load(guid, allAddresses, emailClass, null); } } if (emailAddresses.size() == 0) { if (emailClass != null) { if (emailClass.compareTo("") != 0) { emailAddresses = load(guid, allAddresses, null, null); } } } } return emailAddresses; }
From source file:com.sfs.whichdoctor.dao.TagDAOImpl.java
/** * Used to get an ArrayList of TagBeans for a specified search term. * * @param tagName the tag name/* w ww . ja v a2s . c om*/ * @return the collection * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") public final Collection<TagBean> autocomplete(final String tagName) throws WhichDoctorDaoException { if (tagName == null) { throw new WhichDoctorDaoException("Tag search term cannot be null"); } Collection<TagBean> tags = new ArrayList<TagBean>(); /* Only perform a search if there is more than two characters to search on */ if (tagName.length() > 2) { dataLogger.info("Performing tag search for '" + tagName + "'"); final String loadTags = getSQL().getValue("tag/autocomplete"); try { tags = this.getJdbcTemplateReader().query(loadTags, new Object[] { "%" + tagName + "%" }, new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { TagBean tag = new TagBean(); tag.setTagName(rs.getString("TagName")); return tag; } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results for this search: " + ie.getMessage()); } } return tags; }
From source file:com.sfs.whichdoctor.dao.TagDAOImpl.java
/** * Used to test if a tag is unique or not. * * @param tag the tag//from w ww . j av a 2s . c o m * @return true, if successful * @throws WhichDoctorDaoException the which doctor dao exception */ @SuppressWarnings("unchecked") private boolean uniqueTest(final TagBean tag) throws WhichDoctorDaoException { boolean unique = true; dataLogger.info("Unique tag test requested"); String searchSQL = getSQL().getValue("tag/unique"); Collection<Object> parameters = new ArrayList<Object>(); parameters.add(tag.getGUID()); parameters.add(tag.getTagName()); parameters.add(tag.getTagType()); if (StringUtils.equalsIgnoreCase(tag.getTagType(), "Private")) { searchSQL += " AND tags.CreatedBy = ?"; /* Set the username test condition */ parameters.add(tag.getCreatedBy()); } Collection<TagBean> tags = new ArrayList<TagBean>(); try { tags = this.getJdbcTemplateReader().query(searchSQL, parameters.toArray(), new RowMapper() { public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException { final TagBean tag = new TagBean(); tag.setId(rs.getInt("TagId")); return tag; } }); } catch (IncorrectResultSizeDataAccessException ie) { dataLogger.debug("No results for this search: " + ie.getMessage()); } if (tags.size() > 0) { /* A tag already exists with this name */ unique = false; } return unique; }