ibspan.tss.agents.vta.handlers
Class ViewTransformer

java.lang.Object
  extended by jade.core.behaviours.Behaviour
      extended by jade.core.behaviours.SimpleBehaviour
          extended by jade.core.behaviours.OneShotBehaviour
              extended by ibspan.tss.messaging.RequestHandler
                  extended by ibspan.tss.agents.vta.handlers.ViewTransformer
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
RaccoonTransformer

public abstract class ViewTransformer
extends RequestHandler

This behaviour is responsible for transforming DataModel object given in request message into responding DataView object and prepare reply containing this result. This is done by invoking transform() method.

The behaviour is expected to preserve given UserContext during system-user interaction, usually in such a way each hyperlink a user can go along and each form a user can post were accompanied by information about this context.

Author:
Maciej Gawinecki
See Also:
DataModel, DataView, UserContext, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class jade.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
 
Field Summary
protected  ViewTransformingAgent myAgent
           
 
Fields inherited from class jade.core.behaviours.Behaviour
myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
 
Constructor Summary
ViewTransformer(Agent a, DataStore ds, Object requestKey, Object actKey, Object resultNotificationKey)
          Constructs ViewTransformer object.
 
Method Summary
protected  ACLMessage prepareResponse(ACLMessage request, Action act)
          Returns response to the request.
protected abstract  DataView transform(DataModel model, UserContext context)
          Transforms pure data into browser-readable form.
 
Methods inherited from class ibspan.tss.messaging.RequestHandler
action
 
Methods inherited from class jade.core.behaviours.OneShotBehaviour
done
 
Methods inherited from class jade.core.behaviours.SimpleBehaviour
reset
 
Methods inherited from class jade.core.behaviours.Behaviour
actionWrapper, block, block, getBehaviourName, getDataStore, getExecutionState, getParent, handle, isRunnable, onEnd, onStart, restart, root, setAgent, setBehaviourName, setDataStore, setExecutionState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myAgent

protected ViewTransformingAgent myAgent
Constructor Detail

ViewTransformer

public ViewTransformer(Agent a,
                       DataStore ds,
                       Object requestKey,
                       Object actKey,
                       Object resultNotificationKey)
Constructs ViewTransformer object.

Parameters:
a - is the agent owning this behaviour.
ds - is the DataStore for this constructor.
requestKey -
actKey - is the key in the DataStore where the Action concept extracted from current request can be found.
resultNotificationKey - is the key in the DataStore where the result message is to be put at.
Method Detail

prepareResponse

protected final ACLMessage prepareResponse(ACLMessage request,
                                           Action act)
                                    throws FailureException,
                                           NotUnderstoodException
Description copied from class: RequestHandler
Returns response to the request. Programmers should implenets this method in order process given request.

Specified by:
prepareResponse in class RequestHandler
Parameters:
request - is message.
act - is Action concept extracted previously from request object.
Returns:
response; null means failure.
Throws:
FailureException
NotUnderstoodException

transform

protected abstract DataView transform(DataModel model,
                                      UserContext context)
                               throws ViewTransformingException
Transforms pure data into browser-readable form.

Parameters:
model - are pure data be formatted
context - is context of user request, such type of media, session-id etc.
Returns:
browser-readable form of data
Throws:
ViewTransformingException - when transforming process failed for some reason.