List of usage examples for org.springframework.dao DataAccessException getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public boolean addContext(Context context) { if (log.isDebugEnabled()) { log.debug("addContext( " + context.toString() + ")"); }/* w ww . j a va 2 s .c o m*/ // context_id, context_url, context_title String sql = getStatement("insert.Context"); try { int rows = getJdbcTemplate().update(sql, new Object[] { context.getContextId(), context.getContextUrl(), context.getContextTitle() }); return true; } catch (DataIntegrityViolationException e) { // this means we're trying to insert a duplicate log.debug("addContext() " + e); return false; } catch (DataAccessException ex) { log.warn("addContext: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return false; } catch (Exception e) { log.warn("addCalendarItem: Error executing query: " + e.getClass() + ":" + e.getMessage()); return false; } }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public boolean addNewsItem(NewsItem newsItem) { if (log.isDebugEnabled()) { log.debug("addNewsItem( " + newsItem.toString() + ")"); }/*from ww w . j a v a 2s .c om*/ // news_time, title , entity_url, entity_ref, source_type, context_id, realm_id String subtype = newsItem.getSubtype(); // DASH-191 if (subtype != null && subtype.length() > MAX_LENGTH_SUBTYPE_FIELD) { StringBuilder buf = new StringBuilder(); buf.append("addNewsItem(). Truncating subtype "); buf.append(subtype); buf.append(" for entity "); buf.append(newsItem.getEntityReference()); log.warn(buf); subtype = subtype.substring(0, MAX_LENGTH_SUBTYPE_FIELD - 1); } try { JdbcTemplate template = getJdbcTemplate(); template.update(getStatement("insert.NewsItem"), new Object[] { newsItem.getNewsTime(), newsItem.getTitle(), newsItem.getNewsTimeLabelKey(), newsItem.getEntityReference(), subtype, newsItem.getSourceType().getId(), newsItem.getContext().getId(), newsItem.getGroupingIdentifier() }); return true; } catch (DataIntegrityViolationException e) { // this means we're trying to insert a duplicate log.debug("addNewsItem() " + e); } catch (DataAccessException ex) { log.warn("addNewsItem: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); } return false; }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public boolean addNewsLink(NewsLink newsLink) { if (log.isDebugEnabled()) { log.debug("addNewsLink( " + newsLink.toString() + ")"); }//from w w w . j a va2 s . c o m // person_id, item_id, context_id, realm_id try { getJdbcTemplate().update(getStatement("insert.NewsLink"), new Object[] { newsLink.getPerson().getId(), newsLink.getNewsItem().getId(), newsLink.getContext().getId(), newsLink.isHidden(), newsLink.isSticky() }); return true; } catch (DataIntegrityViolationException e) { // this means we're trying to insert a duplicate log.debug("addNewsLink() " + e); return false; } catch (DataAccessException ex) { log.warn("addNewsLink: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return false; } }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public int addNewsLinks(final List<NewsLink> newsLinks) { if (log.isDebugEnabled()) { log.debug("addNewsLinks( " + newsLinks.size() + ")"); }//w w w. j av a 2s. co m // person_id, item_id, context_id, realm_id int count = 0; try { String sql = getStatement("insert.NewsLink"); int[] updates = getJdbcTemplate().batchUpdate(sql, new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement ps, int i) throws SQLException { NewsLink newsLink = newsLinks.get(i); ps.setLong(1, newsLink.getPerson().getId()); ps.setLong(2, newsLink.getNewsItem().getId()); ps.setLong(3, newsLink.getContext().getId()); ps.setBoolean(4, newsLink.isHidden()); ps.setBoolean(5, newsLink.isSticky()); } @Override public int getBatchSize() { return newsLinks.size(); } }); if (updates != null && updates.length > 0) { for (int u : updates) { count += u; } } } catch (DataIntegrityViolationException e) { // this means we're trying to insert a duplicate log.debug("addNewsLink() " + e); } catch (DataAccessException ex) { log.warn("addNewsLink: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); } return count; }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public boolean addPerson(Person person) { if (log.isDebugEnabled()) { log.debug("addPerson( " + person.toString() + ")"); }//from w w w . j a v a2s . c o m // user_id,sakai_id try { getJdbcTemplate().update(getStatement("insert.Person"), new Object[] { person.getUserId(), person.getSakaiId() }); return true; } catch (DataIntegrityViolationException e) { // this means we're trying to insert a duplicate log.debug("addPerson() " + e); return false; } catch (DataAccessException ex) { log.warn("addPerson: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return false; } }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public boolean addRepeatingCalendarItem(RepeatingCalendarItem repeatingCalendarItem) { if (log.isDebugEnabled()) { log.debug("addRepeatingCalendarItem( " + repeatingCalendarItem.toString() + ")"); }//from w w w .ja v a 2 s. c o m //System.out.println("addRepeatingCalendarItem( " + repeatingCalendarItem.toString() + ")"); // first_time, last_time, frequency, count, calendar_time_label_key, title, entity_ref, entity_type, context_id String sql = getStatement("insert.RepeatingEvent"); //System.out.println("addRepeatingCalendarItem() sql == " + sql); long sourceTypeId = repeatingCalendarItem.getSourceType().getId(); long contextId = repeatingCalendarItem.getContext().getId(); String subtype = repeatingCalendarItem.getSubtype(); // DASH-191 if (subtype != null && subtype.length() > MAX_LENGTH_SUBTYPE_FIELD) { StringBuilder buf = new StringBuilder(); buf.append("addRepeatingCalendarItem(). Truncating subtype "); buf.append(subtype); buf.append(" for entity "); buf.append(repeatingCalendarItem.getEntityReference()); log.warn(buf); subtype = subtype.substring(0, MAX_LENGTH_SUBTYPE_FIELD - 1); } Object[] params = new Object[] { repeatingCalendarItem.getFirstTime(), repeatingCalendarItem.getLastTime(), repeatingCalendarItem.getFrequency(), repeatingCalendarItem.getMaxCount(), repeatingCalendarItem.getCalendarTimeLabelKey(), repeatingCalendarItem.getTitle(), repeatingCalendarItem.getEntityReference(), subtype, sourceTypeId, contextId }; try { getJdbcTemplate().update(sql, params); return true; } catch (DataIntegrityViolationException e) { // this means we're trying to insert a duplicate log.debug("addRepeatingCalendarItem() " + e); return false; } catch (DataAccessException ex) { log.warn("addRepeatingCalendarItem: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); //System.out.println("addRepeatingCalendarItem: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return false; } }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public boolean addSourceType(SourceType sourceType) { if (log.isDebugEnabled()) { log.debug("addSourceType( " + sourceType.toString() + ")"); }//from ww w . j a va 2 s . co m // identifier try { getJdbcTemplate().update(getStatement("insert.SourceType"), new Object[] { sourceType.getIdentifier() } ); return true; } catch (DataIntegrityViolationException e) { // this means we're trying to insert a duplicate log.debug("addSourceType() " + e); return false; } catch (DataAccessException ex) { log.warn("addSourceType: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return false; } }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public boolean addTaskLock(TaskLock taskLock) { if (log.isDebugEnabled()) { log.debug("addTaskLock( " + taskLock.toString() + ")"); }//w w w . ja v a 2 s . c o m // task, server_id, claim_time, last_update try { getJdbcTemplate().update(getStatement("insert.TaskLock"), new Object[] { taskLock.getTask(), taskLock.getServerId(), taskLock.getClaimTime(), taskLock.getLastUpdate(), taskLock.isHasLock() }); return true; } catch (DataIntegrityViolationException e) { // this means we're trying to insert a duplicate log.debug("addTaskLock() " + e); return false; } catch (DataAccessException ex) { log.warn("addTaskLock: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return false; } }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public boolean deleteAvailabilityChecks(String entityReference) { if (log.isDebugEnabled()) { log.debug("deleteAllAvailabilityChecks( " + entityReference + ")"); }/* w w w . j a va 2 s . co m*/ try { getJdbcTemplate().update(getStatement("delete.AvailabilityChecks.by.entityReference"), new Object[] { entityReference }); return true; } catch (DataAccessException ex) { log.warn( "deleteAllAvailabilityChecks: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return false; } }
From source file:org.sakaiproject.dash.dao.impl.DashboardDaoImpl.java
public boolean deleteAvailabilityChecksBeforeTime(Date time) { if (log.isDebugEnabled()) { log.debug("deleteAvailabilityChecksBeforeTime(" + time + ")"); }//from w w w. ja v a2s . c o m String sql = getStatement("delete.AvailabilityChecks.before.date"); Object[] params = new Object[] { time }; try { getJdbcTemplate().update(sql, params); return true; } catch (DataAccessException ex) { log.warn("deleteAvailabilityChecksBeforeTime: Error executing query: " + ex.getClass() + ":" + ex.getMessage()); return false; } }