use of com.google.gerrit.reviewdb.client.PatchSetApproval in project gerrit by GerritCodeReview.
the class ChangeBundle method getLatestTimestamp.
private Timestamp getLatestTimestamp() {
Ordering<Timestamp> o = Ordering.natural().nullsFirst();
Timestamp ts = null;
for (ChangeMessage cm : filterChangeMessages()) {
ts = o.max(ts, cm.getWrittenOn());
}
for (PatchSet ps : getPatchSets()) {
ts = o.max(ts, ps.getCreatedOn());
}
for (PatchSetApproval psa : filterPatchSetApprovals().values()) {
ts = o.max(ts, psa.getGranted());
}
for (PatchLineComment plc : filterPatchLineComments().values()) {
// Ignore draft comments, as they do not show up in the change meta graph.
if (plc.getStatus() != PatchLineComment.Status.DRAFT) {
ts = o.max(ts, plc.getWrittenOn());
}
}
return firstNonNull(ts, change.getLastUpdatedOn());
}
use of com.google.gerrit.reviewdb.client.PatchSetApproval in project gerrit by GerritCodeReview.
the class PRED__load_commit_labels_1 method exec.
@Override
public Operation exec(Prolog engine) throws PrologException {
engine.setB0();
Term a1 = arg1.dereference();
Term listHead = Prolog.Nil;
try {
ChangeData cd = StoredValues.CHANGE_DATA.get(engine);
LabelTypes types = cd.getLabelTypes();
for (PatchSetApproval a : cd.currentApprovals()) {
LabelType t = types.byLabel(a.getLabelId());
if (t == null) {
continue;
}
StructureTerm labelTerm = new StructureTerm(sym_label, SymbolTerm.intern(t.getName()), new IntegerTerm(a.getValue()));
StructureTerm userTerm = new StructureTerm(sym_user, new IntegerTerm(a.getAccountId().get()));
listHead = new ListTerm(new StructureTerm(sym_commit_label, labelTerm, userTerm), listHead);
}
} catch (OrmException err) {
throw new JavaException(this, 1, err);
}
if (!a1.unify(listHead, engine.trail)) {
return engine.fail();
}
return cont;
}
use of com.google.gerrit.reviewdb.client.PatchSetApproval in project gerrit by GerritCodeReview.
the class ChangeJson method labelsForOpenChange.
private Map<String, LabelWithStatus> labelsForOpenChange(PermissionBackend.ForChange perm, ChangeData cd, LabelTypes labelTypes, boolean standard, boolean detailed) throws OrmException, PermissionBackendException {
Map<String, LabelWithStatus> labels = initLabels(cd, labelTypes, standard);
if (detailed) {
setAllApprovals(perm, cd, labels);
}
for (Map.Entry<String, LabelWithStatus> e : labels.entrySet()) {
LabelType type = labelTypes.byLabel(e.getKey());
if (type == null) {
continue;
}
if (standard) {
for (PatchSetApproval psa : cd.currentApprovals()) {
if (type.matches(psa)) {
short val = psa.getValue();
Account.Id accountId = psa.getAccountId();
setLabelScores(type, e.getValue(), val, accountId);
}
}
}
if (detailed) {
setLabelValues(type, e.getValue());
}
}
return labels;
}
use of com.google.gerrit.reviewdb.client.PatchSetApproval in project gerrit by GerritCodeReview.
the class SubmitStrategyOp method zero.
private static Iterable<PatchSetApproval> zero(Iterable<PatchSetApproval> approvals) {
return Iterables.transform(approvals, a -> {
PatchSetApproval copy = new PatchSetApproval(a.getPatchSetId(), a);
copy.setValue((short) 0);
return copy;
});
}
use of com.google.gerrit.reviewdb.client.PatchSetApproval in project gerrit by GerritCodeReview.
the class LabelNormalizerTest method normalizeByType.
@Test
public void normalizeByType() throws Exception {
ProjectConfig pc = loadAllProjects();
allow(pc, forLabel("Code-Review"), -5, 5, REGISTERED_USERS, "refs/heads/*");
allow(pc, forLabel("Verified"), -5, 5, REGISTERED_USERS, "refs/heads/*");
save(pc);
PatchSetApproval cr = psa(userId, "Code-Review", 5);
PatchSetApproval v = psa(userId, "Verified", 5);
assertEquals(Result.create(list(), list(copy(cr, 2), copy(v, 1)), list()), norm.normalize(change, list(cr, v)));
}
Aggregations