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:edu.ku.brc.specify.datamodel.Preparation.java

/**
 * @return//w w w.  j  a  va  2 s  . c  om
 */
@Transient
public Boolean getIsOnLoan() {
    if (isOnLoan == null) {
        Connection conn = null;
        Statement stmt = null;
        try {
            conn = DBConnection.getInstance().createConnection();
            if (conn != null) {
                stmt = conn.createStatement();
                String sql = "SELECT p.CountAmt, lp.Quantity, lp.QuantityResolved, lp.QuantityReturned, lp.IsResolved FROM preparation p "
                        + "INNER JOIN loanpreparation lp ON p.PreparationID = lp.PreparationID WHERE p.PreparationID = "
                        + getId();
                ResultSet rs = stmt.executeQuery(sql);

                int totalOnLoan = 0;
                Integer prepQty = null;

                while (rs.next()) {
                    prepQty = rs.getObject(1) != null ? rs.getInt(1) : 0;
                    //System.err.println("\nprepQty "+prepQty);

                    boolean isResolved = rs.getObject(5) != null ? rs.getBoolean(5) : false;

                    int loanQty = rs.getObject(2) != null ? rs.getInt(2) : 0;
                    int qtyRes = rs.getObject(3) != null ? rs.getInt(3) : 0;
                    //int qtyRtn  = rs.getObject(4) != null ? rs.getInt(4) : 0;

                    //System.err.println("loanQty "+loanQty);
                    //System.err.println("qtyRes  "+qtyRes);
                    //System.err.println("qtyRtn  "+qtyRtn);

                    if (isResolved && qtyRes != loanQty) // this shouldn't happen
                    {
                        qtyRes = loanQty;
                    }

                    totalOnLoan += loanQty - qtyRes;
                }
                rs.close();

                if (prepQty == null) {
                    return false;
                }

                isOnLoan = totalOnLoan > 0;
                //System.err.println("totalOnLoan "+totalOnLoan);
                //System.err.println("isOnLoan    "+isOnLoan);

            } else {
                UsageTracker.incrNetworkUsageCount();
            }

        } catch (SQLException ex) {
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(Preparation.class, ex);
            UsageTracker.incrSQLUsageCount();
            ex.printStackTrace();

        } finally {
            if (stmt != null) {
                try {
                    stmt.close();
                } catch (SQLException ex) {
                }
            }
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException ex) {
                }
            }
        }
    }
    return isOnLoan == null ? false : isOnLoan;
}

From source file:hoot.services.writers.review.ReviewPrepareDbWriter.java

