aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-10 15:16:36 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-10 15:16:36 +0100
commite16e32c653cda7e47a6b9dc8515f187658549921 (patch)
treebebfb7c15bbf7b5ab39dfdcd6627bf79d765b256 /src/main
parent34f5ac99c81dfe39f986e8133fb7fff22c0d30bc (diff)
downloadesper-testing-e16e32c653cda7e47a6b9dc8515f187658549921.tar.gz
esper-testing-e16e32c653cda7e47a6b9dc8515f187658549921.tar.bz2
esper-testing-e16e32c653cda7e47a6b9dc8515f187658549921.tar.xz
esper-testing-e16e32c653cda7e47a6b9dc8515f187658549921.zip
o Adding some utilities.
Diffstat (limited to 'src/main')
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java30
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java17
2 files changed, 35 insertions, 12 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
index bd99768..0195900 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
@@ -18,11 +18,11 @@ public class JenkinsDao {
private final Connection c;
- private static final String JENKINS_SERVER = "uuid, created_date, url";
+ public static final String JENKINS_SERVER = "uuid, created_date, url";
- private static final String JENKINS_JOB = "uuid, created_date, server, url, job_type, display_name";
+ public static final String JENKINS_JOB = "uuid, created_date, server, url, job_type, display_name";
- private static final String JENKINS_BUILD = "uuid, created_date, job, entry_id, url, result, number, duration, timestamp";
+ public static final String JENKINS_BUILD = "uuid, created_date, job, entry_id, url, result, number, duration, timestamp";
public JenkinsDao(Connection c) {
this.c = c;
@@ -36,6 +36,14 @@ public class JenkinsDao {
URI.create(rs.getString(i)));
}
+ public List<JenkinsServerDto> toServerList(ResultSet rs) throws SQLException {
+ List<JenkinsServerDto> list = new ArrayList<>();
+ while (rs.next()) {
+ list.add(jenkinsServer(rs));
+ }
+ return list;
+ }
+
private JenkinsJobDto jenkinsJob(ResultSet rs) throws SQLException {
int i = 1;
return new JenkinsJobDto(
@@ -46,6 +54,14 @@ public class JenkinsDao {
fromNull(rs.getString(i)));
}
+ public List<JenkinsJobDto> toJobList(ResultSet rs) throws SQLException {
+ List<JenkinsJobDto> list = new ArrayList<>();
+ while (rs.next()) {
+ list.add(jenkinsJob(rs));
+ }
+ return list;
+ }
+
private JenkinsBuildDto jenkinsBuild(ResultSet rs) throws SQLException {
int i = 1;
return new JenkinsBuildDto(
@@ -65,13 +81,7 @@ public class JenkinsDao {
where += enabledOnly ? "enabled=true" : "";
try (PreparedStatement s = c.prepareStatement("SELECT " + JENKINS_SERVER + " FROM jenkins_server " + where)) {
- ResultSet rs = s.executeQuery();
-
- List<JenkinsServerDto> servers = new ArrayList<>();
- while (rs.next()) {
- servers.add(jenkinsServer(rs));
- }
- return servers;
+ return toServerList(s.executeQuery());
}
}
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java
index fa30f14..4bbc007 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java
@@ -56,7 +56,7 @@ public class JenkinsServerActor implements TransactionalActor {
JenkinsBuildXml build = buildXmlOption.some();
- URI jobUrl = createJobUrl(build.url.toASCIIString());
+ URI jobUrl = extrapolateJobUrlFromBuildUrl(build.url.toASCIIString());
Option<JenkinsJobDto> jobDtoOption = dao.selectJobByUrl(jobUrl);
@@ -102,7 +102,7 @@ public class JenkinsServerActor implements TransactionalActor {
/**
* This sucks, a build should really include the URL to the job.
*/
- public static URI createJobUrl(String u) {
+ public static URI extrapolateJobUrlFromBuildUrl(String u) {
if (!u.matches(".*/[0-9]*/")) {
throw new RuntimeException("Not a valid build url: " + u);
}
@@ -112,4 +112,17 @@ public class JenkinsServerActor implements TransactionalActor {
return URI.create(u);
}
+
+ public static String extrapolateMavenModuleFromMavenModuleSetUrl(String u) {
+ int i = u.lastIndexOf("/");
+ if (i == -1) {
+ throw new RuntimeException("Illegal URL");
+ }
+ u = u.substring(0, i);
+ i = u.lastIndexOf("/");
+ if (i == -1) {
+ throw new RuntimeException("Illegal URL");
+ }
+ return u.substring(0, i + 1);
+ }
}