org.apache.usergrid.persistence.Query.addIdentifier()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(333)

本文整理了Java中org.apache.usergrid.persistence.Query.addIdentifier方法的一些代码示例,展示了Query.addIdentifier的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.addIdentifier方法的具体详情如下:
包路径:org.apache.usergrid.persistence.Query
类名称:Query
方法名:addIdentifier

Query.addIdentifier介绍

暂无

代码示例

代码示例来源:origin: apache/usergrid

  1. public static Query fromIdentifier( Object id ) {
  2. if (id == null) {
  3. throw new IllegalArgumentException("null identifier passed in");
  4. }
  5. Identifier objectIdentifier = Identifier.from(id);
  6. if (objectIdentifier == null) {
  7. throw new IllegalArgumentException("Supplied id results in null Identifier");
  8. }
  9. Query q = new Query();
  10. q.addIdentifier( Identifier.from(id) );
  11. return q;
  12. }

代码示例来源:origin: apache/usergrid

  1. public static Query fromUUID( UUID uuid ) {
  2. Query q = new Query();
  3. q.addIdentifier( Identifier.fromUUID( uuid ) );
  4. return q;
  5. }

代码示例来源:origin: apache/usergrid

  1. @Test
  2. public void nameIdentifierTest() throws Exception {
  3. logger.debug( "nameIdentifierTest" );
  4. EntityManager em = app.getEntityManager();
  5. assertNotNull( em );
  6. Map<String, Object> properties = new LinkedHashMap<String, Object>();
  7. properties.put( "keywords", "blah,test,game" );
  8. properties.put( "title", "Solitaire" );
  9. properties.put( "name", "test" );
  10. Entity game1 = em.create( "games", properties );
  11. assertNotNull( game1 );
  12. //we create 2 entities, otherwise this test will pass when it shouldn't
  13. properties.put( "name", "test2" );
  14. Entity game2 = em.create( "game", properties );
  15. assertNotNull( game2 );
  16. app.waitForQueueDrainAndRefreshIndex();
  17. // overlap
  18. Query query = new Query();
  19. query.addIdentifier( Identifier.fromName( "test" ) );
  20. Results r = em.searchCollection( em.getApplicationRef(), "games", query );
  21. assertEquals( "We should only get 1 result", 1, r.size() );
  22. assertNull( "No cursor should be present", r.getCursor() );
  23. assertEquals( "Saved entity returned", game1, r.getEntity() );
  24. }

代码示例来源:origin: apache/usergrid

  1. query.setQl("select * where username ='"+pathToken.getIdentifier().getName()+"'");
  2. }else{
  3. query.addIdentifier(pathToken.getIdentifier());

代码示例来源:origin: apache/usergrid

  1. query.setEntityType( eType );
  2. if ( id != null ) {
  3. query.addIdentifier( Identifier.fromUUID( id ) );
  4. query.addIdentifier( Identifier.from( name ) );

代码示例来源:origin: apache/usergrid

  1. @Test
  2. public void uuidIdentifierTest() throws Exception {
  3. logger.debug( "uuidIdentifierTest" );
  4. EntityManager em = app.getEntityManager();
  5. assertNotNull( em );
  6. Map<String, Object> properties = new LinkedHashMap<String, Object>();
  7. properties.put( "keywords", "blah,test,game" );
  8. properties.put( "title", "Solitaire" );
  9. Entity game1 = em.create( "game", properties );
  10. assertNotNull( game1 );
  11. //we create 2 entities, otherwise this test will pass when it shouldn't
  12. Entity game2 = em.create( "game", properties );
  13. assertNotNull( game2 );
  14. app.waitForQueueDrainAndRefreshIndex();
  15. // overlap
  16. Query query = new Query();
  17. query.addIdentifier( Identifier.fromUUID( game1.getUuid() ) );
  18. Results r = em.searchCollection( em.getApplicationRef(), "games", query );
  19. assertEquals( "We should only get 1 result", 1, r.size() );
  20. assertNull( "No cursor should be present", r.getCursor() );
  21. assertEquals( "Saved entity returned", game1, r.getEntity() );
  22. }

代码示例来源:origin: apache/usergrid

  1. @Test
  2. public void emailIdentifierTest() throws Exception {
  3. logger.debug( "emailIdentifierTest" );
  4. EntityManager em = app.getEntityManager();
  5. assertNotNull( em );
  6. User user = new User();
  7. user.setUsername( "foobar" );
  8. user.setEmail( "foobar@usergrid.org" );
  9. Entity createUser = em.create( user );
  10. assertNotNull( createUser );
  11. //we create 2 entities, otherwise this test will pass when it shouldn't
  12. User user2 = new User();
  13. user2.setUsername( "foobar2" );
  14. user2.setEmail( "foobar2@usergrid.org" );
  15. Entity createUser2 = em.create( user2 );
  16. assertNotNull( createUser2 );
  17. app.waitForQueueDrainAndRefreshIndex();
  18. // overlap
  19. Query query = new Query();
  20. query.addIdentifier( Identifier.fromEmail( "foobar@usergrid.org" ) );
  21. Results r = em.searchCollection( em.getApplicationRef(), "users", query );
  22. assertEquals( "We should only get 1 result", 1, r.size() );
  23. assertNull( "No cursor should be present", r.getCursor() );
  24. assertEquals( "Saved entity returned", createUser, r.getEntity() );
  25. }

相关文章