当前位置: 首页>>代码示例>>Java>>正文


Java SubmitRecord.Label方法代码示例

本文整理汇总了Java中com.google.gerrit.common.data.SubmitRecord.Label方法的典型用法代码示例。如果您正苦于以下问题:Java SubmitRecord.Label方法的具体用法?Java SubmitRecord.Label怎么用?Java SubmitRecord.Label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gerrit.common.data.SubmitRecord的用法示例。


在下文中一共展示了SubmitRecord.Label方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:ChangeField.java

示例2: 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;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:ChangeField.java

示例3: 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);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:SubmitRuleEvaluator.java

示例4: 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);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:31,代码来源:MergeOp.java

示例5: 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);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:ChangeField.java

示例6: addSubmitRecordLabels

import com.google.gerrit.common.data.SubmitRecord; //导入方法依赖的package包/类
private void addSubmitRecordLabels(SubmitRecord submitRecord, SubmitRecordAttribute sa) {
  if (submitRecord.labels != null && !submitRecord.labels.isEmpty()) {
    sa.labels = new ArrayList<>();
    for (SubmitRecord.Label lbl : submitRecord.labels) {
      SubmitLabelAttribute la = new SubmitLabelAttribute();
      la.label = lbl.label;
      la.status = lbl.status.name();
      if (lbl.appliedBy != null) {
        Account a = accountCache.get(lbl.appliedBy).getAccount();
        la.by = asAccountAttribute(a);
      }
      sa.labels.add(la);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:EventFactory.java

示例7: initLabels

import com.google.gerrit.common.data.SubmitRecord; //导入方法依赖的package包/类
private Map<String, LabelWithStatus> initLabels(
    ChangeData cd, LabelTypes labelTypes, boolean standard) throws OrmException {
  Map<String, LabelWithStatus> labels = new TreeMap<>(labelTypes.nameComparator());
  for (SubmitRecord rec : submitRecords(cd)) {
    if (rec.labels == null) {
      continue;
    }
    for (SubmitRecord.Label r : rec.labels) {
      LabelWithStatus p = labels.get(r.label);
      if (p == null || p.status().compareTo(r.status) < 0) {
        LabelInfo n = new LabelInfo();
        if (standard) {
          switch (r.status) {
            case OK:
              n.approved = accountLoader.get(r.appliedBy);
              break;
            case REJECT:
              n.rejected = accountLoader.get(r.appliedBy);
              n.blocking = true;
              break;
            case IMPOSSIBLE:
            case MAY:
            case NEED:
            default:
              break;
          }
        }

        n.optional = r.status == SubmitRecord.Label.Status.MAY ? true : null;
        labels.put(r.label, LabelWithStatus.create(n, r.status));
      }
    }
  }
  return labels;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:36,代码来源:ChangeJson.java

示例8: Record

import com.google.gerrit.common.data.SubmitRecord; //导入方法依赖的package包/类
Record(SubmitRecord r, AccountLoader accounts) {
  this.status = r.status;
  this.errorMessage = r.errorMessage;

  if (r.labels != null) {
    for (SubmitRecord.Label n : r.labels) {
      AccountInfo who = n.appliedBy != null ? accounts.get(n.appliedBy) : new AccountInfo(null);
      label(n, who);
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:TestSubmitRule.java

示例9: label

import com.google.gerrit.common.data.SubmitRecord; //导入方法依赖的package包/类
private void label(SubmitRecord.Label n, AccountInfo who) {
  switch (n.status) {
    case OK:
      if (ok == null) {
        ok = new LinkedHashMap<>();
      }
      ok.put(n.label, who);
      break;
    case REJECT:
      if (reject == null) {
        reject = new LinkedHashMap<>();
      }
      reject.put(n.label, who);
      break;
    case NEED:
      if (need == null) {
        need = new LinkedHashMap<>();
      }
      need.put(n.label, new None());
      break;
    case MAY:
      if (may == null) {
        may = new LinkedHashMap<>();
      }
      may.put(n.label, who);
      break;
    case IMPOSSIBLE:
      if (impossible == null) {
        impossible = new LinkedHashMap<>();
      }
      impossible.put(n.label, new None());
      break;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:35,代码来源:TestSubmitRule.java

示例10: submitRecord

import com.google.gerrit.common.data.SubmitRecord; //导入方法依赖的package包/类
protected static SubmitRecord submitRecord(
    String status, String errorMessage, SubmitRecord.Label... labels) {
  SubmitRecord rec = new SubmitRecord();
  rec.status = SubmitRecord.Status.valueOf(status);
  rec.errorMessage = errorMessage;
  if (labels.length > 0) {
    rec.labels = ImmutableList.copyOf(labels);
  }
  return rec;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:AbstractChangeNotesTest.java

示例11: submitLabel

import com.google.gerrit.common.data.SubmitRecord; //导入方法依赖的package包/类
protected static SubmitRecord.Label submitLabel(
    String name, String status, Account.Id appliedBy) {
  SubmitRecord.Label label = new SubmitRecord.Label();
  label.label = name;
  label.status = SubmitRecord.Label.Status.valueOf(status);
  label.appliedBy = appliedBy;
  return label;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:AbstractChangeNotesTest.java

示例12: record

import com.google.gerrit.common.data.SubmitRecord; //导入方法依赖的package包/类
private static SubmitRecord record(SubmitRecord.Status status, SubmitRecord.Label... labels) {
  SubmitRecord r = new SubmitRecord();
  r.status = status;
  if (labels.length > 0) {
    r.labels = ImmutableList.copyOf(labels);
  }
  return r;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:ChangeFieldTest.java

示例13: UserTermExpected

import com.google.gerrit.common.data.SubmitRecord; //导入方法依赖的package包/类
UserTermExpected(SubmitRecord.Label label) {
  super(String.format("A label with the status %s must contain a user.", label.toString()));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:4,代码来源:SubmitRuleEvaluator.java

示例14: format

import com.google.gerrit.common.data.SubmitRecord; //导入方法依赖的package包/类
public ReviewerInfo format(
    CurrentUser user,
    ReviewerInfo out,
    PermissionBackend.ForChange perm,
    ChangeData cd,
    Iterable<PatchSetApproval> approvals)
    throws OrmException, PermissionBackendException {
  LabelTypes labelTypes = cd.getLabelTypes();

  out.approvals = new TreeMap<>(labelTypes.nameComparator());
  for (PatchSetApproval ca : approvals) {
    LabelType at = labelTypes.byLabel(ca.getLabelId());
    if (at != null) {
      out.approvals.put(at.getName(), formatValue(ca.getValue()));
    }
  }

  // Add dummy approvals for all permitted labels for the user even if they
  // do not exist in the DB.
  PatchSet ps = cd.currentPatchSet();
  if (ps != null) {
    for (SubmitRecord rec : submitRuleEvaluatorFactory.create(user, cd).evaluate()) {
      if (rec.labels == null) {
        continue;
      }
      for (SubmitRecord.Label label : rec.labels) {
        String name = label.label;
        LabelType type = labelTypes.byLabel(name);
        if (!out.approvals.containsKey(name)
            && type != null
            && perm.test(new LabelPermission(type))) {
          out.approvals.put(name, formatValue((short) 0));
        }
      }
    }
  }

  if (out.approvals.isEmpty()) {
    out.approvals = null;
  }

  return out;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:44,代码来源:ReviewerJson.java


注:本文中的com.google.gerrit.common.data.SubmitRecord.Label方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。