com.vodafone360.people.engine.content
Class ContentEngine

java.lang.Object
  extended by com.vodafone360.people.engine.BaseEngine
      extended by com.vodafone360.people.engine.content.ContentEngine

public class ContentEngine
extends BaseEngine

Content engine for downloading and uploading all kind of content (pictures, videos, files)


Nested Class Summary
 
Nested classes/interfaces inherited from class com.vodafone360.people.engine.BaseEngine
BaseEngine.IEngineEventCallback
 
Field Summary
private  DatabaseHelper mDbHelper
          Instance of DatabaseHelper.
private  FiFoQueue mDownloadQueue
          Queue with ContentObjects for downloads.
private  FiFoQueue mUnprocessedQueue
          Queue with unprocessed ContentObjects.
private  FiFoQueue mUploadQueue
          Queue with ContentObjects for uploads.
private  java.util.Hashtable<java.lang.Integer,ContentObject> requestContentObjectMatchTable
          Hashtable to match requests to ContentObjects.
 
Fields inherited from class com.vodafone360.people.engine.BaseEngine
mActiveUiRequest, mCurrentTimeout, mEngineId, mEventCallback
 
Constructor Summary
ContentEngine(BaseEngine.IEngineEventCallback eventCallback, DatabaseHelper dbHelper)
          Constructor for the ContentEngine.
 
Method Summary
 DatabaseHelper getDatabaseHelper()
          Getter for the local instance of DatabaseHelper.
 long getNextRunTime()
          Determines the next RunTime of this Engine It first processes the in-queue and then look.
 void onCreate()
          Empty implementation without function at the moment.
 void onDestroy()
          Empty implementation without function at the moment.
protected  void onRequestComplete()
          Empty implementation without function at the moment.
protected  void onTimeoutEvent()
          Empty implementation without function at the moment.
protected  void processCommsResponse(ResponseQueue.Response resp)
          Processes the response Finds the matching contentobject for the repsonse using the id of the response and sets its status to done.
 void processContentObject(ContentObject co)
          Processes one ContentObject.
 void processContentObjects(java.util.List<ContentObject> list)
          Iterates over the ContentObject list and processes every element.
private  void processQueue()
          Processes the main queue and splits it into the download and upload queues.
protected  void processUiRequest(ServiceUiRequest requestId, java.lang.Object data)
          Empty implementation of abstract method from BaseEngine.
 void run()
          run method of this engine iterates over the downloadqueue, makes requests out of ContentObjects and puts them into QueueManager queue.
 
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

mUnprocessedQueue

private FiFoQueue mUnprocessedQueue
Queue with unprocessed ContentObjects.


mDownloadQueue

private FiFoQueue mDownloadQueue
Queue with ContentObjects for downloads.


mUploadQueue

private FiFoQueue mUploadQueue
Queue with ContentObjects for uploads.


mDbHelper

private DatabaseHelper mDbHelper
Instance of DatabaseHelper.


requestContentObjectMatchTable

private java.util.Hashtable<java.lang.Integer,ContentObject> requestContentObjectMatchTable
Hashtable to match requests to ContentObjects.

Constructor Detail

ContentEngine

public ContentEngine(BaseEngine.IEngineEventCallback eventCallback,
                     DatabaseHelper dbHelper)
Constructor for the ContentEngine.

Parameters:
eventCallback - IEngineEventCallback for calling the constructor of the super class
dbHelper - Instance of DatabaseHelper
Method Detail

getDatabaseHelper

public final DatabaseHelper getDatabaseHelper()
Getter for the local instance of DatabaseHelper.

Returns:
local instance of DatabaseHelper

processContentObject

public final void processContentObject(ContentObject co)
Processes one ContentObject.

Parameters:
co - ContentObject to be processed

processContentObjects

public final void processContentObjects(java.util.List<ContentObject> list)
Iterates over the ContentObject list and processes every element.

Parameters:
list - List with ContentObjects which are to be processed

processQueue

private void processQueue()
Processes the main queue and splits it into the download and upload queues.


getNextRunTime

public final long getNextRunTime()
Determines the next RunTime of this Engine It first processes the in-queue and then look.

Specified by:
getNextRunTime in class BaseEngine
Returns:
time in milliseconds from now when the engine should be run

onCreate

public void onCreate()
Empty implementation without function at the moment.

Specified by:
onCreate in class BaseEngine

onDestroy

public void onDestroy()
Empty implementation without function at the moment.

Specified by:
onDestroy in class BaseEngine

onRequestComplete

protected void onRequestComplete()
Empty implementation without function at the moment.

Specified by:
onRequestComplete in class BaseEngine

onTimeoutEvent

protected void onTimeoutEvent()
Empty implementation without function at the moment.

Specified by:
onTimeoutEvent in class BaseEngine

processCommsResponse

protected final void processCommsResponse(ResponseQueue.Response resp)
Processes the response Finds the matching contentobject for the repsonse using the id of the response and sets its status to done. At last the TransferComplete method of the ContentObject is called.

Specified by:
processCommsResponse in class BaseEngine
Parameters:
resp - Response object that has been processed

processUiRequest

protected void processUiRequest(ServiceUiRequest requestId,
                                java.lang.Object data)
Empty implementation of abstract method from BaseEngine.

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

run

public final void run()
run method of this engine iterates over the downloadqueue, makes requests out of ContentObjects and puts them into QueueManager queue.

Specified by:
run in class BaseEngine


JavaDoc