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


Java FindRequest.setFrom方法代码示例

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


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

示例1: buildSimpleRequest

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
public static FindRequest buildSimpleRequest(String entity, String version, String q, String p, String s, Long from, Long to, Long maxResults)
        throws IOException {
    // spec -> https://github.com/lightblue-platform/lightblue/wiki/Rest-Spec-Data#get-simple-find
    String sq = QueryTemplateUtils.buildQueryFieldsTemplate(q);
    LOGGER.debug("query: {} -> {}", q, sq);

    String sp = QueryTemplateUtils.buildProjectionsTemplate(p);
    LOGGER.debug("projection: {} -> {}", p, sp);

    String ss = QueryTemplateUtils.buildSortsTemplate(s);
    LOGGER.debug("sort:{} -> {}", s, ss);

    FindRequest findRequest = new FindRequest();
    findRequest.setEntityVersion(new EntityVersion(entity, version));
    findRequest.setQuery(sq == null ? null : QueryExpression.fromJson(JsonUtils.json(sq)));
    findRequest.setProjection(sp == null ? null : Projection.fromJson(JsonUtils.json(sp)));
    findRequest.setSort(ss == null ? null : Sort.fromJson(JsonUtils.json(ss)));
    findRequest.setFrom(from);
    if(to!=null) {
        findRequest.setTo(to);
    } else if(maxResults!=null&&maxResults>0) {
        findRequest.setTo((from == null ? 0 : from) + maxResults - 1);
    }
    return findRequest;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:26,代码来源:LightblueRequestUtils.java

示例2: buildSimpleRequest

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
private FindRequest buildSimpleRequest(String entity,String version, String q,String p, String s, Long from, Long to,Long maxResults)
    throws IOException {            
    // spec -> https://github.com/lightblue-platform/lightblue/wiki/Rest-Spec-Data#get-simple-find
    String sq = QueryTemplateUtils.buildQueryFieldsTemplate(q);
    LOGGER.debug("query: {} -> {}", q, sq);

    String sp = QueryTemplateUtils.buildProjectionsTemplate(p);
    LOGGER.debug("projection: {} -> {}", p, sp);

    String ss = QueryTemplateUtils.buildSortsTemplate(s);
    LOGGER.debug("sort:{} -> {}", s, ss);

    FindRequest findRequest = new FindRequest();
    findRequest.setEntityVersion(new EntityVersion(entity, version));
    findRequest.setQuery(sq == null ? null : QueryExpression.fromJson(JsonUtils.json(sq)));
    findRequest.setProjection(sp == null ? null : Projection.fromJson(JsonUtils.json(sp)));
    findRequest.setSort(ss == null ? null : Sort.fromJson(JsonUtils.json(ss)));
    findRequest.setFrom(from);
    if(to!=null) {
        findRequest.setTo(to);
    } else if(maxResults!=null&&maxResults>0) {
        findRequest.setTo((from == null ? 0 : from) + maxResults - 1);
    }
    return findRequest;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:26,代码来源:AbstractCrudResource.java

示例3: looping_entities_with_or_query_709_w_n_to_n_refs_max

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void looping_entities_with_or_query_709_w_n_to_n_refs_max() throws Exception {
    FindRequest fr=new FindRequest();
    fr.setQuery(query("{'$and':["+
                      "           {'field':'repository','regex':'repo.*'},"+
                      "           {'field':'images.*.repositories.*.published','op':'=','rvalue':true},"+
                      "           {'$or':["+
                      "                     {'$and':["+
                      "                                {'field':'vendorLabel','op':'!=','rvalue':'Red Hat'},"+
                      "                                {'field':'images.*.certified','op':'=','rvalue':true}"+
                      "                             ]},"+
                      "                     {'field':'vendorLabel','op':'=','rvalue':'Red Hat'}"+
                      "                  ]}"+
                      "]}"));
    fr.setProjection(projection("[{'field':'*'},{'field':'refchild'}]"));
    fr.setEntityVersion(new EntityVersion("containerRepository","1.0.0."));
    fr.setFrom(0l);
    fr.setTo(1l);
    Response response=mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(3,response.getMatchCount());
    Assert.assertEquals(2,response.getEntityData().size());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:24,代码来源:CompositeFinderTest.java

示例4: retrieveAandBonly_manyB_range

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void retrieveAandBonly_manyB_range() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'field':'_id','op':'$in','values':['MANYB1','MANYB2']}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'nonid_b'}]"));
    fr.setSort(sort("{'_id':'$asc'}"));
    fr.setFrom(0l);
    fr.setTo(0l);
    fr.setEntityVersion(new EntityVersion("A", "1.0.0"));
    Response response = mediator.find(fr);
    Assert.assertEquals(1, response.getEntityData().size());
    Assert.assertEquals("MANYB1", response.getEntityData().get(0).get("_id").asText());
    Assert.assertEquals(2, response.getEntityData().get(0).get("nonid_b").size());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:15,代码来源:CompositeFinderTest.java

