From 36c9725f3fd1f6c6c8e47ef6cebdcdfca64c6e71 Mon Sep 17 00:00:00 2001 From: Maxime Guerreiro Date: Tue, 3 Apr 2018 17:26:28 +0000 Subject: [PATCH] Allow plugins to define custom data in SubmitRequirement Replace the raw short/long reasons of SubmitRequirement with a dynamic type and map, allowing for more powerful implementations later. Also remove the label field, superseeded by the data Map. Use AutoValues for the SubmitRequirement class, as it is marked GwtIncompatible. The idea behind this change is to provide a future proof API that both plugins and end users will enjoy. A user interface is being worked on, and will benefit of these changes. Change-Id: I030609cd164d308f2231a2abba2eb16b09524b7f --- Documentation/json.txt | 12 ++- java/com/google/gerrit/common/BUILD | 2 + .../gerrit/common/data/SubmitRecord.java | 6 +- .../gerrit/common/data/SubmitRequirement.java | 100 +++++++++--------- .../data/SubmitRequirementAttribute.java | 8 +- .../gerrit/server/events/EventFactory.java | 6 +- .../server/index/change/ChangeField.java | 23 ++-- .../server/index/change/ChangeFieldTest.java | 27 ++++- 8 files changed, 106 insertions(+), 78 deletions(-) diff --git a/Documentation/json.txt b/Documentation/json.txt index 7360bd4573..3b8a8cba28 100644 --- a/Documentation/json.txt +++ b/Documentation/json.txt @@ -185,14 +185,16 @@ in order for the change to be submittable. [[requirement]] == requirement -Information about a requirement (not met) in order to submit a change. +Information about a requirement in order to submit a change. -shortReason:: A short description of the requirement (a hint). +fallbackText:: A human readable description of the requirement. -fullReason:: A longer and descriptive message explaining what needs to -be changed to meet the requirement. +type:: Alphanumerical (plus hyphens or underscores) string to identify what the requirement is and +why it was triggered. Can be seen as a class: requirements sharing the same type were created for a +similar reason, and the data structure will follow one set of rules. -label:: (Optional) The name of the linked label, if set by a pre-submit rule. +data:: (Optional) Additional key-value data linked to this requirement. This is used in templates to +render rich status messages. [[label]] == label diff --git a/java/com/google/gerrit/common/BUILD b/java/com/google/gerrit/common/BUILD index 919f53211b..a09ef49cc9 100644 --- a/java/com/google/gerrit/common/BUILD +++ b/java/com/google/gerrit/common/BUILD @@ -22,6 +22,7 @@ gwt_module( "//lib:guava", "//lib:gwtorm_client", "//lib:servlet-api-3_1", + "//lib/auto:auto-value", "//lib/jgit/org.eclipse.jgit:jgit", "//lib/log:api", ], @@ -46,6 +47,7 @@ java_library( "//lib:gwtjsonrpc", "//lib:gwtorm", "//lib:servlet-api-3_1", + "//lib/auto:auto-value", "//lib/jgit/org.eclipse.jgit:jgit", "//lib/log:api", ], diff --git a/java/com/google/gerrit/common/data/SubmitRecord.java b/java/com/google/gerrit/common/data/SubmitRecord.java index 3cd9c43557..ae8b2bbdec 100644 --- a/java/com/google/gerrit/common/data/SubmitRecord.java +++ b/java/com/google/gerrit/common/data/SubmitRecord.java @@ -14,6 +14,7 @@ package com.google.gerrit.common.data; +import com.google.common.annotations.GwtIncompatible; import com.google.gerrit.reviewdb.client.Account; import java.util.Collection; import java.util.List; @@ -60,7 +61,7 @@ public class SubmitRecord { public Status status; public List