From 20f0391fc5cc5e87f96f838767bed8b4d707928d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Thu, 17 Jan 2013 22:56:32 +0100 Subject: o Adding "jenkins_users" to the JSON representation of a person. o Showing the avatar on the person page too. --- .../java/io/trygvis/esper/testing/core/db/PersonDao.java | 9 +++++++++ .../io/trygvis/esper/testing/web/resource/CoreResource.java | 11 ++++------- .../trygvis/esper/testing/web/resource/JenkinsResource.java | 11 +++++++++++ .../io/trygvis/esper/testing/web/resource/PersonJson.java | 4 +++- src/main/resources/webapp/WEB-INF/tags/common/head.tagx | 1 + src/main/resources/webapp/apps/core/navbar.html | 8 ++++---- src/main/resources/webapp/apps/frontPageApp/frontPageApp.js | 10 ++++++++-- src/main/resources/webapp/apps/frontPageApp/person.html | 13 ++++++++++++- .../resources/webapp/apps/jenkinsApp/JenkinsResources.js | 8 ++++++++ src/main/resources/webapp/jenkins/index.jspx | 1 - 10 files changed, 60 insertions(+), 16 deletions(-) mode change 100644 => 100755 src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js 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 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 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>() { protected List run() throws SQLException { List list = new ArrayList<>(); @@ -190,11 +185,13 @@ public class CoreResource extends AbstractResource { badgesInProgress.add(getBadge(progress)); } + List 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>() { + protected SqlOption 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 badges; public final List badgesInProgress; + public final List jenkinsUsers; - public PersonDetailJson(PersonJson person, List badges, List badgesInProgress) { + PersonDetailJson(PersonJson person, List badges, List badgesInProgress, List jenkinsUsers) { this.person = person; this.badges = badges; this.badgesInProgress = badgesInProgress; + this.jenkinsUsers = jenkinsUsers; } } diff --git a/src/main/resources/webapp/WEB-INF/tags/common/head.tagx b/src/main/resources/webapp/WEB-INF/tags/common/head.tagx index 7121fe1..2c060b5 100755 --- a/src/main/resources/webapp/WEB-INF/tags/common/head.tagx +++ b/src/main/resources/webapp/WEB-INF/tags/common/head.tagx @@ -31,6 +31,7 @@ {datejs: "/external/datejs-Alpha1/date.js"}, {spin: "/external/spin-1.2.7/spin.js"}, {app: "/apps/app.js"}, + {JenkinsResources: "/apps/jenkinsApp/JenkinsResources.js"}, {PagingTableService: "/apps/core/PagingTableService.js"} ); diff --git a/src/main/resources/webapp/apps/core/navbar.html b/src/main/resources/webapp/apps/core/navbar.html index 9226f2e..672b1e3 100755 --- a/src/main/resources/webapp/apps/core/navbar.html +++ b/src/main/resources/webapp/apps/core/navbar.html @@ -4,10 +4,10 @@ Wat diff --git a/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js b/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js old mode 100644 new mode 100755 index 89f3139..6d91994 --- a/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js +++ b/src/main/resources/webapp/apps/jenkinsApp/JenkinsResources.js @@ -23,3 +23,11 @@ function JenkinsBuild($resource) { angular. module('jenkinsBuild', ['ngResource']). factory('JenkinsBuild', JenkinsBuild); + +function JenkinsUser($resource) { + return $resource('/resource/jenkins/user/:uuid', {uuid: '@uuid'}); +} + +angular. + module('jenkinsUser', ['ngResource']). + factory('JenkinsUser', JenkinsUser); diff --git a/src/main/resources/webapp/jenkins/index.jspx b/src/main/resources/webapp/jenkins/index.jspx index 0e8dc22..a26b07d 100755 --- a/src/main/resources/webapp/jenkins/index.jspx +++ b/src/main/resources/webapp/jenkins/index.jspx @@ -5,7 +5,6 @@ - -- cgit v1.2.3