当前位置: 首页>>代码示例>>Java>>正文


Java Query.asList方法代码示例

本文整理汇总了Java中org.mongodb.morphia.query.Query.asList方法的典型用法代码示例。如果您正苦于以下问题:Java Query.asList方法的具体用法?Java Query.asList怎么用?Java Query.asList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mongodb.morphia.query.Query的用法示例。


在下文中一共展示了Query.asList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filter

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
 *
 * @param queryCriteria - key is field and operator and value is RHS value
 * eg: "Location in" => "Delhi"
 * @param sortCriteria - comma separated field names. use - for descending
 * order eg: "location, -status"
 * @param pageInfo - contain limit and offset
 * @return
 */
public List<T> filter(Map<String, Object> queryCriteria, String sortCriteria, PageInfo pageInfo) {
    Query<T> query = datastore.createQuery(genericType);

    for (Map.Entry<String, Object> entry : queryCriteria.entrySet()) {
        query = query.filter(entry.getKey(), entry.getValue());
    }

    if (pageInfo == null) {
        pageInfo = new PageInfo(100000, 0);
    }

    if (sortCriteria == null) {
        sortCriteria = "_id";
    }

    query = query.limit(pageInfo.getLimit()).offset(pageInfo.getOffset());
    query = query.order(sortCriteria);

    return query.asList();
}
 
开发者ID:nimesh-mittal,项目名称:elastic-match,代码行数:30,代码来源:EntityDAO.java

示例2: findBySalary

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public List<EmployeeEntity> findBySalary(final BigDecimal minimum, final BigDecimal maximum) {

    /**
     * Check that the minimum is not negative and that the maximum is not
     * smaller than the minimum.
     */
    if (((minimum != null) && (minimum.compareTo(BigDecimal.ZERO) < 0))
	|| ((minimum != null) && (maximum != null) && (maximum.compareTo(minimum) < 0))) {
      return new ArrayList<>();
    }
    Query<EmployeeEntity> query = mongoDatastore.find(EmployeeEntity.class);
    if (minimum != null) {
      BigDecimal minimumScale = minimum.setScale(2, BigDecimal.ROUND_HALF_UP);
      query.filter("salaryString >=", minimumScale.toPlainString());
    }
    if (maximum != null) {
      BigDecimal maximumScale = maximum.setScale(2, BigDecimal.ROUND_HALF_UP);
      query.filter("salaryString <=", maximumScale.toPlainString());
    }
    return query.asList();
  }
 
开发者ID:xeraa,项目名称:morphia-demo,代码行数:22,代码来源:MongodbPersistence.java

示例3: findBySalaryFluent

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public List<EmployeeEntity> findBySalaryFluent(final BigDecimal minimum,
					 final BigDecimal maximum) {
   if (((minimum != null) && (minimum.compareTo(BigDecimal.ZERO) < 0))
|| ((minimum != null) && (maximum != null) && (maximum.compareTo(minimum) < 0))) {
     return new ArrayList<>();
   }
   Query<EmployeeEntity> query = mongoDatastore.find(EmployeeEntity.class);
   if (minimum != null) {
     BigDecimal minimumScale = minimum.setScale(2, BigDecimal.ROUND_HALF_UP);
     query.field("salary").greaterThanOrEq(minimumScale.toPlainString());
   }
   if (maximum != null) {
     BigDecimal maximumScale = maximum.setScale(2, BigDecimal.ROUND_HALF_UP);
     query.field("salary").lessThanOrEq(maximumScale.toPlainString());
   }
   return query.asList();
 }
 
开发者ID:xeraa,项目名称:morphia-demo,代码行数:18,代码来源:MongodbPersistence.java

示例4: 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;
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:22,代码来源:DynamicBuildRepository.java