示例5: retrieveAandBonly_manyB_range_incorrect_count

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void retrieveAandBonly_manyB_range_incorrect_count() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'field':'_id','op':'$in','values':['MANYB1','MANYB2']}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'nonid_b'}]"));
    fr.setSort(sort("{'_id':'$asc'}"));
    fr.setFrom(0l);
    fr.setTo(0l);
    fr.setEntityVersion(new EntityVersion("A", "1.0.0"));
    Response response = mediator.find(fr);
    Assert.assertEquals(1, response.getEntityData().size());
    Assert.assertEquals(2, response.getMatchCount());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:14,代码来源:CompositeFinderTest.java

示例6: retrieveAandConly_CFirst_range

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void retrieveAandConly_CFirst_range() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'field':'obj1.c.*.objectType','op':'=','rvalue':'C'}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'obj1.c'}]"));
    fr.setFrom(0l);
    fr.setTo(0l);
    fr.setEntityVersion(new EntityVersion("A", "1.0.0"));
    Response response = mediator.find(fr);
    Assert.assertEquals(1, response.getEntityData().size());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:12,代码来源:CompositeFinderTest.java

示例7: retrieveAandConly_CFirst_range_explain

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void retrieveAandConly_CFirst_range_explain() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'field':'obj1.c.*.objectType','op':'=','rvalue':'C'}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'obj1.c'}]"));
    fr.setFrom(0l);
    fr.setTo(0l);
    fr.setEntityVersion(new EntityVersion("A", "1.0.0"));
    Response response = mediator.explain(fr);
    Assert.assertEquals(1, response.getEntityData().size());
    JsonNode doc=response.getEntityData().get(0);
    // Make sure explain descends all the way to the  controller
    Assert.assertTrue(doc.toString().indexOf("testController")!=-1);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:15,代码来源:CompositeFinderTest.java

示例8: assocRetrievalWithElemMatch_0range

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
 public void assocRetrievalWithElemMatch_0range() throws Exception {
     FindRequest fr = new FindRequest();
     fr.setQuery(query("{'field':'code1','op':'=','rvalue':'A'}"));
     fr.setProjection(projection("{'field':'relationships.*','recursive':1}"));
     fr.setEntityVersion(new EntityVersion("parent_w_elem", "1.0.0"));

     fr.setFrom(0l);
     fr.setTo(-1l);
     Response response = mediator.find(fr);
     System.out.println(response.getEntityData());
     Assert.assertEquals(0, response.getEntityData().size());
     Assert.assertEquals(1, response.getMatchCount());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:15,代码来源:CompositeFinderTest.java

示例9: rev_search_with_arraycond_matchcount_0range

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void rev_search_with_arraycond_matchcount_0range() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'array':'us.*.authentications','elemMatch':{ '$and':[ { 'field':'principal','op':'$in','values':['a']}, {'field':'providerName','op':'$eq','rvalue':'p'} ] } }"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'us','recursive':1}]"));
    fr.setEntityVersion(new EntityVersion("L", "0.0.1"));
    fr.setFrom(0l);
    fr.setTo(-1l);
    Response response = mediator.find(fr);
    Assert.assertEquals(1, response.getMatchCount());
    Assert.assertEquals(0, response.getEntityData().size());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:13,代码来源:CompositeFinderTest.java

示例10: elem_match_forward_0range

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void elem_match_forward_0range() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'field':'userRedHatPrincipal','op':'=','rvalue':'a'}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'users','recursive':1}]"));
    fr.setEntityVersion(new EntityVersion("UC", "0.0.1"));
    fr.setFrom(0l);
    fr.setTo(-1l);
    Response response = mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(0, response.getEntityData().size());
    Assert.assertEquals(1, response.getMatchCount());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:14,代码来源:CompositeFinderTest.java

