List of usage examples for org.springframework.dao DataAccessException getMessage
@Override
@Nullable
public String getMessage()
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 {//w ww .java2 s .com 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:com.ephesoft.gxt.systemconfig.server.SystemConfigServiceImpl.java
/** * Imports new regex groups, which are not already present in database. Returns Map containing all imported file names with * corresponding value , depending on the success of import. * /*from w ww .ja v a2 s .co m*/ * @param importPoolDTOs {@link ImportRegexPoolDTO}- list of imported regex pool DTO. * @return Map<String, Boolean> */ @Override public Map<String, Boolean> importRegexGroups(List<ImportPoolDTO> importPoolDTOs) { Map<String, Boolean> resultMap = new HashMap<String, Boolean>(); if (!CollectionUtil.isEmpty(importPoolDTOs)) { for (ImportPoolDTO importRegexPoolDTO : importPoolDTOs) { if (null != importRegexPoolDTO) { String serializableFilePath = FileUtils.getFileNameOfTypeFromFolder( importRegexPoolDTO.getZipFileLocation(), SERIALIZATION_EXT); InputStream serializableFileStream = null; try { if (!StringUtil.isNullOrEmpty(serializableFilePath)) { serializableFileStream = new FileInputStream(serializableFilePath); Object deserializedObject = SerializationUtils.deserialize(serializableFileStream); if (deserializedObject instanceof List<?>) { boolean instanceOfRegexGroup = true; List<?> deserializedList = (List<?>) deserializedObject; for (Object object : deserializedList) { if (!(object instanceof RegexGroup)) { instanceOfRegexGroup = false; break; } } if (instanceOfRegexGroup) { // List of imported regex groups @SuppressWarnings("unchecked") final List<RegexGroup> importRegexGroupList = (List<RegexGroup>) deserializedObject; insertRegexGroups(importRegexGroupList); resultMap.put(importRegexPoolDTO.getZipFileName(), true); } else { resultMap.put(importRegexPoolDTO.getZipFileName(), false); } } else { resultMap.put(importRegexPoolDTO.getZipFileName(), false); } } else { resultMap.put(importRegexPoolDTO.getZipFileName(), false); } } catch (final FileNotFoundException fileNotFoundException) { LOGGER.error(fileNotFoundException, "Error while importing regex groups: ", fileNotFoundException.getMessage()); resultMap.put(importRegexPoolDTO.getZipFileName(), false); } catch (final DataAccessException dataAccessException) { LOGGER.error(dataAccessException, "Error while importing regex groups: ", dataAccessException.getMessage()); resultMap.put(importRegexPoolDTO.getZipFileName(), false); } } } } return resultMap; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
public List<DBInfoType> getUser(String user, String caller, String password, boolean ignoreDeleted) throws I2B2Exception, I2B2DAOException { String sql = null;/*from w w w . j a v a2 s . c o m*/ List<DBInfoType> queryResult = null; if (caller == null) { sql = "select * from pm_user_data where user_id = ? " + (password != null ? " and password = ? " : ""); if (ignoreDeleted) sql += " and status_cd<>'D'"; try { if (password == null) queryResult = jt.query(sql, getUser(true), user); else queryResult = jt.query(sql, getUser(false), user, password); } catch (DataAccessException e) { log.error(e.getMessage()); throw new I2B2DAOException("Database error in getting userdata with password"); } } else { sql = "select distinct" + " case upper(rr.COLUMN_CD)" + " when '@' then pud.USER_ID" + " when 'USER_ID' then pud.USER_ID" + " else null" + " end as USER_ID," + " case upper(rr.COLUMN_CD)" + " when '@' then pud.FULL_NAME" + " when 'FULL_NAME' then pud.FULL_NAME" + " else null" + " end as FULL_NAME," + " case upper(rr.COLUMN_CD)" + " when '@' then pud.PASSWORD" + " when 'PASSWORD' then pud.PASSWORD" + " else null" + " end as PASSWORD," + " case upper(rr.COLUMN_CD)" + " when '@' then pud.EMAIL" + " when 'EMAIL' then pud.EMAIL" + " else null" + " end as EMAIL " + " from " + " pm_user_data pud, pm_role_requirement rr" + " where " + //" pur.status_cd<>'D' and" + " rr.status_cd<>'D' and" + (ignoreDeleted ? " pud.STATUS_CD<>'D' and " : "") + //" pur.USER_ID = ? and " + " pud.user_id = ? and" + (password != null ? " password = ? and" : "") + " (rr.read_hivemgmt_CD = '@') and" + //OR (upper(rr.read_hivemgmt_CD) = upper(pur.USER_ROLE_CD)) and" + " upper(rr.table_cd) = 'PM_USER_DATA'"; try { if (password == null) queryResult = jt.query(sql, getUser(true), user); else queryResult = jt.query(sql, getUser(false), user, password); } catch (DataAccessException e) { log.error(e.getMessage()); throw new I2B2DAOException("Database error in getting userdata with password"); } } // String sql = "select * from pm_user_data where user_id = ? and password = ? and status_cd <> 'D'"; // log.info(sql + domainId + projectId + ownerId); return queryResult; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
public int setPassword(final String password, String caller) throws I2B2DAOException, I2B2Exception { int numRowsAdded = 0; try {/*w ww . j a v a 2 s . com*/ String addSql = "update pm_user_data " + "set password = ?, change_date = ?, changeby_char = ? where user_id = ?"; numRowsAdded = jt.update(addSql, password, Calendar.getInstance().getTime(), caller, caller); if (numRowsAdded == 0) throw new I2B2DAOException("User not updated, does it exist?"); } catch (DataAccessException e) { log.error("Dao deleteuser failed"); log.error(e.getMessage()); throw new I2B2DAOException("Data access error ", e); } // log.info(addSql + " " + numRowsAdded); log.debug("Number of rows deleted: " + numRowsAdded); return numRowsAdded; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
public int deleteApproval(String id, String project, String caller) throws I2B2DAOException, I2B2Exception { int numRowsAdded = 0; if ((validateRole(caller, "admin", null)) || (validateRole(caller, "manager", project))) { try {/*from w w w . java2 s . c o m*/ String addSql = "update pm_approvals " + "set status_cd = 'D' where approval_id = ?"; numRowsAdded = jt.update(addSql, id); if (numRowsAdded == 0) throw new I2B2DAOException("approval not updated, does it exist?"); } catch (DataAccessException e) { log.error("Dao deleteuser failed"); log.error(e.getMessage()); throw new I2B2DAOException("Data access error ", e); } } // log.info(addSql + " " + numRowsAdded); log.debug("Number of rows deleted: " + numRowsAdded); return numRowsAdded; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
public int deleteCell(String cell, String project, String caller) throws I2B2DAOException, I2B2Exception { int numRowsAdded = 0; if ((validateRole(caller, "admin", null)) || (validateRole(caller, "manager", project))) { try {//w w w .java 2 s .c o m String addSql = "update pm_cell_data " + "set status_cd = 'D' where project_path = ? and cell_id = ?"; numRowsAdded = jt.update(addSql, ((project == null || project.equals("")) ? "@" : project), cell); if (numRowsAdded == 0) throw new I2B2DAOException("Cell not updated, does it exist?"); } catch (DataAccessException e) { log.error("Dao deleteuser failed"); log.error(e.getMessage()); throw new I2B2DAOException("Data access error ", e); } } // log.info(addSql + " " + numRowsAdded); log.debug("Number of rows deleted: " + numRowsAdded); return numRowsAdded; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
public int deleteUser(final String user, String caller) throws I2B2DAOException, I2B2Exception { int numRowsAdded = 0; if (validateRole(caller, "admin", null)) { try {// w w w. j a v a 2s .c om String addSql = "update pm_user_data " + "set status_cd = 'D', change_date = ?, changeby_char = ? where user_id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, user); if (numRowsAdded == 0) throw new I2B2DAOException("User not updated, does it exist?"); } catch (DataAccessException e) { log.error("Dao deleteuser failed"); log.error(e.getMessage()); throw new I2B2DAOException("Data access error ", e); } } else { throw new I2B2DAOException("Access Denied for " + caller); } // log.info(addSql + " " + numRowsAdded); log.debug("Number of rows deleted: " + numRowsAdded); return numRowsAdded; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
public int deleteProject(final Object project, String caller) throws I2B2DAOException, I2B2Exception { int numRowsAdded = 0; if (validateRole(caller, "admin", null)) { try {/*from w w w . jav a2 s . co m*/ String addSql = "update pm_project_data " + "set status_cd = 'D', change_date = ? where project_id = ? and project_path = ? and changeby_char = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), ((ProjectType) project).getId(), ((ProjectType) project).getPath(), caller); if (numRowsAdded == 0) throw new I2B2DAOException("Project not updated, does it exist?"); } catch (DataAccessException e) { log.error("Dao deleteuser failed"); log.error(e.getMessage()); throw new I2B2DAOException("Data access error ", e); } } else { throw new I2B2DAOException("Access Denied for " + caller); } // log.info(addSql + " " + numRowsAdded); log.debug("Number of rows deleted: " + numRowsAdded); return numRowsAdded; }
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 ww .j a v a 2 s . c o m 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; }
From source file:edu.harvard.i2b2.pm.dao.PMDbDao.java
public int deleteParam(Object utype, final String project, String caller) throws I2B2DAOException, I2B2Exception { int numRowsAdded = 0; if (validateRole(caller, "admin", null) || validateRole(caller, "manager", project)) { try {//from w ww .jav a 2 s . com if (utype instanceof UserType) { String addSql = "update pm_user_params " + "set status_cd = 'D', change_date = ?, changeBy_char = ? where id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, ((UserType) utype).getParam().get(0).getId()); } else if (utype instanceof ProjectType) { if ((((ProjectType) utype).getUserName() != null) && (!((ProjectType) utype).getUserName().equals(""))) { String addSql = "update pm_project_user_params " + "set status_cd = 'D', change_date = ?, changeby_char = ? where id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, ((ProjectType) utype).getParam().get(0).getId()); } else { String addSql = "update pm_project_params " + "set status_cd = 'D', change_date = ?, changeby_char = ? where id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, ((ProjectType) utype).getParam().get(0).getId()); } } else if (utype instanceof ConfigureType) { if (((ConfigureType) utype).getParam().isEmpty() == false) // || (((ConfigureType) utype).getDomainId()).size() == 0)) { String addSql = "update pm_hive_params " + "set status_cd = 'D', change_date = ?, changeby_char = ? where id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, ((ConfigureType) utype).getParam().get(0).getId()); } else { String addSql = "update pm_hive_data " + "set status_cd = 'D', change_date = ?, changeby_char = ? where domain_id = ? and active = 0"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, ((ConfigureType) utype).getDomainId()); } } else if (utype instanceof CellDataType) { String addSql = "update pm_cell_params " + "set status_cd = 'D', change_date = ?, changeby_char = ? where id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, ((CellDataType) utype).getParam().get(0).getId()); } else if (utype instanceof ApprovalType) { String addSql = "update pm_approval_params " + "set status_cd = 'D', change_date = ?, changeby_char = ? where id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, ((ApprovalType) utype).getParam().get(0).getId()); } else if (utype instanceof GlobalDataType) { String addSql = "update pm_global_params " + "set status_cd = 'D', change_date = ?, changeby_char = ? where id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, ((GlobalDataType) utype).getParam().get(0).getId()); } else if (utype instanceof RoleType) { if (((RoleType) utype).getRole().equals("DATA_PROT")) { numRowsAdded += executeRemoveRole("DATA_PROT", caller, utype); } else if (((RoleType) utype).getRole().equals("DATA_DEID")) { numRowsAdded += executeRemoveRole("DATA_PROT", caller, utype); numRowsAdded += executeRemoveRole("DATA_DEID", caller, utype); } else if (((RoleType) utype).getRole().equals("DATA_LDS")) { numRowsAdded += executeRemoveRole("DATA_PROT", caller, utype); numRowsAdded += executeRemoveRole("DATA_DEID", caller, utype); numRowsAdded += executeRemoveRole("DATA_LDS", caller, utype); } else if (((RoleType) utype).getRole().equals("DATA_AGG")) { numRowsAdded += executeRemoveRole("DATA_PROT", caller, utype); numRowsAdded += executeRemoveRole("DATA_DEID", caller, utype); numRowsAdded += executeRemoveRole("DATA_LDS", caller, utype); numRowsAdded += executeRemoveRole("DATA_AGG", caller, utype); } else if (((RoleType) utype).getRole().equals("DATA_OBFSC")) { numRowsAdded += executeRemoveRole("DATA_PROT", caller, utype); numRowsAdded += executeRemoveRole("DATA_DEID", caller, utype); numRowsAdded += executeRemoveRole("DATA_LDS", caller, utype); numRowsAdded += executeRemoveRole("DATA_AGG", caller, utype); numRowsAdded += executeRemoveRole("DATA_OBFSC", caller, utype); } //admin track if ((((RoleType) utype).getRole().equals("MANAGER"))) { numRowsAdded += executeRemoveRole("MANAGER", caller, utype); } else if ((((RoleType) utype).getRole().equals("USER"))) { numRowsAdded += executeRemoveRole("MANAGER", caller, utype); numRowsAdded += executeRemoveRole("USER", caller, utype); } else { numRowsAdded += executeRemoveRole(((RoleType) utype).getRole(), caller, utype); } } if (numRowsAdded == 0) throw new I2B2DAOException("not updated, does it exist?"); } catch (DataAccessException e) { log.error("Dao deleteuser failed"); log.error(e.getMessage()); throw new I2B2DAOException("Data access error ", e); } } else if ((utype instanceof UserType) && (caller.equals(((UserType) utype).getUserName()))) { String addSql = "update pm_user_params " + "set status_cd = 'D', change_date = ? where user_id = ? and changeby_char = ? and id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, caller, ((UserType) utype).getParam().get(0).getId()); if (numRowsAdded == 0) throw new I2B2DAOException("Record does not exist or access denied."); } else if ((utype instanceof ProjectType) && (((ProjectType) utype).getUserName() != null) && (((ProjectType) utype).getUserName().equals(caller))) { String addSql = "update pm_project_user_params " + "set status_cd = 'D', change_date = ? where user_id = ? and changeby_char = ? and id = ?"; numRowsAdded = jt.update(addSql, Calendar.getInstance().getTime(), caller, caller, ((ProjectType) utype).getParam().get(0).getId()); if (numRowsAdded == 0) throw new I2B2DAOException("Record does not exist or access denied."); } else { throw new I2B2DAOException("Access Denied for " + caller); } // log.info(addSql + " " + numRowsAdded); log.debug("Number of rows deleted: " + numRowsAdded); return numRowsAdded; }