Read SubmitRecords back from NoteDb if allowClosed is false

NoteDb stores SubmitRecords upon change submission. This enables us to
parse them back and present them to users instead of plainly recomputing
them each time. Recomputing submit records of a submitted change is
especially harmful when the rules have changed in the meantime.

Consider the case where we have added a new label: A change would
suddenly appear to not be submittable anymore while it was submitted
with all necessary approvals at the time.

This commit wires up the parsing logic in ChangeNotes with
SubmitRuleEvaluator in case we read from NoteDb and adds tests to ensure
the behavior is correct.

We change the status of the SR that we read back to CLOSED to reflect the
SRs actual status.

While at it, we rename allowClosed to recomputeOnClosedChanges. If this
flag is true, we compute a fresh SR even for a closed change. If it is
false, we read back data from NoteDb.

Change-Id: Icefecee32dac8a16c1a00c0633054f1df45145eb
This commit is contained in:
Patrick Hiesel
2018-09-11 10:39:20 +02:00
parent c677e7f0fa
commit 78e96009f7
9 changed files with 180 additions and 13 deletions

View File

@@ -25,7 +25,7 @@ import com.google.auto.value.AutoValue;
@AutoValue
public abstract class SubmitRuleOptions {
private static final SubmitRuleOptions defaults =
new AutoValue_SubmitRuleOptions.Builder().allowClosed(false).build();
new AutoValue_SubmitRuleOptions.Builder().recomputeOnClosedChanges(false).build();
public static SubmitRuleOptions defaults() {
return defaults;
@@ -35,13 +35,16 @@ public abstract class SubmitRuleOptions {
return defaults.toBuilder();
}
public abstract boolean allowClosed();
/**
* True if the submit rules should be recomputed even when the change is already closed (merged).
*/
public abstract boolean recomputeOnClosedChanges();
public abstract Builder toBuilder();
@AutoValue.Builder
public abstract static class Builder {
public abstract SubmitRuleOptions.Builder allowClosed(boolean allowClosed);
public abstract SubmitRuleOptions.Builder recomputeOnClosedChanges(boolean allowClosed);
public abstract SubmitRuleOptions build();
}