protected Map<Long, Object> getParseableElementRecords(final long mapId, final ElementType elementType,
        final int limit, final int offset) throws InstantiationException, IllegalAccessException,
        ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
    Map<Long, Object> retMap = new LinkedHashMap<Long, Object>();
    final Element prototype = ElementFactory.getInstance().create(mapId, elementType, conn);
    String tableName = prototype.getElementTable().getTableName();
    String idFieldName = ColumnMetadata.getColumnMetadata(prototype.getElementIdField()).getName();

    String POSTGRESQL_DRIVER = "org.postgresql.Driver";
    Statement stmt = null;// ww w .j a va 2  s .co m
    try {
        Class.forName(POSTGRESQL_DRIVER);

        stmt = conn.createStatement();

        String sql = "select * from " + tableName + "_" + mapId + " where " + "EXIST(tags, 'uuid') = TRUE "
                + " order by " + idFieldName + " limit " + limit + " offset " + offset;
        stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql);

        while (rs.next()) {

            if (elementType == ElementType.Node) {
                CurrentNodes nodes = new CurrentNodes();
                nodes.setId(rs.getLong("id"));

                nodes.setLatitude(rs.getInt("latitude"));
                nodes.setLongitude(rs.getInt("longitude"));
                nodes.setChangesetId(rs.getLong("changeset_id"));
                nodes.setVisible(rs.getBoolean("visible"));
                nodes.setTimestamp(rs.getTimestamp("timestamp"));
                nodes.setTile(rs.getLong("tile"));
                nodes.setVersion(rs.getLong("version"));
                nodes.setTags(rs.getObject("tags"));
                retMap.put(nodes.getId(), nodes);
            } else if (elementType == ElementType.Way) {
                CurrentWays ways = new CurrentWays();
                ways.setId(rs.getLong("id"));

                ways.setChangesetId(rs.getLong("changeset_id"));
                ways.setVisible(rs.getBoolean("visible"));
                ways.setTimestamp(rs.getTimestamp("timestamp"));
                ways.setVersion(rs.getLong("version"));
                ways.setTags(rs.getObject("tags"));
                retMap.put(ways.getId(), ways);
            } else if (elementType == ElementType.Relation) {
                CurrentRelations rel = new CurrentRelations();
                rel.setId(rs.getLong("id"));

                rel.setChangesetId(rs.getLong("changeset_id"));
                rel.setVisible(rs.getBoolean("visible"));
                rel.setTimestamp(rs.getTimestamp("timestamp"));
                rel.setVersion(rs.getLong("version"));
                rel.setTags(rs.getObject("tags"));
                retMap.put(rel.getId(), rel);
            }
        }
        rs.close();

    } catch (Exception e) {
        //throw new Exception("Error inserting node.");
    }

    finally {
        //finally block used to close resources
        try {
            if (stmt != null)
                stmt.close();
        } catch (SQLException se2) {

        } // nothing we can do

    } //end try

    return retMap;
}

From source file:hoot.services.writers.review.ReviewPrepareDbWriter.java

protected Map<Long, Object> getReviewableElementRecords(final long mapId, final ElementType elementType,
        final int limit, final int offset) throws InstantiationException, IllegalAccessException,
        ClassNotFoundException, NoSuchMethodException, InvocationTargetException {

    Map<Long, Object> retMap = new LinkedHashMap<Long, Object>();
    final Element prototype = ElementFactory.getInstance().create(mapId, elementType, conn);

    String tableName = prototype.getElementTable().getTableName();
    String idFieldName = ColumnMetadata.getColumnMetadata(prototype.getElementIdField()).getName();

    String POSTGRESQL_DRIVER = "org.postgresql.Driver";
    Statement stmt = null;//  w  w w.  j  a  v  a  2s .  c  om
    try {
        Class.forName(POSTGRESQL_DRIVER);

        stmt = conn.createStatement();

        String sql = "select * from " + tableName + "_" + mapId + " where "
                + " tags->'hoot:review:needs' = 'yes' " + " order by " + idFieldName + " limit " + limit
                + " offset " + offset;
        stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sql);

        while (rs.next()) {

            if (elementType == ElementType.Node) {
                CurrentNodes nodes = new CurrentNodes();
                nodes.setId(rs.getLong("id"));

                nodes.setLatitude(rs.getInt("latitude"));
                nodes.setLongitude(rs.getInt("longitude"));
                nodes.setChangesetId(rs.getLong("changeset_id"));
                nodes.setVisible(rs.getBoolean("visible"));
                nodes.setTimestamp(rs.getTimestamp("timestamp"));
                nodes.setTile(rs.getLong("tile"));
                nodes.setVersion(rs.getLong("version"));
                nodes.setTags(rs.getObject("tags"));
                retMap.put(nodes.getId(), nodes);
            } else if (elementType == ElementType.Way) {
                CurrentWays ways = new CurrentWays();
                ways.setId(rs.getLong("id"));

                ways.setChangesetId(rs.getLong("changeset_id"));
                ways.setVisible(rs.getBoolean("visible"));
                ways.setTimestamp(rs.getTimestamp("timestamp"));
                ways.setVersion(rs.getLong("version"));
                ways.setTags(rs.getObject("tags"));
                retMap.put(ways.getId(), ways);
            } else if (elementType == ElementType.Relation) {
                CurrentRelations rel = new CurrentRelations();
                rel.setId(rs.getLong("id"));

                rel.setChangesetId(rs.getLong("changeset_id"));
                rel.setVisible(rs.getBoolean("visible"));
                rel.setTimestamp(rs.getTimestamp("timestamp"));
                rel.setVersion(rs.getLong("version"));
                rel.setTags(rs.getObject("tags"));
                retMap.put(rel.getId(), rel);
            }
        }
        rs.close();

    } catch (Exception e) {
        //throw new Exception("Error inserting node.");
    }

    finally {
        //finally block used to close resources
        try {
            if (stmt != null)
                stmt.close();
        } catch (SQLException se2) {

        } // nothing we can do

    } //end try

    return retMap;

}

