aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java3
-rw-r--r--src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java5
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java4
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java6
-rw-r--r--src/main/sql/dbdelta/3-jenkins_server-add-name.sql7
5 files changed, 19 insertions, 6 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 9ecb78a..781df13 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
@@ -20,7 +20,7 @@ public class JenkinsDao {
private final Connection c;
- public static final String JENKINS_SERVER = "uuid, created_date, url, enabled";
+ public static final String JENKINS_SERVER = "uuid, created_date, name, url, enabled";
public static final String JENKINS_JOB = "uuid, created_date, server, file, url, job_type, display_name";
@@ -36,6 +36,7 @@ public class JenkinsDao {
return new JenkinsServerDto(
UUID.fromString(rs.getString(i++)),
new DateTime(rs.getTimestamp(i++).getTime()),
+ rs.getString(i++),
URI.create(rs.getString(i++)),
rs.getBoolean(i));
}
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java
index fb72a99..a5308f5 100644
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java
@@ -1,6 +1,7 @@
package io.trygvis.esper.testing.jenkins;
import com.jolbox.bonecp.*;
+import fj.data.*;
import io.trygvis.esper.testing.*;
import io.trygvis.esper.testing.util.object.*;
import io.trygvis.esper.testing.util.*;
@@ -8,7 +9,7 @@ import org.apache.abdera.*;
import org.codehaus.httpcache4j.cache.*;
import java.sql.*;
-import java.util.*;
+import java.util.HashSet;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
@@ -28,7 +29,7 @@ public class JenkinsImporter {
ObjectManager<JenkinsServerDto, ActorRef<JenkinsServerActor>> serverManager = new ObjectManager<>("JenkinsServerOld", servers, new ObjectFactory<JenkinsServerDto, ActorRef<JenkinsServerActor>>() {
public ActorRef<JenkinsServerActor> create(JenkinsServerDto server) {
- String name = "Jenkins: " + server.url;
+ String name = "Jenkins: " + Option.fromNull(server.name).orSome(server.url.toASCIIString());
return threadedActor(name, config.jenkinsUpdateInterval, boneCp, name, new JenkinsServerActor(jenkinsClient, server));
}
});
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java
index 8195f01..d85554d 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerDto.java
@@ -7,11 +7,13 @@ import java.net.*;
import java.util.*;
public class JenkinsServerDto extends AbstractEntity {
+ public final String name;
public final URI url;
public final boolean enabled;
- JenkinsServerDto(UUID uuid, DateTime createdDate, URI url, boolean enabled) {
+ public JenkinsServerDto(UUID uuid, DateTime createdDate, String name, URI url, boolean enabled) {
super(uuid, createdDate);
+ this.name = name;
this.url = url;
this.enabled = enabled;
}
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 3169096..21bfe19 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
@@ -132,7 +132,7 @@ public class JenkinsResource extends AbstractResource {
jobs.add(getJenkinsJobJson.apply(jobDto));
}
- return new JenkinsServerJson(server.uuid, server.createdDate, server.url, server.enabled, count, jobs);
+ return new JenkinsServerJson(server.uuid, server.createdDate, server.name, server.url, server.enabled, count, jobs);
}
};
@@ -191,14 +191,16 @@ public class JenkinsResource extends AbstractResource {
class JenkinsServerJson {
public final UUID uuid;
public final DateTime createdDate;
+ public final String name;
public final URI url;
public final boolean enabled;
public final int jobCount;
public final List<JenkinsJobJson> recentJobs;
- JenkinsServerJson(UUID uuid, DateTime createdDate, URI url, boolean enabled, int jobCount, List<JenkinsJobJson> recentJobs) {
+ JenkinsServerJson(UUID uuid, DateTime createdDate, String name, URI url, boolean enabled, int jobCount, List<JenkinsJobJson> recentJobs) {
this.uuid = uuid;
this.createdDate = createdDate;
+ this.name = name;
this.url = url;
this.enabled = enabled;
this.jobCount = jobCount;
diff --git a/src/main/sql/dbdelta/3-jenkins_server-add-name.sql b/src/main/sql/dbdelta/3-jenkins_server-add-name.sql
new file mode 100644
index 0000000..4d6a58f
--- /dev/null
+++ b/src/main/sql/dbdelta/3-jenkins_server-add-name.sql
@@ -0,0 +1,7 @@
+ALTER TABLE jenkins_server ADD name VARCHAR(100);
+
+UPDATE jenkins_server SET name = regexp_replace(url, '^https?://([^/]*).*', '\1');
+
+--//@UNDO
+
+ALTER TABLE jenkins_server DROP name;