本文整理汇总了Java中com.google.gerrit.common.data.SubmitRecord类的典型用法代码示例。如果您正苦于以下问题:Java SubmitRecord类的具体用法?Java SubmitRecord怎么用?Java SubmitRecord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubmitRecord类属于com.google.gerrit.common.data包,在下文中一共展示了SubmitRecord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setApproval
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
private void setApproval(ChangeContext ctx, IdentifiedUser user)
throws OrmException, IOException {
Change.Id id = ctx.getChange().getId();
List<SubmitRecord> records = args.commitStatus.getSubmitRecords(id);
PatchSet.Id oldPsId = toMerge.getPatchsetId();
PatchSet.Id newPsId = ctx.getChange().currentPatchSetId();
logDebug("Add approval for " + id);
ChangeUpdate origPsUpdate = ctx.getUpdate(oldPsId);
origPsUpdate.putReviewer(user.getAccountId(), REVIEWER);
LabelNormalizer.Result normalized = approve(ctx, origPsUpdate);
ChangeUpdate newPsUpdate = ctx.getUpdate(newPsId);
newPsUpdate.merge(args.submissionId, records);
// If the submit strategy created a new revision (rebase, cherry-pick), copy
// approvals as well.
if (!newPsId.equals(oldPsId)) {
saveApprovals(normalized, ctx, newPsUpdate, true);
submitter = convertPatchSet(newPsId).apply(submitter);
}
}
示例2: toSubmitRecord
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
private SubmitRecord toSubmitRecord() {
SubmitRecord rec = new SubmitRecord();
rec.status = status;
rec.errorMessage = errorMessage;
if (labels != null) {
rec.labels = new ArrayList<>(labels.size());
for (StoredLabel label : labels) {
SubmitRecord.Label srl = new SubmitRecord.Label();
srl.label = label.label;
srl.status = label.status;
srl.appliedBy = label.appliedBy != null ? new Account.Id(label.appliedBy) : null;
rec.labels.add(srl);
}
}
return rec;
}
示例3: formatSubmitRecordValues
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
@VisibleForTesting
static List<String> formatSubmitRecordValues(List<SubmitRecord> records, Account.Id changeOwner) {
List<String> result = new ArrayList<>();
for (SubmitRecord rec : records) {
result.add(rec.status.name());
if (rec.labels == null) {
continue;
}
for (SubmitRecord.Label label : rec.labels) {
String sl = label.status.toString() + ',' + label.label.toLowerCase();
result.add(sl);
String slc = sl + ',';
if (label.appliedBy != null) {
result.add(slc + label.appliedBy.get());
if (label.appliedBy.equals(changeOwner)) {
result.add(slc + ChangeQueryBuilder.OWNER_ACCOUNT_ID.get());
}
}
}
}
return result;
}
示例4: addSubmitRecords
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
/**
* Add submitRecords to an existing ChangeAttribute.
*
* @param ca
* @param submitRecords
*/
public void addSubmitRecords(ChangeAttribute ca, List<SubmitRecord> submitRecords) {
ca.submitRecords = new ArrayList<>();
for (SubmitRecord submitRecord : submitRecords) {
SubmitRecordAttribute sa = new SubmitRecordAttribute();
sa.status = submitRecord.status.name();
if (submitRecord.status != SubmitRecord.Status.RULE_ERROR) {
addSubmitRecordLabels(submitRecord, sa);
}
ca.submitRecords.add(sa);
}
// Remove empty lists so a confusing label won't be displayed in the output.
if (ca.submitRecords.isEmpty()) {
ca.submitRecords = null;
}
}
示例5: invalidResult
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
private List<SubmitRecord> invalidResult(Term rule, Term record, String reason) {
return ruleError(
String.format(
"Submit rule %s for change %s of %s output invalid result: %s%s",
rule,
cd.getId(),
getProjectName(),
record,
(reason == null ? "" : ". Reason: " + reason)));
}
示例6: ruleError
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
private List<SubmitRecord> ruleError(String err, Exception e) {
if (logErrors) {
if (e == null) {
log.error(err);
} else {
log.error(err, e);
}
return defaultRuleError();
}
return createRuleError(err);
}
示例7: appliedBy
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
private void appliedBy(SubmitRecord.Label label, Term status) throws UserTermExpected {
if (status instanceof StructureTerm && status.arity() == 1) {
Term who = status.arg(0);
if (isUser(who)) {
label.appliedBy = new Account.Id(((IntegerTerm) who.arg(0)).intValue());
} else {
throw new UserTermExpected(label);
}
}
}
示例8: getSubmitRecords
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
public List<SubmitRecord> getSubmitRecords(Change.Id id) {
// Use the cached submit records from the original ChangeData in the input
// ChangeSet, which were checked earlier in the integrate process. Even in
// the case of a race where the submit records may have changed, it makes
// more sense to store the original results of the submit rule evaluator
// than to fail at this point.
//
// However, do NOT expose that ChangeData directly, as it is way out of
// date by this point.
ChangeData cd = checkNotNull(changes.get(id), "ChangeData for %s", id);
return checkNotNull(
cd.getSubmitRecords(submitRuleOptions(allowClosed)),
"getSubmitRecord only valid after submit rules are evalutated");
}
示例9: checkSubmitRule
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
public static void checkSubmitRule(ChangeData cd, boolean allowClosed)
throws ResourceConflictException, OrmException {
PatchSet patchSet = cd.currentPatchSet();
if (patchSet == null) {
throw new ResourceConflictException("missing current patch set for change " + cd.getId());
}
List<SubmitRecord> results = getSubmitRecords(cd, allowClosed);
if (SubmitRecord.findOkRecord(results).isPresent()) {
// Rules supplied a valid solution.
return;
} else if (results.isEmpty()) {
throw new IllegalStateException(
String.format(
"SubmitRuleEvaluator.evaluate for change %s returned empty list for %s in %s",
cd.getId(), patchSet.getId(), cd.change().getProject().get()));
}
for (SubmitRecord record : results) {
switch (record.status) {
case CLOSED:
throw new ResourceConflictException("change is closed");
case RULE_ERROR:
throw new ResourceConflictException("submit rule error: " + record.errorMessage);
case NOT_READY:
throw new ResourceConflictException(describeLabels(cd, record.labels));
case FORCED:
case OK:
default:
throw new IllegalStateException(
String.format(
"Unexpected SubmitRecord status %s for %s in %s",
record.status, patchSet.getId().getId(), cd.change().getProject().get()));
}
}
throw new IllegalStateException();
}
示例10: describeLabels
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
private static String describeLabels(ChangeData cd, List<SubmitRecord.Label> labels)
throws OrmException {
List<String> labelResults = new ArrayList<>();
for (SubmitRecord.Label lbl : labels) {
switch (lbl.status) {
case OK:
case MAY:
break;
case REJECT:
labelResults.add("blocked by " + lbl.label);
break;
case NEED:
labelResults.add("needs " + lbl.label);
break;
case IMPOSSIBLE:
labelResults.add("needs " + lbl.label + " (check project access)");
break;
default:
throw new IllegalStateException(
String.format(
"Unsupported SubmitRecord.Label %s for %s in %s",
lbl, cd.change().currentPatchSetId(), cd.change().getProject()));
}
}
return Joiner.on("; ").join(labelResults);
}
示例11: bypassSubmitRules
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
private void bypassSubmitRules(ChangeSet cs, boolean allowClosed) throws OrmException {
checkArgument(
!cs.furtherHiddenChanges(), "cannot bypass submit rules for topic with hidden change");
for (ChangeData cd : cs.changes()) {
List<SubmitRecord> records = new ArrayList<>(getSubmitRecords(cd, allowClosed));
SubmitRecord forced = new SubmitRecord();
forced.status = SubmitRecord.Status.FORCED;
records.add(forced);
cd.setSubmitRecords(submitRuleOptions(allowClosed), records);
}
}
示例12: submitRecords
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
public List<SubmitRecord> submitRecords(SubmitRuleOptions options) throws OrmException {
List<SubmitRecord> records = submitRecords.get(options);
if (records == null) {
if (!lazyLoad) {
return Collections.emptyList();
}
records =
submitRuleEvaluatorFactory
.create(userFactory.create(change().getOwner()), this)
.setOptions(options)
.evaluate();
submitRecords.put(options, records);
}
return records;
}
示例13: create
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
public static Predicate<ChangeData> create(
String label, SubmitRecord.Label.Status status, Set<Account.Id> accounts) {
String lowerLabel = label.toLowerCase();
if (accounts == null || accounts.isEmpty()) {
return new SubmitRecordPredicate(status.name() + ',' + lowerLabel);
}
return Predicate.or(
accounts
.stream()
.map(a -> new SubmitRecordPredicate(status.name() + ',' + lowerLabel + ',' + a.get()))
.collect(toList()));
}
示例14: submittable
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
@Operator
public Predicate<ChangeData> submittable(String str) throws QueryParseException {
SubmitRecord.Status status =
Enums.getIfPresent(SubmitRecord.Status.class, str.toUpperCase()).orNull();
if (status == null) {
throw error("invalid value for submittable:" + str);
}
return new SubmittablePredicate(status);
}
示例15: StoredSubmitRecord
import com.google.gerrit.common.data.SubmitRecord; //导入依赖的package包/类
StoredSubmitRecord(SubmitRecord rec) {
this.status = rec.status;
this.errorMessage = rec.errorMessage;
if (rec.labels != null) {
this.labels = new ArrayList<>(rec.labels.size());
for (SubmitRecord.Label label : rec.labels) {
StoredLabel sl = new StoredLabel();
sl.label = label.label;
sl.status = label.status;
sl.appliedBy = label.appliedBy != null ? label.appliedBy.get() : null;
this.labels.add(sl);
}
}
}