From source file:com.l2jfree.gameserver.instancemanager.AutoChatManager.java

private void restoreChatData() {
    int numLoaded = 0;
    Connection con = null;/*  w w  w.ja v a  2 s.c o m*/
    PreparedStatement statement = null;
    PreparedStatement statement2 = null;
    ResultSet rs = null;
    ResultSet rs2 = null;

    try {
        con = L2DatabaseFactory.getInstance().getConnection(con);

        statement = con.prepareStatement("SELECT * FROM auto_chat ORDER BY groupId ASC");
        rs = statement.executeQuery();

        while (rs.next()) {
            int groupId = rs.getInt("groupId");
            int npcId = rs.getInt("npcId");
            long chatDelay = rs.getLong("chatDelay") * 1000;
            int chatRange = rs.getInt("chatRange");
            boolean chatRandom = rs.getBoolean("chatRandom");

            numLoaded++;

            statement2 = con.prepareStatement("SELECT * FROM auto_chat_text WHERE groupId=?");
            statement2.setInt(1, groupId);
            rs2 = statement2.executeQuery();

            ArrayList<String> chatTexts = new ArrayList<String>();

            while (rs2.next())
                chatTexts.add(rs2.getString("chatText"));

            if (!chatTexts.isEmpty())
                registerGlobalChat(npcId, chatTexts.toArray(new String[chatTexts.size()]), chatDelay, chatRange,
                        chatRandom);
            else
                _log.warn("AutoChatHandler: Chat group " + groupId + " is empty.");

            statement2.close();
        }

        statement.close();

        if (_log.isDebugEnabled())
            _log.info("AutoChatHandler: Loaded " + numLoaded + " chat group(s) from the database.");
    } catch (Exception e) {
        _log.warn("AutoSpawnHandler: Could not restore chat data: ", e);
    } finally {
        L2DatabaseFactory.close(con);
    }
}

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

