public class GetTransaction extends ResourceTransaction
After a successful execution of the transaction, a list of resource objects in JSON format will be available with getResult. There may be more objects to retrieve than are included in a single response, and the transaction object handles iteration to do multiple transactions, keeping track of the offset and total. The number of objects to retrieve per transaction can be set with setTransactionSize, or the server default is used. After a transaction, call next to advance to the offset. If it returns true, the offset was advanced and there are more objects, so do another transaction. Example:
while (transaction.next()) { objects = service.doTransaction(transaction); //add objects to full list }
Constructor and Description |
---|
GetTransaction(Resources resource) |
Modifier and Type | Method and Description |
---|---|
void |
addFilter(Filter filter)
Add a filter, to specify which resource objects to
retrieve.
|
int |
getTotal()
Once a transaction has been performed with this object,
this will return the total number of resource objects
matching the filters of this transaction.
|
java.lang.String |
getURL(ServiceSpec service)
Implemented to provide URL.
|
boolean |
hasNext()
Check if there are more resource objects to retrieve,
without updating the state of the transaction object.
|
boolean |
hasPrevious()
Returns true if we have iterated past the start of the
total list of resource objects matching the filters.
|
boolean |
next()
Check if there are more resource objects to retrieve,
updating the state of the transaction object to retrieve
the next batch if there are.
|
boolean |
previous()
After using next, it's possible to iterate back in
the total list of resource objects matching the filters.
|
void |
processResponse(JSONObject response,
ServiceSpec service)
The response of a transaction is handed to the Transaction
object, so that it can process it to update its state.
|
void |
setContent(java.lang.String selectStr)
Specify which properties of the resource objects to
include in the reply.
|
void |
setId(long id)
Deprecated.
setResourceId is the recommended way to specify an object
|
void |
setResourceId(java.lang.String id)
Specify resource id to get a specific resource object.
|
void |
setTransactionSize(int size)
Set the number of objects to retrieve per transaction.
|
getResult
execute, getError, getException, getResponseCode
public GetTransaction(Resources resource)
@Deprecated public void setId(long id)
id
- resource id of the object to retrievepublic void setResourceId(java.lang.String id)
id
- UUID string specifying the object to retrievepublic void addFilter(Filter filter)
filter
- public void setContent(java.lang.String selectStr)
Here are some examples for selectStr:
"lastValidPosition+type"
- Only lastValidPosition and type properties,
in addition to name and id. Type (a complex type) will only have id and name."lastValidPosition+type.icon"
- Only lastValidPosition and type properties.
Type will now also have icon as well as id and name."@"
- All properties of the resource.selectStr
- public void setTransactionSize(int size)
size
- public int getTotal()
public boolean next()
public boolean hasNext()
public boolean previous()
public boolean hasPrevious()
public java.lang.String getURL(ServiceSpec service)
Transaction
service
- ServiceSpec holding service/session datapublic void processResponse(JSONObject response, ServiceSpec service) throws JSONException
Transaction
response
- top-level JSON object of replyservice
- ServiceSpec holding service/session dataJSONException