com.vodafone360.people.engine.groups
Class GroupsEngine

java.lang.Object
  extended by com.vodafone360.people.engine.BaseEngine
      extended by com.vodafone360.people.engine.groups.GroupsEngine

public class GroupsEngine
extends BaseEngine


Nested Class Summary
 
Nested classes/interfaces inherited from class com.vodafone360.people.engine.BaseEngine
BaseEngine.IEngineEventCallback
 
Field Summary
private static int MAX_DOWN_PAGE_SIZE
          Max number of groups to fetch from server in one request.
private  DatabaseHelper mDb
           
private  int mNoOfGroupsFetched
          Total number of groups fetched from server.
private  int mPageNo
          Current page number being fetched.
 
Fields inherited from class com.vodafone360.people.engine.BaseEngine
mActiveUiRequest, mCurrentTimeout, mEngineId, mEventCallback
 
Constructor Summary
GroupsEngine(Context context, BaseEngine.IEngineEventCallback eventCallback, DatabaseHelper db)
           
 
Method Summary
 void addUiGetGroupsRequest()
          Adds a request to get groups from the backend that are associated with the server contacts.
 long getNextRunTime()
          Return the absolute time in milliseconds when the engine needs to run (based on System.currentTimeMillis).
 void onCreate()
          This will be called immediately after creation.
 void onDestroy()
          This will be called just before the engine is shutdown.
protected  void onRequestComplete()
          This function must be implemented in the derived engine implementation.
protected  void onTimeoutEvent()
          The derived engine implementation must call the processTimeout() function (normally from within the run() implementation), otherwise this will not be called.
protected  void processCommsResponse(ResponseQueue.Response resp)
          The derived engine implementation must call the processCommsInQueue() function (normally from within the run() implementation), otherwise this will not be called.
protected  void processUiRequest(ServiceUiRequest requestId, java.lang.Object data)
          The derived engine implementation must call the processUiQueue() function (normally from within the run() implementation), otherwise this will not be called.
private  void requestFirstGroupsPage()
          Requests the first group page.
private  void requestNextGroupsPage()
          Requests the next page of groups from the server.
 void run()
          Do some work but anything that takes longer than 1 second must be broken up.
 
Methods inherited from class com.vodafone360.people.engine.BaseEngine
addUiRequestToQueue, clearTimeout, completeUiRequest, completeUiRequest, deactivateEngine, emptyUiRequestQueue, engineId, genericHandleResponseType, getCurrentTimeout, isCommsResponseOutstanding, isDeactivated, isUiRequestOutstanding, onCommsInMessage, onReset, processCommsInQueue, processTimeout, processUiQueue, setReqId, setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_DOWN_PAGE_SIZE

private static final int MAX_DOWN_PAGE_SIZE
Max number of groups to fetch from server in one request.

See Also:
Constant Field Values

mPageNo

private int mPageNo
Current page number being fetched.


mNoOfGroupsFetched

private int mNoOfGroupsFetched
Total number of groups fetched from server.


mDb

private DatabaseHelper mDb
Constructor Detail

GroupsEngine

public GroupsEngine(Context context,
                    BaseEngine.IEngineEventCallback eventCallback,
                    DatabaseHelper db)
Method Detail

getNextRunTime

public long getNextRunTime()
Description copied from class: BaseEngine
Return the absolute time in milliseconds when the engine needs to run (based on System.currentTimeMillis). (Maybe add currentTime in the future to use as the current time, to enable JUnit tests to validate timeout functionality).

Specified by:
getNextRunTime in class BaseEngine
Returns:
-1 never needs to run, 0 needs to run as soon as possible, CurrentTime + 60000 to run in 1 minute, etc.

onCreate

public void onCreate()
Description copied from class: BaseEngine
This will be called immediately after creation.

Specified by:
onCreate in class BaseEngine

onDestroy

public void onDestroy()
Description copied from class: BaseEngine
This will be called just before the engine is shutdown.

Specified by:
onDestroy in class BaseEngine

onRequestComplete

protected void onRequestComplete()
Description copied from class: BaseEngine
This function must be implemented in the derived engine implementation. It can do any post-request complete cleanup.

Specified by:
onRequestComplete in class BaseEngine

onTimeoutEvent

protected void onTimeoutEvent()
Description copied from class: BaseEngine
The derived engine implementation must call the processTimeout() function (normally from within the run() implementation), otherwise this will not be called. This function will be called when a timeout occurs (started by setTimeout and cancelled by clearTimeout). If this function takes longer than 1 second to complete it should be broken up.

Specified by:
onTimeoutEvent in class BaseEngine

processCommsResponse

protected void processCommsResponse(ResponseQueue.Response resp)
Description copied from class: BaseEngine
The derived engine implementation must call the processCommsInQueue() function (normally from within the run() implementation), otherwise this will not be called. This function is called for each Comms response that arrives on the in queue.

Specified by:
processCommsResponse in class BaseEngine
Parameters:
resp - The comms response

processUiRequest

protected void processUiRequest(ServiceUiRequest requestId,
                                java.lang.Object data)
Description copied from class: BaseEngine
The derived engine implementation must call the processUiQueue() function (normally from within the run() implementation), otherwise this will not be called. This function is called for each UI request that arrives on the queue. It should start processing the request. If this function takes longer than 1 second to complete, it should be broken up. Once a request is finished the processUiRequest function must be called.

Specified by:
processUiRequest in class BaseEngine
Parameters:
requestId - The UI request ID
data - Request data (object type is request specific)

run

public void run()
Description copied from class: BaseEngine
Do some work but anything that takes longer than 1 second must be broken up. (Maybe add currentTime as parameter, to enable JUnit tests to validate timeout functionality)

Specified by:
run in class BaseEngine

addUiGetGroupsRequest

public void addUiGetGroupsRequest()
Adds a request to get groups from the backend that are associated with the server contacts.


requestFirstGroupsPage

private void requestFirstGroupsPage()
Requests the first group page.


requestNextGroupsPage

private void requestNextGroupsPage()
Requests the next page of groups from the server.



JavaDoc