@Override
public VocabularyResult searchVocabularies(VocabularyFilter filter) {
    Map<String, Object> params = new HashMap<String, Object>();

    StringBuilder sql = new StringBuilder();
    sql.append(/*from www  .ja va 2s . c om*/
            "select v.VOCABULARY_ID, v.IDENTIFIER, v.LABEL, v.REG_STATUS, v.WORKING_COPY, v.BASE_URI, v.VOCABULARY_TYPE, ");
    sql.append("v.WORKING_USER, v.DATE_MODIFIED, v.USER_MODIFIED, v.CHECKEDOUT_COPY_ID, v.CONTINUITY_ID, ");
    sql.append("v.CONCEPT_IDENTIFIER_NUMERIC, f.ID, f.IDENTIFIER, f.LABEL ");
    sql.append("from VOCABULARY v ");

    sql.append("left join VOCABULARY_SET f on f.ID=v.FOLDER_ID where 1=1 ");

    if (StringUtils.isNotEmpty(filter.getText())) {
        if (filter.isWordMatch()) {
            params.put("text", "[[:<:]]" + filter.getText() + "[[:>:]]");
            sql.append("AND (v.LABEL REGEXP :text ");
            sql.append("or v.IDENTIFIER REGEXP :text) ");

        } else if (filter.isExactMatch()) {
            params.put("text", filter.getText());
            sql.append("AND (v.LABEL = :text ");
            sql.append("or v.IDENTIFIER = :text) ");

        } else {
            params.put("text", "%" + filter.getText() + "%");
            sql.append("AND (v.LABEL like :text ");
            sql.append("or v.IDENTIFIER like :text) ");
        }
    } else if (StringUtils.isNotEmpty(filter.getIdentifier())) {
        params.put("identifier", filter.getIdentifier());
        sql.append("AND v.IDENTIFIER like :identifier ");
    }

    if (filter.getVocabularyWorkingCopyId() != null) {
        if (BooleanUtils.isFalse(filter.isWorkingCopy())) {
            params.put("workingCopyVocabularyId", filter.getVocabularyWorkingCopyId());
            sql.append(
                    "AND ((WORKING_COPY = 0 AND (CHECKEDOUT_COPY_ID IS NULL OR CHECKEDOUT_COPY_ID <> :workingCopyVocabularyId)) "
                            + "OR (WORKING_COPY = 1 AND VOCABULARY_ID = :workingCopyVocabularyId)) ");
        }

    } else if (filter.isWorkingCopy() != null) {
        params.put("workingCopy", filter.isWorkingCopy() ? 1 : 0);
        sql.append("AND WORKING_COPY = :workingCopy");
    }

    if (filter.getStatus() != null) {
        params.put("regStatus", filter.getStatus().getLabel());
        sql.append("AND REG_STATUS = :regStatus");
    }

    // related concepts text:
    if (StringUtils.isNotEmpty(filter.getConceptText())) {
        if (filter.isWordMatch()) {
            params.put("text", "[[:<:]]" + filter.getConceptText() + "[[:>:]]");
            sql.append(
                    " AND EXISTS (SELECT 1 FROM VOCABULARY_CONCEPT vc WHERE vc.VOCABULARY_ID = v.VOCABULARY_ID ");
            sql.append(" AND (vc.LABEL REGEXP :conceptText OR vc.IDENTIFIER REGEXP :conceptText ");
            sql.append(" OR vc.DEFINITION REGEXP :conceptText)) ");
        } else if (filter.isExactMatch()) {
            params.put("conceptText", filter.getConceptText());
            sql.append(
                    " AND EXISTS (SELECT 1 FROM VOCABULARY_CONCEPT vc WHERE vc.VOCABULARY_ID = v.VOCABULARY_ID ");
            sql.append(
                    " AND (vc.LABEL = :conceptText OR vc.IDENTIFIER = :conceptText OR vc.DEFINITION = :conceptText)) ");
        } else {
            params.put("conceptText", "%" + filter.getConceptText() + "%");
            sql.append(
                    " AND EXISTS (SELECT 1 FROM VOCABULARY_CONCEPT vc WHERE vc.VOCABULARY_ID = v.VOCABULARY_ID ");
            sql.append(" AND (vc.LABEL like :conceptText ");
            sql.append(" OR vc.IDENTIFIER like :conceptText OR vc.DEFINITION like :conceptText) ) ");
        }
    }

    if (StringUtils.isNotBlank(filter.getBaseUri())) {
        params.put("baseUri", filter.getBaseUri());
        sql.append(" AND v.BASE_URI like :baseUri ");
    }
    sql.append(" ORDER BY v.IDENTIFIER");

    List<VocabularyFolder> items = getNamedParameterJdbcTemplate().query(sql.toString(), params,
            new RowMapper<VocabularyFolder>() {
                @Override
                public VocabularyFolder mapRow(ResultSet rs, int rowNum) throws SQLException {
                    VocabularyFolder vf = new VocabularyFolder();
                    vf.setId(rs.getInt("v.VOCABULARY_ID"));
                    vf.setIdentifier(rs.getString("v.IDENTIFIER"));
                    vf.setLabel(rs.getString("v.LABEL"));
                    vf.setRegStatus(RegStatus.fromString(rs.getString("v.REG_STATUS")));
                    vf.setWorkingCopy(rs.getBoolean("v.WORKING_COPY"));
                    vf.setBaseUri(rs.getString("v.BASE_URI"));
                    vf.setType(VocabularyType.valueOf(rs.getString("v.VOCABULARY_TYPE")));
                    vf.setWorkingUser(rs.getString("v.WORKING_USER"));
                    vf.setDateModified(rs.getTimestamp("v.DATE_MODIFIED"));
                    vf.setUserModified(rs.getString("v.USER_MODIFIED"));
                    vf.setCheckedOutCopyId(rs.getInt("v.CHECKEDOUT_COPY_ID"));
                    vf.setContinuityId(rs.getString("v.CONTINUITY_ID"));
                    vf.setNumericConceptIdentifiers(rs.getBoolean("v.CONCEPT_IDENTIFIER_NUMERIC"));
                    vf.setFolderId(rs.getInt("f.ID"));
                    vf.setFolderName(rs.getString("f.IDENTIFIER"));
                    vf.setFolderLabel(rs.getString("f.LABEL"));
                    return vf;
                }
            });

    String totalSql = "SELECT FOUND_ROWS()";
    int totalItems = getJdbcTemplate().queryForInt(totalSql);

    VocabularyResult result = new VocabularyResult(items, totalItems, filter);

    return result;
}

