Refactor displaying of reports on Gerrit UI

Refactor to retreive curated data using REST endpoint instead of
curating the data on the client.  The panel's job is just to show
the data.

Change-Id: I9e1f60bd141de52a5dabdfdf3f6a1a072e46198a
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 2725595..953761e 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
@@ -30,9 +30,6 @@
 import com.google.gwt.user.client.ui.InlineHyperlink;
 import com.google.gwt.user.client.ui.InlineLabel;
 
-import java.util.Map;
-import java.util.TreeMap;
-
 /**
  * Extension for change screen that displays a status in the header bar.
  */
@@ -51,15 +48,12 @@
         panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
     new RestApi("changes").id(change.id()).view("revisions").id(rev.id())
         .view(Plugin.get().getPluginName(), "verifications")
+        .addParameter("current", true)
         .get(new AsyncCallback<NativeMap<VerificationInfo>>() {
           @Override
           public void onSuccess(NativeMap<VerificationInfo> result) {
             if (!result.isEmpty()) {
-              Map<String, VerificationInfo> jobs = new TreeMap<>();
-              for (String key : result.keySet()) {
-                jobs.put(key, result.get(key));
-              }
-              display(jobs);
+              display(result);
             }
           }
 
@@ -70,14 +64,14 @@
         });
   }
 
-  private void display(Map<String, VerificationInfo> jobs) {
+  private void display(NativeMap<VerificationInfo> jobs) {
     int row = 0;
     int column = 5;
     Grid grid = new Grid(row, column);
-    for (Map.Entry<String, VerificationInfo> job : jobs.entrySet()) {
+    for (String key : jobs.keySet()) {
       grid.insertRow(row);
       HorizontalPanel p = new HorizontalPanel();
-      short vote = job.getValue().value();
+      short vote = jobs.get(key).value();
       if (vote > 0) {
         p.add(new Image(VerifyStatusPlugin.RESOURCES.greenCheck()));
       } else if (vote < 0) {
@@ -85,16 +79,16 @@
       } else if (vote == 0) {
         p.add(new Image(VerifyStatusPlugin.RESOURCES.warning()));
       }
-      p.add(new InlineHyperlink(job.getKey(), job.getValue().url()));
-      p.add(new InlineLabel("(" + job.getValue().duration() + ")"));
-      if (job.getValue().abstain()) {
+      p.add(new InlineHyperlink(jobs.get(key).name(), jobs.get(key).url()));
+      p.add(new InlineLabel("(" + jobs.get(key).duration() + ")"));
+      if (jobs.get(key).abstain()) {
         p.add(new Image(VerifyStatusPlugin.RESOURCES.info()));
       }
       grid.setWidget(row, 1, p);
-      grid.setWidget(row, 2, new InlineLabel(job.getValue().category()));
-      grid.setWidget(row, 3, new InlineLabel(job.getValue().reporter()));
+      grid.setWidget(row, 2, new InlineLabel(jobs.get(key).category()));
+      grid.setWidget(row, 3, new InlineLabel(jobs.get(key).reporter()));
       grid.setWidget(row, 4,
-          new InlineLabel(FormatUtil.shortFormat(job.getValue().granted())));
+          new InlineLabel(FormatUtil.shortFormat(jobs.get(key).granted())));
       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
index feef675..f908488 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
@@ -29,9 +29,6 @@
 import com.google.gwt.user.client.ui.InlineHyperlink;
 import com.google.gwt.user.client.ui.InlineLabel;
 
-import java.util.Map;
-import java.util.TreeMap;
-
 /**
  * Extension for change screen that displays a status below the label info.
  */
@@ -50,15 +47,12 @@
         panel.getObject(GerritUiExtensionPoint.Key.REVISION_INFO).cast();
     new RestApi("changes").id(change.id()).view("revisions").id(rev.id())
         .view(Plugin.get().getPluginName(), "verifications")
+        .addParameter("current", true)
         .get(new AsyncCallback<NativeMap<VerificationInfo>>() {
           @Override
           public void onSuccess(NativeMap<VerificationInfo> result) {
             if (!result.isEmpty()) {
-              Map<String, VerificationInfo> jobs = new TreeMap<>();
-              for (String key : result.keySet()) {
-                jobs.put(key, result.get(key));
-              }
-              display(jobs);
+              display(result);
             }
           }
 
@@ -69,14 +63,14 @@
         });
   }
 
-  private void display(Map<String, VerificationInfo> jobs) {
+  private void display(NativeMap<VerificationInfo> jobs) {
     int row = 0;
     int column = 1;
     Grid grid = new Grid(row, column);
-    for (Map.Entry<String, VerificationInfo> job : jobs.entrySet()) {
+    for (String key : jobs.keySet()) {
       grid.insertRow(row);
       HorizontalPanel p = new HorizontalPanel();
-      short vote = job.getValue().value();
+      short vote = jobs.get(key).value();
       if (vote > 0) {
         p.add(new Image(VerifyStatusPlugin.RESOURCES.greenCheck()));
       } else if (vote < 0) {
@@ -84,9 +78,9 @@
       } else if (vote == 0) {
         p.add(new Image(VerifyStatusPlugin.RESOURCES.warning()));
       }
-      p.add(new InlineHyperlink(job.getKey(), job.getValue().url()));
-      p.add(new InlineLabel(" (" + job.getValue().duration() + ")"));
-      if (job.getValue().abstain()) {
+      p.add(new InlineHyperlink(jobs.get(key).name(), jobs.get(key).url()));
+      p.add(new InlineLabel(" (" + jobs.get(key).duration() + ")"));
+      if (jobs.get(key).abstain()) {
         p.add(new Image(VerifyStatusPlugin.RESOURCES.info()));
       }
       grid.setWidget(row, 0, p);