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


Java FindRequest.setProjection方法代码示例

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


在下文中一共展示了FindRequest.setProjection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getSearchesForEntity

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@GET
@LZF
@Path("/search/{entity}")
public Response getSearchesForEntity(@PathParam("entity") String entity,
                                     @QueryParam("P") String projection,
                                     @QueryParam("S") String sort) {
    FindRequest freq=new FindRequest();
    freq.setEntityVersion(new EntityVersion(RestConfiguration.getSavedSearchCache().savedSearchEntity,
                                            RestConfiguration.getSavedSearchCache().savedSearchVersion));

    try {
        freq.setProjection(projection==null?FieldProjection.ALL:Projection.fromJson(JsonUtils.json(QueryTemplateUtils.buildProjectionsTemplate(projection))));
        freq.setSort(sort==null?new SortKey(new com.redhat.lightblue.util.Path("name"),false):Sort.fromJson(JsonUtils.json(QueryTemplateUtils.buildSortsTemplate(sort))));
    } catch (Exception e) {
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.toString()).build();
    }
    CallStatus st=new FindCommand(freq.getEntityVersion().getEntity(),
                                  freq.getEntityVersion().getVersion(),
                                  freq.toJson().toString(), METRICS).run();
    return Response.status(st.getHttpStatus()).entity(st.toString()).build();
}
 
开发者ID:lightblue-platform,项目名称:lightblue-rest,代码行数:22,代码来源:AbstractCrudResource.java

示例3: 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

示例4: looping_entities_with_or_query_709_w_n_to_n_refs

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void looping_entities_with_or_query_709_w_n_to_n_refs() 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."));
    Response response=mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(3,response.getMatchCount());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:21,代码来源:CompositeFinderTest.java

示例5: assoc_errors_propagate

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void assoc_errors_propagate() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'field':'_id','op':'=','rvalue':1}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'us','recursive':1}]"));
    fr.setEntityVersion(new EntityVersion("L", "0.0.1"));
    findError = Error.get("NoAccess", "blah");
    errorEntity = "U";
    Response response = mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertTrue(response.getEntityData()==null||response.getEntityData().size()==0);
    Assert.assertEquals(1, response.getErrors().size());

    findError = Error.get("NoAccess", "blah");
    errorEntity = "L";
    response = mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertTrue(response.getEntityData()==null||response.getEntityData().size()==0);
    Assert.assertEquals(1, response.getErrors().size());

}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:22,代码来源:CompositeFinderTest.java

示例6: array_in_reference_fullarr

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void array_in_reference_fullarr() throws Exception {
    init_arr();
    FindRequest fr=new FindRequest();
    fr.setQuery(query("{'field':'_id','op':'=','rvalue':'1'}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'ref'}]"));
    fr.setEntityVersion(new EntityVersion("arr_parent","1.0.0"));
    Response response=getMediator().find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(1, response.getEntityData().size());
    Assert.assertEquals(3,response.getEntityData().get(0).get("ref").size());
    cleanup_arr();
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:14,代码来源:AssocTest.java

示例7: array_in_reference_emptyarr

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void array_in_reference_emptyarr() throws Exception {
    init_arr();
    FindRequest fr=new FindRequest();
    fr.setQuery(query("{'field':'_id','op':'=','rvalue':'2'}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'ref'}]"));
    fr.setEntityVersion(new EntityVersion("arr_parent","1.0.0"));
    Response response=getMediator().find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(1, response.getEntityData().size());
    Assert.assertNull(response.getEntityData().get(0).get("ref"));
    cleanup_arr();
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:14,代码来源:AssocTest.java

示例8: array_in_reference_nullarr

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void array_in_reference_nullarr() throws Exception {
    init_arr();
    FindRequest fr=new FindRequest();
    fr.setQuery(query("{'field':'_id','op':'=','rvalue':'3'}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'ref'}]"));
    fr.setEntityVersion(new EntityVersion("arr_parent","1.0.0"));
    Response response=getMediator().find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(1, response.getEntityData().size());
    Assert.assertNull(response.getEntityData().get(0).get("ref"));
    cleanup_arr();
}
 
开发者ID:lightblue-platform,项目名称:lightblue-mongo,代码行数:14,代码来源:AssocTest.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: retrieveAandBonly

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void retrieveAandBonly() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'field':'_id','op':'=','rvalue':'A01'}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'b'}]"));
    fr.setEntityVersion(new EntityVersion("A", "1.0.0"));
    Response response = mediator.find(fr);
    Assert.assertEquals(1, response.getEntityData().size());
    Assert.assertEquals("A01", response.getEntityData().get(0).get("_id").asText());
    QueryPlan qplan = (QueryPlan) getLastContext(mediator).getProperty(Mediator.CTX_QPLAN);
    // This one must have A -> B
    Assert.assertEquals(1, qplan.getSources().length);
    Assert.assertEquals("A", qplan.getSources()[0].getMetadata().getName());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:15,代码来源:CompositeFinderTest.java

示例11: assocRetrievalWithElemMatch

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
 public void assocRetrievalWithElemMatch() 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"));

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

示例12: two_level_search_three_level_fetch

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

示例13: elem_match_backward

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void elem_match_backward() 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"));
    Response response = mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(1, response.getEntityData().size());
    Assert.assertEquals(1, response.getMatchCount());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:12,代码来源:CompositeFinderTest.java

示例14: test_self_ref_with_parents

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void test_self_ref_with_parents() throws Exception {
    FindRequest fr=new FindRequest();
    fr.setQuery(query("{'field':'_id','op':'=','rvalue':'img1'}"));
    fr.setProjection(projection("[{'field':'*','recursive':true},{'field':'vulnerabilities.*.packages.*.fixed_by_images.*'}]"));
    fr.setEntityVersion(new EntityVersion("containerImage-self","0.0.1"));
    Response response=mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(1,response.getEntityData().size());
    Assert.assertTrue(response.getEntityData().get(0).get("vulnerabilities").get(0).get("packages").get(0).get("fixed_by_images").size()==1);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:12,代码来源:CompositeFinderTest.java

示例15: assocQWithNull2

import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void assocQWithNull2() throws Exception {
    FindRequest fr = new FindRequest();
    fr.setQuery(query("{'$and': [ {'field':'authentications.*.providerName','op':'$nin','values':['x',null]},{'field':'_id','op':'$in','values':[1,2]}]}"));
    fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'legalEntities.*.legalEntity','recursive':1}]"));
    fr.setEntityVersion(new EntityVersion("U", "0.0.1"));
    Response response = mediator.find(fr);
    System.out.println(response.getEntityData());
    Assert.assertEquals(1, response.getEntityData().size());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:11,代码来源:CompositeFinderTest.java


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