From source file:com.flexive.core.storage.genericSQL.GenericEnvironmentLoader.java

/**
 * {@inheritDoc}//from  w  w w .ja  v  a2  s .  c  o  m
 */
@Override
public List<FxSelectList> loadSelectLists(Connection con, FxEnvironmentImpl environment)
        throws FxLoadException {
    PreparedStatement ps = null;
    String sql;
    List<FxSelectList> lists = new ArrayList<FxSelectList>(10);
    try {
        final Map<Long, FxString[]> translations = Database.loadFxStrings(con, TBL_STRUCT_SELECTLIST, "LABEL",
                "DESCRIPTION");
        final Map<Long, FxString[]> itemTranslations = Database.loadFxStrings(con, TBL_STRUCT_SELECTLIST_ITEM,
                "LABEL");

        //            1  2        3    4                 5               6            7            8     9             10
        sql = "SELECT ID,PARENTID,NAME,ALLOW_ITEM_CREATE,ACL_CREATE_ITEM,ACL_ITEM_NEW,DEFAULT_ITEM,BCSEP,SAMELVLSELECT,SORTENTRIES FROM "
                + TBL_STRUCT_SELECTLIST + " ORDER BY NAME";
        ps = con.prepareStatement(sql);
        ResultSet rs = ps.executeQuery();
        while (rs != null && rs.next()) {
            final long id = rs.getLong(1);
            long parent = rs.getLong(2);
            if (rs.wasNull())
                parent = -1;
            String bcSep = rs.getString(8);
            if (rs.wasNull())
                bcSep = " > ";
            boolean sameLvl = rs.getBoolean(9);
            if (rs.wasNull())
                sameLvl = false;
            boolean sort = rs.getBoolean(10);
            if (rs.wasNull())
                sort = false;
            lists.add(new FxSelectList(id, parent, rs.getString(3), getTranslation(translations, id, 0, false),
                    getTranslation(translations, id, 1, false), rs.getBoolean(4),
                    environment.getACL(rs.getLong(5)), environment.getACL(rs.getLong(6)), rs.getLong(7), bcSep,
                    sameLvl, sort));
        }
        ps.close();
        //            1  2    3   4        5    6     7          8          9           10          11      12       13
        sql = "SELECT ID,NAME,ACL,PARENTID,DATA,COLOR,CREATED_BY,CREATED_AT,MODIFIED_BY,MODIFIED_AT,DBIN_ID,DBIN_VER,DBIN_QUALITY FROM "
                + TBL_STRUCT_SELECTLIST_ITEM + " WHERE LISTID=? ORDER BY POS,ID";
        ps = con.prepareStatement(sql);
        for (FxSelectList list : lists) {
            ps.setLong(1, list.getId());
            rs = ps.executeQuery();
            int pos = 0;
            while (rs != null && rs.next()) {
                final long id = rs.getLong(1);
                long parent = rs.getLong(4);
                if (rs.wasNull())
                    parent = -1;
                new FxSelectListItem(id, rs.getString(2), environment.getACL(rs.getLong(3)), list, parent,
                        getTranslation(itemTranslations, id, 0, false), rs.getString(5), rs.getString(6),
                        rs.getLong(11), rs.getInt(12), rs.getInt(13), LifeCycleInfoImpl.load(rs, 7, 8, 9, 10),
                        pos++);
            }
        }
    } catch (SQLException exc) {
        throw new FxLoadException(LOG, exc, "ex.structure.list.load.failed", exc.getMessage());
    } finally {
        Database.closeObjects(GenericEnvironmentLoader.class, null, ps);
    }
    return lists;
}

