Example usage for org.springframework.dao DataAccessException getMessage

List of usage examples for org.springframework.dao DataAccessException getMessage

Introduction

In this page you can find the example usage for org.springframework.dao DataAccessException getMessage.

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

From source file:edu.duke.cabig.c3pr.dao.PersonUserDao.java

/**
 * Update database with remote content./*from   w w w .j a  v a  2s . com*/
 *
 * @param remoteResearchStaffList
 *            the remote research staff list
 */
private void updateDatabaseWithRemoteContent(List<RemotePersonUser> remoteResearchStaffList) {

    try {
        for (RemotePersonUser remoteResearchStaff : remoteResearchStaffList) {
            List<PersonUser> researchStaffFromDatabase = getByExternalIdentifierFromLocal(
                    remoteResearchStaff.getExternalId());
            PersonUser preExistingStaff = null;
            if (researchStaffFromDatabase.size() > 0) {
                // this guy already exists as remote staff...simply update the collections . i.e contact mech and orgs.
                preExistingStaff = researchStaffFromDatabase.get(0);
                updateContactMechanisms(preExistingStaff, remoteResearchStaff);
                for (HealthcareSite healthcareSite : remoteResearchStaff.getHealthcareSites()) {
                    if (!preExistingStaff.getHealthcareSites().contains(healthcareSite)) {
                        preExistingStaff.addHealthcareSite(healthcareSite);
                    }
                }
                save(preExistingStaff);
            } else {
                // Ensure the staff has an organization and that its assignedId is unique.
                if (remoteResearchStaff.getHealthcareSites().size() > 0) {
                    PersonUser researchStaffWithMatchingAssignedIdentifier = getByAssignedIdentifierFromLocal(
                            remoteResearchStaff.getAssignedIdentifier());
                    if (researchStaffWithMatchingAssignedIdentifier == null) {
                        createResearchStaff(remoteResearchStaff);
                    } else {
                        log.error("Unable to save Remote Staff : " + remoteResearchStaff.getFullName()
                                + " as it's NCI Identifier: " + remoteResearchStaff.getAssignedIdentifier()
                                + " is already in the database.");
                    }
                } else {
                    log.error(
                            "Unable to save this Remote Staff as it doesn't have a healthcareSite associated with it."
                                    + remoteResearchStaff.getFullName());
                }
            }
        }
        getHibernateTemplate().flush();
    } catch (DataAccessException e) {
        log.error(e.getMessage());
    } catch (C3PRBaseException e) {
        log.error(e.getMessage());
    }
}

From source file:edu.harvard.i2b2.crc.dao.DblookupDao.java

public List<DblookupType> findDblookups() throws DataAccessException, I2B2DAOException {
    String sql = "SELECT * FROM " + dbluTable + " WHERE" + keyOrder;
    List<DblookupType> queryResult = null;
    try {//from ww  w.  j  av a 2s.c om
        queryResult = jt.query(sql, getMapper(), domainId, userId);
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        throw e;
    }
    log.info("result size = " + queryResult.size());
    return queryResult;
}

From source file:edu.harvard.i2b2.crc.dao.DblookupDao.java

public List<DblookupType> getDblookup(final SetDblookupType dblookupType)
        throws DataAccessException, I2B2Exception {
    String sql = "SELECT * FROM " + dbluTable + " WHERE c_project_path=? AND " + keyOrder;
    List<DblookupType> queryResult = null;
    try {/*  www  .  java 2s .co m*/
        queryResult = jt.query(sql, getMapper(), slashSandwich(dblookupType.getProjectPath()),
                dblookupType.getDomainId(), dblookupType.getOwnerId());
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        e.printStackTrace();
        throw new I2B2DAOException("Database error");
    }
    return queryResult;
}

From source file:edu.harvard.i2b2.crc.dao.DblookupDao.java

public List<DblookupType> getDblookup(String column, String value) throws DataAccessException, I2B2Exception {
    String sql = "SELECT * FROM " + dbluTable + " WHERE ";
    String v = value, s = column.toLowerCase();
    List<DblookupType> queryResult = null;
    try {/* ww w  . j  av  a2  s. c  o  m*/
        if (s.equalsIgnoreCase("domain_id")) {
            sql += keyOrder;
            queryResult = jt.query(sql, getMapper(), value, userId);
        } else if (s.equalsIgnoreCase("owner_id")) {
            sql += keyOrder;
            queryResult = jt.query(sql, getMapper(), domainId, value);
        } else {
            sql += "c_" + column + "=? AND " + keyOrder;
            if (s.equalsIgnoreCase("project_path")) {
                v = slashSandwich(value);
            } else {
            }
            queryResult = jt.query(sql, getMapper(), v, domainId, userId);
        }
        log.info(sql + "(c_" + column + "=" + v + ", domainId=" + domainId + ", userId=" + userId
                + ") -- # of entries found: " + queryResult.size());
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        e.printStackTrace();
        throw new I2B2DAOException("Database error");
    }
    return queryResult;
}

From source file:edu.harvard.i2b2.crc.dao.DblookupDao.java

