use of com.google.gerrit.server.account.AccountLoader in project gerrit by GerritCodeReview.
the class GetPastAssignees method apply.
@Override
public Response<List<AccountInfo>> apply(ChangeResource rsrc) throws OrmException {
Set<Account.Id> pastAssignees = rsrc.getControl().getNotes().load().getPastAssignees();
if (pastAssignees == null) {
return Response.ok(Collections.emptyList());
}
AccountLoader accountLoader = accountLoaderFactory.create(true);
List<AccountInfo> infos = pastAssignees.stream().map(accountLoader::get).collect(toList());
accountLoader.fill();
return Response.ok(infos);
}
use of com.google.gerrit.server.account.AccountLoader in project gerrit by GerritCodeReview.
the class AddMembers method toAccountInfoList.
private List<AccountInfo> toAccountInfoList(Set<Account.Id> accountIds) throws OrmException {
List<AccountInfo> result = new ArrayList<>();
AccountLoader loader = infoFactory.create(true);
for (Account.Id accId : accountIds) {
result.add(loader.get(accId));
}
loader.fill();
return result;
}
use of com.google.gerrit.server.account.AccountLoader in project gerrit by GerritCodeReview.
the class GetMember method apply.
@Override
public AccountInfo apply(MemberResource rsrc) throws OrmException {
AccountLoader loader = infoFactory.create(true);
AccountInfo info = loader.get(rsrc.getMember().getAccountId());
loader.fill();
return info;
}
use of com.google.gerrit.server.account.AccountLoader in project gerrit by GerritCodeReview.
the class RevisionApiImpl method votes.
@Override
public ListMultimap<String, ApprovalInfo> votes() throws RestApiException {
ListMultimap<String, ApprovalInfo> result = ListMultimapBuilder.treeKeys().arrayListValues().build();
try {
Iterable<PatchSetApproval> approvals = approvalsUtil.byPatchSet(revision.getNotes(), revision.getPatchSet().id());
AccountLoader accountLoader = accountLoaderFactory.create(EnumSet.of(FillOptions.ID, FillOptions.NAME, FillOptions.EMAIL, FillOptions.USERNAME));
for (PatchSetApproval approval : approvals) {
String label = approval.label();
ApprovalInfo info = new ApprovalInfo(approval.accountId().get(), Integer.valueOf(approval.value()), null, approval.tag().orElse(null), approval.granted());
accountLoader.put(info);
result.get(label).add(info);
}
accountLoader.fill();
} catch (Exception e) {
throw asRestApiException("Cannot get votes", e);
}
return result;
}
use of com.google.gerrit.server.account.AccountLoader in project gerrit by GerritCodeReview.
the class ReviewersUtil method loadAccounts.
private List<SuggestedReviewerInfo> loadAccounts(List<Account.Id> accountIds) throws PermissionBackendException {
Set<FillOptions> fillOptions = Sets.union(AccountLoader.DETAILED_OPTIONS, EnumSet.of(FillOptions.SECONDARY_EMAILS));
AccountLoader accountLoader = accountLoaderFactory.create(fillOptions);
try (Timer0.Context ctx = metrics.loadAccountsLatency.start()) {
List<SuggestedReviewerInfo> reviewer = accountIds.stream().map(accountLoader::get).filter(Objects::nonNull).map(a -> {
SuggestedReviewerInfo info = new SuggestedReviewerInfo();
info.account = a;
info.count = 1;
return info;
}).collect(toList());
accountLoader.fill();
return reviewer;
}
}
Aggregations