From source file:com.flexive.core.storage.genericSQL.GenericEnvironmentLoader.java

private Map<Long, List<FxStructureOption>> loadAllTypeOptions(Connection con, String idColumn, String table)
        throws SQLException {
    Statement stmt = null;//from   www. j  a  v a2  s.  c  om
    Map<Long, List<FxStructureOption>> result = new HashMap<Long, List<FxStructureOption>>(50);
    try {
        stmt = con.createStatement();
        final ResultSet rs = stmt
                .executeQuery("SELECT " + idColumn + ",OPTKEY,MAYOVERRIDE,ISINHERITED,OPTVALUE FROM " + table);
        while (rs.next()) {
            final long id = rs.getLong(1);
            if (!result.containsKey(id)) {
                result.put(id, new ArrayList<FxStructureOption>());
            }
            FxStructureOption.setOption(result.get(id), rs.getString(2), rs.getBoolean(3), rs.getBoolean(4),
                    rs.getString(5));
        }
        return result;
    } finally {
        Database.closeObjects(GenericEnvironmentLoader.class, null, stmt);
    }
}

From source file:org.apache.syncope.core.util.ImportExport.java

private String getValues(final ResultSet rs, final String columnName, final Integer columnType)
        throws SQLException {

    String res = null;/*from  ww  w .ja v a 2  s  .c  o  m*/

    try {
        switch (columnType) {
        case Types.BINARY:
        case Types.VARBINARY:
        case Types.LONGVARBINARY:
            final InputStream is = rs.getBinaryStream(columnName);
            if (is != null) {
                res = new String(Hex.encode(IOUtils.toByteArray(is)));
            }
            break;

        case Types.BLOB:
            final Blob blob = rs.getBlob(columnName);
            if (blob != null) {
                res = new String(Hex.encode(IOUtils.toByteArray(blob.getBinaryStream())));
            }
            break;

        case Types.BIT:
        case Types.BOOLEAN:
            if (rs.getBoolean(columnName)) {
                res = "1";
            } else {
                res = "0";
            }
            break;

        case Types.DATE:
        case Types.TIME:
        case Types.TIMESTAMP:
            final Timestamp timestamp = rs.getTimestamp(columnName);
            if (timestamp != null) {
                res = DATE_FORMAT.get().format(new Date(timestamp.getTime()));
            }
            break;

        default:
            res = rs.getString(columnName);
        }
    } catch (IOException e) {
        LOG.error("Error retrieving hexadecimal string", e);
    }

    return res;
}

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

/**
 * Load online application bean./*from   w w w .jav a 2  s .  c o  m*/
 *
 * @param rs the result set
 *
 * @return the online application bean
 *
 * @throws SQLException the SQL exception
 */
