本文整理汇总了Java中org.mongodb.morphia.query.Query.and方法的典型用法代码示例。如果您正苦于以下问题:Java Query.and方法的具体用法?Java Query.and怎么用?Java Query.and使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mongodb.morphia.query.Query
的用法示例。
在下文中一共展示了Query.and方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: search
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
* A search function
*
* @param date
* @param width
* @param height
* @param count
* @param offset
* @return
*/
public List<M> search(String datefield, Date date, int width, int height, int count, int offset, UserAccount account, String query, List<String> sources) {
List<Criteria> l = new ArrayList<>();
Query<M> q = getDatastore().createQuery(clazz);
if (query != null) {
Pattern p = Pattern.compile("(.*)" + query + "(.*)", Pattern.CASE_INSENSITIVE);
l.add(q.or(
q.criteria("title").equal(p),
q.criteria("description").equal(p)
));
}
if (account != null) {
l.add(q.criteria("contributor").equal(account));
}
if (width > 0)
l.add(q.criteria("width").greaterThanOrEq(width));
if (height > 0)
l.add(q.criteria("height").greaterThanOrEq(height));
if (date != null)
l.add(q.criteria(datefield).greaterThanOrEq(date));
if (sources != null)
l.add(q.criteria("source").in(sources));
q.and(l.toArray(new Criteria[l.size()]));
return q.order("crawlDate").offset(offset).limit(count).asList();
}
示例2: getJoinableServer
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
public Server getJoinableServer(Filter filter, String uuid) {
Query<Server> query = getFilterQuery(filter);
query.and(getServerQuery().criteria("joinable").equal(true),
getServerQuery().criteria("expiry").greaterThan(System.currentTimeMillis()),
getServerQuery()
.or(new WhereCriteria("this.mpc > this.pc"),
getServerQuery().criteria("mpc").equal(0)));
query.limit(1);
query.order("pc");
query.getSortObject().put("pc", -1);
UpdateOperations<Server> updateOperations = datastore.createUpdateOperations(Server.class);
updateOperations.inc("pc", 1);
updateOperations.add("players", uuid);
Server server = datastore.findAndModify(query, updateOperations, false, false);
if (server == null)
return null;
return server;
}
示例3: endSigal
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
private void endSigal(Stack<Pair<String, Object>> cps, Query<T> q, List<Criteria> cl) throws SQLException
{
CriteriaContainer tmp = null;
while(!cps.isEmpty() && !cps.peek().getLeft().contains("("))
cl.add(makeCriteria(q, cps.pop()));
if(cps.isEmpty())
{
tmp = q.and(cl.toArray(new CriteriaContainer[cl.size()]));
cl.clear();
cl.add(tmp);
return;
}
String operator = cps.pop().getLeft();
if(operator.equals("and("))
{
tmp = q.and(cl.toArray(new CriteriaContainer[cl.size()]));
cl.clear();
cl.add(tmp);
}
else if(operator.equals("or("))
{
tmp = q.or(cl.toArray(new CriteriaContainer[cl.size()]));
cl.clear();
cl.add(tmp);
}
else throw new SQLException();
}
示例4: getAssociationsOfType
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public List<? extends Association> getAssociationsOfType(Object object, Class clazz) {
Query<Association> q = getDatastore().createQuery(Association.class);
q.and(
q.criteria("one").equal(object.getId()),
q.criteria("class").equal(clazz)
);
return q.asList();
}
示例5: find
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public User find(final User criteria) {
final Query<User> qry = createQuery(User.class);
qry.and(qry.criteria("name").equal(criteria.getName()));
return getUserDAO().find(qry).get();
}