org.olat.ims.cp
Class CPManager

java.lang.Object
  extended by org.olat.ims.cp.CPManager
Direct Known Subclasses:
CPManagerImpl

public abstract class CPManager
extends java.lang.Object

Description:
abstract class of the IMS-CP Manager

Initial Date: 26.06.2008

Author:
sergio

Method Summary
abstract  java.lang.String addBlankPage(ContentPackage cp, java.lang.String title)
          Adds a blank new to the end of the organization
abstract  java.lang.String addBlankPage(ContentPackage cp, java.lang.String title, java.lang.String parentNodeID)
          Adds a blank new as a child of the node with given id
abstract  boolean addElement(ContentPackage cp, org.dom4j.tree.DefaultElement newElement)
           
abstract  boolean addElement(ContentPackage cp, org.dom4j.tree.DefaultElement newElement, java.lang.String parentIdentifier, int position)
          Adds a new Element to the manifest.
abstract  boolean addElementAfter(ContentPackage cp, org.dom4j.tree.DefaultElement newElement, java.lang.String identifier)
          adds a element to the manifest.
abstract  java.lang.String copyElement(ContentPackage cp, java.lang.String sourceID)
          duplicates the element with id "sourceID" and inserts it right after the source-Element
abstract  ContentPackage createNewCP(OLATResourceable ores, java.lang.String initalPageTitle)
          creates a new, empty ContentPackage
abstract  org.dom4j.tree.DefaultDocument getDocument(ContentPackage cp)
          Returns the DefaultDocument of the ContentPackage cp
abstract  org.dom4j.tree.DefaultElement getElementByIdentifier(ContentPackage cp, java.lang.String identifier)
          this is case-sensitive!
abstract  CPOrganization getFirstOrganizationInManifest(ContentPackage cp)
          Returns the top most element (if there are more than one)
abstract  CPPage getFirstPageToDisplay(ContentPackage cp)
          Returns the first (topmost) resource to display
static CPManager getInstance()
           
abstract  java.lang.String getItemTitle(ContentPackage cp, java.lang.String itemID)
          returns the title of an item with given id.
abstract  java.lang.String getPageByItemId(ContentPackage cp, java.lang.String itemIDentifier)
           
abstract  CPTreeDataModel getTreeDataModel(ContentPackage cp)
          Returns the CPTreeDataModel which is needed by the TreeController used for gui
abstract  boolean isSingleUsedResource(CPResource res, ContentPackage cp)
          Determines if the given Resource is referenced / linked only by one item-element.
abstract  ContentPackage load(VFSContainer directory, OLATResourceable ores)
          Generates a new Instance of ContentPackage and loads the xmlmanifest
abstract  void moveElement(ContentPackage cp, java.lang.String nodeID, java.lang.String newParentID, int position)
          Moves a Element(with id "sourceID") in cp.
abstract  void removeElement(ContentPackage cp, java.lang.String identifier, boolean deleteResource)
          removes a element from the manifest.
abstract  void updatePage(ContentPackage cp, CPPage page)
          updates the according elements in the datastructure
abstract  void writeToFile(ContentPackage cp)
          writes the ContentPackage-tree to the manifest-xml-file
abstract  VFSLeaf writeToZip(ContentPackage cp)
          Writes the cp to a zip file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static final CPManager getInstance()

load

public abstract ContentPackage load(VFSContainer directory,
                                    OLATResourceable ores)
Generates a new Instance of ContentPackage and loads the xmlmanifest

Parameters:
directory -
Returns:

createNewCP

public abstract ContentPackage createNewCP(OLATResourceable ores,
                                           java.lang.String initalPageTitle)
creates a new, empty ContentPackage

Parameters:
ores -
Returns:
the newly created CP

isSingleUsedResource

public abstract boolean isSingleUsedResource(CPResource res,
                                             ContentPackage cp)
Determines if the given Resource is referenced / linked only by one item-element. In other words: if the given resource is used only bye one item, this will return true

Parameters:
res -
cp -
Returns:
if given Resource is only used by one item-element, this returns true

addBlankPage

public abstract java.lang.String addBlankPage(ContentPackage cp,
                                              java.lang.String title)
Adds a blank new to the end of the organization

