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

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

本文整理了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

public static Query fromIdentifier( Object id ) {
  if (id == null) {
    throw new IllegalArgumentException("null identifier passed in");
  }
  Identifier objectIdentifier = Identifier.from(id);
  if (objectIdentifier == null) {
    throw new IllegalArgumentException("Supplied id results in null Identifier");
  }
  Query q = new Query();
  q.addIdentifier( Identifier.from(id) );
  return q;
}

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

public static Query fromUUID( UUID uuid ) {
  Query q = new Query();
  q.addIdentifier( Identifier.fromUUID( uuid ) );
  return q;
}

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

@Test
public void nameIdentifierTest() throws Exception {
  logger.debug( "nameIdentifierTest" );
  EntityManager em = app.getEntityManager();
  assertNotNull( em );
  Map<String, Object> properties = new LinkedHashMap<String, Object>();
  properties.put( "keywords", "blah,test,game" );
  properties.put( "title", "Solitaire" );
  properties.put( "name", "test" );
  Entity game1 = em.create( "games", properties );
  assertNotNull( game1 );
  //we create 2 entities, otherwise this test will pass when it shouldn't
  properties.put( "name", "test2" );
  Entity game2 = em.create( "game", properties );
  assertNotNull( game2 );
  app.waitForQueueDrainAndRefreshIndex();
  // overlap
  Query query = new Query();
  query.addIdentifier( Identifier.fromName( "test" ) );
  Results r = em.searchCollection( em.getApplicationRef(), "games", query );
  assertEquals( "We should only get 1 result", 1, r.size() );
  assertNull( "No cursor should be present", r.getCursor() );
  assertEquals( "Saved entity returned", game1, r.getEntity() );
}

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

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

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

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

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

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

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

@Test
public void emailIdentifierTest() throws Exception {
  logger.debug( "emailIdentifierTest" );
  EntityManager em = app.getEntityManager();
  assertNotNull( em );
  User user = new User();
  user.setUsername( "foobar" );
  user.setEmail( "foobar@usergrid.org" );
  Entity createUser = em.create( user );
  assertNotNull( createUser );
  //we create 2 entities, otherwise this test will pass when it shouldn't
  User user2 = new User();
  user2.setUsername( "foobar2" );
  user2.setEmail( "foobar2@usergrid.org" );
  Entity createUser2 = em.create( user2 );
  assertNotNull( createUser2 );
  app.waitForQueueDrainAndRefreshIndex();
  // overlap
  Query query = new Query();
  query.addIdentifier( Identifier.fromEmail( "foobar@usergrid.org" ) );
  Results r = em.searchCollection( em.getApplicationRef(), "users", query );
  assertEquals( "We should only get 1 result", 1, r.size() );
  assertNull( "No cursor should be present", r.getCursor() );
  assertEquals( "Saved entity returned", createUser, r.getEntity() );
}

相关文章