Adapt to gerrit master
Remove GWT UI and add gwtorm as new dependency. Except extending the
build documentation, the documentation wasn't adapted in this change.
Change-Id: Ib8a0a503715d6ee381b06cf52909282a1958a5e0
diff --git a/BUILD b/BUILD
index 4de410f..c3ea47d 100644
--- a/BUILD
+++ b/BUILD
@@ -12,7 +12,6 @@
gerrit_plugin(
name = "verify-status",
srcs = glob(["src/main/java/**/*.java"]),
- gwt_module = "com.googlesource.gerrit.plugins.verifystatus.VerifyStatusForm",
manifest_entries = [
"Gerrit-PluginName: verify-status",
"Gerrit-Module: com.googlesource.gerrit.plugins.verifystatus.GlobalModule",
@@ -23,7 +22,8 @@
"Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/verify-status",
],
resource_jars = [":gr-verify-status-static"],
- resources = glob(["src/main/**/*"]),
+ resources = glob(["src/main/resources/**/*"]),
+ deps = ["@gwtorm//jar"],
)
junit_tests(
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..54c792c
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,9 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+ maven_jar(
+ name = "gwtorm",
+ artifact = "com.google.gerrit:gwtorm:1.20",
+ sha1 = "a4809769b710bc8ce3f203125630b8419f0e58b0",
+ src_sha1 = "cb63296276ce3228b2d83a37017a99e38ad8ed42",
+ )
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 cf557ba..d1f2fa5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/HttpModule.java
@@ -15,7 +15,6 @@
package com.googlesource.gerrit.plugins.verifystatus;
import com.google.gerrit.extensions.registration.DynamicSet;
-import com.google.gerrit.extensions.webui.GwtPlugin;
import com.google.gerrit.extensions.webui.JavaScriptPlugin;
import com.google.gerrit.extensions.webui.WebUiPlugin;
import com.google.inject.servlet.ServletModule;
@@ -23,7 +22,6 @@
class HttpModule extends ServletModule {
@Override
protected void configureServlets() {
- DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(new GwtPlugin("verifystatus"));
DynamicSet.bind(binder(), WebUiPlugin.class)
.toInstance(new JavaScriptPlugin("gr-verify-status.html"));
}
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 18d2da7..ec481f9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/PostVerification.java
@@ -21,7 +21,6 @@
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestModifyView;
-import com.google.gerrit.reviewdb.client.LabelId;
import com.google.gerrit.server.change.RevisionResource;
import com.google.gerrit.server.util.time.TimeUtil;
import com.google.gwtorm.server.OrmException;
@@ -31,6 +30,9 @@
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.DbChangeId;
+import com.googlesource.gerrit.plugins.verifystatus.server.DbLabelId;
+import com.googlesource.gerrit.plugins.verifystatus.server.DbPatchSetId;
import com.googlesource.gerrit.plugins.verifystatus.server.PatchSetVerification;
import java.sql.Timestamp;
import java.util.List;
@@ -131,11 +133,12 @@
} 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);
+ DbPatchSetId patchSetId =
+ new DbPatchSetId(
+ new DbChangeId(resource.getPatchSet().id().changeId().get()),
+ resource.getPatchSet().id().get());
+ DbLabelId labelId = new DbLabelId(job_id);
+ c = new PatchSetVerification(new PatchSetVerification.Key(patchSetId, labelId), value, ts);
c.setAbstain(ent.getValue().abstain);
c.setRerun(ent.getValue().rerun);
c.setUrl(ent.getValue().url);
@@ -153,11 +156,14 @@
return !ups.isEmpty();
}
- private Map<String, PatchSetVerification> scanLabels(RevisionResource resource, CiDb db)
+ private Map<String, PatchSetVerification> scanLabels(RevisionResource rsrc, CiDb db)
throws OrmException {
Map<String, PatchSetVerification> current = Maps.newHashMap();
- for (PatchSetVerification v :
- db.patchSetVerifications().byPatchSet(resource.getPatchSet().getId())) {
+ DbPatchSetId id =
+ new DbPatchSetId(
+ new DbChangeId(rsrc.getPatchSet().id().changeId().get()),
+ rsrc.getPatchSet().id().get());
+ for (PatchSetVerification v : db.patchSetVerifications().byPatchSet(id)) {
current.put(v.getJobId().get(), v);
}
return current;
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 1254421..5bb2d9b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
@@ -19,10 +19,11 @@
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
+import com.google.gerrit.entities.PatchSet;
+import com.google.gerrit.exceptions.StorageException;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.RestApiException;
-import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.server.change.RevisionResource;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.project.ProjectState;
@@ -63,7 +64,7 @@
patchSets.add(ps);
} catch (UnloggedFailure e) {
throw new IllegalArgumentException(e.getMessage(), e);
- } catch (OrmException e) {
+ } catch (StorageException e) {
throw new IllegalArgumentException("database error", e);
}
}
@@ -149,8 +150,7 @@
throws RestApiException, OrmException, IOException, PermissionBackendException {
RevisionResource revResource =
revisions.parse(
- changes.parse(patchSet.getId().getParentKey()),
- IdString.fromUrl(patchSet.getId().getId()));
+ changes.parse(patchSet.id().changeId()), IdString.fromUrl(patchSet.id().getId()));
postVerification.apply(revResource, verify);
}
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
deleted file mode 100644
index 2d3f1db..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/ConfigInfo.java
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2016 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
-//
-// 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.
-
-package com.googlesource.gerrit.plugins.verifystatus.client;
-
-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 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 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 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; }-*/;
-
- static ConfigInfo create() {
- ConfigInfo g = (ConfigInfo) createObject();
- return g;
- }
-
- 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
deleted file mode 100644
index 320ab2c..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsDropDownPanel.java
+++ /dev/null
@@ -1,126 +0,0 @@
-// 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
-//
-// 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.
-
-package com.googlesource.gerrit.plugins.verifystatus.client;
-
-import com.google.gerrit.client.GerritUiExtensionPoint;
-import com.google.gerrit.client.info.ChangeInfo;
-import com.google.gerrit.client.info.ChangeInfo.RevisionInfo;
-import com.google.gerrit.client.rpc.NativeMap;
-import com.google.gerrit.plugin.client.FormatUtil;
-import com.google.gerrit.plugin.client.Plugin;
-import com.google.gerrit.plugin.client.extension.Panel;
-import com.google.gerrit.plugin.client.rpc.RestApi;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.Grid;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-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. */
-public class JobsDropDownPanel extends FlowPanel {
- static class Factory implements Panel.EntryPoint {
- private final ConfigInfo info;
-
- public Factory(ConfigInfo info) {
- this.info = info;
- }
-
- @Override
- public void onLoad(Panel panel) {
- RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
- if (rev.isEdit()) {
- return;
- }
-
- panel.setWidget(new JobsDropDownPanel(panel, info));
- }
- }
-
- JobsDropDownPanel(Panel panel, ConfigInfo info) {
- 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())
- .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);
- }
- }
-
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
- }
-
- private void display(NativeMap<VerificationInfo> jobs) {
- int row = 0;
- int column = 5;
- Grid grid = new Grid(row, column);
- for (String key : jobs.keySet()) {
- grid.insertRow(row);
- HorizontalPanel p = new HorizontalPanel();
- short vote = jobs.get(key).value();
- if (vote > 0) {
- p.add(new Image(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.setTitle("view logs");
- p.add(anchor);
- InlineLabel durlabel = new InlineLabel(" (" + jobs.get(key).duration() + ")");
- durlabel.setTitle("duration");
- p.add(durlabel);
- if (jobs.get(key).abstain()) {
- Image img = new Image(VerifyStatusPlugin.RESOURCES.info());
- img.setTitle("non voting");
- p.add(img);
- }
- if (jobs.get(key).rerun()) {
- Image img = new Image(VerifyStatusPlugin.RESOURCES.rerun());
- img.setTitle("re-run");
- p.add(img);
- }
- grid.setWidget(row, 1, p);
- InlineLabel catLabel = new InlineLabel(jobs.get(key).category());
- catLabel.setTitle("category");
- grid.setWidget(row, 2, catLabel);
- 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()));
- grLabel.setTitle("date saved");
- grid.setWidget(row, 4, grLabel);
- row++;
- }
- add(new PopDownButton("Jobs", grid));
- }
-}
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
deleted file mode 100644
index 8c237c1..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsPanel.java
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright (C) 2016 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
-//
-// 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.
-
-package com.googlesource.gerrit.plugins.verifystatus.client;
-
-import com.google.gerrit.client.GerritUiExtensionPoint;
-import com.google.gerrit.client.info.ChangeInfo;
-import com.google.gerrit.client.info.ChangeInfo.RevisionInfo;
-import com.google.gerrit.client.rpc.NativeMap;
-import com.google.gerrit.plugin.client.Plugin;
-import com.google.gerrit.plugin.client.extension.Panel;
-import com.google.gerrit.plugin.client.rpc.RestApi;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.Grid;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Image;
-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. */
-public class JobsPanel extends FlowPanel {
- private final ConfigInfo info;
-
- static class Factory implements Panel.EntryPoint {
- private final ConfigInfo info;
-
- public Factory(ConfigInfo info) {
- this.info = info;
- }
-
- @Override
- public void onLoad(Panel panel) {
- RevisionInfo rev = panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
- if (rev.isEdit()) {
- return;
- }
-
- panel.setWidget(new JobsPanel(panel, info));
- }
- }
-
- JobsPanel(Panel panel, ConfigInfo info) {
- this.info = info;
- 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())
- .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);
- }
- }
-
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
- }
-
- private void display(String patchsetId, NativeMap<VerificationInfo> jobs) {
- int row = 0;
- int column = 1;
- Grid grid = new Grid(row, column);
- for (String key : jobs.keySet()) {
- HorizontalPanel p = new HorizontalPanel();
- short vote = jobs.get(key).value();
- if (vote > 0) {
- p.add(
- new Image(
- ((vote == 2) && info.enableInProgressStatus())
- ? VerifyStatusPlugin.RESOURCES.progress()
- : 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.setTitle("view logs");
- p.add(anchor);
- InlineLabel label = new InlineLabel(" (" + jobs.get(key).duration() + ")");
- label.setTitle("duration");
- p.add(label);
- if (jobs.get(key).rerun()) {
- Image img = new Image(VerifyStatusPlugin.RESOURCES.rerun());
- img.setTitle("re-run");
- p.add(img);
- }
- if (jobs.get(key).abstain()) {
- Image img = new Image(VerifyStatusPlugin.RESOURCES.info());
- img.setTitle("non voting");
- p.add(img);
- }
- grid.insertRow(row);
- grid.setWidget(row, 0, p);
- row++;
- }
- HorizontalPanel p = new HorizontalPanel();
- InlineHyperlink all =
- new InlineHyperlink(
- "Show All Reports", "/x/" + Plugin.get().getName() + "/jobs/" + patchsetId);
- p.add(all);
- grid.insertRow(row);
- grid.setWidget(row, 0, p);
- add(grid);
- }
-}
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
deleted file mode 100644
index 29c7474..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsScreen.java
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright (C) 2016 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
-//
-// 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.
-
-package com.googlesource.gerrit.plugins.verifystatus.client;
-
-import com.google.gerrit.client.rpc.NativeMap;
-import com.google.gerrit.plugin.client.FormatUtil;
-import com.google.gerrit.plugin.client.Plugin;
-import com.google.gerrit.plugin.client.rpc.RestApi;
-import com.google.gerrit.plugin.client.screen.Screen;
-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;
-
-public class JobsScreen extends VerticalPanel {
- static class Factory implements Screen.EntryPoint {
- @Override
- public void onLoad(final Screen screen) {
- // get change and revision number from passed in patchsetId of form
- // $changeNumber/$revisionNumber
- String input = screen.getToken(1);
- String[] patchsetId = input.split("/");
- final String changeNumber = patchsetId[0];
- final String revisionNumber = patchsetId[1];
- screen.setPageTitle("Report History for Change " + input);
- screen.show(new JobsScreen(changeNumber, revisionNumber));
- }
- }
-
- JobsScreen(String changeNumber, String 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);
- }
- }
-
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
- }
-
- private void display(NativeMap<VerificationInfo> jobs) {
- int columns = 7;
- FlexTable t = new FlexTable();
- t.setStyleName("verifystatus-jobsTable");
- FlexCellFormatter fmt = t.getFlexCellFormatter();
- for (int c = 0; c < columns; c++) {
- fmt.addStyleName(0, c, "dataHeader");
- fmt.addStyleName(0, c, "topMostCell");
- }
- fmt.addStyleName(0, 0, "leftMostCell");
-
- t.setText(0, 0, "Result");
- t.setText(0, 1, "Name");
- t.setText(0, 2, "Duration");
- t.setText(0, 3, "Voting");
- t.setText(0, 4, "Rerun");
- t.setText(0, 5, "Category");
- t.setText(0, 6, "Reporter");
- t.setText(0, 7, "Date");
-
- int row = 1;
- for (String key : jobs.keySet()) {
- VerificationInfo vi = jobs.get(key);
-
- for (int c = 0; c < columns; c++) {
- fmt.addStyleName(row, c, "dataCell");
- fmt.addStyleName(row, 0, "leftMostCell");
- }
- short vote = vi.value();
- if (vote > 0) {
- 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) {
- t.setWidget(row, 0, new Image(VerifyStatusPlugin.RESOURCES.warning()));
- }
- Anchor anchor = new Anchor(vi.name(), vi.url());
- t.setWidget(row, 1, anchor);
- t.setText(row, 2, vi.duration());
- if (vi.abstain()) {
- t.setText(row, 3, "non-voting");
- } else {
- t.setText(row, 3, "voting");
- }
- if (vi.rerun()) {
- t.setText(row, 4, "Y");
- } else {
- t.setText(row, 4, "N");
- }
-
- t.setText(row, 5, vi.category());
- t.setText(row, 6, vi.reporter());
- t.setText(row, 7, FormatUtil.shortFormat(vi.granted()));
- row++;
- }
- add(t);
- }
-}
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
deleted file mode 100644
index 503850d..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/JobsSummaryPanel.java
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright (C) 2016 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
-//
-// 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.
-
-package com.googlesource.gerrit.plugins.verifystatus.client;
-
-import com.google.gerrit.client.GerritUiExtensionPoint;
-import com.google.gerrit.client.info.ChangeInfo;
-import com.google.gerrit.client.info.ChangeInfo.RevisionInfo;
-import com.google.gerrit.client.rpc.NativeMap;
-import com.google.gerrit.plugin.client.Plugin;
-import com.google.gerrit.plugin.client.extension.Panel;
-import com.google.gerrit.plugin.client.rpc.RestApi;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-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. */
-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();
- if (rev.isEdit()) {
- return;
- }
-
- panel.setWidget(new JobsSummaryPanel(panel));
- }
- }
-
- 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();
- 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())
- .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);
- }
- }
-
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
- }
-
- private void display(NativeMap<VerificationInfo> jobs) {
- Grid g = createGrid(2, 3);
- g.setText(0, 0, "Passed");
- g.setText(0, 1, "Failed");
- g.setText(0, 2, "Unstable");
-
- int pass = 0;
- int fail = 0;
- int unstable = 0;
- for (String key : jobs.keySet()) {
- int value = jobs.get(key).value();
- if (value > 0) {
- pass++;
- } else if (value < 0) {
- fail++;
- } else {
- unstable++;
- }
- }
-
- Label passedLbl = new Label(Integer.toString(pass));
- passedLbl.getElement().getStyle().setColor(COLOR_GREEN);
- g.setWidget(1, 0, passedLbl);
- Label failedLbl = new Label(Integer.toString(fail));
- failedLbl.getElement().getStyle().setColor(COLOR_RED);
- g.setWidget(1, 1, failedLbl);
- Label unstableLbl = new Label(Integer.toString(unstable));
- g.setWidget(1, 2, unstableLbl);
- add(g);
- }
-
- private static Grid createGrid(int rows, int columns) {
- Grid g = new Grid(rows, columns);
- g.addStyleName("infoBlock");
- g.addStyleName("changeTable");
-
- CellFormatter fmt = g.getCellFormatter();
-
- for (int c = 0; c < columns; c++) {
- fmt.addStyleName(0, c, "header");
- fmt.addStyleName(0, c, "topmost");
- }
-
- for (int r = 1; r < rows; r++) {
- fmt.addStyleName(r, 0, "leftMostCell");
-
- for (int c = 1; c < columns; c++) {
- fmt.addStyleName(r, c, "dataCell");
- }
- }
-
- for (int c = 0; c < columns; c++) {
- fmt.addStyleName(rows - 1, c, "bottomheader");
- }
-
- return g;
- }
-}
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
deleted file mode 100644
index 7607fe3..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/PopDownButton.java
+++ /dev/null
@@ -1,103 +0,0 @@
-// 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
-//
-// 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.
-
-package com.googlesource.gerrit.plugins.verifystatus.client;
-
-import com.google.gwt.dom.client.Document;
-import com.google.gwt.dom.client.Style;
-import com.google.gwt.dom.client.Style.FontWeight;
-import com.google.gwt.dom.client.Style.Unit;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.event.logical.shared.CloseEvent;
-import com.google.gwt.event.logical.shared.CloseHandler;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.PopupPanel;
-import com.google.gwt.user.client.ui.Widget;
-import com.google.gwtexpui.globalkey.client.GlobalKey;
-import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
-
-/**
- * Pop down button for header line in 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.
- *
- * <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;
- private PopupPanel popup;
-
- public PopDownButton(String text, Widget widget) {
- // Create Button with inner div. This is required to get proper styling
- // 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();
- }
- });
- this.widget = widget;
- }
-
- private void show() {
- if (popup != null) {
- getElement().getStyle().clearFontWeight();
- popup.hide();
- return;
- }
-
- final Widget relativeTo = getParent();
- 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);
- }
- };
- 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.add(widget);
- p.showRelativeTo(relativeTo);
- GlobalKey.dialog(p);
- getElement().getStyle().setFontWeight(FontWeight.BOLD);
- popup = 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
deleted file mode 100644
index eff41cd..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/Resources.java
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (C) 2016 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
-//
-// 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.
-
-package com.googlesource.gerrit.plugins.verifystatus.client;
-
-import com.google.gwt.resources.client.ClientBundle;
-import com.google.gwt.resources.client.ImageResource;
-
-public interface Resources extends ClientBundle {
-
- @Source("tick.png")
- ImageResource greenCheck();
-
- @Source("cross.png")
- ImageResource redNot();
-
- @Source("lightbulb.png")
- ImageResource light();
-
- @Source("information.png")
- public ImageResource info();
-
- @Source("exclamation.png")
- public ImageResource warning();
-
- @Source("donut.png")
- public ImageResource rerun();
-
- @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
deleted file mode 100644
index 68462a1..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerificationInfo.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.googlesource.gerrit.plugins.verifystatus.client;
-
-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() {
- Timestamp r = grantedTimestamp();
- if (r == null) {
- String s = grantedRaw();
- if (s != null) {
- r = JavaSqlTimestamp_JsonSerializer.parseTimestamp(s);
- grantedTimestamp(r);
- }
- }
- 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() {}
-}
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
deleted file mode 100644
index 34de386..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/VerifyStatusPlugin.java
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (C) 2013 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
-//
-// 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.
-
-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;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-
-public class VerifyStatusPlugin extends PluginEntryPoint {
- public static final Resources RESOURCES = GWT.create(Resources.class);
-
- @Override
- public void onPluginLoad() {
- Plugin.get().screenRegex("jobs/(.*)", new JobsScreen.Factory());
- 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(),
- "VerifyStatusJobsSummaryPanel");
- }
- 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),
- "VerifyStatusJobsPanel");
- }
- if (info.showJobsDropDownPanel()) {
- Plugin.get()
- .panel(
- GerritUiExtensionPoint.CHANGE_SCREEN_HEADER_RIGHT_OF_POP_DOWNS,
- new JobsDropDownPanel.Factory(info),
- "VerifyStatusJobsDropDownPanel");
- }
- }
-
- @Override
- public void onFailure(Throwable caught) {
- // never invoked
- }
- });
- }
-}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/cross.png b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/cross.png
deleted file mode 100644
index 1514d51..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/cross.png
+++ /dev/null
Binary files differ
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/donut.png b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/donut.png
deleted file mode 100644
index b3418f2..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/donut.png
+++ /dev/null
Binary files differ
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/exclamation.png b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/exclamation.png
deleted file mode 100644
index c37bd06..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/exclamation.png
+++ /dev/null
Binary files differ
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/information.png b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/information.png
deleted file mode 100644
index 12cd1ae..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/information.png
+++ /dev/null
Binary files differ
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/lightbulb.png b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/lightbulb.png
deleted file mode 100644
index d22fde8..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/lightbulb.png
+++ /dev/null
Binary files differ
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/loader.gif b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/loader.gif
deleted file mode 100644
index e40f19a..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/loader.gif
+++ /dev/null
Binary files differ
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/tick.png b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/tick.png
deleted file mode 100644
index a9925a0..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/client/tick.png
+++ /dev/null
Binary files differ
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 088e262..83da444 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
@@ -24,7 +24,6 @@
import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.gerrit.pgm.init.api.InitStep;
import com.google.gerrit.pgm.init.api.Section;
-import com.google.gerrit.reviewdb.client.CurrentSchemaVersion;
import com.google.gerrit.server.config.SitePaths;
import com.google.gwtorm.jdbc.JdbcExecutor;
import com.google.gwtorm.jdbc.JdbcSchema;
@@ -49,6 +48,7 @@
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 com.googlesource.gerrit.plugins.verifystatus.server.schema.CurrentSchemaVersion;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.SchemaVersion;
import com.googlesource.gerrit.plugins.verifystatus.server.schema.UpdateUI;
import java.lang.annotation.Annotation;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/CiDb.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/CiDb.java
index be7b8d1..c82d357 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/CiDb.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/CiDb.java
@@ -14,7 +14,6 @@
package com.googlesource.gerrit.plugins.verifystatus.server;
-import com.google.gerrit.reviewdb.server.SchemaVersionAccess;
import com.google.gwtorm.server.Relation;
import com.google.gwtorm.server.Schema;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/DbChangeId.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/DbChangeId.java
new file mode 100644
index 0000000..14921ce
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/DbChangeId.java
@@ -0,0 +1,41 @@
+// Copyright (C) 2019 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
+//
+// 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.
+
+package com.googlesource.gerrit.plugins.verifystatus.server;
+
+import com.google.gwtorm.client.Column;
+import com.google.gwtorm.client.IntKey;
+
+public class DbChangeId extends IntKey<com.google.gwtorm.client.Key<?>> {
+ private static final long serialVersionUID = 1L;
+
+ @Column(id = 1)
+ public int id;
+
+ protected DbChangeId() {}
+
+ public DbChangeId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public int get() {
+ return id;
+ }
+
+ @Override
+ protected void set(int newValue) {
+ id = newValue;
+ }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/DbLabelId.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/DbLabelId.java
new file mode 100644
index 0000000..811a22b
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/DbLabelId.java
@@ -0,0 +1,41 @@
+// Copyright (C) 2019 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
+//
+// 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.
+
+package com.googlesource.gerrit.plugins.verifystatus.server;
+
+import com.google.gwtorm.client.Column;
+import com.google.gwtorm.client.StringKey;
+
+public class DbLabelId extends StringKey<com.google.gwtorm.client.Key<?>> {
+ private static final long serialVersionUID = 1L;
+
+ @Column(id = 1)
+ public String id;
+
+ public DbLabelId() {}
+
+ public DbLabelId(String n) {
+ id = n;
+ }
+
+ @Override
+ public String get() {
+ return id;
+ }
+
+ @Override
+ protected void set(String newValue) {
+ id = newValue;
+ }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/DbPatchSetId.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/DbPatchSetId.java
new file mode 100644
index 0000000..b5251c2
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/DbPatchSetId.java
@@ -0,0 +1,52 @@
+// Copyright (C) 2019 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
+//
+// 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.
+
+package com.googlesource.gerrit.plugins.verifystatus.server;
+
+import com.google.gwtorm.client.Column;
+import com.google.gwtorm.client.IntKey;
+
+public final class DbPatchSetId extends IntKey<DbChangeId> {
+ private static final long serialVersionUID = 1L;
+
+ @Column(id = 1)
+ public DbChangeId changeId;
+
+ @Column(id = 2)
+ public int patchSetId;
+
+ public DbPatchSetId() {
+ changeId = new DbChangeId();
+ }
+
+ public DbPatchSetId(DbChangeId changeId, int id) {
+ this.changeId = changeId;
+ this.patchSetId = id;
+ }
+
+ @Override
+ public DbChangeId getParentKey() {
+ return changeId;
+ }
+
+ @Override
+ public int get() {
+ return patchSetId;
+ }
+
+ @Override
+ protected void set(int newValue) {
+ patchSetId = newValue;
+ }
+}
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 3ba9176..6cc7530 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
@@ -15,6 +15,7 @@
package com.googlesource.gerrit.plugins.verifystatus.server;
import com.google.gerrit.extensions.annotations.PluginName;
+import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.config.ConfigResource;
import com.google.gerrit.server.config.PluginConfig;
@@ -31,7 +32,7 @@
}
@Override
- public ConfigInfo apply(ConfigResource resource) {
+ public Response<ConfigInfo> apply(ConfigResource resource) {
ConfigInfo info = new ConfigInfo();
info.showJobsPanel = cfg.getBoolean("showJobsPanel", true);
info.showJobsDropDownPanel = cfg.getBoolean("showJobsDropDownPanel", true);
@@ -41,7 +42,7 @@
info.sortJobsPanel = cfg.getEnum(JobsSorting.values(), "sortJobsPanel", JobsSorting.REPORTER);
info.sortJobsDropDownPanel =
cfg.getEnum(JobsSorting.values(), "sortJobsDropDownPanel", JobsSorting.REPORTER);
- return info;
+ return Response.ok(info);
}
public static class ConfigInfo {
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 74ee698..f765ae0 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
@@ -17,6 +17,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gerrit.common.Nullable;
+import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestReadView;
import com.google.gerrit.server.change.RevisionResource;
import com.google.gwtorm.server.OrmException;
@@ -124,12 +125,16 @@
}
@Override
- public Map<String, VerificationInfo> apply(RevisionResource rsrc)
+ public Response<Map<String, VerificationInfo>> apply(RevisionResource rsrc)
throws IOException, OrmException {
Map<String, VerificationInfo> out = Maps.newLinkedHashMap();
try (CiDb db = schemaFactory.open()) {
- ResultSet<PatchSetVerification> rs =
- db.patchSetVerifications().byPatchSet(rsrc.getPatchSet().getId());
+ DbPatchSetId id =
+ new DbPatchSetId(
+ new DbChangeId(rsrc.getPatchSet().id().changeId().get()),
+ rsrc.getPatchSet().id().get());
+
+ ResultSet<PatchSetVerification> rs = db.patchSetVerifications().byPatchSet(id);
List<PatchSetVerification> result = rs.toList();
List<PatchSetVerification> jobs = Lists.newLinkedList();
@@ -179,6 +184,6 @@
out.put(v.getJobId().get(), createVerificationInfo(v));
}
}
- return out;
+ return Response.ok(out);
}
}
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 71225b7..aa30631 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,8 +14,6 @@
package com.googlesource.gerrit.plugins.verifystatus.server;
-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;
@@ -23,31 +21,31 @@
public class PatchSetVerification {
- public static class Key extends CompoundKey<PatchSet.Id> {
+ public static class Key extends CompoundKey<DbPatchSetId> {
private static final long serialVersionUID = 1L;
@Column(id = 1, name = Column.NONE)
- protected PatchSet.Id patchSetId;
+ protected DbPatchSetId patchSetId;
@Column(id = 2)
- protected LabelId jobId;
+ protected DbLabelId jobId;
protected Key() {
- patchSetId = new PatchSet.Id();
- jobId = new LabelId();
+ patchSetId = new DbPatchSetId();
+ jobId = new DbLabelId();
}
- public Key(PatchSet.Id ps, LabelId c) {
+ public Key(DbPatchSetId ps, DbLabelId c) {
this.patchSetId = ps;
this.jobId = c;
}
@Override
- public PatchSet.Id getParentKey() {
+ public DbPatchSetId getParentKey() {
return patchSetId;
}
- public LabelId getLabelId() {
+ public DbLabelId getLabelId() {
return jobId;
}
@@ -102,11 +100,11 @@
return key;
}
- public PatchSet.Id getPatchSetId() {
+ public DbPatchSetId getPatchSetId() {
return key.patchSetId;
}
- public LabelId getJobId() {
+ public DbLabelId getJobId() {
return key.jobId;
}
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 2bd9ffb..dc6eaef 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
@@ -14,8 +14,6 @@
package com.googlesource.gerrit.plugins.verifystatus.server;
-import com.google.gerrit.reviewdb.client.Change;
-import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gwtorm.server.Access;
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.PrimaryKey;
@@ -29,8 +27,8 @@
PatchSetVerification get(PatchSetVerification.Key key) throws OrmException;
@Query("WHERE key.patchSetId.changeId = ?")
- ResultSet<PatchSetVerification> byChange(Change.Id id) throws OrmException;
+ ResultSet<PatchSetVerification> byChange(DbChangeId id) throws OrmException;
@Query("WHERE key.patchSetId = ?")
- ResultSet<PatchSetVerification> byPatchSet(PatchSet.Id id) throws OrmException;
+ ResultSet<PatchSetVerification> byPatchSet(DbPatchSetId id) throws OrmException;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/SchemaVersionAccess.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/SchemaVersionAccess.java
new file mode 100644
index 0000000..256ab0e
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/SchemaVersionAccess.java
@@ -0,0 +1,28 @@
+// Copyright (C) 2019 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
+//
+// 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.
+
+package com.googlesource.gerrit.plugins.verifystatus.server;
+
+import com.google.gwtorm.server.Access;
+import com.google.gwtorm.server.OrmException;
+import com.google.gwtorm.server.PrimaryKey;
+import com.googlesource.gerrit.plugins.verifystatus.server.schema.CurrentSchemaVersion;
+
+/** Access interface for {@link CurrentSchemaVersion}. */
+public interface SchemaVersionAccess
+ extends Access<CurrentSchemaVersion, CurrentSchemaVersion.Key> {
+ @Override
+ @PrimaryKey("singleton")
+ CurrentSchemaVersion get(CurrentSchemaVersion.Key key) throws OrmException;
+}
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 fcd783f..828d2e3 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
@@ -21,7 +21,6 @@
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.events.LifecycleListener;
-import com.google.gerrit.extensions.persistence.DataSourceInterceptor;
import com.google.gerrit.metrics.CallbackMetric1;
import com.google.gerrit.metrics.Description;
import com.google.gerrit.metrics.Field;
@@ -29,6 +28,7 @@
import com.google.gerrit.server.config.ConfigUtil;
import com.google.gerrit.server.config.PluginConfig;
import com.google.gerrit.server.config.SitePaths;
+import com.google.gerrit.server.logging.Metadata;
import com.google.gwtorm.jdbc.SimpleDataSource;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -36,8 +36,6 @@
import com.google.inject.Singleton;
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;
@@ -118,7 +116,6 @@
String username = config.getString("username");
String password = config.getString("password");
- String interceptor = config.getString("dataSourceInterceptorClass");
boolean usePool;
if (context == Context.SINGLE_USER) {
@@ -149,7 +146,7 @@
}
ds.setInitialSize(ds.getMinIdle());
exportPoolMetrics(ds);
- return intercept(interceptor, ds);
+ return ds;
}
// Don't use the connection pool.
try {
@@ -162,7 +159,7 @@
if (password != null) {
p.setProperty("password", password);
}
- return intercept(interceptor, new SimpleDataSource(p));
+ return new SimpleDataSource(p);
} catch (SQLException se) {
throw new ProvisionException("Database unavailable", se);
}
@@ -174,7 +171,7 @@
"sql/connection_pool/connections",
Integer.class,
new Description("SQL database connections").setGauge().setUnit("connections"),
- Field.ofBoolean("active"));
+ Field.ofBoolean("active", Metadata.Builder::partial).build());
metrics.newTrigger(
cnt,
new Runnable() {
@@ -187,23 +184,4 @@
}
});
}
-
- private DataSource intercept(String interceptor, DataSource ds) {
- if (interceptor == null) {
- return ds;
- }
- try {
- Constructor<?> c = Class.forName(interceptor).getConstructor();
- DataSourceInterceptor datasourceInterceptor = (DataSourceInterceptor) c.newInstance();
- return datasourceInterceptor.intercept("CiDb", ds);
- } 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/CurrentSchemaVersion.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CurrentSchemaVersion.java
new file mode 100644
index 0000000..383c094
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CurrentSchemaVersion.java
@@ -0,0 +1,58 @@
+// Copyright (C) 2019 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
+//
+// 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.
+
+package com.googlesource.gerrit.plugins.verifystatus.server.schema;
+
+import com.google.gwtorm.client.Column;
+import com.google.gwtorm.client.StringKey;
+
+/** Current version of the database schema, to facilitate live upgrades. */
+public final class CurrentSchemaVersion {
+ public static final class Key extends StringKey<com.google.gwtorm.client.Key<?>> {
+ private static final long serialVersionUID = 1L;
+
+ private static final String VALUE = "X";
+
+ @Column(id = 1, length = 1)
+ public String one = VALUE;
+
+ public Key() {}
+
+ @Override
+ public String get() {
+ return VALUE;
+ }
+
+ @Override
+ protected void set(String newValue) {
+ assert get().equals(newValue);
+ }
+ }
+
+ /** Construct a new, unconfigured instance. */
+ public static CurrentSchemaVersion create() {
+ final CurrentSchemaVersion r = new CurrentSchemaVersion();
+ r.singleton = new CurrentSchemaVersion.Key();
+ return r;
+ }
+
+ @Column(id = 1)
+ public Key singleton;
+
+ /** Current version number of the schema. */
+ @Column(id = 2)
+ public transient int versionNbr;
+
+ public CurrentSchemaVersion() {}
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/JdbcUtil.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/JdbcUtil.java
new file mode 100644
index 0000000..b59c631
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/JdbcUtil.java
@@ -0,0 +1,34 @@
+// Copyright (C) 2012 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
+//
+// 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.
+
+package com.googlesource.gerrit.plugins.verifystatus.server.schema;
+
+public class JdbcUtil {
+ public static String hostname(String hostname) {
+ if (hostname == null || hostname.isEmpty()) {
+ hostname = "localhost";
+
+ } else if (hostname.contains(":") && !hostname.startsWith("[")) {
+ hostname = "[" + hostname + "]";
+ }
+ return hostname;
+ }
+
+ public static String port(String port) {
+ if (port != null && !port.isEmpty()) {
+ return ":" + port;
+ }
+ return "";
+ }
+}
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 e163091..6906a1f 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
@@ -14,9 +14,6 @@
package com.googlesource.gerrit.plugins.verifystatus.server.schema;
-import static com.google.gerrit.server.schema.JdbcUtil.hostname;
-import static com.google.gerrit.server.schema.JdbcUtil.port;
-
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.PluginConfig;
import com.google.gerrit.server.config.SitePaths;
@@ -48,8 +45,8 @@
public String getUrl() {
final StringBuilder b = new StringBuilder();
b.append("jdbc:mysql://");
- b.append(hostname(config.getString("hostname")));
- b.append(port(config.getString("port")));
+ b.append(JdbcUtil.hostname(config.getString("hostname")));
+ b.append(JdbcUtil.port(config.getString("port")));
b.append("/");
b.append(config.getString("database"));
return b.toString();
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 833333c..20b348a 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
@@ -14,9 +14,6 @@
package com.googlesource.gerrit.plugins.verifystatus.server.schema;
-import static com.google.gerrit.server.schema.JdbcUtil.hostname;
-import static com.google.gerrit.server.schema.JdbcUtil.port;
-
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.PluginConfig;
import com.google.gerrit.server.config.SitePaths;
@@ -48,8 +45,8 @@
public String getUrl() {
final StringBuilder b = new StringBuilder();
b.append("jdbc:oracle:thin:@");
- b.append(hostname(config.getString("hostname")));
- b.append(port(config.getString("port")));
+ b.append(JdbcUtil.hostname(config.getString("hostname")));
+ b.append(JdbcUtil.port(config.getString("port")));
b.append(":");
b.append(config.getString("instance"));
return b.toString();
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 67845a0..8038b46 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
@@ -14,9 +14,6 @@
package com.googlesource.gerrit.plugins.verifystatus.server.schema;
-import static com.google.gerrit.server.schema.JdbcUtil.hostname;
-import static com.google.gerrit.server.schema.JdbcUtil.port;
-
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.PluginConfig;
import com.google.gerrit.server.config.SitePaths;
@@ -48,8 +45,8 @@
public String getUrl() {
final StringBuilder b = new StringBuilder();
b.append("jdbc:postgresql://");
- b.append(hostname(config.getString("hostname")));
- b.append(port(config.getString("port")));
+ b.append(JdbcUtil.hostname(config.getString("hostname")));
+ b.append(JdbcUtil.port(config.getString("port")));
b.append("/");
b.append(config.getString("database"));
return b.toString();
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 fa5db22..8f948fb 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
@@ -15,17 +15,13 @@
package com.googlesource.gerrit.plugins.verifystatus.server.schema;
import com.google.common.collect.Lists;
-import com.google.gerrit.reviewdb.client.CurrentSchemaVersion;
-import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gwtorm.jdbc.JdbcExecutor;
import com.google.gwtorm.jdbc.JdbcSchema;
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;
import java.util.Collections;
import java.util.List;
@@ -55,7 +51,7 @@
return Integer.parseInt(n);
}
- /** @return the {@link CurrentSchemaVersion#versionNbr} this step targets. */
+ /** @return the version number this step targets. */
public final int getVersionNbr() {
return versionNbr;
}
@@ -162,43 +158,4 @@
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 {
- JdbcSchema s = (JdbcSchema) db;
- try (JdbcExecutor e = new JdbcExecutor(s)) {
- s.renameTable(e, from, to);
- }
- }
-
- /** Rename an existing column. */
- protected static void renameColumn(ReviewDb db, String table, String from, String to)
- throws OrmException {
- JdbcSchema s = (JdbcSchema) db;
- try (JdbcExecutor e = new JdbcExecutor(s)) {
- s.renameField(e, table, from, to);
- }
- }
-
- /** Execute an SQL statement. */
- protected static void execute(ReviewDb db, String sql) throws SQLException {
- try (Statement s = newStatement(db)) {
- s.execute(sql);
- }
- }
-
- /** Open a new single statement. */
- protected static Statement newStatement(ReviewDb db) throws SQLException {
- return ((JdbcSchema) db).getConnection().createStatement();
- }
-
- /** Open a new prepared statement. */
- protected static PreparedStatement prepareStatement(ReviewDb db, String sql) throws SQLException {
- return ((JdbcSchema) db).getConnection().prepareStatement(sql);
- }
-
- /** Open a new statement executor. */
- protected static JdbcExecutor newExecutor(ReviewDb db) throws OrmException {
- return new JdbcExecutor(((JdbcSchema) db).getConnection());
- }
}
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index fae7b0c..e9e1526 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -33,7 +33,18 @@
### Build in Gerrit tree
Clone or link this plugin to the plugins directory of Gerrit's source
-tree, and issue the command:
+tree.
+
+Put the external dependency Bazel build file into the Gerrit /plugins
+directory, replacing the existing empty one.
+
+```
+ cd gerrit/plugins
+ rm external_plugin_deps.bzl
+ ln -s @PLUGIN@/external_plugin_deps.bzl .
+```
+
+From Gerrit source tree issue the command:
```
bazel build plugins/@PLUGIN@