diff options
Diffstat (limited to 'src/main/java/io/trygvis/esper/testing')
4 files changed, 27 insertions, 8 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/core/db/PersonDao.java b/src/main/java/io/trygvis/esper/testing/core/db/PersonDao.java index 2b74771..290d6d5 100755 --- a/src/main/java/io/trygvis/esper/testing/core/db/PersonDao.java +++ b/src/main/java/io/trygvis/esper/testing/core/db/PersonDao.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.*; import static io.trygvis.esper.testing.Util.*; +import static io.trygvis.esper.testing.util.sql.ResultSetF.getUUID; import static io.trygvis.esper.testing.util.sql.SqlOption.*; import static java.lang.System.*; @@ -147,6 +148,14 @@ public class PersonDao { } } + public List<UUID> selectJenkinsUserUuidsByPerson(Uuid person) throws SQLException { + try (PreparedStatement s = c.prepareStatement("SELECT jenkins_user FROM person_jenkins_user WHERE person=?")) { + int i = 1; + s.setString(i, person.toUuidString()); + return toList(s, getUUID); + } + } + public boolean hasPersonJenkinsUser(Uuid person, UUID jenkinsUser) throws SQLException { try (PreparedStatement s = c.prepareStatement("SELECT 1 FROM person_jenkins_user WHERE person=? AND jenkins_user=?")) { int i = 1; diff --git a/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java b/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java index e95b7fa..9a69a75 100755 --- a/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java +++ b/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java @@ -35,11 +35,6 @@ public class CoreResource extends AbstractResource { @Path("/person") public List<PersonDetailJson> getPersons(@MagicParam final PageRequest pageRequest, @QueryParam("query") final String query) throws Exception { - - int sleep = 1; - System.out.println("Awesome"); - Thread.sleep(sleep * 1000); - return da.inTransaction(new CoreDaosCallback<List<PersonDetailJson>>() { protected List<PersonDetailJson> run() throws SQLException { List<PersonDetailJson> list = new ArrayList<>(); @@ -190,11 +185,13 @@ public class CoreResource extends AbstractResource { badgesInProgress.add(getBadge(progress)); } + List<UUID> jenkinsUserUuid = daos.personDao.selectJenkinsUserUuidsByPerson(person.uuid); + return new PersonDetailJson( getPersonJson.apply(person), badges, - badgesInProgress - ); + badgesInProgress, + jenkinsUserUuid); } }; diff --git a/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java b/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java index 21bfe19..0c0c6a9 100755 --- a/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java +++ b/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java @@ -103,6 +103,17 @@ public class JenkinsResource extends AbstractResource { }); } + @GET + @Path("/user/{uuid}") + @Produces(MediaType.APPLICATION_JSON) + public JenkinsUserJson getUser(@MagicParam final UUID user) throws Exception { + return sql(new JenkinsDaosCallback<SqlOption<JenkinsUserJson>>() { + protected SqlOption<JenkinsUserJson> run() throws SQLException { + return daos.jenkinsDao.selectUser(user).map(getJenkinsUserJson); + } + }); + } + public static UUID parseUuid(String s) { try { return UUID.fromString(s); diff --git a/src/main/java/io/trygvis/esper/testing/web/resource/PersonJson.java b/src/main/java/io/trygvis/esper/testing/web/resource/PersonJson.java index 285ae8e..21fd110 100755 --- a/src/main/java/io/trygvis/esper/testing/web/resource/PersonJson.java +++ b/src/main/java/io/trygvis/esper/testing/web/resource/PersonJson.java @@ -25,10 +25,12 @@ class PersonDetailJson { public final PersonJson person; public final List<BadgeJson> badges; public final List<BadgeJson> badgesInProgress; + public final List<UUID> jenkinsUsers; - public PersonDetailJson(PersonJson person, List<BadgeJson> badges, List<BadgeJson> badgesInProgress) { + PersonDetailJson(PersonJson person, List<BadgeJson> badges, List<BadgeJson> badgesInProgress, List<UUID> jenkinsUsers) { this.person = person; this.badges = badges; this.badgesInProgress = badgesInProgress; + this.jenkinsUsers = jenkinsUsers; } } |