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


Java Find.as方法代码示例

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


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

示例1: findByQuery

import org.jongo.Find; //导入方法依赖的package包/类
@Override
public Iterable<Profile> findByQuery(String query, String sortBy, SortOrder sortOrder, Integer start,
                                     Integer count, String... attributesToReturn) throws MongoDataException {
    try {
        Find find = getCollection().find(query);

        addSort(find, sortBy, sortOrder);
        addRange(find, start, count);
        addProjection(find, attributesToReturn);

        return find.as(Profile.class);
    } catch (MongoException ex) {
        String msg = "Unable to find profiles by query " + query;
        logger.error(msg, ex);
        throw new MongoDataException(msg, ex);
    }
}
 
开发者ID:craftercms,项目名称:profile,代码行数:18,代码来源:ProfileRepositoryImpl.java

示例2: findRange

import org.jongo.Find; //导入方法依赖的package包/类
@Override
public Iterable<Profile> findRange(String tenantName, String sortBy, SortOrder sortOrder, Integer start,
                                   Integer count, String... attributesToReturn) throws MongoDataException {
    try {
        String query = getQueryFor(KEY_FIND_BY_TENANT_QUERY);
        Find find = getCollection().find(query, tenantName);

        addSort(find, sortBy, sortOrder);
        addRange(find, start, count);
        addProjection(find, attributesToReturn);

        return find.as(Profile.class);
    } catch (MongoException ex) {
        String msg = "Unable to find range of profiles for tenant '" + tenantName + "'";
        logger.error(msg, ex);
        throw new MongoDataException(msg, ex);
    }
}
 
开发者ID:craftercms,项目名称:profile,代码行数:19,代码来源:ProfileRepositoryImpl.java

示例3: findByTenantAndRole

import org.jongo.Find; //导入方法依赖的package包/类
@Override
public Iterable<Profile> findByTenantAndRole(String tenantName, String role, String sortBy, SortOrder sortOrder,
                                             String... attributesToReturn) throws MongoDataException {
    try {
        String query = getQueryFor(KEY_FIND_BY_TENANT_AND_ROLE_QUERY);
        Find find = getCollection().find(query, tenantName, role);

        addSort(find, sortBy, sortOrder);
        addProjection(find, attributesToReturn);

        return find.as(Profile.class);
    } catch (MongoException ex) {
        String msg = "Unable to find profiles for role '" + role + " and tenant '" + tenantName + "'";
        logger.error(msg, ex);
        throw new MongoDataException(msg, ex);
    }
}
 
开发者ID:craftercms,项目名称:profile,代码行数:18,代码来源:ProfileRepositoryImpl.java

示例4: findByTenantAndExistingAttribute

import org.jongo.Find; //导入方法依赖的package包/类
@Override
public Iterable<Profile> findByTenantAndExistingAttribute(String tenantName, String attributeName, String sortBy,
                                                          SortOrder sortOrder,
                                                          String... attributesToReturn) throws MongoDataException {
    try {
        String query = getQueryFor(KEY_FIND_BY_TENANT_AND_EXISTING_ATTRIB_QUERY);
        Find find = getCollection().find(query, tenantName, attributeName);

        addSort(find, sortBy, sortOrder);
        addProjection(find, attributesToReturn);

        return find.as(Profile.class);
    } catch (MongoException ex) {
        String msg = "Unable to find profiles with attribute " + attributeName + " and tenant '" + tenantName + "'";
        logger.error(msg, ex);
        throw new MongoDataException(msg, ex);
    }
}
 
开发者ID:craftercms,项目名称:profile,代码行数:19,代码来源:ProfileRepositoryImpl.java

示例5: findByTenantAndAttributeValue

import org.jongo.Find; //导入方法依赖的package包/类
@Override
public Iterable<Profile> findByTenantAndAttributeValue(String tenantName, String attributeName,
                                                       String attributeValue, String sortBy, SortOrder sortOrder,
                                                       String... attributesToReturn) throws MongoDataException {
    try {
        String query = getQueryFor(KEY_FIND_BY_TENANT_AND_ATTRIB_VALUE_QUERY);
        Find find = getCollection().find(query, tenantName, attributeName, attributeValue);

        addSort(find, sortBy, sortOrder);
        addProjection(find, attributesToReturn);

        return find.as(Profile.class);
    } catch (MongoException ex) {
        String msg = "Unable to find profiles for attribute " + attributeName + " = " + attributeValue +
            " and tenant '" + tenantName + "'";
        logger.error(msg, ex);
        throw new MongoDataException(msg, ex);
    }
}
 
开发者ID:craftercms,项目名称:profile,代码行数:20,代码来源:ProfileRepositoryImpl.java

示例6: selectOne

import org.jongo.Find; //导入方法依赖的package包/类
private void selectOne(){

        Jongo jongo = new Jongo(dbconn.getDB(database));
        org.jongo.MongoCollection mc = jongo.getCollection(collection);
        JSONObject findField = (JSONObject)data.get("findField");
        JSONObject sortField = (JSONObject)data.get("sortField");
        JSONObject projectionField = (JSONObject)data.get("projectionField");

        Find result = null;
        if(findField != null){
            result = mc.find(findField.toJSONString());
        }
        if(sortField != null){
            result = result.sort(sortField.toString());
        }
        if(projectionField != null){
            result = result.projection(projectionField.toString());
        }
        String resultJson = "";
        org.jongo.MongoCursor cursor = result.as(Object.class);
        if(cursor.hasNext()){
            resultJson += cursor.next();
        }
        System.out.println(resultJson);
        Response res= new Response(200, resultJson);
        try {
            res.writeData(client);
        }
        catch(IOException ioe){
            System.out.println("[Error]" + ioe.getMessage());
        }
    }
 
开发者ID:aninditamondal,项目名称:FireAnt,代码行数:33,代码来源:MongoHandler.java

示例7: selectMany

import org.jongo.Find; //导入方法依赖的package包/类
private void selectMany(){
    Jongo jongo = new Jongo(dbconn.getDB(database));
    org.jongo.MongoCollection mc = jongo.getCollection(collection);
    JSONObject findField = (JSONObject)data.get("findField");
    JSONObject sortField = (JSONObject)data.get("sortField");
    JSONObject projectionField = (JSONObject)data.get("projectionField");

    Find result = null;
    if(findField != null){
        result = mc.find(findField.toJSONString());
    }
    if(sortField != null){
        result = result.sort(sortField.toString());
    }
    if(projectionField != null){
        result = result.projection(projectionField.toString());
    }
    String resultJson = "";
    org.jongo.MongoCursor cursor = result.as(Object.class);
    while(cursor.hasNext()){
        resultJson += cursor.next();
    }
    System.out.println(resultJson);
    Response res= new Response(200, resultJson);
    try {
        res.writeData(client);
    }
    catch(IOException ioe){
        System.out.println("[Error]" + ioe.getMessage());
    }
}
 
开发者ID:aninditamondal,项目名称:FireAnt,代码行数:32,代码来源:MongoHandler.java


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