org.activemath.content.items
Class DynamicItem

java.lang.Object
  extended by org.activemath.content.items.Item
      extended by org.activemath.content.items.DynamicItem
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DynamicItemDynamicTask, DynamicItemLearningService, DynamicItemText

public abstract class DynamicItem
extends Item

This class defines a datatype DynamicItem, which supplies features for Dynamic Item. The Datatype DynmaicItem is originally transformed from OJDynamicItem. As the OJDynamicItem is an OJElement, which is only visible internally, the Datatype DynamicItem serves as an external interface to other packages and even thirdparty programm like some kind of service Call and NLG Generator. Because the class extends his parent class Item, it overwrite many method of its parent too. As the class DynamicItem has an abstract method executeDynamicItem(), the class is also an abstract class, which have following Instances:

See Also:
Serialized Form

Field Summary
protected static Category log
           
protected  String queryName
          the queryname or pedagogical Objective, like "introduction", "getexcersise"
protected  List queryParameters
          A List, which contains property, value pairs as Lists.
protected  List<String> references
          a List of all mbase references(String)
protected static long serializedNumber
          This is the static member for counting the generated Object.
protected  String serviceName
          Actually this is only used for service like icmap.
protected  String type
          The type of this Object, which can be one of the TYPE defined in his sub classes.
protected  String userId
          Currently there's no case we need to store this information.
 
Fields inherited from class org.activemath.content.items.Item
copyrights, dependsOn, factory, flavorSet, forId, forIds, id, mbaseId, metadata, omdocTag, omdocType, relatedTo, relationsIn, relationsOut, shouldUseTitleFromID, theoryId, title, titles
 
Constructor Summary
protected DynamicItem(OJDynamicItem ojitem, String id)
          This Constructor is a common constructor for each type of DynamicItem.
 
Method Summary
 Map getCopyrightData()
           
 OJElement getCopyrightElement()
           
 String getForId()
           
 List getForIds()
          we don't have any for Ids for dynamic item.
 List getIncomingRelations()
           
 Metadata getMetadata()
           
 OJElement getMetadataElement()
           
 List getOutgoingRelations()
          Get or build outgoing relations for this item.
 String getQueryName()
           
 List getQueryParameters()
           
 List getReferences()
           
static long getSerializedNumber()
          count up the number of object
 String getServiceName()
           
 Map<String,String> getTitles(String userId)
           
 String getType()
           
 boolean hasFlavors()
           
protected  List initQueryParameters(OJDynamicItem ojitem)
          Initiate the member queryParameters
abstract  void initTitles(String userId)
           
abstract  List instanciateDynamicItem(String userId)
          This is a stratergie method for all kind of DynamicItem.
 boolean isLazyTask()
          check if this Item is a kind of LazyTask
 boolean isNLGText()
          check if the dynamic item is a NLGText by checking the servicename.
 boolean isServiceCall()
          check if this Item is a serviceCall
 boolean isText()
          check if this Item is a kind of NIText
 void setLink(String url, String type, int width, int height, Map<String,String> linkTextMap, OJElement localOmdocElement)
          We build up the hyperlink for the item here.
 OJDynamicItem toOJDynamicItem()
          This method transfers a DynamicItem data object to a OJDynamicItem.
 String toString()
          Return type + serviceName + queryName
 
Methods inherited from class org.activemath.content.items.Item
equals, getDependsOn, getDifficulty, getFlavorSet, getFullDOM, getId, getMBaseId, getNumWords, getOmdocTag, getOmdocType, getRelatedTo, getSystemId, getTextualDOM, getTheoryId, getTitle, getTitle, getTitle, getTitles, hashCode, setUseTitleFromID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static Category log

serializedNumber

protected static long serializedNumber
This is the static member for counting the generated Object. Also it's important to register a DynamicItem by ContentManager. Further more, it's nessesary to have this for such special page, which only contains dynamic items.


type

protected String type
The type of this Object, which can be one of the TYPE defined in his sub classes.


serviceName

protected String serviceName
Actually this is only used for service like icmap. But we set this member just empty for other kind of DynamicItem.


queryName

protected String queryName
the queryname or pedagogical Objective, like "introduction", "getexcersise"


references

protected List<String> references
a List of all mbase references(String)


queryParameters

