Format Java files with google-java-format 1.6
Change-Id: Ic01cf1c17a21d863b1ed70932dbb438d815f251b
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/GlobalModule.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/GlobalModule.java
index e6f5a6c..4307c48 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/GlobalModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/GlobalModule.java
@@ -14,9 +14,9 @@
package com.googlesource.gerrit.plugins.verifystatus;
-import static com.google.inject.Scopes.SINGLETON;
import static com.google.gerrit.server.change.RevisionResource.REVISION_KIND;
import static com.google.gerrit.server.config.ConfigResource.CONFIG_KIND;
+import static com.google.inject.Scopes.SINGLETON;
import com.google.gerrit.extensions.annotations.Exports;
import com.google.gerrit.extensions.config.CapabilityDefinition;
@@ -28,19 +28,16 @@
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.name.Names;
-
-import com.googlesource.gerrit.plugins.verifystatus.server.PutConfig;
import com.googlesource.gerrit.plugins.verifystatus.server.GetConfig;
import com.googlesource.gerrit.plugins.verifystatus.server.GetVerifications;
+import com.googlesource.gerrit.plugins.verifystatus.server.PutConfig;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.CiDataSourceModule;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.CiDataSourceProvider;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.CiDataSourceType;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.CiDataSourceTypeGuesser;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.CiDatabaseModule;
-
import java.util.ArrayList;
import java.util.List;
-
import javax.sql.DataSource;
class GlobalModule extends FactoryModule {
@@ -54,47 +51,52 @@
@Override
protected void configure() {
bind(CapabilityDefinition.class)
- .annotatedWith(Exports.named(AccessCiDatabaseCapability.ID))
- .to(AccessCiDatabaseCapability.class);
+ .annotatedWith(Exports.named(AccessCiDatabaseCapability.ID))
+ .to(AccessCiDatabaseCapability.class);
bind(CapabilityDefinition.class)
- .annotatedWith(Exports.named(SaveReportCapability.ID))
- .to(SaveReportCapability.class);
+ .annotatedWith(Exports.named(SaveReportCapability.ID))
+ .to(SaveReportCapability.class);
List<Module> modules = new ArrayList<>();
- modules.add(new LifecycleModule() {
- @Override
- protected void configure() {
- // For bootstrap we need to retrieve the ds type first
- CiDataSourceTypeGuesser guesser =
- injector.createChildInjector(
- new CiDataSourceModule()).getInstance(
- Key.get(CiDataSourceTypeGuesser.class));
+ modules.add(
+ new LifecycleModule() {
+ @Override
+ protected void configure() {
+ // For bootstrap we need to retrieve the ds type first
+ CiDataSourceTypeGuesser guesser =
+ injector
+ .createChildInjector(new CiDataSourceModule())
+ .getInstance(Key.get(CiDataSourceTypeGuesser.class));
- // For the ds type we retrieve the underlying implementation
- CiDataSourceType dst = injector.createChildInjector(
- new CiDataSourceModule()).getInstance(
- Key.get(CiDataSourceType.class,
- Names.named(guesser.guessDataSourceType())));
- // Bind the type to the retrieved instance
- bind(CiDataSourceType.class).toInstance(dst);
- bind(CiDataSourceProvider.Context.class).toInstance(
- CiDataSourceProvider.Context.MULTI_USER);
- bind(Key.get(DataSource.class, Names.named("CiDb"))).toProvider(
- CiDataSourceProvider.class).in(SINGLETON);
- listener().to(CiDataSourceProvider.class);
- }
- });
+ // For the ds type we retrieve the underlying implementation
+ CiDataSourceType dst =
+ injector
+ .createChildInjector(new CiDataSourceModule())
+ .getInstance(
+ Key.get(
+ CiDataSourceType.class, Names.named(guesser.guessDataSourceType())));
+ // Bind the type to the retrieved instance
+ bind(CiDataSourceType.class).toInstance(dst);
+ bind(CiDataSourceProvider.Context.class)
+ .toInstance(CiDataSourceProvider.Context.MULTI_USER);
+ bind(Key.get(DataSource.class, Names.named("CiDb")))
+ .toProvider(CiDataSourceProvider.class)
+ .in(SINGLETON);
+ listener().to(CiDataSourceProvider.class);
+ }
+ });
modules.add(new CiDatabaseModule());
for (Module module : modules) {
install(module);
}
- install(new RestApiModule() {
- @Override
- protected void configure() {
- get(CONFIG_KIND, "config").to(GetConfig.class);
- put(CONFIG_KIND, "config").to(PutConfig.class);
- get(REVISION_KIND, "verifications").to(GetVerifications.class);
- post(REVISION_KIND, "verifications").to(PostVerification.class);
- }
- });
+ install(
+ new RestApiModule() {
+ @Override
+ protected void configure() {
+ get(CONFIG_KIND, "config").to(GetConfig.class);
+ put(CONFIG_KIND, "config").to(PutConfig.class);
+ get(REVISION_KIND, "verifications").to(GetVerifications.class);
+ post(REVISION_KIND, "verifications").to(PostVerification.class);
+ }
+ });
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
index d48a40d..8ea70ca 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
@@ -22,7 +22,6 @@
class HttpModule extends HttpPluginModule {
@Override
protected void configureServlets() {
- DynamicSet.bind(binder(), WebUiPlugin.class)
- .toInstance(new GwtPlugin("verifystatus"));
+ DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new GwtPlugin("verifystatus"));
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java
index 8198981..cce3202 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.googlesource.gerrit.plugins.verifystatus;
+package com.googlesource.gerrit.plugins.verifystatus;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
@@ -35,33 +35,29 @@
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
-
import com.googlesource.gerrit.plugins.verifystatus.common.VerificationInfo;
import com.googlesource.gerrit.plugins.verifystatus.common.VerifyInput;
import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
import com.googlesource.gerrit.plugins.verifystatus.server.PatchSetVerification;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Singleton
@RequiresCapability(SaveReportCapability.ID)
-public class PostVerification
- implements RestModifyView<RevisionResource, VerifyInput> {
- private static final Logger log =
- LoggerFactory.getLogger(PostVerification.class);
+public class PostVerification implements RestModifyView<RevisionResource, VerifyInput> {
+ private static final Logger log = LoggerFactory.getLogger(PostVerification.class);
private final SchemaFactory<CiDb> schemaFactory;
private final String pluginName;
private final Provider<CurrentUser> userProvider;
@Inject
- PostVerification(@PluginName String pluginName,
+ PostVerification(
+ @PluginName String pluginName,
Provider<CurrentUser> userProvider,
SchemaFactory<CiDb> schemaFactory) {
this.pluginName = pluginName;
@@ -71,8 +67,8 @@
@Override
public Response<?> apply(RevisionResource revision, VerifyInput input)
- throws AuthException, BadRequestException, UnprocessableEntityException,
- OrmException, IOException {
+ throws AuthException, BadRequestException, UnprocessableEntityException, OrmException,
+ IOException {
try {
checkPermission();
@@ -100,8 +96,8 @@
return Response.none();
}
- private boolean updateLabels(RevisionResource resource, CiDb db,
- Map<String, VerificationInfo> jobs)
+ private boolean updateLabels(
+ RevisionResource resource, CiDb db, Map<String, VerificationInfo> jobs)
throws OrmException, BadRequestException {
Preconditions.checkNotNull(jobs);
@@ -153,16 +149,16 @@
if (duration != null) {
c.setDuration(duration);
}
- log.info("Updating job " + c.getJob() + " for change "
- + c.getPatchSetId());
+ log.info("Updating job " + c.getJob() + " for change " + c.getPatchSetId());
ups.add(c);
} else {
// add new result
String job_id = UUID.randomUUID().toString();
- c = new PatchSetVerification(new PatchSetVerification.Key(
- resource.getPatchSet().getId(),
- new LabelId(job_id)),
- value, ts);
+ c =
+ new PatchSetVerification(
+ new PatchSetVerification.Key(resource.getPatchSet().getId(), new LabelId(job_id)),
+ value,
+ ts);
c.setAbstain(ent.getValue().abstain);
c.setRerun(ent.getValue().rerun);
c.setUrl(ent.getValue().url);
@@ -171,8 +167,7 @@
c.setComment(ent.getValue().comment);
c.setCategory(ent.getValue().category);
c.setDuration(ent.getValue().duration);
- log.info("Adding job " + c.getJob() + " for change "
- + c.getPatchSetId());
+ log.info("Adding job " + c.getJob() + " for change " + c.getPatchSetId());
ups.add(c);
}
}
@@ -181,35 +176,33 @@
return !ups.isEmpty();
}
- private Map<String, PatchSetVerification> scanLabels(
- RevisionResource resource, CiDb db)
+ private Map<String, PatchSetVerification> scanLabels(RevisionResource resource, CiDb db)
throws OrmException {
Map<String, PatchSetVerification> current = Maps.newHashMap();
- for (PatchSetVerification v : db.patchSetVerifications()
- .byPatchSet(resource.getPatchSet().getId())) {
+ for (PatchSetVerification v :
+ db.patchSetVerifications().byPatchSet(resource.getPatchSet().getId())) {
current.put(v.getJobId().get(), v);
}
return current;
}
/**
- * Assert that the current user is permitted to perform saving of verification
- * reports.
- * <p>
- * As the @RequireCapability guards at various entry points of internal
- * commands implicitly add administrators (which we want to avoid), we also
- * check permissions within QueryShell and grant access only to those who
- * canPerformRawQuery, regardless of whether they are administrators or not.
+ * Assert that the current user is permitted to perform saving of verification reports.
+ *
+ * <p>As the @RequireCapability guards at various entry points of internal commands implicitly add
+ * administrators (which we want to avoid), we also check permissions within QueryShell and grant
+ * access only to those who canPerformRawQuery, regardless of whether they are administrators or
+ * not.
*
* @throws PermissionDeniedException
*/
private void checkPermission() throws PermissionDeniedException {
CapabilityControl ctl = userProvider.get().getCapabilities();
if (!ctl.canPerform(SaveReportCapability.getName(pluginName))) {
- throw new PermissionDeniedException(String.format(
- "%s does not have \"%s\" capability.",
- userProvider.get().getUserName(),
- new SaveReportCapability().getDescription()));
+ throw new PermissionDeniedException(
+ String.format(
+ "%s does not have \"%s\" capability.",
+ userProvider.get().getUserName(), new SaveReportCapability().getDescription()));
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
index b2da1de..a24126c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
@@ -37,44 +37,41 @@
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
-
import com.googlesource.gerrit.plugins.verifystatus.common.VerificationInfo;
import com.googlesource.gerrit.plugins.verifystatus.common.VerifyInput;
-
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
@RequiresCapability(SaveReportCapability.ID)
@CommandMetaData(name = "save", description = "Save patchset verification data")
public class SaveCommand extends SshCommand {
- private static final Logger log =
- LoggerFactory.getLogger(SaveCommand.class);
+ private static final Logger log = LoggerFactory.getLogger(SaveCommand.class);
private final Set<PatchSet> patchSets = new HashSet<>();
private final String pluginName;
private final Provider<CurrentUser> userProvider;
@Inject
- SaveCommand(@PluginName String pluginName,
- Provider<CurrentUser> userProvider) {
+ SaveCommand(@PluginName String pluginName, Provider<CurrentUser> userProvider) {
this.pluginName = pluginName;
this.userProvider = userProvider;
}
- @Argument(index = 0, required = true, multiValued = true,
+ @Argument(
+ index = 0,
+ required = true,
+ multiValued = true,
metaVar = "{COMMIT | CHANGE,PATCHSET}",
usage = "list of commits or patch sets to verify")
void addPatchSetId(String token) {
try {
- PatchSet ps = psParser.parsePatchSet(token, projectControl,
- branch);
+ PatchSet ps = psParser.parsePatchSet(token, projectControl, branch);
patchSets.add(ps);
} catch (UnloggedFailure e) {
throw new IllegalArgumentException(e.getMessage(), e);
@@ -83,16 +80,20 @@
}
}
- @Option(name = "--project", aliases = "-p",
+ @Option(
+ name = "--project",
+ aliases = "-p",
usage = "project containing the specified patch set(s)")
private ProjectControl projectControl;
- @Option(name = "--branch", aliases = "-b",
- usage = "branch containing the specified patch set(s)")
+ @Option(name = "--branch", aliases = "-b", usage = "branch containing the specified patch set(s)")
private String branch;
- @Option(name = "--verification", aliases = "-v",
- usage = "verification to set the result for", metaVar = "VERIFY=OUTCOME")
+ @Option(
+ name = "--verification",
+ aliases = "-v",
+ usage = "verification to set the result for",
+ metaVar = "VERIFY=OUTCOME")
void addJob(String token) {
parseWithEquals(token);
}
@@ -128,17 +129,13 @@
jobResult.put(name, data);
}
- @Inject
- private PostVerification postVerification;
+ @Inject private PostVerification postVerification;
- @Inject
- private PatchSetParser psParser;
+ @Inject private PatchSetParser psParser;
- @Inject
- private Revisions revisions;
+ @Inject private Revisions revisions;
- @Inject
- private ChangesCollection changes;
+ @Inject private ChangesCollection changes;
private Map<String, VerificationInfo> jobResult = Maps.newHashMap();
@@ -161,17 +158,16 @@
}
if (!ok) {
- throw new UnloggedFailure(1, "one or more verifications failed;"
- + " review output above");
+ throw new UnloggedFailure(1, "one or more verifications failed;" + " review output above");
}
}
private void applyVerification(PatchSet patchSet, VerifyInput verify)
- throws RestApiException, OrmException,
- IOException {
- RevisionResource revResource = revisions.parse(
- changes.parse(patchSet.getId().getParentKey()),
- IdString.fromUrl(patchSet.getId().getId()));
+ throws RestApiException, OrmException, IOException {
+ RevisionResource revResource =
+ revisions.parse(
+ changes.parse(patchSet.getId().getParentKey()),
+ IdString.fromUrl(patchSet.getId().getId()));
postVerification.apply(revResource, verify);
}
@@ -180,8 +176,7 @@
verify.verifications = jobResult;
try {
applyVerification(patchSet, verify);
- } catch (RestApiException | OrmException
- | IOException e) {
+ } catch (RestApiException | OrmException | IOException e) {
throw PatchSetParser.error(e.getMessage());
}
}
@@ -194,23 +189,22 @@
}
/**
- * Assert that the current user is permitted to perform saving of verification
- * reports.
- * <p>
- * As the @RequireCapability guards at various entry points of internal
- * commands implicitly add administrators (which we want to avoid), we also
- * check permissions within QueryShell and grant access only to those who
- * canPerformRawQuery, regardless of whether they are administrators or not.
+ * Assert that the current user is permitted to perform saving of verification reports.
+ *
+ * <p>As the @RequireCapability guards at various entry points of internal commands implicitly add
+ * administrators (which we want to avoid), we also check permissions within QueryShell and grant
+ * access only to those who canPerformRawQuery, regardless of whether they are administrators or
+ * not.
*
* @throws PermissionDeniedException
*/
private void checkPermission() throws PermissionDeniedException {
CapabilityControl ctl = userProvider.get().getCapabilities();
if (!ctl.canPerform(pluginName + "-" + SaveReportCapability.ID)) {
- throw new PermissionDeniedException(String.format(
- "%s does not have \"%s\" capability.",
- userProvider.get().getUserName(),
- new SaveReportCapability().getDescription()));
+ throw new PermissionDeniedException(
+ String.format(
+ "%s does not have \"%s\" capability.",
+ userProvider.get().getUserName(), new SaveReportCapability().getDescription()));
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SshModule.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SshModule.java
index 1bbd3df..0f43a54 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SshModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SshModule.java
@@ -16,7 +16,6 @@
import com.google.gerrit.sshd.PluginCommandModule;
-
class SshModule extends PluginCommandModule {
@Override
protected void configureCommands() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusAdminQueryShell.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusAdminQueryShell.java
index 3bf9ea3..03fe5b7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusAdminQueryShell.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusAdminQueryShell.java
@@ -24,7 +24,6 @@
import com.google.gerrit.sshd.SshCommand;
import com.google.inject.Inject;
import com.google.inject.Provider;
-
import org.kohsuke.args4j.Option;
/** Opens a query processor. */
@@ -35,8 +34,7 @@
private final String pluginName;
private final Provider<CurrentUser> userProvider;
- @Inject
- private VerifyStatusQueryShell.Factory factory;
+ @Inject private VerifyStatusQueryShell.Factory factory;
@Option(name = "--format", usage = "Set output format")
private VerifyStatusQueryShell.OutputFormat format = VerifyStatusQueryShell.OutputFormat.PRETTY;
@@ -45,8 +43,7 @@
private String query;
@Inject
- VerifyStatusAdminQueryShell(@PluginName String pluginName,
- Provider<CurrentUser> userProvider) {
+ VerifyStatusAdminQueryShell(@PluginName String pluginName, Provider<CurrentUser> userProvider) {
this.pluginName = pluginName;
this.userProvider = userProvider;
}
@@ -70,21 +67,21 @@
/**
* Assert that the current user is permitted to perform raw queries.
- * <p>
- * As the @RequireCapability guards at various entry points of internal
- * commands implicitly add administrators (which we want to avoid), we also
- * check permissions within QueryShell and grant access only to those who
- * canPerformRawQuery, regardless of whether they are administrators or not.
+ *
+ * <p>As the @RequireCapability guards at various entry points of internal commands implicitly add
+ * administrators (which we want to avoid), we also check permissions within QueryShell and grant
+ * access only to those who canPerformRawQuery, regardless of whether they are administrators or
+ * not.
*
* @throws PermissionDeniedException
*/
private void checkPermission() throws PermissionDeniedException {
CapabilityControl ctl = userProvider.get().getCapabilities();
if (!ctl.canPerform(pluginName + "-" + AccessCiDatabaseCapability.ID)) {
- throw new PermissionDeniedException(String.format(
- "%s does not have \"%s\" capability.",
- userProvider.get().getUserName(),
- new AccessCiDatabaseCapability().getDescription()));
+ throw new PermissionDeniedException(
+ String.format(
+ "%s does not have \"%s\" capability.",
+ userProvider.get().getUserName(), new AccessCiDatabaseCapability().getDescription()));
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusQueryShell.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusQueryShell.java
index 980e754..1fd180c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusQueryShell.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusQueryShell.java
@@ -26,9 +26,7 @@
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
-
import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
-
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -55,7 +53,9 @@
}
public static enum OutputFormat {
- PRETTY, JSON, JSON_SINGLE
+ PRETTY,
+ JSON,
+ JSON_SINGLE
}
private final BufferedReader in;
@@ -68,9 +68,8 @@
private Statement statement;
@Inject
- VerifyStatusQueryShell(SchemaFactory<CiDb> dbFactory,
- @Assisted InputStream in,
- @Assisted OutputStream out) {
+ VerifyStatusQueryShell(
+ SchemaFactory<CiDb> dbFactory, @Assisted InputStream in, @Assisted OutputStream out) {
this.dbFactory = dbFactory;
this.in = new BufferedReader(new InputStreamReader(in, UTF_8));
this.out = new PrintWriter(new OutputStreamWriter(out, UTF_8));
@@ -134,7 +133,7 @@
private void readEvalPrintLoop() {
final StringBuilder buffer = new StringBuilder();
boolean executed = false;
- for (;;) {
+ for (; ; ) {
if (outputFormat == OutputFormat.PRETTY) {
print(buffer.length() == 0 || executed ? "gerrit> " : " -> ");
}
@@ -179,13 +178,14 @@
final String msg = "'\\" + line + "' not supported";
switch (outputFormat) {
case JSON_SINGLE:
- case JSON: {
- final JsonObject err = new JsonObject();
- err.addProperty("type", "error");
- err.addProperty("message", msg);
- println(err.toString());
- break;
- }
+ case JSON:
+ {
+ final JsonObject err = new JsonObject();
+ err.addProperty("type", "error");
+ err.addProperty("message", msg);
+ println(err.toString());
+ break;
+ }
case PRETTY:
default:
println("ERROR: " + msg);
@@ -227,7 +227,10 @@
if (outputFormat == OutputFormat.PRETTY) {
println(" List of relations");
}
- showResultSet(rs, false, 0,
+ showResultSet(
+ rs,
+ false,
+ 0,
Identity.create(rs, "TABLE_SCHEM"),
Identity.create(rs, "TABLE_NAME"),
Identity.create(rs, "TABLE_TYPE"));
@@ -261,7 +264,10 @@
if (outputFormat == OutputFormat.PRETTY) {
println(" Table " + tableName);
}
- showResultSet(rs, true, 0,
+ showResultSet(
+ rs,
+ true,
+ 0,
Identity.create(rs, "COLUMN_NAME"),
new Function("TYPE") {
@Override
@@ -358,14 +364,15 @@
final long ms = TimeUtil.nowMs() - start;
switch (outputFormat) {
case JSON_SINGLE:
- case JSON: {
- final JsonObject tail = new JsonObject();
- tail.addProperty("type", "update-stats");
- tail.addProperty("rowCount", updateCount);
- tail.addProperty("runTimeMilliseconds", ms);
- println(tail.toString());
- break;
- }
+ case JSON:
+ {
+ final JsonObject tail = new JsonObject();
+ tail.addProperty("type", "update-stats");
+ tail.addProperty("rowCount", updateCount);
+ tail.addProperty("runTimeMilliseconds", ms);
+ println(tail.toString());
+ break;
+ }
case PRETTY:
default:
@@ -382,20 +389,19 @@
* Outputs a result set to stdout.
*
* @param rs ResultSet to show.
- * @param alreadyOnRow true if rs is already on the first row. false
- * otherwise.
- * @param start Timestamp in milliseconds when executing the statement
- * started. This timestamp is used to compute statistics about the
- * statement. If no statistics should be shown, set it to 0.
+ * @param alreadyOnRow true if rs is already on the first row. false otherwise.
+ * @param start Timestamp in milliseconds when executing the statement started. This timestamp is
+ * used to compute statistics about the statement. If no statistics should be shown, set it to
+ * 0.
* @param show Functions to map columns
* @throws SQLException
*/
- private void showResultSet(final ResultSet rs, boolean alreadyOnRow,
- long start, Function... show) throws SQLException {
+ private void showResultSet(final ResultSet rs, boolean alreadyOnRow, long start, Function... show)
+ throws SQLException {
switch (outputFormat) {
case JSON_SINGLE:
case JSON:
- showResultSetJson(rs, alreadyOnRow, start, show);
+ showResultSetJson(rs, alreadyOnRow, start, show);
break;
case PRETTY:
default:
@@ -408,16 +414,15 @@
* Outputs a result set to stdout in Json format.
*
* @param rs ResultSet to show.
- * @param alreadyOnRow true if rs is already on the first row. false
- * otherwise.
- * @param start Timestamp in milliseconds when executing the statement
- * started. This timestamp is used to compute statistics about the
- * statement. If no statistics should be shown, set it to 0.
+ * @param alreadyOnRow true if rs is already on the first row. false otherwise.
+ * @param start Timestamp in milliseconds when executing the statement started. This timestamp is
+ * used to compute statistics about the statement. If no statistics should be shown, set it to
+ * 0.
* @param show Functions to map columns
* @throws SQLException
*/
- private void showResultSetJson(final ResultSet rs, boolean alreadyOnRow,
- long start, Function... show) throws SQLException {
+ private void showResultSetJson(
+ final ResultSet rs, boolean alreadyOnRow, long start, Function... show) throws SQLException {
JsonArray collector = new JsonArray();
final ResultSetMetaData meta = rs.getMetaData();
final Function[] columnMap;
@@ -498,16 +503,15 @@
* Outputs a result set to stdout in plain text format.
*
* @param rs ResultSet to show.
- * @param alreadyOnRow true if rs is already on the first row. false
- * otherwise.
- * @param start Timestamp in milliseconds when executing the statement
- * started. This timestamp is used to compute statistics about the
- * statement. If no statistics should be shown, set it to 0.
+ * @param alreadyOnRow true if rs is already on the first row. false otherwise.
+ * @param start Timestamp in milliseconds when executing the statement started. This timestamp is
+ * used to compute statistics about the statement. If no statistics should be shown, set it to
+ * 0.
* @param show Functions to map columns
* @throws SQLException
*/
- private void showResultSetPretty(final ResultSet rs, boolean alreadyOnRow,
- long start, Function... show) throws SQLException {
+ private void showResultSetPretty(
+ final ResultSet rs, boolean alreadyOnRow, long start, Function... show) throws SQLException {
final ResultSetMetaData meta = rs.getMetaData();
final Function[] columnMap;
@@ -609,21 +613,21 @@
if (start != 0) {
final int rowCount = rows.size();
final long ms = TimeUtil.nowMs() - start;
- println("(" + rowCount + (rowCount == 1 ? " row" : " rows")
- + "; " + ms + " ms)");
+ println("(" + rowCount + (rowCount == 1 ? " row" : " rows") + "; " + ms + " ms)");
}
}
private void warning(final String msg) {
switch (outputFormat) {
case JSON_SINGLE:
- case JSON: {
- final JsonObject obj = new JsonObject();
- obj.addProperty("type", "warning");
- obj.addProperty("message", msg);
- println(obj.toString());
- break;
- }
+ case JSON:
+ {
+ final JsonObject obj = new JsonObject();
+ obj.addProperty("type", "warning");
+ obj.addProperty("message", msg);
+ println(obj.toString());
+ break;
+ }
case PRETTY:
default:
@@ -635,13 +639,14 @@
private void error(final SQLException err) {
switch (outputFormat) {
case JSON_SINGLE:
- case JSON: {
- final JsonObject obj = new JsonObject();
- obj.addProperty("type", "error");
- obj.addProperty("message", err.getMessage());
- println(obj.toString());
- break;
- }
+ case JSON:
+ {
+ final JsonObject obj = new JsonObject();
+ obj.addProperty("type", "error");
+ obj.addProperty("message", err.getMessage());
+ println(obj.toString());
+ break;
+ }
case PRETTY:
default:
@@ -718,8 +723,7 @@
}
private static class Identity extends Function {
- static Identity create(final ResultSet rs, final String name)
- throws SQLException {
+ static Identity create(final ResultSet rs, final String name) throws SQLException {
return new Identity(rs.findColumn(name), name);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/ConfigInfo.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/ConfigInfo.java
index 731da60..2d3f1db 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/ConfigInfo.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/ConfigInfo.java
@@ -17,27 +17,45 @@
import com.google.gwt.core.client.JavaScriptObject;
public class ConfigInfo extends JavaScriptObject {
- final native boolean showJobsSummaryPanel() /*-{ return this.show_jobs_summary_panel ? true : false; }-*/;
+ final native boolean
+ showJobsSummaryPanel() /*-{ return this.show_jobs_summary_panel ? true : false; }-*/;
+
final native boolean showJobsPanel() /*-{ return this.show_jobs_panel ? true : false; }-*/;
- final native boolean showJobsDropDownPanel() /*-{ return this.show_jobs_drop_down_panel ? true : false; }-*/;
- final native boolean showJobsBelowRelatedInfoBlock() /*-{ return this.show_jobs_below_related_info_block ? true : false; }-*/;
- final native boolean enableInProgressStatus() /*-{ return this.enable_in_progress_status ? true : false; }-*/;
+
+ final native boolean
+ showJobsDropDownPanel() /*-{ return this.show_jobs_drop_down_panel ? true : false; }-*/;
+
+ final native boolean
+ showJobsBelowRelatedInfoBlock() /*-{ return this.show_jobs_below_related_info_block ? true : false; }-*/;
+
+ final native boolean
+ enableInProgressStatus() /*-{ return this.enable_in_progress_status ? true : false; }-*/;
+
final native String sortJobsPanel() /*-{ return this.sort_jobs_panel }-*/;
+
final native String sortJobsDropDownPanel() /*-{ return this.sort_jobs_drop_down_panel }-*/;
final native void setShowJobsSummaryPanel(boolean s) /*-{ this.show_jobs_summary_panel = s; }-*/;
+
final native void setShowJobsPanel(boolean s) /*-{ this.show_jobs_panel = s; }-*/;
- final native void setShowJobsDropDownPanel(boolean s) /*-{ this.show_jobs_drop_down_panel = s; }-*/;
- final native void setShowJobsBelowRelatedInfoBlock(boolean s) /*-{ this.show_jobs_below_related_info_block = s; }-*/;
+
+ final native void setShowJobsDropDownPanel(
+ boolean s) /*-{ this.show_jobs_drop_down_panel = s; }-*/;
+
+ final native void setShowJobsBelowRelatedInfoBlock(
+ boolean s) /*-{ this.show_jobs_below_related_info_block = s; }-*/;
+
final native void setEnableInProgressStatus() /*-{ this.enable_in_progress_status = s; }-*/;
+
final native void setSortJobsPanel(String s) /*-{ this.sort_jobs_panel = s; }-*/;
- final native void setSortJobsDropDownPanel(String s) /*-{ this.sort_jobs_drop_down_panel = s; }-*/;
+
+ final native void setSortJobsDropDownPanel(
+ String s) /*-{ this.sort_jobs_drop_down_panel = s; }-*/;
static ConfigInfo create() {
ConfigInfo g = (ConfigInfo) createObject();
return g;
}
- protected ConfigInfo() {
- }
+ protected ConfigInfo() {}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsDropDownPanel.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsDropDownPanel.java
index c4c5dc7..320ab2c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsDropDownPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsDropDownPanel.java
@@ -31,9 +31,7 @@
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.InlineLabel;
-/**
- * Extension for change screen that displays a status in the header bar.
- */
+/** Extension for change screen that displays a status in the header bar. */
public class JobsDropDownPanel extends FlowPanel {
static class Factory implements Panel.EntryPoint {
private final ConfigInfo info;
@@ -44,8 +42,7 @@
@Override
public void onLoad(Panel panel) {
- RevisionInfo rev =
- panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
+ RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
if (rev.isEdit()) {
return;
}
@@ -55,28 +52,30 @@
}
JobsDropDownPanel(Panel panel, ConfigInfo info) {
- ChangeInfo change =
- panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
+ ChangeInfo change = panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
String decodedChangeId = URL.decodePathSegment(change.id());
- RevisionInfo rev =
- panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
- new RestApi("changes").id(decodedChangeId).view("revisions").id(rev.id())
+ RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
+ new RestApi("changes")
+ .id(decodedChangeId)
+ .view("revisions")
+ .id(rev.id())
.view(Plugin.get().getPluginName(), "verifications")
.addParameter("sort", info.sortJobsDropDownPanel())
.addParameter("filter", "CURRENT")
- .get(new AsyncCallback<NativeMap<VerificationInfo>>() {
- @Override
- public void onSuccess(NativeMap<VerificationInfo> result) {
- if (!result.isEmpty()) {
- display(result);
- }
- }
+ .get(
+ new AsyncCallback<NativeMap<VerificationInfo>>() {
+ @Override
+ public void onSuccess(NativeMap<VerificationInfo> result) {
+ if (!result.isEmpty()) {
+ display(result);
+ }
+ }
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
}
private void display(NativeMap<VerificationInfo> jobs) {
@@ -117,8 +116,7 @@
InlineLabel repLabel = new InlineLabel(jobs.get(key).reporter());
repLabel.setTitle("reporter");
grid.setWidget(row, 3, repLabel);
- InlineLabel grLabel = new InlineLabel(
- FormatUtil.shortFormat(jobs.get(key).granted()));
+ InlineLabel grLabel = new InlineLabel(FormatUtil.shortFormat(jobs.get(key).granted()));
grLabel.setTitle("date saved");
grid.setWidget(row, 4, grLabel);
row++;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsPanel.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsPanel.java
index a2d7724..8c237c1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsPanel.java
@@ -31,11 +31,10 @@
import com.google.gwt.user.client.ui.InlineHyperlink;
import com.google.gwt.user.client.ui.InlineLabel;
-/**
- * Extension for change screen that displays a status below the label info.
- */
+/** Extension for change screen that displays a status below the label info. */
public class JobsPanel extends FlowPanel {
private final ConfigInfo info;
+
static class Factory implements Panel.EntryPoint {
private final ConfigInfo info;
@@ -45,8 +44,7 @@
@Override
public void onLoad(Panel panel) {
- RevisionInfo rev =
- panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
+ RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
if (rev.isEdit()) {
return;
}
@@ -57,29 +55,31 @@
JobsPanel(Panel panel, ConfigInfo info) {
this.info = info;
- final ChangeInfo change =
- panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
+ final ChangeInfo change = panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
String decodedChangeId = URL.decodePathSegment(change.id());
- final RevisionInfo rev =
- panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
- new RestApi("changes").id(decodedChangeId).view("revisions").id(rev.id())
+ final RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
+ new RestApi("changes")
+ .id(decodedChangeId)
+ .view("revisions")
+ .id(rev.id())
.view(Plugin.get().getPluginName(), "verifications")
.addParameter("sort", info.sortJobsPanel())
.addParameter("filter", "CURRENT")
- .get(new AsyncCallback<NativeMap<VerificationInfo>>() {
- @Override
- public void onSuccess(NativeMap<VerificationInfo> result) {
- if (!result.isEmpty()) {
- final String patchsetId = change._number() + "/" + rev.id();
- display(patchsetId, result);
- }
- }
+ .get(
+ new AsyncCallback<NativeMap<VerificationInfo>>() {
+ @Override
+ public void onSuccess(NativeMap<VerificationInfo> result) {
+ if (!result.isEmpty()) {
+ final String patchsetId = change._number() + "/" + rev.id();
+ display(patchsetId, result);
+ }
+ }
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
}
private void display(String patchsetId, NativeMap<VerificationInfo> jobs) {
@@ -90,22 +90,20 @@
HorizontalPanel p = new HorizontalPanel();
short vote = jobs.get(key).value();
if (vote > 0) {
- p.add(new Image(
+ p.add(
+ new Image(
((vote == 2) && info.enableInProgressStatus())
? VerifyStatusPlugin.RESOURCES.progress()
- : VerifyStatusPlugin.RESOURCES.greenCheck()
- ));
+ : VerifyStatusPlugin.RESOURCES.greenCheck()));
} else if (vote < 0) {
p.add(new Image(VerifyStatusPlugin.RESOURCES.redNot()));
} else if (vote == 0) {
p.add(new Image(VerifyStatusPlugin.RESOURCES.warning()));
}
- Anchor anchor =
- new Anchor(jobs.get(key).name(), jobs.get(key).url());
+ Anchor anchor = new Anchor(jobs.get(key).name(), jobs.get(key).url());
anchor.setTitle("view logs");
p.add(anchor);
- InlineLabel label =
- new InlineLabel(" (" + jobs.get(key).duration() + ")");
+ InlineLabel label = new InlineLabel(" (" + jobs.get(key).duration() + ")");
label.setTitle("duration");
p.add(label);
if (jobs.get(key).rerun()) {
@@ -123,8 +121,9 @@
row++;
}
HorizontalPanel p = new HorizontalPanel();
- InlineHyperlink all = new InlineHyperlink("Show All Reports",
- "/x/" + Plugin.get().getName() + "/jobs/" + patchsetId);
+ InlineHyperlink all =
+ new InlineHyperlink(
+ "Show All Reports", "/x/" + Plugin.get().getName() + "/jobs/" + patchsetId);
p.add(all);
grid.insertRow(row);
grid.setWidget(row, 0, p);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsScreen.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsScreen.java
index 37aa615..29c7474 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsScreen.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsScreen.java
@@ -22,9 +22,9 @@
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter;
public class JobsScreen extends VerticalPanel {
static class Factory implements Screen.EntryPoint {
@@ -42,22 +42,26 @@
}
JobsScreen(String changeNumber, String revisionNumber) {
- new RestApi("changes").id(changeNumber).view("revisions").id(revisionNumber)
+ new RestApi("changes")
+ .id(changeNumber)
+ .view("revisions")
+ .id(revisionNumber)
.view(Plugin.get().getPluginName(), "verifications")
.addParameter("sort", "DATE")
- .get(new AsyncCallback<NativeMap<VerificationInfo>>() {
- @Override
- public void onSuccess(NativeMap<VerificationInfo> result) {
- if (!result.isEmpty()) {
- display(result);
- }
- }
+ .get(
+ new AsyncCallback<NativeMap<VerificationInfo>>() {
+ @Override
+ public void onSuccess(NativeMap<VerificationInfo> result) {
+ if (!result.isEmpty()) {
+ display(result);
+ }
+ }
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
}
private void display(NativeMap<VerificationInfo> jobs) {
@@ -90,8 +94,7 @@
}
short vote = vi.value();
if (vote > 0) {
- t.setWidget(row, 0,
- new Image(VerifyStatusPlugin.RESOURCES.greenCheck()));
+ t.setWidget(row, 0, new Image(VerifyStatusPlugin.RESOURCES.greenCheck()));
} else if (vote < 0) {
t.setWidget(row, 0, new Image(VerifyStatusPlugin.RESOURCES.redNot()));
} else if (vote == 0) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsSummaryPanel.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsSummaryPanel.java
index fc495df..503850d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsSummaryPanel.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsSummaryPanel.java
@@ -26,18 +26,14 @@
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
-
import com.google.gwt.user.client.ui.Label;
-/**
- * Extension for change screen that displays job summary table.
- */
+/** Extension for change screen that displays job summary table. */
public class JobsSummaryPanel extends FlowPanel {
static class Factory implements Panel.EntryPoint {
@Override
public void onLoad(Panel panel) {
- RevisionInfo rev =
- panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
+ RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
if (rev.isEdit()) {
return;
}
@@ -46,31 +42,34 @@
}
}
- private final static String COLOR_GREEN = "#060";
- private final static String COLOR_RED = "#F00";
+ private static final String COLOR_GREEN = "#060";
+ private static final String COLOR_RED = "#F00";
JobsSummaryPanel(Panel panel) {
- final ChangeInfo change =
- panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
+ final ChangeInfo change = panel.getObject(GerritUiExtensionPoint.Key.CHANGE_INFO).cast();
String decodedChangeId = URL.decodePathSegment(change.id());
- final RevisionInfo rev =
- panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
- new RestApi("changes").id(decodedChangeId).view("revisions").id(rev.id())
+ final RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
+ new RestApi("changes")
+ .id(decodedChangeId)
+ .view("revisions")
+ .id(rev.id())
.view(Plugin.get().getPluginName(), "verifications")
- .addParameter("sort", "REPORTER").addParameter("filter", "CURRENT")
- .get(new AsyncCallback<NativeMap<VerificationInfo>>() {
- @Override
- public void onSuccess(NativeMap<VerificationInfo> result) {
- if (!result.isEmpty()) {
- display(result);
- }
- }
+ .addParameter("sort", "REPORTER")
+ .addParameter("filter", "CURRENT")
+ .get(
+ new AsyncCallback<NativeMap<VerificationInfo>>() {
+ @Override
+ public void onSuccess(NativeMap<VerificationInfo> result) {
+ if (!result.isEmpty()) {
+ display(result);
+ }
+ }
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
}
private void display(NativeMap<VerificationInfo> jobs) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/PopDownButton.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/PopDownButton.java
index ffbac97..7607fe3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/PopDownButton.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/PopDownButton.java
@@ -32,12 +32,11 @@
/**
* Pop down button for header line in change screen.
*
- * This class implements a button that on click opens a pop down panel with the
- * provided widget, similar to the "Patch Sets", "Download" or "Included In" pop
- * down panels on the change screen.
+ * <p>This class implements a button that on click opens a pop down panel with the provided widget,
+ * similar to the "Patch Sets", "Download" or "Included In" pop down panels on the change screen.
*
- * This class can *only* be used within a panel that extends the header line of
- * the change screen, but will not work standalone.
+ * <p>This class can *only* be used within a panel that extends the header line of the change
+ * screen, but will not work standalone.
*/
public class PopDownButton extends Button {
private final Widget widget;
@@ -48,12 +47,13 @@
// in the context of the change screen.
super((new SafeHtmlBuilder()).openDiv().append(text).closeDiv());
getElement().removeClassName("gwt-Button");
- addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- show();
- }
- });
+ addClickHandler(
+ new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ show();
+ }
+ });
this.widget = widget;
}
@@ -65,33 +65,35 @@
}
final Widget relativeTo = getParent();
- final PopupPanel p = new PopupPanel(true) {
- @Override
- public void setPopupPosition(int left, int top) {
- top -= Document.get().getBodyOffsetTop();
+ final PopupPanel p =
+ new PopupPanel(true) {
+ @Override
+ public void setPopupPosition(int left, int top) {
+ top -= Document.get().getBodyOffsetTop();
- int w = Window.getScrollLeft() + Window.getClientWidth();
- int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth();
- int right = w - r;
- Style style = getElement().getStyle();
- style.clearProperty("left");
- style.setPropertyPx("right", right);
- style.setPropertyPx("top", top);
- }
- };
+ int w = Window.getScrollLeft() + Window.getClientWidth();
+ int r = relativeTo.getAbsoluteLeft() + relativeTo.getOffsetWidth();
+ int right = w - r;
+ Style style = getElement().getStyle();
+ style.clearProperty("left");
+ style.setPropertyPx("right", right);
+ style.setPropertyPx("top", top);
+ }
+ };
Style popupStyle = p.getElement().getStyle();
popupStyle.setBorderWidth(0, Unit.PX);
popupStyle.setBackgroundColor("#EEEEEE");
p.addAutoHidePartner(getElement());
- p.addCloseHandler(new CloseHandler<PopupPanel>() {
- @Override
- public void onClose(CloseEvent<PopupPanel> event) {
- if (popup == p) {
- getElement().getStyle().clearFontWeight();
- popup = null;
- }
- }
- });
+ p.addCloseHandler(
+ new CloseHandler<PopupPanel>() {
+ @Override
+ public void onClose(CloseEvent<PopupPanel> event) {
+ if (popup == p) {
+ getElement().getStyle().clearFontWeight();
+ popup = null;
+ }
+ }
+ });
p.add(widget);
p.showRelativeTo(relativeTo);
GlobalKey.dialog(p);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/Resources.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/Resources.java
index 358c033..eff41cd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/Resources.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/Resources.java
@@ -39,5 +39,4 @@
@Source("loader.gif")
public ImageResource progress();
-
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerificationInfo.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerificationInfo.java
index 958bdd7..68462a1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerificationInfo.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerificationInfo.java
@@ -2,19 +2,26 @@
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer;
-
import java.sql.Timestamp;
public class VerificationInfo extends JavaScriptObject {
public final native String url() /*-{ return this.url; }-*/;
+
public final native String name() /*-{ return this.name; }-*/;
+
public final native String comment() /*-{ return this.comment; }-*/;
+
public final native short value() /*-{ return this.value; }-*/;
+
public final native boolean abstain() /*-{ return this.abstain || false; }-*/;
+
public final native boolean rerun() /*-{ return this.rerun || false; }-*/;
+
public final native String category() /*-{ return this.category; }-*/;
+
public final native String duration() /*-{ return this.duration; }-*/;
+
public final native String reporter() /*-{ return this.reporter; }-*/;
public final Timestamp granted() {
@@ -28,10 +35,12 @@
}
return r;
}
+
private final native String grantedRaw() /*-{ return this.granted; }-*/;
+
private final native Timestamp grantedTimestamp() /*-{ return this._ts }-*/;
+
private final native void grantedTimestamp(Timestamp t) /*-{ this._ts = t }-*/;
- protected VerificationInfo() {
- }
+ protected VerificationInfo() {}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerifyStatusPlugin.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerifyStatusPlugin.java
index 5d8d5da..c7b693f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerifyStatusPlugin.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerifyStatusPlugin.java
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.verifystatus.client;
import com.google.gerrit.client.GerritUiExtensionPoint;
-
import com.google.gerrit.plugin.client.Plugin;
import com.google.gerrit.plugin.client.PluginEntryPoint;
import com.google.gerrit.plugin.client.rpc.RestApi;
@@ -28,34 +27,39 @@
@Override
public void onPluginLoad() {
Plugin.get().screenRegex("jobs/(.*)", new JobsScreen.Factory());
- new RestApi("config").view("server")
+ new RestApi("config")
+ .view("server")
.view(Plugin.get().getPluginName(), "config")
- .get(new AsyncCallback<ConfigInfo>() {
- @Override
- public void onSuccess(ConfigInfo info) {
- if (info.showJobsSummaryPanel()) {
- Plugin.get().panel(
- GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
- new JobsSummaryPanel.Factory());
- }
- if (info.showJobsPanel()) {
- Plugin.get().panel(
- info.showJobsBelowRelatedInfoBlock()
- ? GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_RELATED_INFO_BLOCK
- : GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
- new JobsPanel.Factory(info));
- }
- if (info.showJobsDropDownPanel()) {
- Plugin.get().panel(
- GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS,
- new JobsDropDownPanel.Factory(info));
- }
- }
+ .get(
+ new AsyncCallback<ConfigInfo>() {
+ @Override
+ public void onSuccess(ConfigInfo info) {
+ if (info.showJobsSummaryPanel()) {
+ Plugin.get()
+ .panel(
+ GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
+ new JobsSummaryPanel.Factory());
+ }
+ if (info.showJobsPanel()) {
+ Plugin.get()
+ .panel(
+ info.showJobsBelowRelatedInfoBlock()
+ ? GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_RELATED_INFO_BLOCK
+ : GerritUiExtensionPoint.CHANGE_SCREEN_BELOW_CHANGE_INFO_BLOCK,
+ new JobsPanel.Factory(info));
+ }
+ if (info.showJobsDropDownPanel()) {
+ Plugin.get()
+ .panel(
+ GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS,
+ new JobsDropDownPanel.Factory(info));
+ }
+ }
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // never invoked
+ }
+ });
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerificationInfo.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerificationInfo.java
index 52385a8..b8f6648 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerificationInfo.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerificationInfo.java
@@ -27,4 +27,4 @@
public Timestamp granted;
public String category;
public String duration;
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerifyInput.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerifyInput.java
index b0199b8..84d795c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerifyInput.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/common/VerifyInput.java
@@ -15,10 +15,8 @@
package com.googlesource.gerrit.plugins.verifystatus.common;
import com.google.gerrit.extensions.restapi.DefaultInput;
-
import java.util.Map;
public class VerifyInput {
- @DefaultInput
- public Map<String, VerificationInfo> verifications;
+ @DefaultInput public Map<String, VerificationInfo> verifications;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DatabaseConfigInitializer.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DatabaseConfigInitializer.java
index 5c6feff..8e3d325 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DatabaseConfigInitializer.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DatabaseConfigInitializer.java
@@ -20,8 +20,8 @@
interface DatabaseConfigInitializer {
/**
- * Performs database platform specific configuration steps and writes
- * configuration parameters into the given database section
+ * Performs database platform specific configuration steps and writes configuration parameters
+ * into the given database section
*/
void initConfig(Section pluginSection);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DatabaseConfigModule.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DatabaseConfigModule.java
index 8a5921a..885bf1d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DatabaseConfigModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DatabaseConfigModule.java
@@ -29,15 +29,18 @@
@Override
protected void configure() {
bind(SitePaths.class).toInstance(site);
- bind(DatabaseConfigInitializer.class).annotatedWith(
- Names.named("derby")).to(DerbyInitializer.class);
- bind(DatabaseConfigInitializer.class).annotatedWith(
- Names.named("h2")).to(H2Initializer.class);
- bind(DatabaseConfigInitializer.class).annotatedWith(
- Names.named("mysql")).to(MySqlInitializer.class);
- bind(DatabaseConfigInitializer.class).annotatedWith(
- Names.named("oracle")).to(OracleInitializer.class);
- bind(DatabaseConfigInitializer.class).annotatedWith(
- Names.named("postgresql")).to(PostgreSQLInitializer.class);
+ bind(DatabaseConfigInitializer.class)
+ .annotatedWith(Names.named("derby"))
+ .to(DerbyInitializer.class);
+ bind(DatabaseConfigInitializer.class).annotatedWith(Names.named("h2")).to(H2Initializer.class);
+ bind(DatabaseConfigInitializer.class)
+ .annotatedWith(Names.named("mysql"))
+ .to(MySqlInitializer.class);
+ bind(DatabaseConfigInitializer.class)
+ .annotatedWith(Names.named("oracle"))
+ .to(OracleInitializer.class);
+ bind(DatabaseConfigInitializer.class)
+ .annotatedWith(Names.named("postgresql"))
+ .to(PostgreSQLInitializer.class);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DerbyInitializer.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DerbyInitializer.java
index f636959..7f57e74 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DerbyInitializer.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/DerbyInitializer.java
@@ -20,7 +20,6 @@
import com.google.gerrit.pgm.init.api.Section;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
-
import java.nio.file.Path;
class DerbyInitializer implements DatabaseConfigInitializer {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/H2Initializer.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/H2Initializer.java
index efc3a0e..7842f90 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/H2Initializer.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/H2Initializer.java
@@ -20,7 +20,6 @@
import com.google.gerrit.pgm.init.api.Section;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
-
import java.nio.file.Path;
class H2Initializer implements DatabaseConfigInitializer {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/InitPlugin.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/InitPlugin.java
index 9efb68f..088e262 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/InitPlugin.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/InitPlugin.java
@@ -43,7 +43,6 @@
import com.google.inject.TypeLiteral;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
-
import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.CiDataSourceModule;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.CiDataSourceProvider;
@@ -52,14 +51,12 @@
import com.googlesource.gerrit.plugins.verifystatus.server.schema.CiDatabaseModule;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.SchemaVersion;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.UpdateUI;
-
import java.lang.annotation.Annotation;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
-
import javax.sql.DataSource;
@Singleton
@@ -72,7 +69,8 @@
private Provider<SchemaVersion> updater;
@Inject
- InitPlugin(Section.Factory sections,
+ InitPlugin(
+ Section.Factory sections,
@PluginName String pluginName,
ConsoleUI ui,
SitePaths site,
@@ -88,8 +86,7 @@
ui.header("SQL Database for CI plugin");
Set<String> allowedValues = Sets.newTreeSet();
- Injector i = Guice.createInjector(PRODUCTION,
- new DatabaseConfigModule(site));
+ Injector i = Guice.createInjector(PRODUCTION, new DatabaseConfigModule(site));
List<Binding<DatabaseConfigInitializer>> dbConfigBindings =
i.findBindingsByType(new TypeLiteral<DatabaseConfigInitializer>() {});
@@ -105,28 +102,19 @@
configSection.set("dbType", "h2");
}
- String dbType =
- configSection.select("Database server type", "dbType", "h2",
- allowedValues);
+ String dbType = configSection.select("Database server type", "dbType", "h2", allowedValues);
DatabaseConfigInitializer dci =
- i.getInstance(Key.get(DatabaseConfigInitializer.class,
- Names.named(dbType.toLowerCase())));
+ i.getInstance(Key.get(DatabaseConfigInitializer.class, Names.named(dbType.toLowerCase())));
- /** TODO(davido): We probably don't need that, as
- * CI database would be from the same type as
- * ReviewDb. So we expect that the needed libraries
- * were already installed.
+ /**
+ * TODO(davido): We probably don't need that, as CI database would be from the same type as
+ * ReviewDb. So we expect that the needed libraries were already installed.
*
- if (dci instanceof MySqlInitializer) {
- libraries.mysqlDriver.downloadRequired();
- } else if (dci instanceof OracleInitializer) {
- libraries.oracleDriver.downloadRequired();
- } else if (dci instanceof DB2Initializer) {
- libraries.db2Driver.downloadRequired();
- }
- **/
-
+ * <p>if (dci instanceof MySqlInitializer) { libraries.mysqlDriver.downloadRequired(); } else if
+ * (dci instanceof OracleInitializer) { libraries.oracleDriver.downloadRequired(); } else if
+ * (dci instanceof DB2Initializer) { libraries.db2Driver.downloadRequired(); }
+ */
dci.initConfig(configSection);
}
@@ -134,81 +122,85 @@
public void postRun() throws Exception {
Injector i = buildInjector(parent);
updater = i.getProvider(SchemaVersion.class);
- this.dbFactory = i.getInstance(
- Key.get(
- new TypeLiteral<SchemaFactory<CiDb>>() {}));
+ this.dbFactory = i.getInstance(Key.get(new TypeLiteral<SchemaFactory<CiDb>>() {}));
upgradeSchema();
}
private Injector buildInjector(final Injector parent) {
List<Module> modules = new ArrayList<>();
- modules.add(new LifecycleModule() {
- @Override
- protected void configure() {
- // For bootstrap we need to retrieve the ds type first
- CiDataSourceTypeGuesser guesser =
- parent.createChildInjector(
- new CiDataSourceModule()).getInstance(
- Key.get(CiDataSourceTypeGuesser.class));
+ modules.add(
+ new LifecycleModule() {
+ @Override
+ protected void configure() {
+ // For bootstrap we need to retrieve the ds type first
+ CiDataSourceTypeGuesser guesser =
+ parent
+ .createChildInjector(new CiDataSourceModule())
+ .getInstance(Key.get(CiDataSourceTypeGuesser.class));
- // For the ds type we retrieve the underlying implementation
- CiDataSourceType dst = parent.createChildInjector(
- new CiDataSourceModule()).getInstance(
- Key.get(CiDataSourceType.class,
- Names.named(guesser.guessDataSourceType())));
+ // For the ds type we retrieve the underlying implementation
+ CiDataSourceType dst =
+ parent
+ .createChildInjector(new CiDataSourceModule())
+ .getInstance(
+ Key.get(
+ CiDataSourceType.class, Names.named(guesser.guessDataSourceType())));
- // Bind the type to the retrieved instance
- bind(CiDataSourceType.class).toInstance(dst);
- bind(CiDataSourceProvider.Context.class).toInstance(
- CiDataSourceProvider.Context.MULTI_USER);
- bind(Key.get(DataSource.class, Names.named("CiDb"))).toProvider(
- CiDataSourceProvider.class).in(SINGLETON);
+ // Bind the type to the retrieved instance
+ bind(CiDataSourceType.class).toInstance(dst);
+ bind(CiDataSourceProvider.Context.class)
+ .toInstance(CiDataSourceProvider.Context.MULTI_USER);
+ bind(Key.get(DataSource.class, Names.named("CiDb")))
+ .toProvider(CiDataSourceProvider.class)
+ .in(SINGLETON);
- listener().to(CiDataSourceProvider.class);
- }
- });
+ listener().to(CiDataSourceProvider.class);
+ }
+ });
modules.add(new CiDatabaseModule());
- modules.add(new AbstractModule() {
- @Override
- protected void configure() {
- bind(SchemaVersion.class).to(SchemaVersion.C);
- }
- });
+ modules.add(
+ new AbstractModule() {
+ @Override
+ protected void configure() {
+ bind(SchemaVersion.class).to(SchemaVersion.C);
+ }
+ });
return parent.createChildInjector(modules);
}
private void upgradeSchema() throws OrmException {
final List<String> pruneList = new ArrayList<>();
- update(new UpdateUI() {
- @Override
- public void message(String msg) {
- System.err.println(msg);
- System.err.flush();
- }
-
- @Override
- public boolean yesno(boolean def, String msg) {
- return ui.yesno(def, msg);
- }
-
- @Override
- public boolean isBatch() {
- return ui.isBatch();
- }
-
- @Override
- public void pruneSchema(StatementExecutor e, List<String> prune) {
- for (String p : prune) {
- if (!pruneList.contains(p)) {
- pruneList.add(p);
+ update(
+ new UpdateUI() {
+ @Override
+ public void message(String msg) {
+ System.err.println(msg);
+ System.err.flush();
}
- }
- }
- });
+
+ @Override
+ public boolean yesno(boolean def, String msg) {
+ return ui.yesno(def, msg);
+ }
+
+ @Override
+ public boolean isBatch() {
+ return ui.isBatch();
+ }
+
+ @Override
+ public void pruneSchema(StatementExecutor e, List<String> prune) {
+ for (String p : prune) {
+ if (!pruneList.contains(p)) {
+ pruneList.add(p);
+ }
+ }
+ }
+ });
if (!pruneList.isEmpty()) {
StringBuilder msg = new StringBuilder();
@@ -240,12 +232,12 @@
SchemaVersion u = updater.get();
CurrentSchemaVersion version = getSchemaVersion(db);
if (version == null) {
- try (JdbcExecutor e = new JdbcExecutor((JdbcSchema) db)) {
- ((JdbcSchema) db).updateSchema(e);
- }
- final CurrentSchemaVersion sVer = CurrentSchemaVersion.create();
- sVer.versionNbr = SchemaVersion.getBinaryVersion();
- db.schemaVersion().insert(Collections.singleton(sVer));
+ try (JdbcExecutor e = new JdbcExecutor((JdbcSchema) db)) {
+ ((JdbcSchema) db).updateSchema(e);
+ }
+ final CurrentSchemaVersion sVer = CurrentSchemaVersion.create();
+ sVer.versionNbr = SchemaVersion.getBinaryVersion();
+ db.schemaVersion().insert(Collections.singleton(sVer));
} else {
try {
u.check(ui, version, db);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/PostgreSQLInitializer.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/PostgreSQLInitializer.java
index 1b4ca3d..466f4e6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/PostgreSQLInitializer.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/init/PostgreSQLInitializer.java
@@ -29,4 +29,4 @@
configSection.string("Database username", "username", username());
configSection.password("username", "password");
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetConfig.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetConfig.java
index d1e5cf2..3ba9176 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetConfig.java
@@ -26,8 +26,7 @@
private final PluginConfig cfg;
@Inject
- public GetConfig(PluginConfigFactory cfgFactory,
- @PluginName String pluginName) {
+ public GetConfig(PluginConfigFactory cfgFactory, @PluginName String pluginName) {
this.cfg = cfgFactory.getFromGerritConfig(pluginName);
}
@@ -37,14 +36,11 @@
info.showJobsPanel = cfg.getBoolean("showJobsPanel", true);
info.showJobsDropDownPanel = cfg.getBoolean("showJobsDropDownPanel", true);
info.showJobsSummaryPanel = cfg.getBoolean("showJobsSummaryPanel", true);
- info.showJobsBelowRelatedInfoBlock = cfg.getBoolean(
- "showJobsBelowRelatedInfoBlock", false);
- info.enableInProgressStatus = cfg.getBoolean(
- "enableInProgressStatus", false);
- info.sortJobsPanel = cfg.getEnum(JobsSorting.values(),
- "sortJobsPanel", JobsSorting.REPORTER);
- info.sortJobsDropDownPanel = cfg.getEnum(JobsSorting.values(),
- "sortJobsDropDownPanel", JobsSorting.REPORTER);
+ info.showJobsBelowRelatedInfoBlock = cfg.getBoolean("showJobsBelowRelatedInfoBlock", false);
+ info.enableInProgressStatus = cfg.getBoolean("enableInProgressStatus", false);
+ info.sortJobsPanel = cfg.getEnum(JobsSorting.values(), "sortJobsPanel", JobsSorting.REPORTER);
+ info.sortJobsDropDownPanel =
+ cfg.getEnum(JobsSorting.values(), "sortJobsDropDownPanel", JobsSorting.REPORTER);
return info;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java
index 7e67516..74ee698 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java
@@ -23,17 +23,14 @@
import com.google.gwtorm.server.ResultSet;
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.verifystatus.common.VerificationInfo;
-
-import org.apache.commons.lang.builder.CompareToBuilder;
-import org.kohsuke.args4j.Option;
-
import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang.builder.CompareToBuilder;
+import org.kohsuke.args4j.Option;
public class GetVerifications implements RestReadView<RevisionResource> {
private final SchemaFactory<CiDb> schemaFactory;
@@ -43,12 +40,19 @@
this.schemaFactory = schemaFactory;
}
- @Option(name = "--sort", aliases = {"-s"}, metaVar = "SORT",
+ @Option(
+ name = "--sort",
+ aliases = {"-s"},
+ metaVar = "SORT",
usage = "Sort the list by an entry")
private JobsSorting sort;
+
private String filter;
- @Option(name = "--filter", aliases = {"-f"}, metaVar = "FILTER",
+ @Option(
+ name = "--filter",
+ aliases = {"-f"},
+ metaVar = "FILTER",
usage = "filter the results")
public void setFilter(String filter) {
this.filter = filter.toUpperCase();
@@ -69,47 +73,50 @@
return info;
}
- private void sortJobs(List<PatchSetVerification> jobs,
- @Nullable JobsSorting order) {
+ private void sortJobs(List<PatchSetVerification> jobs, @Nullable JobsSorting order) {
if (order == null) {
return;
}
switch (order) {
case REPORTER:
// sort the jobs list by reporter(A-Z)/Name(A-Z)/Granted(Z-A)
- Collections.sort(jobs, new Comparator<PatchSetVerification>() {
- @Override
- public int compare(PatchSetVerification a, PatchSetVerification b) {
- return new CompareToBuilder()
- .append(a.getReporter(),b.getReporter())
- .append(a.getName(), b.getName())
- .append(b.getGranted(),a.getGranted())
- .toComparison();
- }
- });
+ Collections.sort(
+ jobs,
+ new Comparator<PatchSetVerification>() {
+ @Override
+ public int compare(PatchSetVerification a, PatchSetVerification b) {
+ return new CompareToBuilder()
+ .append(a.getReporter(), b.getReporter())
+ .append(a.getName(), b.getName())
+ .append(b.getGranted(), a.getGranted())
+ .toComparison();
+ }
+ });
break;
case NAME:
// sort the jobs list by Name(A-Z)/Granted(Z-A)
- Collections.sort(jobs, new Comparator<PatchSetVerification>() {
- @Override
- public int compare(PatchSetVerification a, PatchSetVerification b) {
- return new CompareToBuilder()
- .append(a.getName(),b.getName())
- .append(b.getGranted(),a.getGranted())
- .toComparison();
- }
- });
+ Collections.sort(
+ jobs,
+ new Comparator<PatchSetVerification>() {
+ @Override
+ public int compare(PatchSetVerification a, PatchSetVerification b) {
+ return new CompareToBuilder()
+ .append(a.getName(), b.getName())
+ .append(b.getGranted(), a.getGranted())
+ .toComparison();
+ }
+ });
break;
case DATE:
// sort the jobs list by Granted(Z-A)
- Collections.sort(jobs, new Comparator<PatchSetVerification>() {
- @Override
- public int compare(PatchSetVerification a, PatchSetVerification b) {
- return new CompareToBuilder()
- .append(b.getGranted(),a.getGranted())
- .toComparison();
- }
- });
+ Collections.sort(
+ jobs,
+ new Comparator<PatchSetVerification>() {
+ @Override
+ public int compare(PatchSetVerification a, PatchSetVerification b) {
+ return new CompareToBuilder().append(b.getGranted(), a.getGranted()).toComparison();
+ }
+ });
break;
default:
break;
@@ -129,7 +136,7 @@
// filter jobs
boolean isSorted = false;
if (filter != null && !filter.isEmpty()) {
- if (filter.equals("CURRENT") ) {
+ if (filter.equals("CURRENT")) {
// logic to get current jobs assumes list is sorted by reporter
sortJobs(result, JobsSorting.REPORTER);
isSorted = true;
@@ -149,16 +156,16 @@
prevReporter = reporter;
prevName = jobName;
}
- } else if (filter.equals("FAILED") ) {
- for (PatchSetVerification v : result) {
- if (v.getValue() < 0) {
- jobs.add(v);
- }
+ } else if (filter.equals("FAILED")) {
+ for (PatchSetVerification v : result) {
+ if (v.getValue() < 0) {
+ jobs.add(v);
}
- } else {
- // assume no filtering for an invalid filter option
- jobs.addAll(result);
- }
+ }
+ } else {
+ // assume no filtering for an invalid filter option
+ jobs.addAll(result);
+ }
} else {
jobs.addAll(result);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerification.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerification.java
index 4801321..71225b7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerification.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerification.java
@@ -14,13 +14,12 @@
package com.googlesource.gerrit.plugins.verifystatus.server;
-import java.sql.Timestamp;
-import java.util.Objects;
-
import com.google.gerrit.reviewdb.client.LabelId;
import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwtorm.client.Column;
import com.google.gwtorm.client.CompoundKey;
+import java.sql.Timestamp;
+import java.util.Objects;
public class PatchSetVerification {
@@ -91,11 +90,9 @@
@Column(id = 11)
protected boolean rerun;
- protected PatchSetVerification() {
- }
+ protected PatchSetVerification() {}
- public PatchSetVerification(PatchSetVerification.Key k, short v,
- Timestamp ts) {
+ public PatchSetVerification(PatchSetVerification.Key k, short v, Timestamp ts) {
key = k;
setValue(v);
setGranted(ts);
@@ -199,15 +196,21 @@
@Override
public String toString() {
- return new StringBuilder().append('[').append(key).append(": ")
- .append(value).append(']').toString();
+ return new StringBuilder()
+ .append('[')
+ .append(key)
+ .append(": ")
+ .append(value)
+ .append(']')
+ .toString();
}
@Override
public boolean equals(Object o) {
if (o instanceof PatchSetVerification) {
PatchSetVerification p = (PatchSetVerification) o;
- return Objects.equals(key, p.key) && Objects.equals(value, p.value)
+ return Objects.equals(key, p.key)
+ && Objects.equals(value, p.value)
&& Objects.equals(granted, p.granted);
}
return false;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerificationAccess.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerificationAccess.java
index 3823205..2bd9ffb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerificationAccess.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerificationAccess.java
@@ -1,16 +1,16 @@
-//Copyright (C) 2015 The Android Open Source Project
+// Copyright (C) 2015 The Android Open Source Project
//
-//Licensed under the Apache License, Version 2.0 (the "License");
-//you may not use this file except in compliance with the License.
-//You may obtain a copy of the License at
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-//http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-//Unless required by applicable law or agreed to in writing, software
-//distributed under the License is distributed on an "AS IS" BASIS,
-//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//See the License for the specific language governing permissions and
-//limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package com.googlesource.gerrit.plugins.verifystatus.server;
@@ -22,8 +22,8 @@
import com.google.gwtorm.server.Query;
import com.google.gwtorm.server.ResultSet;
-public interface PatchSetVerificationAccess extends
- Access<PatchSetVerification, PatchSetVerification.Key> {
+public interface PatchSetVerificationAccess
+ extends Access<PatchSetVerification, PatchSetVerification.Key> {
@Override
@PrimaryKey("key")
PatchSetVerification get(PatchSetVerification.Key key) throws OrmException;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PutConfig.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PutConfig.java
index d7304d3..a9de8b0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PutConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PutConfig.java
@@ -25,18 +25,14 @@
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.verifystatus.server.PutConfig.Input;
-
+import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
-import java.io.IOException;
-
-@RequiresCapability(
- value = GlobalCapability.ADMINISTRATE_SERVER, scope = CapabilityScope.CORE)
-public class PutConfig implements RestModifyView<ConfigResource, Input>{
+@RequiresCapability(value = GlobalCapability.ADMINISTRATE_SERVER, scope = CapabilityScope.CORE)
+public class PutConfig implements RestModifyView<ConfigResource, Input> {
public static class Input {
public Boolean showJobsPanel;
public Boolean showJobsDropDownPanel;
@@ -52,9 +48,7 @@
private final String pluginName;
@Inject
- PutConfig(PluginConfigFactory cfgFactory,
- SitePaths sitePaths,
- @PluginName String pluginName) {
+ PutConfig(PluginConfigFactory cfgFactory, SitePaths sitePaths, @PluginName String pluginName) {
this.cfgFactory = cfgFactory;
this.sitePaths = sitePaths;
this.pluginName = pluginName;
@@ -66,48 +60,48 @@
if (input == null) {
input = new Input();
}
- FileBasedConfig cfg =
- new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.DETECTED);
+ FileBasedConfig cfg = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.DETECTED);
cfg.load();
if (input.showJobsPanel != null) {
- cfg.setBoolean("plugin", pluginName, "showJobsPanel",
- input.showJobsPanel);
+ cfg.setBoolean("plugin", pluginName, "showJobsPanel", input.showJobsPanel);
} else {
cfg.unset("plugin", pluginName, "showJobsPanel");
}
if (input.showJobsDropDownPanel != null) {
- cfg.setBoolean("plugin", pluginName, "showJobsDropDownPanel",
- input.showJobsDropDownPanel);
+ cfg.setBoolean("plugin", pluginName, "showJobsDropDownPanel", input.showJobsDropDownPanel);
} else {
cfg.unset("plugin", pluginName, "showJobsDropDownPanel");
}
if (input.showJobsSummaryPanel != null) {
- cfg.setBoolean("plugin", pluginName, "showJobsSummaryPanel",
- input.showJobsSummaryPanel);
+ cfg.setBoolean("plugin", pluginName, "showJobsSummaryPanel", input.showJobsSummaryPanel);
} else {
cfg.unset("plugin", pluginName, "showJobsSummaryPanel");
}
if (input.showJobsBelowRelatedInfoBlock != null) {
- cfg.setBoolean("plugin", pluginName, "showJobsBelowRelatedInfoBlock",
+ cfg.setBoolean(
+ "plugin",
+ pluginName,
+ "showJobsBelowRelatedInfoBlock",
input.showJobsBelowRelatedInfoBlock);
} else {
cfg.unset("plugin", pluginName, "showJobsBelowRelatedInfoBlock");
}
if (input.enableInProgressStatus != null) {
- cfg.setBoolean("plugin", pluginName, "enableInProgressStatus",
- input.enableInProgressStatus);
+ cfg.setBoolean("plugin", pluginName, "enableInProgressStatus", input.enableInProgressStatus);
} else {
cfg.unset("plugin", pluginName, "enableInProgressStatus");
}
if (input.sortJobsPanel != null) {
- cfg.setEnum("plugin", pluginName, "sortJobsPanel",
- JobsSorting.valueOf(input.sortJobsPanel));
+ cfg.setEnum("plugin", pluginName, "sortJobsPanel", JobsSorting.valueOf(input.sortJobsPanel));
} else {
cfg.unset("plugin", pluginName, "sortJobsPanel");
}
if (input.sortJobsDropDownPanel != null) {
- cfg.setEnum("plugin", pluginName, "sortJobsDropDownPanel",
+ cfg.setEnum(
+ "plugin",
+ pluginName,
+ "sortJobsDropDownPanel",
JobsSorting.valueOf(input.sortJobsDropDownPanel));
} else {
cfg.unset("plugin", pluginName, "sortJobsDropDownPanel");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiBaseDataSourceType.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiBaseDataSourceType.java
index 044524d..beb3ec5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiBaseDataSourceType.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiBaseDataSourceType.java
@@ -14,11 +14,10 @@
package com.googlesource.gerrit.plugins.verifystatus.server.schema;
+import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
import java.io.IOException;
import java.io.InputStream;
-import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
-
public abstract class CiBaseDataSourceType implements CiDataSourceType {
private final String driver;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceProvider.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceProvider.java
index 8af154c..c908adc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceProvider.java
@@ -34,25 +34,21 @@
import com.google.inject.Provider;
import com.google.inject.ProvisionException;
import com.google.inject.Singleton;
-
-import org.apache.commons.dbcp.BasicDataSource;
-import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.eclipse.jgit.storage.file.FileBasedConfig;
-import org.eclipse.jgit.util.FS;
-
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.sql.SQLException;
import java.util.Properties;
-
import javax.sql.DataSource;
+import org.apache.commons.dbcp.BasicDataSource;
+import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.storage.file.FileBasedConfig;
+import org.eclipse.jgit.util.FS;
/** Provides access to the DataSource. */
@Singleton
-public class CiDataSourceProvider implements Provider<DataSource>,
- LifecycleListener {
+public class CiDataSourceProvider implements Provider<DataSource>, LifecycleListener {
public static final int DEFAULT_POOL_LIMIT = 8;
private final MetricMaker metrics;
@@ -62,7 +58,8 @@
private DataSource ds;
@Inject
- protected CiDataSourceProvider(SitePaths site,
+ protected CiDataSourceProvider(
+ SitePaths site,
@PluginName String pluginName,
@Nullable MetricMaker metrics,
Context ctx,
@@ -89,8 +86,7 @@
}
@Override
- public void start() {
- }
+ public void start() {}
@Override
public synchronized void stop() {
@@ -104,11 +100,12 @@
}
public static enum Context {
- SINGLE_USER, MULTI_USER
+ SINGLE_USER,
+ MULTI_USER
}
private DataSource open(Context context, CiDataSourceType dst) {
- //ConfigSection dbs = new ConfigSection(cfg, "database");
+ // ConfigSection dbs = new ConfigSection(cfg, "database");
String driver = config.getString("driver");
if (Strings.isNullOrEmpty(driver)) {
driver = dst.getDriver();
@@ -147,8 +144,8 @@
if (Strings.isNullOrEmpty(valueString)) {
ds.setMaxWait(MILLISECONDS.convert(30, SECONDS));
} else {
- ds.setMaxWait(ConfigUtil.getTimeUnit(
- valueString, MILLISECONDS.convert(30, SECONDS), MILLISECONDS));
+ ds.setMaxWait(
+ ConfigUtil.getTimeUnit(valueString, MILLISECONDS.convert(30, SECONDS), MILLISECONDS));
}
ds.setInitialSize(ds.getMinIdle());
exportPoolMetrics(ds);
@@ -174,22 +171,23 @@
}
private void exportPoolMetrics(final BasicDataSource pool) {
- final CallbackMetric1<Boolean, Integer> cnt = metrics.newCallbackMetric(
- "sql/connection_pool/connections",
- Integer.class,
- new Description("SQL database connections")
- .setGauge()
- .setUnit("connections"),
- Field.ofBoolean("active"));
- metrics.newTrigger(cnt, new Runnable() {
- @Override
- public void run() {
- synchronized (pool) {
- cnt.set(true, pool.getNumActive());
- cnt.set(false, pool.getNumIdle());
- }
- }
- });
+ final CallbackMetric1<Boolean, Integer> cnt =
+ metrics.newCallbackMetric(
+ "sql/connection_pool/connections",
+ Integer.class,
+ new Description("SQL database connections").setGauge().setUnit("connections"),
+ Field.ofBoolean("active"));
+ metrics.newTrigger(
+ cnt,
+ new Runnable() {
+ @Override
+ public void run() {
+ synchronized (pool) {
+ cnt.set(true, pool.getNumActive());
+ cnt.set(false, pool.getNumIdle());
+ }
+ }
+ });
}
private DataSource intercept(String interceptor, DataSource ds) {
@@ -198,12 +196,15 @@
}
try {
Constructor<?> c = Class.forName(interceptor).getConstructor();
- DataSourceInterceptor datasourceInterceptor =
- (DataSourceInterceptor) c.newInstance();
+ DataSourceInterceptor datasourceInterceptor = (DataSourceInterceptor) c.newInstance();
return datasourceInterceptor.intercept("CiDb", ds);
- } catch (ClassNotFoundException | SecurityException | NoSuchMethodException
- | IllegalArgumentException | InstantiationException
- | IllegalAccessException | InvocationTargetException e) {
+ } catch (ClassNotFoundException
+ | SecurityException
+ | NoSuchMethodException
+ | IllegalArgumentException
+ | InstantiationException
+ | IllegalAccessException
+ | InvocationTargetException e) {
throw new ProvisionException("Cannot intercept datasource", e);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceType.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceType.java
index 2e6c3fa..1a15033 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceType.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceType.java
@@ -26,8 +26,8 @@
public boolean usePool();
/**
- * Return a ScriptRunner that runs the index script. Must not return
- * {@code null}, but may return a ScriptRunner that does nothing.
+ * Return a ScriptRunner that runs the index script. Must not return {@code null}, but may return
+ * a ScriptRunner that does nothing.
*
* @throws IOException
*/
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceTypeGuesser.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceTypeGuesser.java
index a895815..00bf457 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceTypeGuesser.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceTypeGuesser.java
@@ -20,21 +20,18 @@
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.ProvisionException;
-
+import java.io.File;
+import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
-import java.io.File;
-import java.io.IOException;
-
public class CiDataSourceTypeGuesser {
private final PluginConfig config;
@Inject
- CiDataSourceTypeGuesser(SitePaths site,
- @PluginName String pluginName) {
+ CiDataSourceTypeGuesser(SitePaths site, @PluginName String pluginName) {
File file = site.gerrit_config.toFile();
FileBasedConfig cfg = new FileBasedConfig(file, FS.DETECTED);
try {
@@ -48,8 +45,7 @@
public String guessDataSourceType() {
String dbType = config.getString("dbType");
if (Strings.isNullOrEmpty(dbType)) {
- throw new ProvisionException(
- String.format("'dbType' must be defined in config file"));
+ throw new ProvisionException(String.format("'dbType' must be defined in config file"));
}
return dbType.toLowerCase();
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDatabaseModule.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDatabaseModule.java
index 73570f9..e535436 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDatabaseModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDatabaseModule.java
@@ -20,16 +20,15 @@
import com.google.gwtorm.jdbc.Database;
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.TypeLiteral;
-
import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
/** Loads the database with standard dependencies. */
public class CiDatabaseModule extends FactoryModule {
@Override
protected void configure() {
- bind(new TypeLiteral<SchemaFactory<CiDb>>() {}).to(
- new TypeLiteral<Database<CiDb>>() {}).in(SINGLETON);
- bind(new TypeLiteral<Database<CiDb>>() {}).toProvider(
- CiDbDatabaseProvider.class).in(SINGLETON);
+ bind(new TypeLiteral<SchemaFactory<CiDb>>() {})
+ .to(new TypeLiteral<Database<CiDb>>() {})
+ .in(SINGLETON);
+ bind(new TypeLiteral<Database<CiDb>>() {}).toProvider(CiDbDatabaseProvider.class).in(SINGLETON);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDbDatabaseProvider.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDbDatabaseProvider.java
index 6f57c50..000bce1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDbDatabaseProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDbDatabaseProvider.java
@@ -14,8 +14,6 @@
package com.googlesource.gerrit.plugins.verifystatus.server.schema;
-import javax.sql.DataSource;
-
import com.google.gwtorm.jdbc.Database;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
@@ -23,6 +21,7 @@
import com.google.inject.ProvisionException;
import com.google.inject.name.Named;
import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
+import javax.sql.DataSource;
/** Provides the {@code Database<CiDb>} database handle. */
final class CiDbDatabaseProvider implements Provider<Database<CiDb>> {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Derby.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Derby.java
index e4ded2a..2e8b173 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Derby.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Derby.java
@@ -19,21 +19,18 @@
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.ProvisionException;
-
+import java.io.File;
+import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
-import java.io.File;
-import java.io.IOException;
-
class Derby extends CiBaseDataSourceType {
private final SitePaths site;
private final PluginConfig config;
@Inject
- Derby(SitePaths site,
- @PluginName String pluginName) {
+ Derby(SitePaths site, @PluginName String pluginName) {
super("org.apache.derby.jdbc.EmbeddedDriver");
this.site = site;
File file = site.gerrit_config.toFile();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/H2.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/H2.java
index b7199eb..8685f21 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/H2.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/H2.java
@@ -19,21 +19,18 @@
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.ProvisionException;
-
+import java.io.File;
+import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
-import java.io.File;
-import java.io.IOException;
-
class H2 extends CiBaseDataSourceType {
private final SitePaths site;
private final PluginConfig config;
@Inject
- H2(SitePaths site,
- @PluginName String pluginName) {
+ H2(SitePaths site, @PluginName String pluginName) {
super("org.h2.Driver");
this.site = site;
File file = site.gerrit_config.toFile();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/MySql.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/MySql.java
index e99cd6a..e163091 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/MySql.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/MySql.java
@@ -22,20 +22,17 @@
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.ProvisionException;
-
+import java.io.File;
+import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
-import java.io.File;
-import java.io.IOException;
-
class MySql extends CiBaseDataSourceType {
private final PluginConfig config;
@Inject
- public MySql(SitePaths site,
- @PluginName String pluginName) {
+ public MySql(SitePaths site, @PluginName String pluginName) {
super("com.mysql.jdbc.Driver");
File file = site.gerrit_config.toFile();
FileBasedConfig cfg = new FileBasedConfig(file, FS.DETECTED);
@@ -66,4 +63,4 @@
// a new MySQL connection is usually very fast.
return false;
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Oracle.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Oracle.java
index 3a81caa..833333c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Oracle.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Oracle.java
@@ -22,20 +22,17 @@
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.ProvisionException;
-
+import java.io.File;
+import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
-import java.io.File;
-import java.io.IOException;
-
public class Oracle extends CiBaseDataSourceType {
private final PluginConfig config;
@Inject
- public Oracle(SitePaths site,
- @PluginName String pluginName) {
+ public Oracle(SitePaths site, @PluginName String pluginName) {
super("oracle.jdbc.driver.OracleDriver");
File file = site.gerrit_config.toFile();
FileBasedConfig cfg = new FileBasedConfig(file, FS.DETECTED);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/PostgreSQL.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/PostgreSQL.java
index 7ef0051..67845a0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/PostgreSQL.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/PostgreSQL.java
@@ -22,20 +22,17 @@
import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.ProvisionException;
-
+import java.io.File;
+import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
-import java.io.File;
-import java.io.IOException;
-
class PostgreSQL extends CiBaseDataSourceType {
private final PluginConfig config;
@Inject
- public PostgreSQL(SitePaths site,
- @PluginName String pluginName) {
+ public PostgreSQL(SitePaths site, @PluginName String pluginName) {
super("org.postgresql.Driver");
File file = site.gerrit_config.toFile();
FileBasedConfig cfg = new FileBasedConfig(file, FS.DETECTED);
@@ -57,4 +54,4 @@
b.append(config.getString("database"));
return b.toString();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/SchemaVersion.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/SchemaVersion.java
index 4ab5aad..fa5db22 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/SchemaVersion.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/SchemaVersion.java
@@ -22,9 +22,7 @@
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.StatementExecutor;
import com.google.inject.Provider;
-
import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
-
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
@@ -67,8 +65,12 @@
if (curr.versionNbr == versionNbr) {
// Nothing to do, we are at the correct schema.
} else if (curr.versionNbr > versionNbr) {
- throw new OrmException("Cannot downgrade database schema from version "
- + curr.versionNbr + " to " + versionNbr + ".");
+ throw new OrmException(
+ "Cannot downgrade database schema from version "
+ + curr.versionNbr
+ + " to "
+ + versionNbr
+ + ".");
} else {
upgradeFrom(ui, curr, db);
}
@@ -83,17 +85,18 @@
JdbcSchema s = (JdbcSchema) db;
final List<String> pruneList = Lists.newArrayList();
- s.pruneSchema(new StatementExecutor() {
- @Override
- public void execute(String sql) {
- pruneList.add(sql);
- }
+ s.pruneSchema(
+ new StatementExecutor() {
+ @Override
+ public void execute(String sql) {
+ pruneList.add(sql);
+ }
- @Override
- public void close() {
- // Do nothing.
- }
- });
+ @Override
+ public void close() {
+ // Do nothing.
+ }
+ });
try (JdbcExecutor e = new JdbcExecutor(s)) {
if (!pruneList.isEmpty()) {
@@ -111,8 +114,8 @@
return r;
}
- private void updateSchema(List<SchemaVersion> pending, UpdateUI ui,
- CiDb db) throws OrmException, SQLException {
+ private void updateSchema(List<SchemaVersion> pending, UpdateUI ui, CiDb db)
+ throws OrmException, SQLException {
for (SchemaVersion v : pending) {
ui.message(String.format("Upgrading schema to %d ...", v.getVersionNbr()));
v.preUpdateSchema(db);
@@ -131,42 +134,37 @@
* @throws OrmException if a Gerrit-specific exception occurred.
* @throws SQLException if an underlying SQL exception occurred.
*/
- protected void preUpdateSchema(CiDb db) throws OrmException, SQLException {
- }
+ protected void preUpdateSchema(CiDb db) throws OrmException, SQLException {}
- private void migrateData(List<SchemaVersion> pending, UpdateUI ui,
- CurrentSchemaVersion curr, CiDb db) throws OrmException, SQLException {
+ private void migrateData(
+ List<SchemaVersion> pending, UpdateUI ui, CurrentSchemaVersion curr, CiDb db)
+ throws OrmException, SQLException {
for (SchemaVersion v : pending) {
- ui.message(String.format(
- "Migrating data to schema %d ...",
- v.getVersionNbr()));
+ ui.message(String.format("Migrating data to schema %d ...", v.getVersionNbr()));
v.migrateData(db, ui);
v.finish(curr, db);
}
}
/**
- * Invoked between updateSchema (adds new columns/tables) and pruneSchema
- * (removes deleted columns/tables).
+ * Invoked between updateSchema (adds new columns/tables) and pruneSchema (removes deleted
+ * columns/tables).
*
* @param db open database handle.
* @param ui interface for interacting with the user.
* @throws OrmException if a Gerrit-specific exception occurred.
* @throws SQLException if an underlying SQL exception occurred.
*/
- protected void migrateData(CiDb db, UpdateUI ui) throws OrmException, SQLException {
- }
+ protected void migrateData(CiDb db, UpdateUI ui) throws OrmException, SQLException {}
/** Mark the current schema version. */
- protected void finish(CurrentSchemaVersion curr, CiDb db)
- throws OrmException {
+ protected void finish(CurrentSchemaVersion curr, CiDb db) throws OrmException {
curr.versionNbr = versionNbr;
db.schemaVersion().update(Collections.singleton(curr));
}
/** Rename an existing table. */
- protected static void renameTable(ReviewDb db, String from, String to)
- throws OrmException {
+ protected static void renameTable(ReviewDb db, String from, String to) throws OrmException {
JdbcSchema s = (JdbcSchema) db;
try (JdbcExecutor e = new JdbcExecutor(s)) {
s.renameTable(e, from, to);
@@ -195,8 +193,7 @@
}
/** Open a new prepared statement. */
- protected static PreparedStatement prepareStatement(ReviewDb db, String sql)
- throws SQLException {
+ protected static PreparedStatement prepareStatement(ReviewDb db, String sql) throws SQLException {
return ((JdbcSchema) db).getConnection().prepareStatement(sql);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Schema_1.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Schema_1.java
index bf3c959..fae684c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Schema_1.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/Schema_1.java
@@ -21,11 +21,12 @@
public class Schema_1 extends SchemaVersion {
@Inject
Schema_1() {
- super(new Provider<SchemaVersion>() {
- @Override
- public SchemaVersion get() {
- throw new ProvisionException("initial version");
- }
- });
+ super(
+ new Provider<SchemaVersion>() {
+ @Override
+ public SchemaVersion get() {
+ throw new ProvisionException("initial version");
+ }
+ });
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/ScriptRunner.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/ScriptRunner.java
index 5691e80..3520d7c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/ScriptRunner.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/ScriptRunner.java
@@ -16,6 +16,11 @@
import static java.nio.charset.StandardCharsets.UTF_8;
+import com.google.common.base.CharMatcher;
+import com.google.gwtorm.jdbc.JdbcSchema;
+import com.google.gwtorm.schema.sql.SqlDialect;
+import com.google.gwtorm.server.OrmException;
+import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -26,22 +31,16 @@
import java.util.ArrayList;
import java.util.List;
-import com.google.common.base.CharMatcher;
-import com.google.gwtorm.jdbc.JdbcSchema;
-import com.google.gwtorm.schema.sql.SqlDialect;
-import com.google.gwtorm.server.OrmException;
-import com.googlesource.gerrit.plugins.verifystatus.server.CiDb;
-
/** Parses an SQL script from a resource file and later runs it. */
class ScriptRunner {
private final String name;
private final List<String> commands;
- static final ScriptRunner NOOP = new ScriptRunner(null, null) {
- @Override
- void run(CiDb db) {
- }
- };
+ static final ScriptRunner NOOP =
+ new ScriptRunner(null, null) {
+ @Override
+ void run(CiDb db) {}
+ };
ScriptRunner(String scriptName, InputStream script) {
this.name = scriptName;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/UpdateUI.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/UpdateUI.java
index 766dd27..ee335b6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/UpdateUI.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/UpdateUI.java
@@ -16,7 +16,6 @@
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.StatementExecutor;
-
import java.util.List;
public interface UpdateUI {
@@ -26,6 +25,5 @@
boolean isBatch();
- void pruneSchema(StatementExecutor e, List<String> pruneList)
- throws OrmException;
+ void pruneSchema(StatementExecutor e, List<String> pruneList) throws OrmException;
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java b/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
index dcdf255..2906561 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
@@ -26,56 +26,52 @@
import com.google.gerrit.acceptance.UseLocalDisk;
import com.google.gson.reflect.TypeToken;
import com.google.gwtorm.jdbc.SimpleDataSource;
-
import com.googlesource.gerrit.plugins.verifystatus.common.VerificationInfo;
import com.googlesource.gerrit.plugins.verifystatus.common.VerifyInput;
-
-import org.junit.Before;
-import org.junit.Test;
-
import java.sql.Connection;
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import org.junit.Before;
+import org.junit.Test;
@TestPlugin(
name = "verify-status",
sysModule = "com.googlesource.gerrit.plugins.verifystatus.GlobalModule",
httpModule = "com.googlesource.gerrit.plugins.verifystatus.HttpModule",
- sshModule = "com.googlesource.gerrit.plugins.verifystatus.SshModule"
-)
+ sshModule = "com.googlesource.gerrit.plugins.verifystatus.SshModule")
public class VerifyStatusIT extends LightweightPluginDaemonTest {
- private final static String NAME = "verify-status";
- private final static String DB_TYPE_CONFIG = "plugin." + NAME + ".dbType";
- private final static String DB_URL_CONFIG = "plugin." + NAME + ".dbUrl";
- private final static String H2 = "h2";
- private final static String URL = "jdbc:h2:mem:TestCiDB;DB_CLOSE_DELAY=-1";
- private final static String TABLE = "PATCH_SET_VERIFICATIONS";
+ private static final String NAME = "verify-status";
+ private static final String DB_TYPE_CONFIG = "plugin." + NAME + ".dbType";
+ private static final String DB_URL_CONFIG = "plugin." + NAME + ".dbUrl";
+ private static final String H2 = "h2";
+ private static final String URL = "jdbc:h2:mem:TestCiDB;DB_CLOSE_DELAY=-1";
+ private static final String TABLE = "PATCH_SET_VERIFICATIONS";
private static final String CREATE_TABLE =
- "CREATE TABLE IF NOT EXISTS " + TABLE + " (" +
- "VALUE SMALLINT DEFAULT 0 NOT NULL," +
- "GRANTED TIMESTAMP NOT NULL," +
- "URL VARCHAR(255)," +
- "REPORTER VARCHAR(255)," +
- "COMMENT VARCHAR(255)," +
- "CATEGORY VARCHAR(255)," +
- "DURATION VARCHAR(255)," +
- "ABSTAIN CHAR(1) DEFAULT 'N' NOT NULL," +
- "RERUN CHAR(1) DEFAULT 'N' NOT NULL," +
- "NAME VARCHAR(255)," +
- "CHANGE_ID INTEGER DEFAULT 0 NOT NULL," +
- "PATCH_SET_ID INTEGER DEFAULT 0 NOT NULL," +
- "JOB_ID VARCHAR(255) DEFAULT '' NOT NULL)";
- private static final String DELETE_TABLE =
- "DELETE FROM " + TABLE;
+ "CREATE TABLE IF NOT EXISTS "
+ + TABLE
+ + " ("
+ + "VALUE SMALLINT DEFAULT 0 NOT NULL,"
+ + "GRANTED TIMESTAMP NOT NULL,"
+ + "URL VARCHAR(255),"
+ + "REPORTER VARCHAR(255),"
+ + "COMMENT VARCHAR(255),"
+ + "CATEGORY VARCHAR(255),"
+ + "DURATION VARCHAR(255),"
+ + "ABSTAIN CHAR(1) DEFAULT 'N' NOT NULL,"
+ + "RERUN CHAR(1) DEFAULT 'N' NOT NULL,"
+ + "NAME VARCHAR(255),"
+ + "CHANGE_ID INTEGER DEFAULT 0 NOT NULL,"
+ + "PATCH_SET_ID INTEGER DEFAULT 0 NOT NULL,"
+ + "JOB_ID VARCHAR(255) DEFAULT '' NOT NULL)";
+ private static final String DELETE_TABLE = "DELETE FROM " + TABLE;
@Before
@Override
public void setUp() throws Exception {
super.setUp();
- allowGlobalCapabilities(REGISTERED_USERS,
- SaveReportCapability.getName(NAME));
+ allowGlobalCapabilities(REGISTERED_USERS, SaveReportCapability.getName(NAME));
Properties p = new Properties();
p.setProperty("driver", "org.h2.Driver");
@@ -193,8 +189,7 @@
assertVerification(Iterables.getOnlyElement(infos.values()), i);
}
- private Map<String, VerificationInfo> getVerifications(Result c, String filter)
- throws Exception {
+ private Map<String, VerificationInfo> getVerifications(Result c, String filter) throws Exception {
String endPoint = url(c);
if (filter != null) {
endPoint += "/?filter=" + filter;
@@ -202,20 +197,19 @@
RestResponse r = adminRestSession.get(endPoint);
r.assertOK();
- return newGson().fromJson(r.getReader(),
- new TypeToken<Map<String, VerificationInfo>>() {}.getType());
+ return newGson()
+ .fromJson(r.getReader(), new TypeToken<Map<String, VerificationInfo>>() {}.getType());
}
private String url(Result c) throws Exception {
- return "/changes/" +
- c.getChangeId() +
- "/revisions/" +
- c.getPatchSetId().get() +
- "/verify-status~verifications";
+ return "/changes/"
+ + c.getChangeId()
+ + "/revisions/"
+ + c.getPatchSetId().get()
+ + "/verify-status~verifications";
}
- private static void assertVerification(VerificationInfo r,
- VerificationInfo e) {
+ private static void assertVerification(VerificationInfo r, VerificationInfo e) {
assertThat(r.value).isEqualTo(e.value);
assertThat(r.reporter).isEqualTo(e.reporter);
assertThat(r.comment).isEqualTo(e.comment);