Example usage for java.sql ResultSet getBoolean

List of usage examples for java.sql ResultSet getBoolean

Introduction

In this page you can find the example usage for java.sql ResultSet getBoolean.

Prototype

boolean getBoolean(String columnLabel) throws SQLException;

Source Link

Document

Retrieves the value of the designated column in the current row of this ResultSet object as a boolean in the Java programming language.

Usage

From source file:com.sfs.whichdoctor.analysis.FinancialSummaryAnalysisDAOImpl.java

/**
 * Gets the running total./*  ww  w .jav a  2 s. c  om*/
 *
 * @param sqlWHERE the sql where
 * @param parameters the parameters
 * @param date the date
 * @param summaryId the summary id
 *
 * @return the running total
 */
@SuppressWarnings("unchecked")
private double getRunningTotal(final String sqlWHERE, final Collection<Object> parameters, final Date date,
        final int summaryId) {

    double runningTotal = 0;

    runningTotal = getBalance(sqlWHERE, parameters, date, true);

    // Get a list of all the transactions on the
    // current day in order to find balance
    StringBuffer findBalanceSql = new StringBuffer();
    findBalanceSql.append(this.getSQL().getValue("financialSummary/find"));
    findBalanceSql.append(sqlWHERE);
    findBalanceSql.append(" AND financial_summary.Issued = ?");
    findBalanceSql.append(this.sqlORDER);

    String field = df.format(date);
    parameters.add(field);

    dataLogger.info("SQL Query: " + findBalanceSql.toString());

    Collection<TransactionSummaryBean> transactions = new ArrayList<TransactionSummaryBean>();
    try {
        transactions = this.getJdbcTemplateReader().query(findBalanceSql.toString(), parameters.toArray(),
                new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        TransactionSummaryBean transaction = new TransactionSummaryBean();

                        transaction.setSummaryId(rs.getInt("SummaryId"));
                        transaction.setFinancialType(rs.getString("Class"));
                        transaction.setCategory(rs.getString("Object"));
                        transaction.setValue(rs.getDouble("Value"));
                        transaction.setNetValue(rs.getDouble("NetValue"));
                        transaction.setCancelled(rs.getBoolean("Cancelled"));

                        return transaction;
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        // No results found for this search
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }

    for (TransactionSummaryBean transaction : transactions) {
        if (transaction.getSummaryId() != summaryId) {
            if (!transaction.getCancelled()) {
                if (StringUtils.equalsIgnoreCase(transaction.getCategory(), "Debit")) {
                    runningTotal += transaction.getNetValue();
                }
                if (StringUtils.equalsIgnoreCase(transaction.getCategory(), "Receipt")) {
                    runningTotal -= transaction.getNetValue();
                }
                if (StringUtils.equalsIgnoreCase(transaction.getCategory(), "Credit")) {
                    if (StringUtils.equalsIgnoreCase(transaction.getFinancialType(), "Refund")) {
                        runningTotal += transaction.getNetValue();
                    } else {
                        runningTotal -= transaction.getNetValue();
                    }
                }
            }
        } else {
            return runningTotal;
        }
    }
    return runningTotal;
}

From source file:com.sfs.whichdoctor.dao.WhichDoctorDAOImpl.java

/**
 * Load history.//from w ww .j  ava  2s. c  o m
 *
 * @param rs the rs
 *
 * @return the which doctor bean
 *
 * @throws SQLException the SQL exception
 */
private WhichDoctorBean loadHistory(final ResultSet rs) throws SQLException {

    WhichDoctorBean whichdoctor = new WhichDoctorBean();

    whichdoctor.setGUID(rs.getInt("GUID"));
    whichdoctor.setId(rs.getInt("Id"));
    whichdoctor.setDescription(rs.getString("Description"));
    try {
        whichdoctor.setEntryCreatedDate(rs.getTimestamp("Created"));
    } catch (SQLException sqe) {
        dataLogger.debug("Error setting Created date: " + sqe.getMessage());
    }

    whichdoctor.setLogMessage(rs.getString("LogMessage"));
    whichdoctor.setActive(rs.getBoolean("Active"));

    UserBean user = new UserBean();
    user.setDN(rs.getString("CreatedBy"));
    user.setPreferredName(rs.getString("PreferredName"));
    user.setLastName(rs.getString("LastName"));
    whichdoctor.setEntryCreatedUser(user);

    return whichdoctor;
}

From source file:eionet.meta.dao.mysql.SchemaDAOImpl.java

/**
 * @see eionet.meta.dao.ISchemaDAO#getRootLevelSchemas(String)
 */// ww  w  .  j  av a2  s.  c o  m
@Override
public List<Schema> getRootLevelSchemas(String userName) {

    // Get the ID of 'Name' attribute beforehand.
    int nameAttrId = getNameAttributeId();

    // Now build the main sql, joining to ATTRIBUTE table via above-found ID of 'Name'.

    String sql = "select * ";
    if (nameAttrId > 0) {
        sql += ",ATTRIBUTE.VALUE as NAME ";
    }

    Map<String, Object> params = new HashMap<String, Object>();
    sql += "from T_SCHEMA ";

    if (nameAttrId > 0) {
        sql += "left outer join ATTRIBUTE on ";
        sql += "(T_SCHEMA.SCHEMA_ID=ATTRIBUTE.DATAELEM_ID and ATTRIBUTE.PARENT_TYPE=:attrParentType ";
        sql += "and ATTRIBUTE.M_ATTRIBUTE_ID=:nameAttrId) ";

        params.put("attrParentType", DElemAttribute.ParentType.SCHEMA.toString());
        params.put("nameAttrId", nameAttrId);
    }

    sql += "where (SCHEMA_SET_ID is null or SCHEMA_SET_ID<=0) ";

    if (StringUtils.isBlank(userName)) {
        sql += "and WORKING_COPY=false ";
        // sql += "and (WORKING_COPY=false and REG_STATUS=:regStatus) ";
        // params.put("regStatus", SchemaSet.RegStatus.RELEASED.toString());
    } else {
        sql += "and (WORKING_COPY=false or WORKING_USER=:workingUser) ";
        params.put("workingUser", userName);
    }

    sql += "order by ifnull(NAME,FILENAME), SCHEMA_ID";

    List<Schema> schema = getNamedParameterJdbcTemplate().query(sql, params, new RowMapper<Schema>() {
        @Override
        public Schema mapRow(ResultSet rs, int rowNum) throws SQLException {
            Schema schema = new Schema();
            schema.setId(rs.getInt("SCHEMA_ID"));
            schema.setFileName(rs.getString("FILENAME"));
            schema.setContinuityId(rs.getString("CONTINUITY_ID"));
            schema.setRegStatus(RegStatus.fromString(rs.getString("REG_STATUS")));
            schema.setWorkingCopy(rs.getBoolean("WORKING_COPY"));
            schema.setWorkingUser(rs.getString("WORKING_USER"));
            schema.setDateModified(rs.getTimestamp("DATE_MODIFIED"));
            schema.setUserModified(rs.getString("USER_MODIFIED"));
            schema.setComment(rs.getString("COMMENT"));
            schema.setCheckedOutCopyId(rs.getInt("CHECKEDOUT_COPY_ID"));
            schema.setOtherDocument(rs.getBoolean("OTHER_DOCUMENT"));

            String name = rs.getString("NAME");
            if (StringUtils.isNotBlank(name)) {
                schema.setAttributeValues(Collections.singletonMap("Name", Collections.singletonList(name)));
            }

            return schema;
        }
    });

    return schema;
}

From source file:com.concursive.connect.web.modules.profile.dao.ProjectIndexer.java

/**
 * Given a database and an indexer, this method will add content to the
 * searchable index/*  w w w.  j  av a2 s  .  c o m*/
 *
 * @param writer  Description of the Parameter
 * @param db      Description of the Parameter
 * @param context Servlet context
 * @throws SQLException Description of the Exception
 * @throws IOException  Description of the Exception
 */
public void add(IIndexerService writer, Connection db, IndexerContext context) throws Exception {
    long startTime = System.currentTimeMillis();
    int count = 0;
    PreparedStatement pst = db.prepareStatement(
            "SELECT instance_id, project_id, title, shortdescription, description, requestedby, requesteddept, entered, modified, "
                    + "category_id, subcategory1_id, "
                    + "allow_guests, membership_required, allows_user_observers, approvaldate, closedate, portal, "
                    + "city, state, postalcode, keywords, " + "rating_count, rating_value, rating_avg "
                    + "FROM projects " + "WHERE project_id > -1 ");
    ResultSet rs = pst.executeQuery();
    while (rs.next() && context.getEnabled()) {
        ++count;
        // read the record
        Project project = new Project();
        project.setInstanceId(rs.getInt("instance_id"));
        project.setId(rs.getInt("project_id"));
        project.setTitle(rs.getString("title"));
        project.setShortDescription(rs.getString("shortdescription"));
        project.setDescription(rs.getString("description"));
        project.setRequestedBy(rs.getString("requestedby"));
        project.setRequestedByDept(rs.getString("requesteddept"));
        project.setEntered(rs.getTimestamp("entered"));
        project.setModified(rs.getTimestamp("modified"));
        project.setCategoryId(DatabaseUtils.getInt(rs, "category_id"));
        project.setSubCategory1Id(DatabaseUtils.getInt(rs, "subcategory1_id"));
        project.getFeatures().setAllowGuests(rs.getBoolean("allow_guests"));
        project.getFeatures().setMembershipRequired(rs.getBoolean("membership_required"));
        project.getFeatures().setAllowParticipants(rs.getBoolean("allows_user_observers"));
        project.setApprovalDate(rs.getTimestamp("approvaldate"));
        if (project.getApprovalDate() != null) {
            project.setApproved(true);
        }
        project.setCloseDate(rs.getTimestamp("closedate"));
        if (project.getCloseDate() != null) {
            project.setClosed(true);
        }
        project.setPortal(rs.getBoolean("portal"));
        project.setCity(rs.getString("city"));
        project.setState(rs.getString("state"));
        project.setPostalCode(rs.getString("postalcode"));
        project.setKeywords(rs.getString("keywords"));
        project.setRatingCount(rs.getInt("rating_count"));
        project.setRatingValue(rs.getInt("rating_value"));
        project.setRatingAverage((rs.getDouble("rating_avg")));
        // add the document
        if (writer instanceof LuceneIndexer) {
            LuceneIndexer luceneWriter = (LuceneIndexer) writer;
            luceneWriter.indexAddItem(project, false, context.getIndexType());
        } else {
            // Don't know specifically what to do...
            writer.indexAddItem(project, false);
        }
    }
    rs.close();
    pst.close();
    long endTime = System.currentTimeMillis();
    long totalTime = endTime - startTime;
    LOG.info("Finished: " + count + " took " + totalTime + " ms");
}

From source file:com.adito.webforwards.JDBCWebForwardDatabase.java

/**
 * @param rs// w w  w.jav  a  2  s .c om
 * @return WebForward
 * @throws Exception
 */
WebForward buildWebForward(ResultSet rs) throws Exception {
    int id = rs.getInt("id");
    int type = rs.getInt("type");
    String category = rs.getString("category");
    String name = rs.getString("short_name");
    String description = rs.getString("description");
    String url = rs.getString("destination_url");
    boolean autoStart = rs.getBoolean("auto_start");
    Calendar created = JDBCUtil.getCalendar(rs, "date_created");
    Calendar amended = JDBCUtil.getCalendar(rs, "date_amended");
    int realmID = rs.getInt("realm_id");

    if (type == WebForward.TYPE_PATH_BASED_REVERSE_PROXY || type == WebForward.TYPE_HOST_BASED_REVERSE_PROXY) {
        JDBCPreparedStatement ps2 = db.getStatement("getWebForward.reverseProxy.selectById");
        try {
            ps2.setInt(1, id);
            ResultSet rs2 = ps2.executeQuery();
            try {
                StringBuffer paths = new StringBuffer();
                String hostHeader = "";
                while (rs2.next()) {
                    if (paths.length() > 0) {
                        paths.append('\n');
                    }
                    paths.append(rs2.getString("path"));
                }
                JDBCPreparedStatement ps3 = db.getStatement("getWebForward.reverseProxyOptions.selectById");
                try {
                    ps3.setInt(1, id);
                    ResultSet rs3 = ps3.executeQuery();
                    try {
                        String authUsername = "";
                        String authPassword = "";
                        String preferredAuthScheme = HttpAuthenticatorFactory.BASIC;
                        boolean activeDNS = false;
                        String formType = "";
                        String formParameters = "";
                        String charset = null;
                        if (rs3.next()) {
                            authUsername = rs3.getString("authentication_username");
                            authPassword = rs3.getString("authentication_password");
                            preferredAuthScheme = rs3.getString("preferred_authentication_scheme");
                            activeDNS = rs3.getInt("active_dns") == 1;
                            hostHeader = rs3.getString("host_header");
                            formType = rs3.getString("form_type");
                            formParameters = rs3.getString("form_parameters");
                            charset = rs3.getString("charset");
                        }
                        return new ReverseProxyWebForward(realmID, id, type, url, name, description, category,
                                authUsername, authPassword, preferredAuthScheme, formType, formParameters,
                                paths.toString(), hostHeader, activeDNS, autoStart, created, amended, charset);
                    } finally {
                        rs3.close();
                    }
                } finally {
                    ps3.releasePreparedStatement();
                }
            } finally {
                rs2.close();
            }
        } finally {
            ps2.releasePreparedStatement();
        }

    } else if (type == WebForward.TYPE_REPLACEMENT_PROXY) {
        JDBCPreparedStatement ps3 = db.getStatement("getWebForward.replacementProxyOptions.selectById");
        try {
            ps3.setInt(1, id);
            ResultSet rs3 = ps3.executeQuery();
            try {
                String authUsername = "";
                String authPassword = "";
                String preferredAuthScheme = HttpAuthenticatorFactory.BASIC;
                String encoding = "";
                String formType = "";
                String formParameters = "";
                PropertyList restrictToHosts = new PropertyList();
                if (rs3.next()) {
                    authUsername = rs3.getString("authentication_username");
                    authPassword = rs3.getString("authentication_password");
                    preferredAuthScheme = rs3.getString("preferred_authentication_scheme");
                    encoding = rs3.getString("encoding");
                    restrictToHosts.setAsPropertyText(rs3.getString("restrict_to_hosts"));
                    formType = rs3.getString("form_type");
                    formParameters = rs3.getString("form_parameters");
                }
                return new ReplacementProxyWebForward(realmID, id, url, name, description, category,
                        authUsername, authPassword, preferredAuthScheme, encoding, restrictToHosts, formType,
                        formParameters, autoStart, created, amended);
            } finally {
                rs3.close();
            }
        } finally {
            ps3.releasePreparedStatement();
        }

    } else {
        return new TunneledSiteWebForward(realmID, id, url, name, description, category, autoStart, created,
                amended);
    }

}

From source file:eionet.meta.dao.mysql.SchemaDAOImpl.java

/**
 * @see eionet.meta.dao.ISchemaDAO#getWorkingCopyOfSchema(int)
 */// w  w w.  j a va 2s  .c om
@Override
public Schema getWorkingCopyOfSchema(int schemaId) {

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("checkedOutCopyId", schemaId);

    Schema result = getNamedParameterJdbcTemplate().queryForObject(GET_WORKING_COPY_OF_SQL, parameters,
            new RowMapper<Schema>() {
                @Override
                public Schema mapRow(ResultSet rs, int rowNum) throws SQLException {
                    Schema schema = new Schema();
                    schema.setId(rs.getInt("SCHEMA_ID"));
                    schema.setFileName(rs.getString("FILENAME"));
                    schema.setContinuityId(rs.getString("CONTINUITY_ID"));
                    schema.setRegStatus(RegStatus.fromString(rs.getString("REG_STATUS")));
                    schema.setWorkingCopy(rs.getBoolean("WORKING_COPY"));
                    schema.setWorkingUser(rs.getString("WORKING_USER"));
                    schema.setDateModified(rs.getTimestamp("DATE_MODIFIED"));
                    schema.setUserModified(rs.getString("USER_MODIFIED"));
                    schema.setComment(rs.getString("COMMENT"));
                    schema.setCheckedOutCopyId(rs.getInt("CHECKEDOUT_COPY_ID"));
                    schema.setOtherDocument(rs.getBoolean("OTHER_DOCUMENT"));
                    return schema;
                }
            });
    return result;
}

From source file:eionet.meta.dao.mysql.SchemaDAOImpl.java

/**
 * @see eionet.meta.dao.ISchemaDAO#getWorkingCopiesOf(java.lang.String)
 *//*from  w w  w.  j  ava2 s.  c  om*/
@Override
public List<Schema> getWorkingCopiesOf(String userName) {

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("userName", userName);

    List<Schema> resultList = getNamedParameterJdbcTemplate().query(GET_WORKING_COPIES_SQL, parameters,
            new RowMapper<Schema>() {
                @Override
                public Schema mapRow(ResultSet rs, int rowNum) throws SQLException {
                    Schema schema = new Schema();
                    schema.setId(rs.getInt("SCHEMA_ID"));
                    schema.setFileName(rs.getString("FILENAME"));
                    schema.setContinuityId(rs.getString("CONTINUITY_ID"));
                    schema.setRegStatus(RegStatus.fromString(rs.getString("REG_STATUS")));
                    schema.setWorkingCopy(rs.getBoolean("WORKING_COPY"));
                    schema.setWorkingUser(rs.getString("WORKING_USER"));
                    schema.setDateModified(rs.getTimestamp("DATE_MODIFIED"));
                    schema.setUserModified(rs.getString("USER_MODIFIED"));
                    schema.setComment(rs.getString("COMMENT"));
                    schema.setCheckedOutCopyId(rs.getInt("CHECKEDOUT_COPY_ID"));
                    schema.setOtherDocument(rs.getBoolean("OTHER_DOCUMENT"));
                    return schema;
                }
            });

    return resultList;
}

From source file:com.flexive.ejb.beans.UserGroupEngineBean.java

/**
 * {@inheritDoc}//  w w w. ja  v a  2 s  . c  o m
 */
@Override
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public UserGroup load(long groupId) throws FxApplicationException {
    Connection con = null;
    Statement stmt = null;
    String sql = "SELECT MANDATOR,NAME,COLOR,AUTOMANDATOR,ISSYSTEM FROM " + TBL_USERGROUPS + " WHERE ID="
            + groupId;
    try {

        // Obtain a database connection
        con = Database.getDbConnection();

        // Create the new workflow instance
        stmt = con.createStatement();

        // Build statement
        ResultSet rs = stmt.executeQuery(sql);

        // Does the group exist at all?
        if (rs == null || !rs.next()) {
            FxNotFoundException nfe = new FxNotFoundException("ex.account.group.notFound.id", groupId);
            if (LOG.isInfoEnabled())
                LOG.info(nfe);
            throw nfe;
        }
        long autoMandator = rs.getLong(4);
        if (rs.wasNull())
            autoMandator = -1;
        return new UserGroup(groupId, rs.getLong(1), autoMandator, rs.getBoolean(5), rs.getString(2),
                rs.getString(3));

    } catch (SQLException exc) {
        FxLoadException de = new FxLoadException(exc, "ex.usergroup.sqlError", exc.getMessage(), sql);
        LOG.error(de);
        throw de;
    } finally {
        Database.closeObjects(UserGroupEngineBean.class, con, stmt);
    }
}

From source file:eionet.meta.dao.mysql.SchemaDAOImpl.java

/**
 * @see eionet.meta.dao.ISchemaDAO#getSchemaVersions(String, java.lang.String, int...)
 *//* w  ww.  j a va 2 s . co  m*/
@Override
public List<Schema> getSchemaVersions(String userName, String continuityId, int... excludeIds) {

    if (StringUtils.isBlank(continuityId)) {
        throw new IllegalArgumentException("Continuity id must not be blank!");
    }

    String sql = "select * from T_SCHEMA where (SCHEMA_SET_ID is null or SCHEMA_SET_ID<=0) and WORKING_COPY=false"
            + " and CONTINUITY_ID=:continuityId";
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("continuityId", continuityId);

    if (StringUtils.isBlank(userName)) {
        sql += " and REG_STATUS=:regStatus";
        params.put("regStatus", RegStatus.RELEASED.toString());
    }

    if (excludeIds != null && excludeIds.length > 0) {
        sql += " and SCHEMA_ID not in (:excludeIds)";
        params.put("excludeIds", Arrays.asList(ArrayUtils.toObject(excludeIds)));
    }
    sql += " order by SCHEMA_ID desc";

    List<Schema> resultList = getNamedParameterJdbcTemplate().query(sql, params, new RowMapper<Schema>() {
        @Override
        public Schema mapRow(ResultSet rs, int rowNum) throws SQLException {
            Schema ss = new Schema();
            ss.setId(rs.getInt("SCHEMA_ID"));
            ss.setSchemaSetId(rs.getInt("SCHEMA_SET_ID"));
            ss.setFileName(rs.getString("FILENAME"));
            ss.setContinuityId(rs.getString("CONTINUITY_ID"));
            ss.setRegStatus(RegStatus.fromString(rs.getString("REG_STATUS")));
            ss.setWorkingCopy(rs.getBoolean("WORKING_COPY"));
            ss.setWorkingUser(rs.getString("WORKING_USER"));
            ss.setDateModified(rs.getTimestamp("DATE_MODIFIED"));
            ss.setUserModified(rs.getString("USER_MODIFIED"));
            ss.setComment(rs.getString("COMMENT"));
            ss.setCheckedOutCopyId(rs.getInt("CHECKEDOUT_COPY_ID"));
            ss.setOtherDocument(rs.getBoolean("OTHER_DOCUMENT"));
            return ss;
        }
    });

    return resultList;
}

From source file:com.sfs.whichdoctor.dao.AccreditationDAOImpl.java

/**
 * Gets the training summary./*from   w w  w .java2  s .co  m*/
 *
 * @param guid the guid
 * @param type the type
 *
 * @return the training summary
 *
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
@SuppressWarnings("unchecked")
public final TreeMap<String, AccreditationBean[]> getTrainingSummary(final int guid, final String type)
        throws WhichDoctorDaoException {

    if (type == null) {
        throw new NullPointerException("Training type cannot be null");
    }

    dataLogger.info("Getting " + type + " Training Summary for Member GUID: " + guid);

    TreeMap<String, AccreditationBean[]> summary = new TreeMap<String, AccreditationBean[]>();

    Collection<AccreditationBean> accreditations = new ArrayList<AccreditationBean>();
    try {
        accreditations = this.getJdbcTemplateReader().query(this.getSQL().getValue("accreditation/loadSummary"),
                new Object[] { guid, type }, new RowMapper() {
                    public Object mapRow(final ResultSet rs, final int rowNum) throws SQLException {
                        AccreditationBean accreditation = new AccreditationBean();

                        accreditation.setAbbreviation(rs.getString("AccreditationTypeAbbreviation"));
                        accreditation.setAccreditationType(rs.getString("AccreditationType"));
                        accreditation.setSpecialtyType(rs.getString("SpecialtyTypeClass"));
                        accreditation.setSpecialtySubType(rs.getString("SpecialtyTypeName"));
                        accreditation.setSpecialtyTypeAbbreviation(rs.getString("SpecialtyTypeAbbreviation"));
                        accreditation.setCore(rs.getBoolean("Core"));
                        accreditation.setWeeksApproved(rs.getInt("WeeksApproved"));
                        accreditation.setWeeksCertified(rs.getInt("WeeksCertified"));

                        // The active flag holds whether the accreditation is excess
                        boolean active = true;

                        String trainingClass = rs.getString("TrainingClass");
                        if (StringUtils.contains(trainingClass, "nterrupted")
                                || StringUtils.contains(trainingClass, "ontinuing")) {
                            active = false;
                        }
                        accreditation.setActive(active);

                        return accreditation;
                    }
                });

    } catch (IncorrectResultSizeDataAccessException ie) {
        dataLogger.debug("No results found for search: " + ie.getMessage());
    }

    for (AccreditationBean acrd : accreditations) {
        if (acrd.getActive()) {

            // Generate index key
            String specialtyAbbreviation = acrd.getAccreditationType();
            String specialtyTypeName = acrd.getSpecialtyType();
            if (StringUtils.isNotBlank(acrd.getAbbreviation())) {
                specialtyAbbreviation = acrd.getAbbreviation();
            }
            if (StringUtils.isNotBlank(acrd.getSpecialtySubType())) {
                specialtyTypeName = acrd.getSpecialtyType() + " - " + acrd.getSpecialtySubType();
            }
            String specialtyKey = specialtyAbbreviation + ": " + specialtyTypeName;

            AccreditationBean core = new AccreditationBean();
            core.setAbbreviation(acrd.getAbbreviation());
            core.setAccreditationType(acrd.getAccreditationType());
            core.setCore(true);
            core.setSpecialtyType(acrd.getSpecialtyType());
            core.setSpecialtySubType(acrd.getSpecialtySubType());
            core.setSpecialtyTypeAbbreviation(acrd.getSpecialtyTypeAbbreviation());

            AccreditationBean nonCore = new AccreditationBean();
            nonCore.setAbbreviation(acrd.getAbbreviation());
            nonCore.setAccreditationType(acrd.getAccreditationType());
            nonCore.setCore(false);
            nonCore.setSpecialtyType(acrd.getSpecialtyType());
            nonCore.setSpecialtySubType(acrd.getSpecialtySubType());
            nonCore.setSpecialtyTypeAbbreviation(acrd.getSpecialtyTypeAbbreviation());

            if (summary.containsKey(specialtyKey)) {
                // Specialty exists in TreeMap -> Get array and modify
                try {
                    AccreditationBean[] existing = summary.get(specialtyKey);
                    core = existing[0];
                    nonCore = existing[1];
                } catch (Exception e) {
                    dataLogger.error("Error loading existing training summary item: " + e.getMessage());
                }
            }

            // Add to the relevant core/nonCore running totals
            if (acrd.getCore()) {
                core.setWeeksApproved(core.getWeeksApproved() + acrd.getWeeksApproved());
                core.setWeeksCertified(core.getWeeksCertified() + acrd.getWeeksCertified());
            } else {
                nonCore.setWeeksApproved(nonCore.getWeeksApproved() + acrd.getWeeksApproved());
                nonCore.setWeeksCertified(nonCore.getWeeksCertified() + acrd.getWeeksCertified());
            }

            // Set accreditation details
            AccreditationBean[] details = new AccreditationBean[] { core, nonCore };

            // Add accreditation to map
            summary.put(specialtyKey, details);
        }
    }
    return summary;
}