org.activemath.content
Class ContentManager

java.lang.Object
  extended by org.activemath.content.ContentManager
All Implemented Interfaces:
EventListener, ActivemathEventListener

public class ContentManager
extends Object
implements ActivemathEventListener

Content Manager Singleton Handle all sorts of content Items, their creation and caching.


Field Summary
protected static Logger log
           
 
Method Summary
 void addDynamicItem(String id, DynamicItem item)
          Register a dynamic item with the ContentManager.
 String getAssociatedTutorBook(UserBook userBook)
           
 CollabSessions getCollabSessions()
           
 ContentCollection getCollection(String collectionId)
          Return a specific collection
 List<ContentCollection> getCollections()
          Return a list of available Collections.
 Item getContentItem(MBaseID mbaseId)
          Deprecated. use getContentItem(String).
 Item getContentItem(String id)
          Fetch any content item, possibly cached.
 List getContentItems(Iterator it)
           
 List getContentItems(List ids)
          Fetch a list of content items (possibly cached)
 DynamicItem getDynamicItem(String id)
          Fetch a dynamic item.
 Grouping getGrouping(String groupingId)
          Return a specific grouping
 List<Grouping> getGroupings()
          Return a list of available Groupings.
static ContentManager getInstance()
           
 Mediator getMediator()
           
 int getNextUserBookId()
           
 int getNumExercises(String bookId)
           
 RecBook getRecBook(String recBookKey)
          Return a recorded Book.
 RecBook getRecBookByMbaseId(String mbaseId)
           
 List<Book> getRecBooks()
           
 Map<String,RecBook> getRecBooksMap()
           
 HashMap<String,List<String>> getStructuredCollectionItems(ContentCollection coll)
          Deprecated. use ContentCollection.getStructuredItems()
 String getTypeString(String mbaseId)
           
 void initContent()
          Causes RecBooks and Groupings to be read from configuration and (re-)initialized.
 void onActivemathEvent(ActivemathEvent event)
          Event handler for ContentManager.
 Book publishBook(UserBook userBook)
          Publish a user book, making it a "TutorBook".
 List query_WithoutCache(String queryString)
          The same as query_, but does not use the MediatorCache.
 List query(String queryString)
          The new Mediator call.
 void removeDynamicItem(String id)
          Remove a dynamic item from the ContentManager.
 void unpublishBook(String bookId)
          Remove a published book
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Logger log
Method Detail

getCollabSessions

public CollabSessions getCollabSessions()

getInstance

public static ContentManager getInstance()

initContent

public void initContent()
Causes RecBooks and Groupings to be read from configuration and (re-)initialized.


query

public List query(String queryString)
The new Mediator call. Returns a List of strings where each represents an item id. This method will be renamed to 'query'.

Parameters:
queryString -
Returns:
List of id-strings, or null on error.

query_WithoutCache

public List query_WithoutCache(String queryString)
The same as query_, but does not use the MediatorCache. This method is for testing only.

Parameters:
queryString -
Returns:

onActivemathEvent

public void onActivemathEvent(ActivemathEvent event)
Event handler for ContentManager. Currently only handles MBaseCollectionsChangedEvent:

Specified by:
onActivemathEvent in interface ActivemathEventListener
Parameters:
event - the event to respond to

getTypeString

public String getTypeString(String mbaseId)
Parameters:
mbaseId - The absolute MBase ID of the item
Returns:
The type string of the item

getRecBook

public RecBook getRecBook(String recBookKey)
Return a recorded Book. Once created, a RecBook is stored in our list and fetched from there. If the book is not yet initialized by its defining document, we try to do so, but may fail in case MBase is not yet available. Until MBase is available, the Book will at least contain its title.

Parameters:
recBookKey -
Returns:
a RecBook (possiblibly only partly initialized)

getRecBooks

public List<Book> getRecBooks()
Returns:
List of Book objects (unordered)

getRecBookByMbaseId

public RecBook getRecBookByMbaseId(String mbaseId)

getContentItem

public Item getContentItem(String id)
Fetch any content item, possibly cached. There are two kinds of items:

Parameters:
id - - id of the content item (assumed to be in absolute form)
Returns:
initialized Item, or null
Throws:
IllegalArgumentException - if id is null.

getContentItem

public Item getContentItem(MBaseID mbaseId)
Deprecated. use getContentItem(String).


getContentItems

public List getContentItems(List ids)
Fetch a list of content items (possibly cached)

Parameters:
it - - List of mbaseIds (type String or MBaseID) of the content items
Returns:
List of Item objects

getContentItems

public List getContentItems(Iterator it)

getDynamicItem

public DynamicItem getDynamicItem(String id)
Fetch a dynamic item. Dynamic items are not stored in MBase, but need to be registered with addDynamicItem(String). With DynamicItem being an abstract class, this method will return concrete instances, such as DynamicItemDynamicTask, DynamicItemLearningService or DynamicItemText...

Parameters:
id -
Returns:
DynamicItem or null if item does not exist.

addDynamicItem

public void addDynamicItem(String id,
                           DynamicItem item)
Register a dynamic item with the ContentManager.


removeDynamicItem

public void removeDynamicItem(String id)
Remove a dynamic item from the ContentManager.


getGroupings

public List<Grouping> getGroupings()
Return a list of available Groupings. Groupings are the basis for creating user books.

Returns:
List of Grouping objects

getGrouping

public Grouping getGrouping(String groupingId)
Return a specific grouping

Returns:
Grouping with id groupingId, or null.

getCollections

public List<ContentCollection> getCollections()
Return a list of available Collections.

Returns:
List of Collection objects

getCollection

public ContentCollection getCollection(String collectionId)
Return a specific collection

Returns:
ContentCollection with id collectionId, or null.

publishBook

public Book publishBook(UserBook userBook)
Publish a user book, making it a "TutorBook".


getAssociatedTutorBook

public String getAssociatedTutorBook(UserBook userBook)
Returns:
id of TutorBook that has been published from userBook, or null.

unpublishBook

public void unpublishBook(String bookId)
Remove a published book


getMediator

public Mediator getMediator()

getRecBooksMap

public Map<String,RecBook> getRecBooksMap()
Returns:
Map "book id" -> Book

getNextUserBookId

public int getNextUserBookId()
Returns:
next system-wide id for user book

getNumExercises

public int getNumExercises(String bookId)

getStructuredCollectionItems

public HashMap<String,List<String>> getStructuredCollectionItems(ContentCollection coll)
Deprecated. use ContentCollection.getStructuredItems()