List of usage examples for org.springframework.dao DataAccessException printStackTrace
public void printStackTrace()
From source file:org.sakaiproject.lessonbuildertool.model.SimplePageToolDaoImpl.java
public boolean quickSaveItem(Object o) { try {/*from ww w .ja va 2s . com*/ Object id = getHibernateTemplate().save(o); return true; } catch (DataAccessException e) { e.printStackTrace(); log.warn("Hibernate could not save: " + e.toString()); return false; } }
From source file:org.sakaiproject.lessonbuildertool.model.SimplePageToolDaoImpl.java
public boolean deleteItem(Object o) { /*// w w w . j a v a 2s. c om * If o is SimplePageItem or SimplePage, it makes sure it gets the right page and checks the * permissions on it. If the item isn't SimplePageItem or SimplePage, it lets it go. * * Essentially, if any of those say that the edit is fine, it won't throw the error. */ if (!(o instanceof SimplePageItem && canEditPage(((SimplePageItem) o).getPageId())) && !(o instanceof SimplePage && canEditPage((SimplePage) o)) && (o instanceof SimplePage || o instanceof SimplePageItem)) { return false; } if (o instanceof SimplePageItem) { SimplePageItem i = (SimplePageItem) o; EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.delete", "/lessonbuilder/item/" + i.getId(), true)); } else if (o instanceof SimplePage) { SimplePage i = (SimplePage) o; EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.delete", "/lessonbuilder/page/" + i.getPageId(), true)); } else if (o instanceof SimplePageComment) { SimplePageComment i = (SimplePageComment) o; EventTrackingService.post(EventTrackingService.newEvent("lessonbuilder.delete", "/lessonbuilder/comment/" + i.getId(), true)); } try { getHibernateTemplate().delete(o); return true; } catch (DataAccessException e) { try { /* If we have multiple objects of the same item, you must merge them * before deleting. If the first delete fails, we merge and try again. */ getHibernateTemplate().delete(getHibernateTemplate().merge(o)); return true; } catch (DataAccessException ex) { ex.printStackTrace(); log.warn("Hibernate could not delete: " + e.toString()); return false; } } }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
@SuppressWarnings("unchecked") public List<DBInfoType> getProjectParams(String projectId) throws I2B2Exception, I2B2DAOException { String sql = "select * from pm_project_params where project_id=? and status_cd<>'D'"; //log.debug(sql + projectId ); List<DBInfoType> queryResult = null; try {/*from w w w . j a va2 s . c om*/ queryResult = jt.query(sql, getProjectParams(), projectId); } catch (DataAccessException e) { log.error(e.getMessage()); e.printStackTrace(); throw new I2B2DAOException("Database error"); } return queryResult; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
@SuppressWarnings("unchecked") public List<DBInfoType> getCellParam(String cellId, String project) throws I2B2Exception, I2B2DAOException { String sql = "select * from pm_cell_params where cell_id = ? and project_path = ? and status_cd<>'D'"; // log.info(sql + domainId + projectId + ownerId); List<DBInfoType> queryResult = null; try {//from www. j a v a2s . c o m queryResult = jt.query(sql, getParam(), cellId, project); } catch (DataAccessException e) { log.error(e.getMessage()); e.printStackTrace(); throw new I2B2DAOException("Database error"); } return queryResult; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
@SuppressWarnings("unchecked") public List<DBInfoType> getProjectUserParams(String projectId, String userId) throws I2B2Exception, I2B2DAOException { String sql = "select * from pm_project_user_params where project_id=? and user_id=? and status_cd<>'D'"; // log.info(sql + domainId + projectId + ownerId); List<DBInfoType> queryResult = null; try {/* ww w . j av a2s. c o m*/ queryResult = jt.query(sql, getProjectUserParams(), projectId, userId); } catch (DataAccessException e) { log.error(e.getMessage()); e.printStackTrace(); throw new I2B2DAOException("Database error"); } return queryResult; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
@SuppressWarnings("unchecked") public List<DBInfoType> getRole(String userId, String project) throws I2B2Exception, I2B2DAOException { String sql = "select distinct" + " case upper(rr.COLUMN_CD)" + " when '@' then pur.PROJECT_ID" + " when 'PROJECT_ID' then pur.PROJECT_ID" + " else null" + " end as PROJECT_ID," + " case upper(rr.COLUMN_CD)" + " when '@' then pur.USER_ID" + " when 'USER_ID' then pur.USER_ID" + " else null" + " end as USER_ID," + " case upper(rr.COLUMN_CD)" + " when '@' then pur.USER_ROLE_CD" + " when 'USER_ROLE_CD' then pur.USER_ROLE_CD" + " else null" + " end as USER_ROLE_CD" + " from " + " pm_project_user_roles pur, pm_role_requirement rr" + " where " + " pur.status_cd<>'D' and" + " rr.status_cd<>'D' and" + " pur.user_id = ? and" + (project != null ? " pur.project_id = ? and" : "") + " (rr.read_hivemgmt_CD = '@') OR (upper(rr.read_hivemgmt_CD) = upper(pur.USER_ROLE_CD)) and" + " upper(rr.table_cd) = 'PM_PROJECT_USER_ROLES'"; // String sql = "select * from pm_project_user_roles where user_id=? and project_id=? and status_cd<>'D'"; // log.info(sql + domainId + projectId + ownerId); List<DBInfoType> queryResult = null; try {/*from w ww .j a v a 2 s.c o m*/ if (project == null) queryResult = jt.query(sql, getRole(), userId); else queryResult = jt.query(sql, getRole(), userId, project); } catch (DataAccessException e) { log.error(e.getMessage()); e.printStackTrace(); throw new I2B2DAOException("Database error"); } return queryResult; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
@SuppressWarnings("unchecked") public List<DBInfoType> getCell(String cell, String project, boolean ignoreDeleted) throws I2B2Exception, I2B2DAOException { // log.info(sql + domainId + projectId + ownerId); List<DBInfoType> queryResult = null; log.debug("Searching for cell: " + cell + " within project " + project); try {/* w w w .j a v a2s . c o m*/ if (cell.equals("@")) { String sql = "select * from pm_cell_data where project_path = ?"; if (ignoreDeleted) sql += " and status_cd<>'D'"; queryResult = jt.query(sql, getCell(), project); } else if ((cell.equals("@") && !project.equals("/"))) { String sql = "select * from pm_cell_data where project_path = ?"; if (ignoreDeleted) sql += " and status_cd<>'D'"; queryResult = jt.query(sql, getCell(), project); } else { String sql = "select * from pm_cell_data where cell_id = ? and project_path = ?"; if (ignoreDeleted) sql += " and status_cd<>'D'"; queryResult = jt.query(sql, getCell(), cell, project); } } catch (DataAccessException e) { log.error(e.getMessage()); e.printStackTrace(); throw new I2B2DAOException("Database error"); } return queryResult; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
public List<DBInfoType> getUserProject(String user) throws I2B2Exception, I2B2DAOException { String sql = "select distinct" + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_ID" + " when 'PROJECT_ID' then pd.PROJECT_ID" + " else null" + " end as PROJECT_ID," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_NAME" + " when 'PROJECT_NAME' then pd.PROJECT_NAME" + " else null" + " end as PROJECT_NAME," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_WIKI" + " when 'PROJECT_WIKI' then pd.PROJECT_WIKI" + " else null" + " end as PROJECT_WIKI," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_PATH" + " when 'PROJECT_PATH' then pd.PROJECT_PATH" + " else null" + " end as PROJECT_PATH," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_KEY" + " when 'PROJECT_KEY' then pd.PROJECT_KEY" + " else null" + " end as PROJECT_KEY," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_DESCRIPTION" + " when 'PROJECT_DESCRIPTION' then pd.PROJECT_DESCRIPTION" + " else null" + " end as PROJECT_DESCRIPTION" + " from " + " pm_project_data pd, pm_project_user_roles pur, pm_role_requirement rr" + " where " + " pd.status_cd<>'D' and" + " pur.status_cd<>'D' and" + " rr.status_cd<>'D' and" + " pur.user_ID = ? and" + " pd.PROJECT_ID = pur.PROJECT_ID and" + " (rr.read_hivemgmt_CD = '@') OR (upper(rr.read_hivemgmt_CD) = upper(pur.USER_ROLE_CD)) and" + " pd.PROJECT_ID = pur.project_id and" + " upper(rr.table_cd) = 'PM_PROJECT_DATA'"; // String sql = "select distinct pd.* from pm_project_data pd, pm_project_user_roles pur where pd.project_id=pur.project_id and pur.user_id = ? and pur.status_cd<>'D' and pd.status_cd<>'D'"; // log.info(sql + domainId + projectId + ownerId); List<DBInfoType> queryResult = null; try {// ww w . j av a 2s .co m queryResult = jt.query(sql, getProject(), user); } catch (DataAccessException e) { log.error(e.getMessage()); e.printStackTrace(); throw new I2B2DAOException("Database error"); } return queryResult; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
@SuppressWarnings("unchecked") public List<DBInfoType> getProject(Object utype, boolean ignoreDeleted) throws I2B2Exception, I2B2DAOException { String sql = "select distinct" + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_ID" + " when 'PROJECT_ID' then pd.PROJECT_ID" + " else null" + " end as PROJECT_ID," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_NAME" + " when 'PROJECT_NAME' then pd.PROJECT_NAME" + " else null" + " end as PROJECT_NAME," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_WIKI" + " when 'PROJECT_WIKI' then pd.PROJECT_WIKI" + " else null" + " end as PROJECT_WIKI," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_PATH" + " when 'PROJECT_PATH' then pd.PROJECT_PATH" + " else null" + " end as PROJECT_PATH," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_KEY" + " when 'PROJECT_KEY' then pd.PROJECT_KEY" + " else null" + " end as PROJECT_KEY," + " case upper(rr.COLUMN_CD)" + " when '@' then pd.PROJECT_DESCRIPTION" + " when 'PROJECT_DESCRIPTION' then pd.PROJECT_DESCRIPTION" + " else null" + " end as PROJECT_DESCRIPTION" + " from " + " pm_project_data pd, pm_project_user_roles pur, pm_role_requirement rr" + " where " + " pur.status_cd<>'D' and" + (ignoreDeleted ? " pd.STATUS_CD<>'D' and " : "") + " rr.status_cd<>'D' and" + " pd.project_ID = ? and" + //" pd.project_path = ? and" + " (rr.read_hivemgmt_CD = '@') OR (upper(rr.read_hivemgmt_CD) = upper(pur.USER_ROLE_CD)) and" + " pd.PROJECT_ID = pur.project_id and" + " upper(rr.table_cd) = 'PM_PROJECT_USER_ROLES'"; // String sql = "select * from pm_project_data where project_id=? and status_cd<>'D'"; // log.info(sql + domainId + projectId + ownerId); List<DBInfoType> queryResult = null; try {/*from w w w . j ava 2 s.c o m*/ queryResult = jt.query(sql, getProject(), ((ProjectType) utype).getId()); //, ((ProjectType) utype).getPath()); } catch (DataAccessException e) { log.error(e.getMessage()); e.printStackTrace(); throw new I2B2DAOException("Database error"); } return queryResult; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
@SuppressWarnings("unchecked") public List<DBInfoType> getApproval(ApprovalType approval, boolean ignoreDeleted) throws I2B2Exception, I2B2DAOException { // log.info(sql + domainId + projectId + ownerId); String sql = "select a.* from pm_approvals a "; String sqlWhere = " where a.object_cd = 'APPROVAL' "; String sqlFrom = ""; List<DBInfoType> queryResult = null; try {/*from w w w.ja v a 2s .c om*/ ArrayList al = new ArrayList(); if (approval.getId() != null) { sqlWhere += "and a.approval_id = ? "; if (ignoreDeleted) sqlWhere += "and a.status_cd<>'D' "; al.add(approval.getId()); } else { // Search if user and project are set String foundUser = "", foundProject = ""; for (int i = 0; i < approval.getSearch().size(); i++) { if (approval.getSearch().get(i).getBy().equalsIgnoreCase("USER")) foundUser = approval.getSearch().get(i).getValue().toUpperCase(); if (approval.getSearch().get(i).getBy().equalsIgnoreCase("PROJECT")) foundUser = approval.getSearch().get(i).getValue().toUpperCase(); } if ((foundUser != "") && (foundProject != "")) { sqlFrom += ", pm_project_user_params p "; sqlWhere += "and a.STATUS_CD = 'A' and p.STATUS_CD = 'A' and " + "p.PARAM_NAME_CD = 'APPROVAL_ID' and p.VALUE = a.APPROVAL_ID and p.USER_ID = ? and p.PROJECT_ID = ?"; al.add(foundUser); al.add(foundProject); } for (int i = 0; i < approval.getSearch().size(); i++) { if ((approval.getSearch() != null) && (approval.getSearch().get(i).getBy().equalsIgnoreCase("NAME"))) { sqlWhere += "and UPPER(a.approval_name) = ? "; if (ignoreDeleted) sqlWhere += "and a.status_cd<>'D' "; al.add(approval.getSearch().get(i).getValue().toUpperCase()); // queryResult = jt.query(sql, getApproval(), approval.getActivationDate()); } if ((approval.getSearch() != null) && (approval.getSearch().get(i).getBy().equalsIgnoreCase("ACTIVATION_DATE"))) { sqlWhere += "and a.activation_date = ? "; if (ignoreDeleted) sqlWhere += "and a.status_cd<>'D' "; al.add(approval.getSearch().get(i).getValue().toUpperCase()); // queryResult = jt.query(sql, getApproval(), approval.getActivationDate()); } else if ((approval.getSearch() != null) && ((foundUser == "") || (foundProject == "")) && (approval.getSearch().get(i).getBy().equalsIgnoreCase("USER"))) { sqlFrom += ", pm_user_params p "; sqlWhere += "and a.STATUS_CD = 'A' and p.STATUS_CD = 'A' and " + "p.PARAM_NAME_CD = 'APPROVAL_ID' and p.VALUE = a.APPROVAL_ID and p.USER_ID = ? "; al.add(approval.getSearch().get(i).getValue()); //sql = "select a.* from pm_approvals a, pm_user_params p where a.STATUS_CD = 'A' and p.STATUS_CD = 'A' and " + //"p.PARAM_NAME_CD = 'APPROVAL' and p.VALUE = a.OBJECT_CD and p.USER_ID = ? "; // queryResult = jt.query(sql, getApproval(), approval.getSearch().get(0).getValue()); } else if ((approval.getSearch() != null) && ((foundUser == "") || (foundProject == "")) && (approval.getSearch().get(i).getBy().equalsIgnoreCase("PROJECT"))) { sqlFrom += ", pm_project_params p "; sqlWhere += "and a.STATUS_CD = 'A' and p.STATUS_CD = 'A' and " + "p.PARAM_NAME_CD = 'APPROVAL_ID' and p.VALUE = a.APPROVAL_ID and p.PROJECT_ID = ? "; al.add(approval.getSearch().get(i).getValue()); //sql = "select a.* from pm_approvals a, pm_project_params p where a.STATUS_CD = 'A' and p.STATUS_CD = 'A' and " + //"p.PARAM_NAME_CD = 'APPROVAL' and p.VALUE = a.OBJECT_CD and p.PROJECT_ID = ? "; // queryResult = jt.query(sql, getApproval(), approval.getSearch().get(0).getValue()); } } } sql += sqlFrom + sqlWhere; log.debug("My sql statement: " + sql); queryResult = jt.query(sql, getApproval(), al.toArray()); } catch (DataAccessException e) { log.error(e.getMessage()); e.printStackTrace(); throw new I2B2DAOException("Database error"); } return queryResult; }