try {
PrologEnvironment env = (PrologEnvironment) engine.control;
ReviewDb db = StoredValues.REVIEW_DB.get(engine);
PatchSet patchSet = StoredValues.PATCH_SET.get(engine);
ChangeData cd = StoredValues.CHANGE_DATA.getOrNull(engine);
ApprovalTypes types = env.getInjector().getInstance(ApprovalTypes.class);
Iterable<PatchSetApproval> approvals;
if (cd != null) {
approvals = cd.currentApprovals(Providers.of(db));
} else {
approvals = db.patchSetApprovals().byPatchSet(patchSet.getId());
}
for (PatchSetApproval a : approvals) {
if (a.getValue() == 0) {
continue;
}
ApprovalType t = types.byId(a.getCategoryId());
if (t == null) {
continue;
}
StructureTerm labelTerm = new StructureTerm(