/** * Add a criteria */ private T addCrit(FilterOperator op, Object val) { target.add(new FieldCriteria(query, field, op, val, validateName, query.isValidatingTypes(), not)); return target; }
private T addGeoCrit(FilterOperator op, Object val, Map<String, Object> opts) { if (not) throw new QueryException("Geospatial queries cannot be negated with 'not'."); target.add(new GeoFieldCriteria(query, field, op, val, validateName, false, opts)); return target; }
private FieldEnd<? extends CriteriaContainerImpl> criteria(String field, boolean validate) { CriteriaContainerImpl container = new CriteriaContainerImpl(this, CriteriaJoin.AND); this.add(container); return new FieldEndImpl<CriteriaContainerImpl>(this, field, container, validate); }
public TestPlanImpl getReferenceProjectByName(final String projectName, final String idProject) { final Query<TestPlanImpl> query = createQuery(); final Criteria nameCriteria = query.criteria("name").equal(projectName); final Criteria iterationCriteria = query.criteria("iteration").equal((short) 0); query.and(nameCriteria, iterationCriteria); return find(query).get(); }
public UpdateOperations<T> removeAll(String fieldExpr, Object value) { if (value == null) throw new QueryException("Value cannot be null."); // Object dbObj = mapr.toMongoObject(value); add(UpdateOperator.PULL, fieldExpr, value, true); return this; }
public Query<T> where(CodeWScope js) { this.add(new WhereCriteria(js)); return this; }
public FieldEnd<? extends CriteriaContainer> criteria(String name) { return this.criteria(name, this.query.isValidatingNames()); }
private CriteriaContainer collect(CriteriaJoin cj, Criteria... criteria) { CriteriaContainerImpl parent = new CriteriaContainerImpl(this.query, cj); for (Criteria c : criteria) parent.add(c); add(parent); return parent; }
/** * @return number inserted; this should be either 0/1. */ public int getInsertedCount() { return !getUpdatedExisting() ? getN() : 0; }
public Iterable<T> fetchEmptyEntities() { String[] oldFields = fields; Boolean oldInclude = includeFields; fields = new String[]{Mapper.ID_KEY}; includeFields = true; Iterable<T> res = fetch(); fields = oldFields; includeFields = oldInclude; return res; }
public List<TestPlanImpl> findAllIterationsByProjectName(final String pName, final String idProject, final String version) { final Query<TestPlanImpl> query = createQuery(); final CriteriaContainerImpl versionCriteria = query.criteria("version").equal(version); final CriteriaContainerImpl idProjectCriteria = query.criteria("project._id").equal(new ObjectId(idProject)); query.criteria("name").equal(pName).and(versionCriteria, idProjectCriteria); return find(query).asList(); }
public UpdateOperations<T> add(String fieldExpr, Object value, boolean addDups) { if (value == null) throw new QueryException("Value cannot be null."); // Object dbObj = mapr.toMongoObject(value, true); add((addDups) ? UpdateOperator.PUSH : UpdateOperator.ADD_TO_SET, fieldExpr, value, true); return this; }
public Query<T> where(String js) { this.add(new WhereCriteria(js)); return this; }
public UpdateOperations<T> inc(String fieldExpr, Number value) { if (value == null) throw new QueryException("Value cannot be null."); add(UpdateOperator.INC, fieldExpr, value, false); return this; }
public UpdateOperations<T> set(String fieldExpr, Object value) { if (value == null) throw new QueryException("Value cannot be null."); // Object dbObj = mapr.toMongoObject(value, true); add(UpdateOperator.SET, fieldExpr, value, true); return this; }