Search in sources :

Example 6 with JavaException

use of com.googlecode.prolog_cafe.exceptions.JavaException in project gerrit by GerritCodeReview.

the class PRED__load_commit_labels_1 method exec.

@Override
public Operation exec(Prolog engine) throws PrologException {
    engine.setB0();
    Term a1 = arg1.dereference();
    Term listHead = Prolog.Nil;
    try {
        ChangeData cd = StoredValues.CHANGE_DATA.get(engine);
        LabelTypes types = cd.getLabelTypes();
        for (PatchSetApproval a : cd.currentApprovals()) {
            LabelType t = types.byLabel(a.getLabelId());
            if (t == null) {
                continue;
            }
            StructureTerm labelTerm = new StructureTerm(sym_label, SymbolTerm.intern(t.getName()), new IntegerTerm(a.getValue()));
            StructureTerm userTerm = new StructureTerm(sym_user, new IntegerTerm(a.getAccountId().get()));
            listHead = new ListTerm(new StructureTerm(sym_commit_label, labelTerm, userTerm), listHead);
        }
    } catch (OrmException err) {
        throw new JavaException(this, 1, err);
    }
    if (!a1.unify(listHead, engine.trail)) {
        return engine.fail();
    }
    return cont;
}
Also used : LabelTypes(com.google.gerrit.common.data.LabelTypes) IntegerTerm(com.googlecode.prolog_cafe.lang.IntegerTerm) JavaException(com.googlecode.prolog_cafe.exceptions.JavaException) StructureTerm(com.googlecode.prolog_cafe.lang.StructureTerm) ListTerm(com.googlecode.prolog_cafe.lang.ListTerm) OrmException(com.google.gwtorm.server.OrmException) LabelType(com.google.gerrit.common.data.LabelType) Term(com.googlecode.prolog_cafe.lang.Term) IntegerTerm(com.googlecode.prolog_cafe.lang.IntegerTerm) StructureTerm(com.googlecode.prolog_cafe.lang.StructureTerm) SymbolTerm(com.googlecode.prolog_cafe.lang.SymbolTerm) ListTerm(com.googlecode.prolog_cafe.lang.ListTerm) ChangeData(com.google.gerrit.server.query.change.ChangeData) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval)

Aggregations

JavaException (com.googlecode.prolog_cafe.exceptions.JavaException)6 Term (com.googlecode.prolog_cafe.lang.Term)6 OrmException (com.google.gwtorm.server.OrmException)5 IntegerTerm (com.googlecode.prolog_cafe.lang.IntegerTerm)5 SymbolTerm (com.googlecode.prolog_cafe.lang.SymbolTerm)5 LabelType (com.google.gerrit.common.data.LabelType)4 ChangeData (com.google.gerrit.server.query.change.ChangeData)3 VariableTerm (com.googlecode.prolog_cafe.lang.VariableTerm)3 CurrentUser (com.google.gerrit.server.CurrentUser)2 LabelPermission (com.google.gerrit.server.permissions.LabelPermission)2 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)2 IllegalTypeException (com.googlecode.prolog_cafe.exceptions.IllegalTypeException)2 PInstantiationException (com.googlecode.prolog_cafe.exceptions.PInstantiationException)2 SystemException (com.googlecode.prolog_cafe.exceptions.SystemException)2 JavaObjectTerm (com.googlecode.prolog_cafe.lang.JavaObjectTerm)2 ListTerm (com.googlecode.prolog_cafe.lang.ListTerm)2 StructureTerm (com.googlecode.prolog_cafe.lang.StructureTerm)2 LabelTypes (com.google.gerrit.common.data.LabelTypes)1 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)1