Example usage for org.springframework.jdbc.core RowMapperResultSetExtractor RowMapperResultSetExtractor

List of usage examples for org.springframework.jdbc.core RowMapperResultSetExtractor RowMapperResultSetExtractor

Introduction

In this page you can find the example usage for org.springframework.jdbc.core RowMapperResultSetExtractor RowMapperResultSetExtractor.

Prototype

public RowMapperResultSetExtractor(RowMapper<T> rowMapper, int rowsExpected) 

Source Link

Document

Create a new RowMapperResultSetExtractor.

Usage

From source file:org.gbif.portal.dao.impl.jdbc.RawOccurrenceRecordDAOImpl.java

/**
 * @see org.gbif.portal.dao.RawOccurrenceRecordDAO#getUniqueRecord(long, java.lang.String, java.lang.String, java.lang.String)
 *///from  ww w. java  2 s  .c o  m
@SuppressWarnings("unchecked")
public RawOccurrenceRecord getUniqueRecord(long dataResourceId, String institutionCode, String collectionCode,
        String catalogueNumber, String unitQualifier) {
    StringBuffer query = new StringBuffer(RawOccurrenceRecordDAOImpl.QUERY_UNIQUE_SQL);
    List<Object> params = new LinkedList<Object>();
    params.add(new Long(dataResourceId));
    if (StringUtils.isNotEmpty(institutionCode)) {
        query.append(" and institution_code=?");
        params.add(institutionCode);
    }
    if (StringUtils.isNotEmpty(collectionCode)) {
        query.append(" and collection_code=?");
        params.add(collectionCode);
    }
    if (StringUtils.isNotEmpty(catalogueNumber)) {
        query.append(" and catalogue_number=?");
        params.add(catalogueNumber);
    }
    if (StringUtils.isNotEmpty(unitQualifier)) {
        query.append(" and unit_qualifier=?");
        params.add(unitQualifier);
    }

    List<RawOccurrenceRecord> results = (List<RawOccurrenceRecord>) getJdbcTemplate().query(query.toString(),
            params.toArray(), new RowMapperResultSetExtractor(rawOccurrenceRecordRowMapper, 1));
    if (results.size() == 0) {
        return null;
    } else if (results.size() > 1) {
        logger.warn("Found multiple RawOccurrenceRecords with dataResourceId[" + dataResourceId
                + "], institutionCode[" + institutionCode + "], collectionCode[" + collectionCode
                + "] and catalogueNumber[" + catalogueNumber + "]");
    }
    return results.get(0);
}

From source file:org.gbif.portal.dao.impl.jdbc.RawOccurrenceRecordDAOImpl.java

/**
 * @see org.gbif.portal.dao.RawOccurrenceRecordDAO#getById(long)
 *///from   w w  w.  jav a2  s . c om
@SuppressWarnings("unchecked")
public RawOccurrenceRecord getById(final long id) {
    List<RawOccurrenceRecord> results = (List<RawOccurrenceRecord>) getJdbcTemplate().query(
            RawOccurrenceRecordDAOImpl.QUERY_ID_SQL, new Object[] { id },
            new RowMapperResultSetExtractor(rawOccurrenceRecordRowMapper, 1));
    if (results.size() == 0) {
        return null;
    } else if (results.size() > 1) {
        logger.warn("Found multiple RawOccurrenceRecords with Id[" + id + "]");
    }
    return results.get(0);
}

From source file:org.gbif.portal.dao.impl.jdbc.RawOccurrenceRecordDAOImpl.java

/**
 * @see org.gbif.portal.dao.RawOccurrenceRecordDAO#getFullRawDistinctClassification(long)
 *///from   www  .j av  a2s  .c o m
@SuppressWarnings("unchecked")
public List<LinnaeanRankClassification> getFullRawDistinctClassification(long dataResourceId) {
    List<LinnaeanRankClassification> results = (List<LinnaeanRankClassification>) getJdbcTemplate().query(
            RawOccurrenceRecordDAOImpl.QUERY_RAW_TAXONOMY, new Object[] { dataResourceId },
            new RowMapperResultSetExtractor(linnaeanRankClassificationRowMapper, 1000));
    return results;
}

