use of com.googlecode.prolog_cafe.lang.IntegerTerm in project gerrit by GerritCodeReview.
the class PRED_commit_stats_3 method exec.
@Override
public Operation exec(Prolog engine) throws PrologException {
engine.setB0();
Term a1 = arg1.dereference();
Term a2 = arg2.dereference();
Term a3 = arg3.dereference();
PatchList pl = StoredValues.PATCH_LIST.get(engine);
// Account for magic files
if (!a1.unify(new IntegerTerm(pl.getPatches().size() - countMagicFiles(pl.getPatches())), engine.trail)) {
return engine.fail();
}
if (!a2.unify(new IntegerTerm(pl.getInsertions()), engine.trail)) {
return engine.fail();
}
if (!a3.unify(new IntegerTerm(pl.getDeletions()), engine.trail)) {
return engine.fail();
}
return cont;
}
use of com.googlecode.prolog_cafe.lang.IntegerTerm in project gerrit by GerritCodeReview.
the class PRED_current_user_1 method exec.
@Override
public Operation exec(Prolog engine) throws PrologException {
engine.setB0();
Term a1 = arg1.dereference();
CurrentUser curUser = StoredValues.CURRENT_USER.getOrNull(engine);
if (curUser == null) {
throw new EvaluationException("Current user not available in this rule type");
}
Term resultTerm;
if (curUser.isIdentifiedUser()) {
Account.Id id = curUser.getAccountId();
resultTerm = new IntegerTerm(id.get());
} else if (curUser instanceof AnonymousUser) {
resultTerm = anonymous;
} else if (curUser instanceof PeerDaemonUser) {
resultTerm = peerDaemon;
} else {
throw new EvaluationException("Unknown user type");
}
if (!a1.unify(new StructureTerm(user, resultTerm), engine.trail)) {
return engine.fail();
}
return cont;
}
use of com.googlecode.prolog_cafe.lang.IntegerTerm in project gerrit by GerritCodeReview.
the class PRED_get_legacy_label_types_1 method export.
static Term export(LabelType type) {
LabelValue min = type.getMin();
LabelValue max = type.getMax();
return new StructureTerm(symLabelType, SymbolTerm.intern(type.getName()), SymbolTerm.intern(type.getFunctionName()), min != null ? new IntegerTerm(min.getValue()) : NONE, max != null ? new IntegerTerm(max.getValue()) : NONE);
}
use of com.googlecode.prolog_cafe.lang.IntegerTerm in project gerrit by GerritCodeReview.
the class PRED_unresolved_comments_count_1 method exec.
@Override
public Operation exec(Prolog engine) throws PrologException {
engine.setB0();
Term a1 = arg1.dereference();
try {
Integer count = StoredValues.CHANGE_DATA.get(engine).unresolvedCommentCount();
if (!a1.unify(new IntegerTerm(count != null ? count : 0), engine.trail)) {
return engine.fail();
}
} catch (OrmException err) {
throw new JavaException(this, 1, err);
}
return cont;
}
use of com.googlecode.prolog_cafe.lang.IntegerTerm in project gerrit by GerritCodeReview.
the class PRED_uploader_1 method exec.
@Override
public Operation exec(Prolog engine) throws PrologException {
engine.setB0();
Term a1 = arg1.dereference();
PatchSet patchSet = StoredValues.getPatchSet(engine);
if (patchSet == null) {
log.error("Failed to load current patch set of change " + StoredValues.getChange(engine).getChangeId());
return engine.fail();
}
Account.Id uploaderId = patchSet.getUploader();
if (!a1.unify(new StructureTerm(user, new IntegerTerm(uploaderId.get())), engine.trail)) {
return engine.fail();
}
return cont;
}
Aggregations