public int deleteDblookup(final DeleteDblookupType dblookupType) throws DataAccessException, I2B2Exception {
    int numRowsDeleted = 0;
    String sql = "DELETE FROM " + dbluTable + " WHERE c_project_path=? AND " + key;
    try {/*from ww  w .  jav a 2s . co m*/
        numRowsDeleted = jt.update(sql, slashSandwich(dblookupType.getProjectPath()),
                dblookupType.getDomainId(), dblookupType.getOwnerId());
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        e.printStackTrace();
        throw new I2B2DAOException("Database error");
    }
    return numRowsDeleted;
}

From source file:edu.harvard.i2b2.im.dao.DblookupDao.java

public List<DblookupType> getDblookup(final SetDblookupType dblookupType)
        throws DataAccessException, I2B2Exception {
    String sql = "SELECT * FROM " + dbluTable + " WHERE c_project_path=? AND " + keyOrder;
    List<DblookupType> queryResult = null;
    try {/*from w ww.  j  av a2s. c o m*/
        queryResult = jt.query(sql, getMapper(), slashEnd(dblookupType.getProjectPath()),
                dblookupType.getDomainId(), dblookupType.getOwnerId());
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        e.printStackTrace();
        throw new I2B2DAOException("Database error");
    }
    return queryResult;
}

From source file:edu.harvard.i2b2.im.dao.DblookupDao.java

public List<DblookupType> getDblookup(String column, String value) throws DataAccessException, I2B2Exception {
    String sql = "SELECT * FROM " + dbluTable + " WHERE ";
    String v = value, s = column.toLowerCase();
    List<DblookupType> queryResult = null;
    try {//from ww w .j  a  v  a2s  .  c  o  m
        if (s.equalsIgnoreCase("domain_id")) {
            sql += keyOrder;
            queryResult = jt.query(sql, getMapper(), value, userId);
        } else if (s.equalsIgnoreCase("owner_id")) {
            sql += keyOrder;
            queryResult = jt.query(sql, getMapper(), domainId, value);
        } else {
            sql += "c_" + column + "=? AND " + keyOrder;
            if (s.equalsIgnoreCase("project_path")) {
                v = slashEnd(value);
            } else {
            }
            queryResult = jt.query(sql, getMapper(), v, domainId, userId);
        }
        log.info(sql + "(c_" + column + "=" + v + ", domainId=" + domainId + ", userId=" + userId
                + ") -- # of entries found: " + queryResult.size());
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        e.printStackTrace();
        throw new I2B2DAOException("Database error");
    }
    return queryResult;
}

From source file:edu.harvard.i2b2.im.dao.DblookupDao.java

public int deleteDblookup(final DeleteDblookupType dblookupType) throws DataAccessException, I2B2Exception {
    int numRowsDeleted = 0;
    String sql = "DELETE FROM " + dbluTable + " WHERE c_project_path=? AND " + key;
    try {//w w  w . j a v  a  2 s  .  co  m
        numRowsDeleted = jt.update(sql, slashEnd(dblookupType.getProjectPath()), dblookupType.getDomainId(),
                dblookupType.getOwnerId());
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        e.printStackTrace();
        throw new I2B2DAOException("Database error");
    }
    return numRowsDeleted;
}

From source file:edu.harvard.i2b2.im.dao.IMDbDao.java

public List<DBInfoType> getDbLookupByHiveOwner(String domainId, String ownerId)
        throws I2B2Exception, I2B2DAOException {
    String metadataSchema = getIMSchema();
    String sql = "select * from " + metadataSchema
            + "im_db_lookup where LOWER(c_domain_id) = ? and c_project_path = ? and (LOWER(c_owner_id) = ? or c_owner_id ='@') order by c_project_path";
    String projectId = "@";
    //      log.info(sql + domainId + projectId + ownerId);
    List queryResult = null;/* w  ww  .  j  a  v a  2 s . co m*/
    try {
        queryResult = jt.query(sql, getMapper(), domainId.toLowerCase(), projectId, ownerId.toLowerCase());
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        throw new I2B2DAOException("Database error: " + e.getMessage());
    }
    return queryResult;

    //      List<DBInfoType> dataSourceLookupList = 
    //         this.query(sql, new Object[]{domainId,projectId,ownerId}, new mapper());
    //      return dataSourceLookupList;
}

From source file:edu.harvard.i2b2.im.dao.IMDbDao.java

@SuppressWarnings("unchecked")
public List<DBInfoType> getDbLookupByHiveProjectOwner(String domainId, String projectId, String ownerId)
        throws I2B2Exception, I2B2DAOException {
    String metadataSchema = getIMSchema();
    String sql = "select * from " + metadataSchema
            + "im_db_lookup where LOWER(c_domain_id) = ? and LOWER(c_project_path) like  ? and (LOWER(c_owner_id) =? or c_owner_id = '@') order by c_project_path"; // desc  c_owner_id desc"; 
    //      List<DBInfoType> dataSourceLookupList = this.query(sql, new Object[]{domainId,projectId+"%",ownerId},new int[]{Types.VARCHAR,Types.VARCHAR,Types.VARCHAR},new mapper()  );
    //      return dataSourceLookupList;
    //      log.info(sql + domainId + projectId + ownerId);
    List queryResult = null;/*from   www . jav a  2  s.com*/
    try {
        queryResult = jt.query(sql, getMapper(), domainId.toLowerCase(), projectId.toLowerCase(),
                ownerId.toLowerCase());
    } catch (DataAccessException e) {
        log.error(e.getMessage());
        throw new I2B2DAOException("Database error:" + e.getMessage());
    }
    return queryResult;

}