From source file:org.gbif.portal.dao.impl.jdbc.RawOccurrenceRecordDAOImpl.java

/**
 * @see org.gbif.portal.dao.RawOccurrenceRecordDAO#getDataResourceIdsFor(long)
 *//*from w  w  w.j av  a 2s . c  om*/
@SuppressWarnings("unchecked")
public List<Long> getDataResourceIdsFor(long resourceAccessPointId) {
    List<Long> results = (List<Long>) getJdbcTemplate().query(RawOccurrenceRecordDAOImpl.QUERY_DATA_RESOURCE,
            new Object[] { resourceAccessPointId }, new RowMapperResultSetExtractor(longRowMapper, 3));
    return results;
}

From source file:org.gbif.portal.dao.impl.jdbc.TaxonNameDAOImpl.java

/**
 * @see org.gbif.portal.dao.TaxonNameDAO#getUnique(java.lang.String, java.lang.String, int)
 *///w  w w.  ja v a  2 s.c  o  m
@SuppressWarnings("unchecked")
public TaxonName getUnique(String canonical, String author, int rank) {
    List<TaxonName> results = null;
    if (StringUtils.isEmpty(author)) {
        results = (List<TaxonName>) getJdbcTemplate().query(
                TaxonNameDAOImpl.QUERY_BY_CANONICAL_RANK_NOAUTHOR_SQL, new Object[] { canonical, rank },
                new RowMapperResultSetExtractor(taxonNameRowMapper, 1));
    } else {
        results = (List<TaxonName>) getJdbcTemplate().query(TaxonNameDAOImpl.QUERY_BY_CANONICAL_AUTHOR_RANK_SQL,
                new Object[] { canonical, author, rank },
                new RowMapperResultSetExtractor(taxonNameRowMapper, 1));
    }
    if (results.size() == 0) {
        return null;
    } else if (results.size() > 1) {
        logger.warn("Found multiple TaxonNames with canonical[" + canonical + "], author[" + author + "], rank["
                + rank + "]");
    }
    return results.get(0);
}

From source file:org.gbif.portal.dao.impl.jdbc.TaxonNameDAOImpl.java

/**
 * @see org.gbif.portal.dao.TaxonNameDAO#getUnique(java.lang.String, java.lang.String, int)
 *///from  w  ww. j a va  2s .  co m
@SuppressWarnings("unchecked")
public TaxonName getById(long id) {
    List<TaxonName> results = (List<TaxonName>) getJdbcTemplate().query(TaxonNameDAOImpl.QUERY_BY_ID_SQL,
            new Object[] { id }, new RowMapperResultSetExtractor(taxonNameRowMapper, 1));
    if (results.size() == 0) {
        return null;
    } else if (results.size() > 1) {
        logger.warn("Found multiple TaxonNames with id[" + id + "]");
    }
    return results.get(0);
}

From source file:org.gbif.portal.dao.impl.jdbc.TaxonNameDAOImpl.java

/**
 * @see org.gbif.portal.dao.TaxonNameDAO#getTaxonName(long, int)
 *///from   www  . j a  v a 2 s .  c om
@SuppressWarnings("unchecked")
public List<TaxonName> getTaxonName(long start, int limit) {
    return (List<TaxonName>) getJdbcTemplate().query(TaxonNameDAOImpl.GET_ALL, new Object[] { start, limit },
            new RowMapperResultSetExtractor(taxonNameRowMapper, limit));
}

From source file:org.gbif.portal.dao.impl.jdbc.TaxonNameDAOImpl.java

/**
 * @see org.gbif.portal.dao.TaxonNameDAO#getByCanonicalAndLowestRank(java.lang.String, int)
 *//*from  w w w  . ja  v  a  2s.c  o m*/
@SuppressWarnings("unchecked")
public List<TaxonName> getByCanonicalAndLowestRank(String canonical, int lowestRankInclusive) {
    return (List<TaxonName>) getJdbcTemplate().query(TaxonNameDAOImpl.QUERY_BY_CANONICAL_LOWEST_RANK_SQL,
            new Object[] { canonical, lowestRankInclusive },
            new RowMapperResultSetExtractor(taxonNameRowMapper, 10));
}