Search in sources :

Example 1 with ApprovalAttribute

use of com.google.gerrit.server.data.ApprovalAttribute in project gerrit by GerritCodeReview.

the class StreamEventsApiListener method getApprovalAttribute.

private ApprovalAttribute getApprovalAttribute(LabelTypes labelTypes, Entry<String, Short> approval, Map<String, Short> oldApprovals) {
    ApprovalAttribute a = new ApprovalAttribute();
    a.type = approval.getKey();
    if (oldApprovals != null && !oldApprovals.isEmpty()) {
        if (oldApprovals.get(approval.getKey()) != null) {
            a.oldValue = Short.toString(oldApprovals.get(approval.getKey()));
        }
    }
    LabelType lt = labelTypes.byLabel(approval.getKey());
    if (lt != null) {
        a.description = lt.getName();
    }
    if (approval.getValue() != null) {
        a.value = Short.toString(approval.getValue());
    }
    return a;
}
Also used : LabelType(com.google.gerrit.common.data.LabelType) ApprovalAttribute(com.google.gerrit.server.data.ApprovalAttribute)

Example 2 with ApprovalAttribute

use of com.google.gerrit.server.data.ApprovalAttribute in project gerrit by GerritCodeReview.

the class EventFactory method asApprovalAttribute.

/**
   * Create an ApprovalAttribute for the given approval suitable for serialization to JSON.
   *
   * @param approval
   * @param labelTypes label types for the containing project
   * @return object suitable for serialization to JSON
   */
public ApprovalAttribute asApprovalAttribute(PatchSetApproval approval, LabelTypes labelTypes) {
    ApprovalAttribute a = new ApprovalAttribute();
    a.type = approval.getLabelId().get();
    a.value = Short.toString(approval.getValue());
    a.by = asAccountAttribute(approval.getAccountId());
    a.grantedOn = approval.getGranted().getTime() / 1000L;
    a.oldValue = null;
    LabelType lt = labelTypes.byLabel(approval.getLabelId());
    if (lt != null) {
        a.description = lt.getName();
    }
    return a;
}
Also used : LabelType(com.google.gerrit.common.data.LabelType) ApprovalAttribute(com.google.gerrit.server.data.ApprovalAttribute)

Aggregations

LabelType (com.google.gerrit.common.data.LabelType)2 ApprovalAttribute (com.google.gerrit.server.data.ApprovalAttribute)2