protected List queryParameters
A List, which contains property, value pairs as Lists. This is specially for extern service call and any other services, which is still not considered. All other properties which special for particular purpose can be defined in this HashMap. Actually this is only used for service like icmap. But we set this member just empty for other kind of DynamicItem.


userId

protected String userId
Currently there's no case we need to store this information. But every DynamicItem must corresponds to unique user. Besides, each DynamicItem should have titles. TODO: Titles should adapt to different users, which is currently not the case.

Constructor Detail

DynamicItem

protected DynamicItem(OJDynamicItem ojitem,
                      String id)
This Constructor is a common constructor for each type of DynamicItem. With given OJDynamicItem, we can build up a DynamicItem Object. This constructor should only be called by DynamicItemFactory,

Parameters:
id -
ojitem -
Method Detail

initQueryParameters

protected List initQueryParameters(OJDynamicItem ojitem)
Initiate the member queryParameters


getReferences

public List getReferences()

getQueryName

public String getQueryName()

getQueryParameters

public List getQueryParameters()

getServiceName

public String getServiceName()

getType

public String getType()

isLazyTask

public boolean isLazyTask()
check if this Item is a kind of LazyTask


isServiceCall

public boolean isServiceCall()
check if this Item is a serviceCall


isText

public boolean isText()
check if this Item is a kind of NIText


instanciateDynamicItem

public abstract List instanciateDynamicItem(String userId)
This is a stratergie method for all kind of DynamicItem. It generally use the userId to look up the relevant information from User Model and call the apporpriate Services and Methods to ask for a List as result. The Services or Methods should put the result as a List, e.g. by LazyTask it is a list of mbase Ids; or they can put the result as the first element of the list, if the service returns only one data object. The concret implement is in seperate subclass descripted.

Parameters:
userId - - may be null
Returns:
an empty List if the caller don't expect any result, a list of mbase Ids for dynamicItemLazyTask as result, null if there's something wrong with executing.

initTitles

public abstract void initTitles(String userId)

isNLGText

public boolean isNLGText()
check if the dynamic item is a NLGText by checking the servicename.


setLink

public void setLink(String url,
                    String type,
                    int width,
                    int height,
                    Map<String,String> linkTextMap,
                    OJElement localOmdocElement)
We build up the hyperlink for the item here. Many dynamicItem needs this function, so I wrote this general one and put it here. The pupup window shown to the user will be set with given size and given type.

Parameters:
url -
width -
height -
type -

toOJDynamicItem

public OJDynamicItem toOJDynamicItem()
This method transfers a DynamicItem data object to a OJDynamicItem. It's used to update the omgroup in OJDocument with created new List of items. If you want to see the real result of executing of dynamicItem, please don't use this method, but the getTextualDOM().

Returns:
OJDynamciItem ojDynItem

getTitles

public Map<String,String> getTitles(String userId)

toString

public String toString()
Return type + serviceName + queryName

Overrides:
toString in class Item

getSerializedNumber

public static long getSerializedNumber()
count up the number of object

Returns:
long a countup of SerialVersionUID from 1

getForIds

public List getForIds()
we don't have any for Ids for dynamic item. But to avoid ERROR by running Formatter, I have to overwrite the mothed, which originally call the mbase for "ForIDs".

Overrides:
getForIds in class Item
Returns:
result of MBaseRef.getForWhat() (List of Strings (item ids))

getIncomingRelations

public List getIncomingRelations()
Overrides:
getIncomingRelations in class Item

getOutgoingRelations

public List getOutgoingRelations()
Description copied from class: Item
Get or build outgoing relations for this item.

Relation list is initialized lazily on first access.

Outgoing relations are based on MBaseRef.getDependencies(), whose result is turned into a list of ItemRelation objects.

Overrides:
getOutgoingRelations in class Item
Returns:
List of ItemRelation objects (empty on MBase error)

getCopyrightData

public Map getCopyrightData()
Overrides:
getCopyrightData in class Item

getCopyrightElement

public OJElement getCopyrightElement()
Overrides:
getCopyrightElement in class Item

getForId

public String getForId()
Overrides:
getForId in class Item
Returns:
value of the "for" attribute of this item.

hasFlavors

public boolean hasFlavors()
Overrides:
hasFlavors in class Item
Returns:
true if flavors are available for this item

getMetadata

public Metadata getMetadata()
Overrides:
getMetadata in class Item
Returns:
metadata object for this item

getMetadataElement

public OJElement getMetadataElement()
Overrides:
getMetadataElement in class Item