diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-17 22:56:32 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2013-01-17 22:56:32 +0100 |
commit | 20f0391fc5cc5e87f96f838767bed8b4d707928d (patch) | |
tree | a96a11db8d57845ca6b5534453a5a2f9d5c6daa7 /src/main/java/io/trygvis/esper | |
parent | 4e75fdc85ff2a9e04d1820a3a2f8dc62e431295b (diff) | |
download | esper-testing-20f0391fc5cc5e87f96f838767bed8b4d707928d.tar.gz esper-testing-20f0391fc5cc5e87f96f838767bed8b4d707928d.tar.bz2 esper-testing-20f0391fc5cc5e87f96f838767bed8b4d707928d.tar.xz esper-testing-20f0391fc5cc5e87f96f838767bed8b4d707928d.zip |
o Adding "jenkins_users" to the JSON representation of a person.
o Showing the avatar on the person page too.
Diffstat (limited to 'src/main/java/io/trygvis/esper')
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; } } |