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


Java PatchSetApproval.getValue方法代码示例

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


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

示例1: isPatchSetLocked

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
/** Is the current patch set locked against state changes? */
private boolean isPatchSetLocked(ReviewDb db) throws OrmException {
  if (getChange().getStatus() == Change.Status.MERGED) {
    return false;
  }

  for (PatchSetApproval ap :
      approvalsUtil.byPatchSet(
          db, getNotes(), getUser(), getChange().currentPatchSetId(), null, null)) {
    LabelType type =
        getProjectControl()
            .getProjectState()
            .getLabelTypes(getNotes(), getUser())
            .byLabel(ap.getLabel());
    if (type != null
        && ap.getValue() == 1
        && type.getFunction() == LabelFunction.PATCH_SET_LOCK) {
      return true;
    }
  }
  return false;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:ChangeControl.java

示例2: fromApprovals

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
public static ReviewerSet fromApprovals(Iterable<PatchSetApproval> approvals) {
  PatchSetApproval first = null;
  Table<ReviewerStateInternal, Account.Id, Timestamp> reviewers = HashBasedTable.create();
  for (PatchSetApproval psa : approvals) {
    if (first == null) {
      first = psa;
    } else {
      checkArgument(
          first
              .getKey()
              .getParentKey()
              .getParentKey()
              .equals(psa.getKey().getParentKey().getParentKey()),
          "multiple change IDs: %s, %s",
          first.getKey(),
          psa.getKey());
    }
    Account.Id id = psa.getAccountId();
    reviewers.put(REVIEWER, id, psa.getGranted());
    if (psa.getValue() != 0) {
      reviewers.remove(CC, id);
    }
  }
  return new ReviewerSet(reviewers);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:ReviewerSet.java

示例3: getLabels

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
private static Iterable<String> getLabels(ChangeData cd, boolean owners) throws OrmException {
  Set<String> allApprovals = new HashSet<>();
  Set<String> distinctApprovals = new HashSet<>();
  for (PatchSetApproval a : cd.currentApprovals()) {
    if (a.getValue() != 0 && !a.isLegacySubmit()) {
      allApprovals.add(formatLabel(a.getLabel(), a.getValue(), a.getAccountId()));
      if (owners && cd.change().getOwner().equals(a.getAccountId())) {
        allApprovals.add(
            formatLabel(a.getLabel(), a.getValue(), ChangeQueryBuilder.OWNER_ACCOUNT_ID));
      }
      distinctApprovals.add(formatLabel(a.getLabel(), a.getValue()));
    }
  }
  allApprovals.addAll(distinctApprovals);
  return allApprovals;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:17,代码来源:ChangeField.java

示例4: exec

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
@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;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:35,代码来源:PRED__load_commit_labels_1.java

示例5: normalize

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
/**
 * @param notes change notes containing the given approvals.
 * @param user current user.
 * @param approvals list of approvals.
 * @return copies of approvals normalized to the defined ranges for the label type. Approvals for
 *     unknown labels are not included in the output.
 */
public Result normalize(
    ChangeNotes notes, CurrentUser user, Collection<PatchSetApproval> approvals)
    throws IOException {
  List<PatchSetApproval> unchanged = Lists.newArrayListWithCapacity(approvals.size());
  List<PatchSetApproval> updated = Lists.newArrayListWithCapacity(approvals.size());
  List<PatchSetApproval> deleted = Lists.newArrayListWithCapacity(approvals.size());
  LabelTypes labelTypes =
      projectCache.checkedGet(notes.getProjectName()).getLabelTypes(notes, user);
  for (PatchSetApproval psa : approvals) {
    Change.Id changeId = psa.getKey().getParentKey().getParentKey();
    checkArgument(
        changeId.equals(notes.getChangeId()),
        "Approval %s does not match change %s",
        psa.getKey(),
        notes.getChange().getKey());
    if (psa.isLegacySubmit()) {
      unchanged.add(psa);
      continue;
    }
    LabelType label = labelTypes.byLabel(psa.getLabelId());
    if (label == null) {
      deleted.add(psa);
      continue;
    }
    PatchSetApproval copy = copy(psa);
    applyTypeFloor(label, copy);
    if (copy.getValue() != psa.getValue()) {
      updated.add(copy);
    } else {
      unchanged.add(psa);
    }
  }
  return Result.create(unchanged, updated, deleted);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:42,代码来源:LabelNormalizer.java

示例6: applyTypeFloor

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
private void applyTypeFloor(LabelType lt, PatchSetApproval a) {
  LabelValue atMin = lt.getMin();
  if (atMin != null && a.getValue() < atMin.getValue()) {
    a.setValue(atMin.getValue());
  }
  LabelValue atMax = lt.getMax();
  if (atMax != null && a.getValue() > atMax.getValue()) {
    a.setValue(atMax.getValue());
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:LabelNormalizer.java

示例7: getApprovals

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
public String getApprovals() {
  try {
    Table<Account.Id, String, PatchSetApproval> pos = HashBasedTable.create();
    Table<Account.Id, String, PatchSetApproval> neg = HashBasedTable.create();
    for (PatchSetApproval ca :
        args.approvalsUtil.byPatchSet(
            args.db.get(),
            changeData.notes(),
            args.identifiedUserFactory.create(changeData.change().getOwner()),
            patchSet.getId(),
            null,
            null)) {
      LabelType lt = labelTypes.byLabel(ca.getLabelId());
      if (lt == null) {
        continue;
      }
      if (ca.getValue() > 0) {
        pos.put(ca.getAccountId(), lt.getName(), ca);
      } else if (ca.getValue() < 0) {
        neg.put(ca.getAccountId(), lt.getName(), ca);
      }
    }

    return format("Approvals", pos) + format("Objections", neg);
  } catch (OrmException err) {
    // Don't list the approvals
  }
  return "";
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:30,代码来源:MergedSender.java

示例8: addApprovals

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
public void addApprovals(
    PatchSetAttribute p, Collection<PatchSetApproval> list, LabelTypes labelTypes) {
  if (!list.isEmpty()) {
    p.approvals = new ArrayList<>(list.size());
    for (PatchSetApproval a : list) {
      if (a.getValue() != 0) {
        p.approvals.add(asApprovalAttribute(a, labelTypes));
      }
    }
    if (p.approvals.isEmpty()) {
      p.approvals = null;
    }
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:EventFactory.java

示例9: labelsForUnsubmittedChange

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
private Map<String, LabelWithStatus> labelsForUnsubmittedChange(
    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;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:32,代码来源:ChangeJson.java

示例10: getSubmitter

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
public static PatchSetApproval getSubmitter(PatchSet.Id c, Iterable<PatchSetApproval> approvals) {
  if (c == null) {
    return null;
  }
  PatchSetApproval submitter = null;
  for (PatchSetApproval a : approvals) {
    if (a.getPatchSetId().equals(c) && a.getValue() > 0 && a.isLegacySubmit()) {
      if (submitter == null || a.getGranted().compareTo(submitter.getGranted()) > 0) {
        submitter = a;
      }
    }
  }
  return submitter;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:15,代码来源:ApprovalsUtil.java

示例11: diffPatchSetApprovals

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
private static void diffPatchSetApprovals(
    List<String> diffs, ChangeBundle bundleA, ChangeBundle bundleB) {
  Map<PatchSetApproval.Key, PatchSetApproval> as = bundleA.filterPatchSetApprovals();
  Map<PatchSetApproval.Key, PatchSetApproval> bs = bundleB.filterPatchSetApprovals();
  for (PatchSetApproval.Key k : diffKeySets(diffs, as, bs)) {
    PatchSetApproval a = as.get(k);
    PatchSetApproval b = bs.get(k);
    String desc = describe(k);

    // ReviewDb allows timestamps before patch set was created, but NoteDb
    // truncates this to the patch set creation timestamp.
    //
    // ChangeRebuilder ensures all post-submit approvals happen after the
    // actual submit, so the timestamps may not line up. This shouldn't really
    // happen, because postSubmit shouldn't be set in ReviewDb until after the
    // change is submitted in ReviewDb, but you never know.
    //
    // Due to a quirk of PostReview, post-submit 0 votes might not have the
    // postSubmit bit set in ReviewDb. As these are only used for tombstone
    // purposes, ignore the postSubmit bit in NoteDb in this case.
    Timestamp ta = a.getGranted();
    Timestamp tb = b.getGranted();
    PatchSet psa = checkNotNull(bundleA.patchSets.get(a.getPatchSetId()));
    PatchSet psb = checkNotNull(bundleB.patchSets.get(b.getPatchSetId()));
    boolean excludeGranted = false;
    boolean excludePostSubmit = false;
    List<String> exclude = new ArrayList<>(1);
    if (bundleA.source == REVIEW_DB && bundleB.source == NOTE_DB) {
      excludeGranted =
          (ta.before(psa.getCreatedOn()) && tb.equals(psb.getCreatedOn()))
              || ta.compareTo(tb) < 0;
      excludePostSubmit = a.getValue() == 0 && b.isPostSubmit();
    } else if (bundleA.source == NOTE_DB && bundleB.source == REVIEW_DB) {
      excludeGranted =
          tb.before(psb.getCreatedOn()) && ta.equals(psa.getCreatedOn()) || tb.compareTo(ta) < 0;
      excludePostSubmit = b.getValue() == 0 && a.isPostSubmit();
    }

    // Legacy submit approvals may or may not have tags associated with them,
    // depending on whether ChangeRebuilder happened to group them with the
    // status change.
    boolean excludeTag =
        bundleA.source != bundleB.source && a.isLegacySubmit() && b.isLegacySubmit();

    if (excludeGranted) {
      exclude.add("granted");
    }
    if (excludePostSubmit) {
      exclude.add("postSubmit");
    }
    if (excludeTag) {
      exclude.add("tag");
    }

    diffColumnsExcluding(diffs, PatchSetApproval.class, desc, bundleA, a, bundleB, b, exclude);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:58,代码来源:ChangeBundle.java

示例12: updateLabels

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
private boolean updateLabels(ProjectState projectState, ChangeContext ctx)
    throws OrmException, ResourceConflictException, IOException {
  Map<String, Short> inLabels =
      MoreObjects.firstNonNull(in.labels, Collections.<String, Short>emptyMap());

  // If no labels were modified and change is closed, abort early.
  // This avoids trying to record a modified label caused by a user
  // losing access to a label after the change was submitted.
  if (inLabels.isEmpty() && ctx.getChange().getStatus().isClosed()) {
    return false;
  }

  List<PatchSetApproval> del = new ArrayList<>();
  List<PatchSetApproval> ups = new ArrayList<>();
  Map<String, PatchSetApproval> current = scanLabels(projectState, ctx, del);
  LabelTypes labelTypes = projectState.getLabelTypes(ctx.getNotes(), ctx.getUser());
  Map<String, Short> allApprovals =
      getAllApprovals(labelTypes, approvalsByKey(current.values()), inLabels);
  Map<String, Short> previous =
      getPreviousApprovals(allApprovals, approvalsByKey(current.values()));

  ChangeUpdate update = ctx.getUpdate(psId);
  for (Map.Entry<String, Short> ent : allApprovals.entrySet()) {
    String name = ent.getKey();
    LabelType lt = checkNotNull(labelTypes.byLabel(name), name);

    PatchSetApproval c = current.remove(lt.getName());
    String normName = lt.getName();
    approvals.put(normName, (short) 0);
    if (ent.getValue() == null || ent.getValue() == 0) {
      // User requested delete of this label.
      oldApprovals.put(normName, null);
      if (c != null) {
        if (c.getValue() != 0) {
          addLabelDelta(normName, (short) 0);
          oldApprovals.put(normName, previous.get(normName));
        }
        del.add(c);
        update.putApproval(normName, (short) 0);
      }
    } else if (c != null && c.getValue() != ent.getValue()) {
      c.setValue(ent.getValue());
      c.setGranted(ctx.getWhen());
      c.setTag(in.tag);
      ctx.getUser().updateRealAccountId(c::setRealAccountId);
      ups.add(c);
      addLabelDelta(normName, c.getValue());
      oldApprovals.put(normName, previous.get(normName));
      approvals.put(normName, c.getValue());
      update.putApproval(normName, ent.getValue());
    } else if (c != null && c.getValue() == ent.getValue()) {
      current.put(normName, c);
      oldApprovals.put(normName, null);
      approvals.put(normName, c.getValue());
    } else if (c == null) {
      c = ApprovalsUtil.newApproval(psId, user, lt.getLabelId(), ent.getValue(), ctx.getWhen());
      c.setTag(in.tag);
      c.setGranted(ctx.getWhen());
      ups.add(c);
      addLabelDelta(normName, c.getValue());
      oldApprovals.put(normName, previous.get(normName));
      approvals.put(normName, c.getValue());
      update.putReviewer(user.getAccountId(), REVIEWER);
      update.putApproval(normName, ent.getValue());
    }
  }

  validatePostSubmitLabels(ctx, labelTypes, previous, ups, del);

  // Return early if user is not a reviewer and not posting any labels.
  // This allows us to preserve their CC status.
  if (current.isEmpty() && del.isEmpty() && ups.isEmpty() && !isReviewer(ctx)) {
    return false;
  }

  forceCallerAsReviewer(projectState, ctx, current, ups, del);
  ctx.getDb().patchSetApprovals().delete(del);
  ctx.getDb().patchSetApprovals().upsert(ups);
  return !del.isEmpty() || !ups.isEmpty();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:81,代码来源:PostReview.java

示例13: updateChange

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
@Override
public boolean updateChange(ChangeContext ctx)
    throws AuthException, ResourceNotFoundException, OrmException, PermissionBackendException,
        IOException, NoSuchProjectException {
  Account.Id reviewerId = reviewer.getId();
  if (!approvalsUtil.getReviewers(ctx.getDb(), ctx.getNotes()).all().contains(reviewerId)) {
    throw new ResourceNotFoundException();
  }
  currChange = ctx.getChange();
  currPs = psUtil.current(ctx.getDb(), ctx.getNotes());

  LabelTypes labelTypes =
      projectCache.checkedGet(ctx.getProject()).getLabelTypes(ctx.getNotes(), ctx.getUser());
  // removing a reviewer will remove all her votes
  for (LabelType lt : labelTypes.getLabelTypes()) {
    newApprovals.put(lt.getName(), (short) 0);
  }

  StringBuilder msg = new StringBuilder();
  msg.append("Removed reviewer " + reviewer.getFullName());
  StringBuilder removedVotesMsg = new StringBuilder();
  removedVotesMsg.append(" with the following votes:\n\n");
  List<PatchSetApproval> del = new ArrayList<>();
  boolean votesRemoved = false;
  for (PatchSetApproval a : approvals(ctx, reviewerId)) {
    removeReviewerControl.checkRemoveReviewer(ctx.getNotes(), ctx.getUser(), a);
    del.add(a);
    if (a.getPatchSetId().equals(currPs.getId()) && a.getValue() != 0) {
      oldApprovals.put(a.getLabel(), a.getValue());
      removedVotesMsg
          .append("* ")
          .append(a.getLabel())
          .append(formatLabelValue(a.getValue()))
          .append(" by ")
          .append(userFactory.create(a.getAccountId()).getNameEmail())
          .append("\n");
      votesRemoved = true;
    }
  }

  if (votesRemoved) {
    msg.append(removedVotesMsg);
  } else {
    msg.append(".");
  }
  ctx.getDb().patchSetApprovals().delete(del);
  ChangeUpdate update = ctx.getUpdate(currPs.getId());
  update.removeReviewer(reviewerId);

  changeMessage =
      ChangeMessagesUtil.newMessage(ctx, msg.toString(), ChangeMessagesUtil.TAG_DELETE_REVIEWER);
  cmUtil.addChangeMessage(ctx.getDb(), update, changeMessage);

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

示例14: isMaxNegative

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
public boolean isMaxNegative(PatchSetApproval ca) {
  return maxNegative == ca.getValue();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:4,代码来源:LabelType.java

示例15: isMaxPositive

import com.google.gerrit.reviewdb.client.PatchSetApproval; //导入方法依赖的package包/类
public boolean isMaxPositive(PatchSetApproval ca) {
  return maxPositive == ca.getValue();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:4,代码来源:LabelType.java


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