本文整理汇总了Java中org.mongodb.morphia.query.Query.or方法的典型用法代码示例。如果您正苦于以下问题:Java Query.or方法的具体用法?Java Query.or怎么用?Java Query.or使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mongodb.morphia.query.Query
的用法示例。
在下文中一共展示了Query.or方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: getCurrentUserBuilds
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public <T extends DbBackedBuild> Iterable<T> getCurrentUserBuilds(final DbBackedProject project, final int i, final Result result) {
Query<DbBackedBuild> query = getQuery(project)
.limit(i)
.order("-number");
query.or(
query.criteria("actions.causes.user").equal(Jenkins.getAuthentication().getName()),
query.criteria("actions.causes.pusher").equal(Jenkins.getAuthentication().getName())
);
if (result != null) {
query = query.filter("result", result.toString());
}
final List<DbBackedBuild> builds = query.asList();
for (final DbBackedBuild build : builds) {
associateProject(project, build);
}
return (Iterable<T>) builds;
}
示例3: queryApplySearch
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
private void queryApplySearch(Optional<String> searchTerm, Optional<String> groupName, Query<User> q) {
if (searchTerm.isPresent()) {
final String searchTerm_ = searchTerm.get();
q.or(
q.criteria("username").containsIgnoreCase(searchTerm_),
q.criteria("email").containsIgnoreCase(searchTerm_),
q.criteria("description").containsIgnoreCase(searchTerm_));
}
//
if (groupName.isPresent()) {
Optional<Group> g = groupService.getByName(groupName.get().toString());
if (g.isPresent()) {
q.criteria("groups").hasThisOne(g.get());
} else {
LOG.warn(String.format("GROUP [%s] NOT FOUND, IGNORED IN CRITERIA.", groupName));
}
}
}
示例4: register
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
* 注册前检查
* @param param
* @return
*/
public MUser register(MUser param) {
Query<MUser> query = createQuery();
query.or(query.criteria("userName").equal(param.getUserName()),
query.criteria("nickName").equal(param.getNickName()),
query.criteria("validationEmail").equal(param.getValidationEmail()));
MUser result=findOne(query);
//是否有重名
if(result!=null){
return null;
}
result = new MUser();
result.setUserName(param.getUserName());
result.setPassword(passwordEncoderUtil.encodePassword(param.getPassword()));
result.setNickName(param.getNickName());
result.setValidationEmail(param.getValidationEmail());
save(result);
return result;
}
示例5: findAssociationsForObject
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public List<Association> findAssociationsForObject(gr.iti.mklab.simmo.core.Object object) {
Query<Association> q = getDatastore().createQuery(Association.class);
q.or(
q.criteria("one").equal(object),
q.criteria("other").equal(object)
);
return q.asList();
}
示例6: findAssociationsForUserAccount
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public List<Association> findAssociationsForUserAccount(UserAccount u) {
Query<Association> q = getDatastore().createQuery(Association.class);
q.or(
q.criteria("one").equal(u),
q.criteria("other").equal(u)
);
return q.asList();
}
示例7: similar
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
* Returns a list of objects that are similar to the specified object
*
* @param object
* @param threshold
* @return
*/
public List<Similarity> similar(Image object, double threshold) {
//return getDatastore().find(Similarity.class).field("firstObject").equal(object).order("similarityScore").asList();
Query<Similarity> q = getDatastore().createQuery(Similarity.class);
q.or(
q.criteria("firstObject").equal(object),
q.criteria("secondObject").equal(object)
);
return q.order("-similarityScore").filter("similarityScore >", threshold).asList();
}
示例8: filterBranch
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
private Query<DynamicBuild> filterBranch(final Query<DynamicBuild> query) {
final String branch = getBranch();
if ("All".equals(branch)) {
return query;
}
if ("Mine".equals(branch)) {
query.or(
query.criteria("actions.causes.user").equal(Jenkins.getAuthentication().getName()),
query.criteria("actions.causes.pusher").equal(Jenkins.getAuthentication().getName())
);
return query;
}
return getDynamicBuildRepository().filterExpression(branch, query);
}
示例9: getDynamicBuildsForUser
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
private Query<DynamicBuild> getDynamicBuildsForUser(final String user, final int numberOfBuilds) {
final Query<DynamicBuild> query = getDatastore().createQuery(DynamicBuild.class)
.limit(numberOfBuilds)
.disableValidation()
.order("-timestamp")
.field("className").equal("com.groupon.jenkins.dynamic.build.DynamicBuild");
query.or(
query.criteria("actions.causes.user").equal(user),
query.criteria("actions.causes.pusher").equal(user)
);
return query;
}
示例10: queryApplySearchTerm
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
private void queryApplySearchTerm(Optional<String> searchTerm, Query<Group> q) {
if (searchTerm.isPresent()) {
final String searchTerm_ = searchTerm.get();
q.or(q.criteria("name").containsIgnoreCase(searchTerm_),
q.criteria("description").containsIgnoreCase(searchTerm_));
}
}
示例11: listPages
import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public ImmutablePair<Long, List<Page>> listPages(Optional<String> searchTerm, final int offset, final int limit) {
Query<Page> q = datastore.createQuery(Page.class);
if (searchTerm.isPresent()) {
final String s = searchTerm.get();
final Pattern p = Pattern.compile(searchTerm.get(), Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
//
//List<PageContent> pageContents = datastore.createQuery(PageContent.class).filter("content", p).asList();
q.or(q.criteria("title").containsIgnoreCase(s), q.criteria("tags").containsIgnoreCase(s)/*, q.criteria("current").hasAnyOf(pageContents)*/);
}
//LOG.debug(q.toString());
return new ImmutablePair<Long, List<Page>>(q.countAll(),
q.offset(offset).limit(limit).order("title").asList());
}