use of com.google.gerrit.reviewdb.client.UserIdentity in project gerrit by GerritCodeReview.
the class EventFactory method toUserIdentity.
// TODO: The same method exists in PatchSetInfoFactory, find a common place
// for it
private UserIdentity toUserIdentity(PersonIdent who) {
UserIdentity u = new UserIdentity();
u.setName(who.getName());
u.setEmail(who.getEmailAddress());
u.setDate(new Timestamp(who.getWhen().getTime()));
u.setTimeZone(who.getTimeZoneOffset());
// If only one account has access to this email address, select it
// as the identity of the user.
//
Set<Account.Id> a = byEmailCache.get(u.getEmail());
if (a.size() == 1) {
u.setAccount(a.iterator().next());
}
return u;
}
use of com.google.gerrit.reviewdb.client.UserIdentity in project gerrit by GerritCodeReview.
the class PatchSetInfoFactory method toUserIdentity.
// TODO: The same method exists in EventFactory, find a common place for it
private UserIdentity toUserIdentity(final PersonIdent who) {
final UserIdentity u = new UserIdentity();
u.setName(who.getName());
u.setEmail(who.getEmailAddress());
u.setDate(new Timestamp(who.getWhen().getTime()));
u.setTimeZone(who.getTimeZoneOffset());
// If only one account has access to this email address, select it
// as the identity of the user.
//
final Set<Account.Id> a = byEmailCache.get(u.getEmail());
if (a.size() == 1) {
u.setAccount(a.iterator().next());
}
return u;
}
use of com.google.gerrit.reviewdb.client.UserIdentity in project gerrit by GerritCodeReview.
the class EventFactory method asPatchSetAttribute.
/**
* Create a PatchSetAttribute for the given patchset suitable for serialization to JSON.
*
* @param db Review database
* @param patchSet
* @return object suitable for serialization to JSON
*/
public PatchSetAttribute asPatchSetAttribute(ReviewDb db, RevWalk revWalk, Change change, PatchSet patchSet) {
PatchSetAttribute p = new PatchSetAttribute();
p.revision = patchSet.getRevision().get();
p.number = patchSet.getPatchSetId();
p.ref = patchSet.getRefName();
p.uploader = asAccountAttribute(patchSet.getUploader());
p.createdOn = patchSet.getCreatedOn().getTime() / 1000L;
p.isDraft = patchSet.isDraft();
PatchSet.Id pId = patchSet.getId();
try {
p.parents = new ArrayList<>();
RevCommit c = revWalk.parseCommit(ObjectId.fromString(p.revision));
for (RevCommit parent : c.getParents()) {
p.parents.add(parent.name());
}
UserIdentity author = toUserIdentity(c.getAuthorIdent());
if (author.getAccount() == null) {
p.author = new AccountAttribute();
p.author.email = author.getEmail();
p.author.name = author.getName();
p.author.username = "";
} else {
p.author = asAccountAttribute(author.getAccount());
}
List<Patch> list = patchListCache.get(change, patchSet).toPatchList(pId);
for (Patch pe : list) {
if (!Patch.isMagic(pe.getFileName())) {
p.sizeDeletions -= pe.getDeletions();
p.sizeInsertions += pe.getInsertions();
}
}
p.kind = changeKindCache.getChangeKind(db, change, patchSet);
} catch (IOException e) {
log.error("Cannot load patch set data for " + patchSet.getId(), e);
} catch (PatchListNotAvailableException e) {
log.error(String.format("Cannot get size information for %s.", pId), e);
}
return p;
}
use of com.google.gerrit.reviewdb.client.UserIdentity in project gerrit by GerritCodeReview.
the class PRED_commit_author_3 method exec.
@Override
public Operation exec(Prolog engine) throws PrologException {
PatchSetInfo psInfo = StoredValues.PATCH_SET_INFO.get(engine);
UserIdentity author = psInfo.getAuthor();
return exec(engine, author);
}
use of com.google.gerrit.reviewdb.client.UserIdentity in project gerrit by GerritCodeReview.
the class PRED_commit_committer_3 method exec.
@Override
public Operation exec(Prolog engine) throws PrologException {
PatchSetInfo psInfo = StoredValues.PATCH_SET_INFO.get(engine);
UserIdentity committer = psInfo.getCommitter();
return exec(engine, committer);
}
Aggregations