示例5: compositeProperty

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
private Criteria compositeProperty(Class<?> clazz, Object value){
	
	EntityClassProvider ecp = ServiceLocator.getServiceImplementation(EntityClassProvider.class);
	
	String[] properties = propertyName.split("\\.");
	
	Query<?> q = getQuery(ecp.getEntityClass(properties[properties.length - 2]));
	
	switch(compType){
		case GREATER_OR_EQUALS: q.field(properties[properties.length - 1]).greaterThanOrEq(value); break;
		case LESSER_OR_EQUALS: q.field(properties[properties.length - 1]).lessThanOrEq(value); break;
		case GREATER: q.field(properties[properties.length - 1]).greaterThan(value); break;
		case LESSER: q.field(properties[properties.length - 1]).lessThan(value); break;
		case NOT_EQUALS: q.field(properties[properties.length - 1]).notEqual(value); break;
		case EQUALS: q.field(properties[properties.length - 1]).equal(value); break;
		default: q.field(properties[properties.length - 1]).contains((String)value); break;
	}
	
	List<?> results = q.asList();
	
	for(int i = properties.length - 3; i >= 0; i--){
		Query<?> query = getQuery(ecp.getEntityClass(properties[i]));
		query.field(properties[i + 1]).in(results);
		results = query.asList();
	}
	
	return getQuery(clazz).criteria(properties[0]).in(results);
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:29,代码来源:ConditionDescription.java

示例6: getLast

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public <T extends DbBackedBuild> Iterable<T> getLast(final DbBackedProject project, final int i, final String branch, final Result result) {
    Query<DbBackedBuild> query = getQuery(project).limit(i).order("-number");

    if (branch != null) {
        query = filterExpression(branch, query);
    }
    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;
}
 
开发者ID:groupon,项目名称:DotCi,代码行数:19,代码来源:DynamicBuildRepository.java

示例7: findAll

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <T extends BaseEntity> List<T> findAll(Class<T> tClass, FindOptions findOptions, Map<String, Object> criteriaMap) {
    Query<T> tQuery = this.datastore.createQuery(tClass);
    if (criteriaMap.size() > 0) {
        criteriaMap.forEach(
            (key, value) -> {
                tQuery.field(key)
                        .equal(value);
            }
        );
    }
    return (Objects.nonNull(findOptions)) ?
            tQuery.asList(findOptions) : tQuery.asList();
}
 
开发者ID:AdeptJ,项目名称:adeptj-modules,代码行数:18,代码来源:MongoCrudRepositoryImpl.java

示例8: load

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
protected List<JobPo> load(String loadTaskTrackerNodeGroup, int loadSize) {
    // load
    String tableName = JobQueueUtils.getExecutableQueueName(loadTaskTrackerNodeGroup);
    Query<JobPo> query = template.createQuery(tableName, JobPo.class);
    query.field("isRunning").equal(false)
            .filter("triggerTime < ", SystemClock.now())
            .order(" triggerTime, priority , gmtCreated").offset(0).limit(loadSize);
    return query.asList();
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:10,代码来源:MongoPreLoader.java

示例9: getDeadJob

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
@Override
public List<JobPo> getDeadJob(String taskTrackerNodeGroup, long deadline) {
    String tableName = JobQueueUtils.getExecutableQueueName(taskTrackerNodeGroup);
    Query<JobPo> query = template.createQuery(tableName, JobPo.class);
    query.field("isRunning").equal(true).
            filter("gmtCreated < ", deadline);
    return query.asList();
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:9,代码来源:MongoExecutableJobQueue.java

示例10: getMany

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
 * @param ids
 * @param sortCriteria - comma separated field names. use - for descending
 * order eg: "location, -status"
 * @param pageInfo - contain limit and offset
 * @return
 */
public List<T> getMany(List<String> ids, String sortCriteria, PageInfo pageInfo) {
    Query<T> query = datastore.createQuery(genericType);
    query = query.field("_id").in(ids);
    query = query.limit(pageInfo.getLimit()).offset(pageInfo.getOffset());
    query = query.order(sortCriteria);

    return query.asList();
}
 
开发者ID:nimesh-mittal,项目名称:elastic-match,代码行数:16,代码来源:EntityDAO.java

示例11: queryForList

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
/**
 * 查询日志通用接口查询多个对象
 * @param filter	条件字符串组
 * @param value		参数组
 * @throws SQLException
 */
public List<T> queryForList(String[] filter, Object[] value) throws SQLException
{
	if(filter == null || value == null)
		return new ArrayList<T>();
	Query<T> query = getDao().createQuery().disableValidation();
	queryAnalasis(query, filter, value);
	return query.asList();
}
 
开发者ID:liyang-bsy,项目名称:LYLab,代码行数:15,代码来源:MongoDBService.java

示例12: getLastBuildsForUser

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public Iterable<DynamicBuild> getLastBuildsForUser(final String user, final int numberOfBuilds) {

        final Query<DynamicBuild> query = getDynamicBuildsForUser(user, numberOfBuilds);

        final List<DynamicBuild> builds = query.asList();

        final DynamicProjectRepository repo = SetupConfig.get().getDynamicProjectRepository();
        for (final DbBackedBuild build : builds) {
            final DbBackedProject project = repo.getProjectById(build.getProjectId());
            associateProject(project, build);
        }

        return builds;
    }
 
开发者ID:groupon,项目名称:DotCi,代码行数:15,代码来源:DynamicBuildRepository.java

示例13: 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();
}
 
开发者ID:MKLab-ITI,项目名称:simmo,代码行数:9,代码来源:AssociationDAO.java

示例14: 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();
}
 
开发者ID:MKLab-ITI,项目名称:simmo,代码行数:9,代码来源:ObjectDAO.java

示例15: getNotVIndexed

import org.mongodb.morphia.query.Query; //导入方法依赖的package包/类
public List<M> getNotVIndexed(int numImages) {
    //Disable validation because className is not a declared field
	Query<M> q = getDatastore().find(clazz).disableValidation().filter("annotations.className nin", LocalDescriptors.class.getName()).limit(numImages);
	List<M> result = q.asList();
	
	return result;
}
 
开发者ID:MKLab-ITI,项目名称:simmo,代码行数:8,代码来源:MediaDAO.java


注:本文中的org.mongodb.morphia.query.Query.asList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。