Search in sources :

Example 26 with RowCallbackHandler

use of org.springframework.jdbc.core.RowCallbackHandler in project spring-cloud-task by spring-cloud.

the class JdbcTaskExecutionDao method getTaskArguments.

private List<String> getTaskArguments(long taskExecutionId) {
    final List<String> params = new ArrayList<>();
    RowCallbackHandler handler = new RowCallbackHandler() {

        @Override
        public void processRow(ResultSet rs) throws SQLException {
            params.add(rs.getString(2));
        }
    };
    this.jdbcTemplate.query(getQuery(FIND_ARGUMENT_FROM_ID), new MapSqlParameterSource("taskExecutionId", taskExecutionId), handler);
    return params;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler)

Example 27 with RowCallbackHandler

use of org.springframework.jdbc.core.RowCallbackHandler in project fcrepo by fcrepo.

the class MembershipIndexManager method logMembership.

/**
 * Log all membership entries, for debugging usage only
 */
protected void logMembership() {
    log.info("source_id, proxy_id, subject_id, property, object_id, start_time, end_time, last_updated");
    jdbcTemplate.query(SELECT_ALL_MEMBERSHIP, new RowCallbackHandler() {

        @Override
        public void processRow(final ResultSet rs) throws SQLException {
            log.info("{}, {}, {}, {}, {}, {}, {}, {}", rs.getString("source_id"), rs.getString("proxy_id"), rs.getString("subject_id"), rs.getString("property"), rs.getString("object_id"), rs.getTimestamp("start_time"), rs.getTimestamp("end_time"), rs.getTimestamp("last_updated"));
        }
    });
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler)

Example 28 with RowCallbackHandler

use of org.springframework.jdbc.core.RowCallbackHandler in project biosamples-v4 by EBIBioSamples.

the class TestConversion method test_with_failing.

@Test
public void test_with_failing() {
    RowCallbackHandler rowCallbackHandler = resultSet -> {
        String sampleAccession = resultSet.getString("BIOSAMPLE_ID");
        EnaCallable enaCallable = new EnaCallable(sampleAccession, null, 0, bioSamplesWebinClient, enaXmlEnhancer, enaElementConverter, egaSampleExporter, eraProDao, false, false, null);
        try {
            enaCallable.call();
        } catch (Exception e) {
            e.printStackTrace();
            fail();
        }
    };
    eraProDao.getSingleSample("SAMEA104371999", rowCallbackHandler);
}
Also used : BioSamplesClient(uk.ac.ebi.biosamples.client.BioSamplesClient) RunWith(org.junit.runner.RunWith) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) Ignore(org.junit.Ignore) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) EgaSampleExporter(uk.ac.ebi.biosamples.ega.EgaSampleExporter) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Assert.fail(org.junit.Assert.fail) SpringRunner(org.springframework.test.context.junit4.SpringRunner) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with RowCallbackHandler

use of org.springframework.jdbc.core.RowCallbackHandler in project biosamples-v4 by EBIBioSamples.

the class TestConversion method test_over_all_samples.

@Test
@Ignore
public void test_over_all_samples() {
    RowCallbackHandler rowCallbackHandler = resultSet -> {
        String sampleAccession = resultSet.getString("BIOSAMPLE_ID");
        EnaCallable enaCallable = new EnaCallable(sampleAccession, null, 0, bioSamplesWebinClient, enaXmlEnhancer, enaElementConverter, egaSampleExporter, eraProDao, false, false, null);
        try {
            enaCallable.call();
        } catch (Exception e) {
            e.printStackTrace();
        }
    };
    LocalDate fromDate = LocalDate.parse("1000-01-01", DateTimeFormatter.ISO_LOCAL_DATE);
    LocalDate toDate = LocalDate.parse("3000-01-01", DateTimeFormatter.ISO_LOCAL_DATE);
    eraProDao.doSampleCallback(fromDate, toDate, rowCallbackHandler);
}
Also used : BioSamplesClient(uk.ac.ebi.biosamples.client.BioSamplesClient) RunWith(org.junit.runner.RunWith) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) Ignore(org.junit.Ignore) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) EgaSampleExporter(uk.ac.ebi.biosamples.ega.EgaSampleExporter) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Assert.fail(org.junit.Assert.fail) SpringRunner(org.springframework.test.context.junit4.SpringRunner) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) LocalDate(java.time.LocalDate) Ignore(org.junit.Ignore) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 30 with RowCallbackHandler

use of org.springframework.jdbc.core.RowCallbackHandler in project biosamples-v4 by EBIBioSamples.

the class TestConversion method test_with_killed.

@Test
public void test_with_killed() {
    RowCallbackHandler rowCallbackHandler = resultSet -> {
        String sampleAccession = resultSet.getString("BIOSAMPLE_ID");
        EnaCallable enaCallable = new EnaCallable(sampleAccession, null, 0, bioSamplesWebinClient, enaXmlEnhancer, enaElementConverter, egaSampleExporter, eraProDao, false, false, null);
        try {
            enaCallable.call();
        } catch (Exception e) {
            e.printStackTrace();
            fail();
        }
    };
    eraProDao.getSingleSample("SAMEA1935107", rowCallbackHandler);
}
Also used : BioSamplesClient(uk.ac.ebi.biosamples.client.BioSamplesClient) RunWith(org.junit.runner.RunWith) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) Ignore(org.junit.Ignore) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) EgaSampleExporter(uk.ac.ebi.biosamples.ega.EgaSampleExporter) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Assert.fail(org.junit.Assert.fail) SpringRunner(org.springframework.test.context.junit4.SpringRunner) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

RowCallbackHandler (org.springframework.jdbc.core.RowCallbackHandler)72 ResultSet (java.sql.ResultSet)63 SQLException (java.sql.SQLException)59 HashMap (java.util.HashMap)21 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)9 Autowired (org.springframework.beans.factory.annotation.Autowired)6 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)6 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)5 LocalDate (java.time.LocalDate)5 DateTimeFormatter (java.time.format.DateTimeFormatter)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 BigDecimal (java.math.BigDecimal)4 LinkedHashMap (java.util.LinkedHashMap)4 Assert.fail (org.junit.Assert.fail)4 Ignore (org.junit.Ignore)4 RunWith (org.junit.runner.RunWith)4 Qualifier (org.springframework.beans.factory.annotation.Qualifier)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 SpringRunner (org.springframework.test.context.junit4.SpringRunner)4