private OnlineApplicationBean loadOnlineApplicationBean(final ResultSet rs) throws SQLException {

    OnlineApplicationBean onlineApplication = new OnlineApplicationBean();

    onlineApplication.setId(rs.getInt("OnlineApplicationId"));
    onlineApplication.setKey(rs.getString("ApplicationKey"));
    onlineApplication.setFirstName(rs.getString("FirstName"));
    onlineApplication.setLastName(rs.getString("LastName"));
    onlineApplication.setPersonGUID(rs.getInt("PersonGUID"));
    onlineApplication.setApplicationXml(rs.getString("ApplicationXML"));
    onlineApplication.setStatus(rs.getString("Status"));
    onlineApplication.setRecordNumber(rs.getString("RecordNumber"));
    onlineApplication.setType(rs.getString("Type"));
    onlineApplication.setProcessed(rs.getBoolean("Processed"));
    try {
        onlineApplication.setCreatedDate(rs.getTimestamp("Created"));
    } catch (SQLException e) {
        dataLogger.debug("Error reading Created date: " + e.getMessage());
    }
    try {
        onlineApplication.setModifiedDate(rs.getTimestamp("Modified"));
    } catch (SQLException e) {
        dataLogger.debug("Error reading Modified date: " + e.getMessage());
    }

    if (!onlineApplication.getProcessed() && onlineApplication.getPersonGUID() == 0
            && StringUtils.equals(onlineApplication.getStatus(), "Unprocessed")) {
        // Check to see if a relevant person already exists
        try {
            onlineApplication.setExistingRecord(this.getExistingRecord(onlineApplication));
        } catch (WhichDoctorDaoException wde) {
            dataLogger.error("Error searching for an existing person: " + wde.getMessage());
        }
    }

    return onlineApplication;
}

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

/**
 * {@inheritDoc}//from   ww  w  .j  a v  a2 s .c o m
 */
@Override
public List<VocabularyFolder> getWorkingCopies(String userName) {
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("workingUser", userName);

    StringBuilder sql = new StringBuilder();
    sql.append(
            "select v.VOCABULARY_ID, v.IDENTIFIER, v.LABEL, v.REG_STATUS, v.WORKING_COPY, v.BASE_URI, v.VOCABULARY_TYPE, ");
    sql.append("v.WORKING_USER, v.DATE_MODIFIED, v.USER_MODIFIED, v.CHECKEDOUT_COPY_ID, v.CONTINUITY_ID, ");
    sql.append("v.CONCEPT_IDENTIFIER_NUMERIC, ");
    sql.append("f.ID, f.IDENTIFIER, f.LABEL ");
    sql.append("from VOCABULARY v ");
    sql.append("left join VOCABULARY_SET f on f.ID=v.FOLDER_ID ");
    sql.append("where v.WORKING_USER=:workingUser and v.WORKING_COPY = 1");

    List<VocabularyFolder> items = getNamedParameterJdbcTemplate().query(sql.toString(), params,
            new RowMapper<VocabularyFolder>() {
                @Override
                public VocabularyFolder mapRow(ResultSet rs, int rowNum) throws SQLException {
                    VocabularyFolder vf = new VocabularyFolder();
                    vf.setId(rs.getInt("v.VOCABULARY_ID"));
                    vf.setIdentifier(rs.getString("v.IDENTIFIER"));
                    vf.setLabel(rs.getString("v.LABEL"));
                    vf.setRegStatus(RegStatus.fromString(rs.getString("v.REG_STATUS")));
                    vf.setType(VocabularyType.valueOf(rs.getString("v.VOCABULARY_TYPE")));
                    vf.setWorkingCopy(rs.getBoolean("v.WORKING_COPY"));
                    vf.setWorkingUser(rs.getString("v.WORKING_USER"));
                    vf.setDateModified(rs.getTimestamp("v.DATE_MODIFIED"));
                    vf.setUserModified(rs.getString("v.USER_MODIFIED"));
                    vf.setCheckedOutCopyId(rs.getInt("v.CHECKEDOUT_COPY_ID"));
                    vf.setFolderName(rs.getString("f.IDENTIFIER"));
                    vf.setFolderId(rs.getInt("f.ID"));
                    vf.setFolderLabel(rs.getString("f.LABEL"));
                    return vf;
                }
            });

    return items;

}