/** * 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; }
/** * Destroys a connection between two entities. * * @param connectType the type of connection * @param targetEntity the UUID of the entity to disconnect from * @return an ApiResponse object */ public ApiResponse disconnect(String connectType, Entity targetEntity) { return this.client.disconnectEntities( this.getType(), this.getUuid().toString(), connectType, targetEntity.getUuid().toString()); }