Returns:

addBlankPage

public abstract java.lang.String addBlankPage(ContentPackage cp,
                                              java.lang.String title,
                                              java.lang.String parentNodeID)
Adds a blank new as a child of the node with given id

Parameters:
parentNodeID -
Returns:

updatePage

public abstract void updatePage(ContentPackage cp,
                                CPPage page)
updates the according elements in the datastructure

Parameters:
cp -
page -

addElement

public abstract boolean addElement(ContentPackage cp,
                                   org.dom4j.tree.DefaultElement newElement)
Parameters:
cp -
newElement -
Returns:

addElement

public abstract boolean addElement(ContentPackage cp,
                                   org.dom4j.tree.DefaultElement newElement,
                                   java.lang.String parentIdentifier,
                                   int position)
Adds a new Element to the manifest. the new Element is inserted as a child of the element with id "parentIdentifier" if new position is null, element is added at the end

Parameters:
cp -
newElement - the new Element to add
parentIdentifier - the identifier of the parent element
position: - the new position of the moved element, can be null!
Returns:
true if successfully added

addElementAfter

public abstract boolean addElementAfter(ContentPackage cp,
                                        org.dom4j.tree.DefaultElement newElement,
                                        java.lang.String identifier)
adds a element to the manifest. Element is inserted after the Element with id "identifier"

Parameters:
cp - the contentPackage where the manipulation is performed on
newElement - the new Element to Add
identifier - the identifier of the previous element
Returns:
true if successfully added

removeElement

public abstract void removeElement(ContentPackage cp,
                                   java.lang.String identifier,
                                   boolean deleteResource)
removes a element from the manifest. If deleting an , all referenced resources are removed from the manifest as well.


moveElement

public abstract void moveElement(ContentPackage cp,
                                 java.lang.String nodeID,
                                 java.lang.String newParentID,
                                 int position)
Moves a Element(with id "sourceID") in cp. Inserts it into (as child) Element with id "targetID"

Parameters:
cp -
sourceID -
targetID -

copyElement

public abstract java.lang.String copyElement(ContentPackage cp,
                                             java.lang.String sourceID)
duplicates the element with id "sourceID" and inserts it right after the source-Element

Parameters:
cp -
sourceID -
Returns:
String the identifier of the newly generated element

getDocument

public abstract org.dom4j.tree.DefaultDocument getDocument(ContentPackage cp)
Returns the DefaultDocument of the ContentPackage cp

Returns:
the xml Document of the cp

getItemTitle

public abstract java.lang.String getItemTitle(ContentPackage cp,
                                              java.lang.String itemID)
returns the title of an item with given id. if element with id is not found or is not an , an empty String is returned

Parameters:
cp -
itemID -
Returns:
the title of the

getTreeDataModel

public abstract CPTreeDataModel getTreeDataModel(ContentPackage cp)
Returns the CPTreeDataModel which is needed by the TreeController used for gui

Parameters:
cp -
Returns:

getFirstOrganizationInManifest

public abstract CPOrganization getFirstOrganizationInManifest(ContentPackage cp)
Returns the top most element (if there are more than one)

Parameters:
cp -
Returns:

getFirstPageToDisplay

public abstract CPPage getFirstPageToDisplay(ContentPackage cp)
Returns the first (topmost) resource to display

Parameters:
cp -
Returns:

getPageByItemId

public abstract java.lang.String getPageByItemId(ContentPackage cp,
                                                 java.lang.String itemIDentifier)
Parameters:
cp -
itemIDentifier -
Returns:

writeToFile

public abstract void writeToFile(ContentPackage cp)
writes the ContentPackage-tree to the manifest-xml-file

Parameters:
cp -

writeToZip

public abstract VFSLeaf writeToZip(ContentPackage cp)
Writes the cp to a zip file.

Parameters:
cp -
Returns:
The VFS zip archive

getElementByIdentifier

public abstract org.dom4j.tree.DefaultElement getElementByIdentifier(ContentPackage cp,
                                                                     java.lang.String identifier)
this is case-sensitive!

Parameters:
identifier -
Returns:
an Element by its IDENTIFIER attribute starting at the manifests root element. This will do a deep recursive search