aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/trygvis/esper/testing/core/db
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-28 13:13:14 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-28 13:13:14 +0100
commitc9ff3d5495b0229d837fa0ec23486cc7b6b191d0 (patch)
treeb978427f431aa41c59115978c6a017db84b9f2ec /src/main/java/io/trygvis/esper/testing/core/db
parent422b1caeaa9f7d069a9208ecb0d0249485b1a05e (diff)
downloadesper-testing-c9ff3d5495b0229d837fa0ec23486cc7b6b191d0.tar.gz
esper-testing-c9ff3d5495b0229d837fa0ec23486cc7b6b191d0.tar.bz2
esper-testing-c9ff3d5495b0229d837fa0ec23486cc7b6b191d0.tar.xz
esper-testing-c9ff3d5495b0229d837fa0ec23486cc7b6b191d0.zip
o Listing builds on the person view.
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing/core/db')
-rw-r--r--src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java b/src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java
index 24ecfd3..e498017 100644
--- a/src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java
+++ b/src/main/java/io/trygvis/esper/testing/core/db/BuildDao.java
@@ -7,7 +7,9 @@ import org.joda.time.*;
import java.sql.*;
import java.util.*;
+import static io.trygvis.esper.testing.Util.toList;
import static io.trygvis.esper.testing.util.sql.ResultSetF.*;
+import static io.trygvis.esper.testing.util.sql.SqlOption.fromRs;
import static java.lang.System.*;
public class BuildDao {
@@ -59,7 +61,34 @@ public class BuildDao {
try (PreparedStatement s = c.prepareStatement("SELECT person FROM build_participant WHERE build=?")) {
int i = 1;
s.setString(i, build.toString());
- return Util.toList(s, getUuid);
+ return toList(s, getUuid);
+ }
+ }
+
+ public SqlOption<BuildDto> selectBuild(UUID uuid) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("SELECT " + BUILD + " FROM build WHERE uuid=?")) {
+ int i = 1;
+ s.setString(i, uuid.toString());
+ return fromRs(s.executeQuery()).map(build);
+ }
+ }
+
+ public List<BuildDto> selectBuildsByPerson(UUID person, PageRequest page) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("SELECT " + BUILD + " FROM build b, build_participant bp WHERE bp.person=? AND b.uuid = bp.build ORDER BY created_date LIMIT ? OFFSET ?")) {
+ int i = 1;
+ s.setString(i++, person.toString());
+ s.setInt(i++, page.count.orSome(10));
+ s.setInt(i, page.startIndex.orSome(0));
+ return toList(s, build);
+ }
+ }
+
+ public List<BuildDto> selectBuilds(PageRequest page) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("SELECT " + BUILD + " FROM build ORDER BY created_date LIMIT ? OFFSET ?")) {
+ int i = 1;
+ s.setInt(i++, page.count.orSome(10));
+ s.setInt(i, page.startIndex.orSome(0));
+ return toList(s, build);
}
}
}