Search in sources :

Example 6 with ChangeAttribute

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

the class EventFactory method asChangeAttribute.

/**
   * Create a ChangeAttribute for the given change suitable for serialization to JSON.
   *
   * @param db Review database
   * @param change
   * @return object suitable for serialization to JSON
   */
public ChangeAttribute asChangeAttribute(ReviewDb db, Change change) {
    ChangeAttribute a = new ChangeAttribute();
    a.project = change.getProject().get();
    a.branch = change.getDest().getShortName();
    a.topic = change.getTopic();
    a.id = change.getKey().get();
    a.number = change.getId().get();
    a.subject = change.getSubject();
    try {
        a.commitMessage = changeDataFactory.create(db, change).commitMessage();
    } catch (Exception e) {
        log.error("Error while getting full commit message for change " + a.number);
    }
    a.url = getChangeUrl(change);
    a.owner = asAccountAttribute(change.getOwner());
    a.assignee = asAccountAttribute(change.getAssignee());
    a.status = change.getStatus();
    return a;
}
Also used : ChangeAttribute(com.google.gerrit.server.data.ChangeAttribute) OrmException(com.google.gwtorm.server.OrmException) PatchListNotAvailableException(com.google.gerrit.server.patch.PatchListNotAvailableException) IOException(java.io.IOException)

Aggregations

ChangeAttribute (com.google.gerrit.server.data.ChangeAttribute)6 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 Test (org.junit.Test)4 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)2 SshSession (com.google.gerrit.acceptance.SshSession)1 LabelTypes (com.google.gerrit.common.data.LabelTypes)1 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)1 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)1 Project (com.google.gerrit.reviewdb.client.Project)1 PatchSetAttribute (com.google.gerrit.server.data.PatchSetAttribute)1 PatchListNotAvailableException (com.google.gerrit.server.patch.PatchListNotAvailableException)1 ChangeControl (com.google.gerrit.server.project.ChangeControl)1 SubmitRuleEvaluator (com.google.gerrit.server.project.SubmitRuleEvaluator)1 OrmException (com.google.gwtorm.server.OrmException)1 IOException (java.io.IOException)1 Repository (org.eclipse.jgit.lib.Repository)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1