コード例 #1
0
ファイル: Collection.java プロジェクト: funkyidol/usergrid
  /**
   * Retrieves the current state of the collection from the server, and populates an the Collection
   * object with the returned set of entities. Executes synchronously.
   *
   * @return an ApiResponse object
   */
  public ApiResponse fetch() {
    if (this.cursor != null) {
      this.qs.put("cursor", this.cursor);
    }

    Query query =
        this.client.queryEntitiesRequest(
            "GET",
            this.qs,
            null,
            this.client.getOrganizationId(),
            this.client.getApplicationId(),
            this.type);
    ApiResponse response = query.getResponse();
    if (response.getError() != null) {
      this.client.writeLog("Error getting collection.");
    } else {
      String theCursor = response.getCursor();
      int count = response.getEntityCount();

      UUID nextUUID = response.getNext();
      if (nextUUID != null) {
        this.next = nextUUID.toString();
      } else {
        this.next = null;
      }
      this.cursor = theCursor;

      this.saveCursor(theCursor);
      if (count > 0) {
        this.resetEntityPointer();
        this.list = new ArrayList<Entity>();
        List<Entity> retrievedEntities = response.getEntities();

        for (Entity retrievedEntity : retrievedEntities) {
          if (retrievedEntity.getUuid() != null) {
            retrievedEntity.setType(this.type);
            this.list.add(retrievedEntity);
          }
        }
      }
    }

    return response;
  }
コード例 #2
0
ファイル: Collection.java プロジェクト: funkyidol/usergrid
 /**
  * Retrieves an entity from the server.
  *
  * @param uuid the UUID of the entity to retrieve
  * @return an ApiResponse object
  */
 public ApiResponse getEntityByUuid(UUID uuid) {
   Entity entity = new Entity(this.client);
   entity.setType(this.type);
   entity.setUuid(uuid);
   return entity.fetch();
 }
コード例 #3
0
ファイル: Entity.java プロジェクト: funkyidol/usergrid
 /**
  * Constructor for instantiating an Entity with a UGClient and entity type. Normally this is the
  * constructor that should be used to model an entity locally.
  *
  * @param UGClient a UGClient object
  * @param type the 'type' property of the entity
  */
 public Entity(UGClient client, String type) {
   this.client = client;
   setType(type);
 }