示例11: elem_match_backward_0range

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void elem_match_backward_0range() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'array':'users.*.legalEntities.*.emails','elemMatch':{'field':'address','op':'=','rvalue':'[email protected]'}}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'users','recursive':1}]"));
    fr.setEntityVersion(new EntityVersion("UC", "0.0.1"));
    fr.setFrom(0l);
    fr.setTo(-1l);
    Response response = mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(0, response.getEntityData().size());
    Assert.assertEquals(1, response.getMatchCount());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:14,代码来源:CompositeFinderTest.java

示例12: dont_do_outer_joins_0range

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void dont_do_outer_joins_0range() throws Exception {
    // We need to use a_with_index in this test, so the execution plan becomes A->B instead of B-> A
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'$and': [ {'field':'_id','op':'$in','values':['A99','ADEEP']}, {'field':'level1.arr1.*.ref.*.field1','op':'=','rvalue':'bdeep1'} ] }"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'level1.arr1.*.ref','recursive':1}]"));
    fr.setEntityVersion(new EntityVersion("A_with_index", "1.0.0"));
    fr.setFrom(0l);
    fr.setTo(-1l);
    Response response = mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(0, response.getEntityData().size());
    Assert.assertEquals(1, response.getMatchCount());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:15,代码来源:CompositeFinderTest.java

示例13: three_level_search_w_0range

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void three_level_search_w_0range() throws Exception {
    FindRequest fr=new FindRequest();
    fr.setQuery(query("{'array':'obj1.c','elemMatch':{'field':'b.*.field1','op':'=','rvalue':'F, BLYO4OjLMAT aG.4qJ'}}"));
    fr.setProjection(projection("[{'field':'*','recursive':1}]"));
    fr.setEntityVersion(new EntityVersion("A","1.0.0"));
    fr.setFrom(0l);
    fr.setTo(-1l);
    Response response=mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(0, response.getEntityData().size());
    Assert.assertEquals(1, response.getMatchCount());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:14,代码来源:CompositeFinderTest.java

示例14: buildRequest

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
/**
 * Builds a find request from the saved search by rewriting the
 * search bound parameters using parameter values. The search
 * query components can be either strings, or JSON objects. If
 * they are strings, the parameters are replaced first, then the
 * resulting json string is converted to a query/projection. If
 * the components are JSON objects, then the values of those json
 * objects are replaced with parameter values.
 */
public static FindRequest buildRequest(JsonNode savedSearch,
                                       String entity,
                                       String version,
                                       ClientIdentification clid,
                                       Map<String,String> parameterValues)
    throws IOException {
    FindRequest request=new FindRequest();
    request.setEntityVersion(new EntityVersion(entity,version));
    request.setClientId(clid);
    JsonNode node=savedSearch.get("query");
    if(node instanceof TextNode) {
        request.setQuery(QueryExpression.fromJson(JsonUtils.json(applyParameters(node.asText(),parameterValues))));
    } else {
        request.setQuery(QueryExpression.fromJson(applyParameters(node,parameterValues)));
    }
    node=savedSearch.get("projection");
    if(node instanceof ArrayNode||
       node instanceof ObjectNode) {
        request.setProjection(Projection.fromJson(applyParameters(node,parameterValues)));
    } else if(node instanceof TextNode) {
        request.setProjection(Projection.fromJson(JsonUtils.json(applyParameters(node.asText(),parameterValues))));
    }
    node=savedSearch.get("sort");
    if(node instanceof ArrayNode||
       node instanceof ObjectNode) {
        request.setSort(Sort.fromJson(applyParameters(node,parameterValues)));
    } else if(node instanceof TextNode) {
        request.setSort(Sort.fromJson(JsonUtils.json(applyParameters(node.asText(),parameterValues))));
    }
    node=savedSearch.get("range");
    if(node instanceof ArrayNode) {
        if(node.size()==2) {
            request.setFrom(node.get(0).asLong());
            request.setTo(node.get(1).asLong());
        }
    }
    return request;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:48,代码来源:FindRequestBuilder.java


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