org.olat.ims.cp
Class CPCore

java.lang.Object
  extended by org.olat.ims.cp.CPCore

public class CPCore
extends java.lang.Object

Description:
This class provides basic functionality for a IMS Content Package

Initial Date: 27.06.2008

Author:
Sergio Trentini

Field Summary
static java.lang.String BASE
           
static java.lang.String DEFAULT
           
static java.lang.String DEPENDENCY
           
static java.lang.String FILE
           
static java.lang.String HREF
           
static java.lang.String IDENTIFIER
           
static java.lang.String IDENTIFIERREF
           
static java.lang.String ISVISIBLE
           
static java.lang.String ITEM
           
static java.lang.String MANIFEST
           
static java.lang.String MANIFEST_NAME
          The CP Manifest name
static java.lang.String METADATA
           
static java.lang.String OLAT_MANIFEST_IDENTIFIER
           
static java.lang.String OLAT_ORGANIZATION_IDENTIFIER
           
static java.lang.String ORGANIZATION
           
static java.lang.String ORGANIZATIONS
           
static java.lang.String PARAMETERS
           
static java.lang.String RESOURCE
           
static java.lang.String RESOURCES
           
static java.lang.String SCHEMA
           
static java.lang.String SCHEMALOCATION
           
static java.lang.String SCHEMAVERSION
           
static java.lang.String STRUCTURE
           
static java.lang.String TITLE
           
static java.lang.String TYPE
           
static java.lang.String VERSION
           
 
Constructor Summary
CPCore(org.dom4j.tree.DefaultDocument doc, VFSContainer rootDir)
           
 
Method Summary
 void addElement(org.dom4j.tree.DefaultElement newElement)
          adds an element to the CP.
 boolean addElement(org.dom4j.tree.DefaultElement newElement, java.lang.String parentId, int position)
          adds an element as a child to the element with id parentId if the element with parentId is not found, it returns false if adding was successful, it returns true
 boolean addElementAfter(org.dom4j.tree.DefaultElement newElement, java.lang.String id)
          adds an element to the cp.
 org.dom4j.tree.DefaultDocument buildDocument()
          Returns the DefaultDocument of this CP
 void buildTree()
          parses the document, builds manifest-datamodel-tree-structure
 java.lang.String copyElement(java.lang.String sourceID, java.lang.String targetID)
          duplicates an element and inserts it after targetID
 org.dom4j.tree.DefaultElement findReferencesToResource(java.lang.String resourceIdentifier)
          Searches for -elements or -elements which references to the resource with id "resourceIdentifier" if an element is found, search is aborted and the found element is returned
 org.dom4j.tree.DefaultElement getElementByIdentifier(java.lang.String identifier)
          this is case-sensitive!
 CPOrganization getFirstOrganizationInManifest()
          returns the first element of this manifest Note: IMS standard allows multiple -elements
 CPItem getFirstPageToDisplay()
          Returns the first page within the given organization returns null if no page found (empty organization)
 java.lang.String getItemTitle(java.lang.String itemID)
          returns the item of an element (with given identifier) in the manifest
 java.lang.String getPageByItemID(java.lang.String id)
          Gets the linked page for the element with given id if no resource (page) is referenced, null is returned
 VFSContainer getRootDir()
           
 CPManifest getRootNode()
          Returns the rootNode of the manifest
 boolean isOLATContentPackage()
           
 void moveElement(java.lang.String nodeID, java.lang.String newParentID, int position)
           
 void removeElement(java.lang.String identifier, boolean resourceFlag)
          removes an element with identifier "identifier" from the manifest
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANIFEST_NAME

public static final java.lang.String MANIFEST_NAME
The CP Manifest name

See Also:
Constant Field Values

MANIFEST

public static final java.lang.String MANIFEST
See Also:
Constant Field Values

ORGANIZATIONS

public static final java.lang.String ORGANIZATIONS
See Also:
Constant Field Values

RESOURCES

public static final java.lang.String RESOURCES
See Also:
Constant Field Values

DEFAULT

public static final java.lang.String DEFAULT
See Also:
Constant Field Values

ORGANIZATION

public static final java.lang.String ORGANIZATION
See Also:
Constant Field Values

ITEM

public static final java.lang.String ITEM
See Also:
Constant Field Values

PARAMETERS

public static final java.lang.String PARAMETERS
See Also:
Constant Field Values

RESOURCE

public static final java.lang.String RESOURCE
See Also:
Constant Field Values

BASE

public static final java.lang.String BASE
See Also:
Constant Field Values

FILE

public static final java.lang.String FILE
See Also:
Constant Field Values

TYPE

public static final java.lang.String TYPE
See Also:
Constant Field Values

HREF

public static final java.lang.String HREF
See Also:
Constant Field Values

METADATA

public static final java.lang.String METADATA
See Also:
Constant Field Values

IDENTIFIER

public static final java.lang.String IDENTIFIER
See Also:
Constant Field Values

IDENTIFIERREF

public static final java.lang.String IDENTIFIERREF
See Also:
Constant Field Values

STRUCTURE

public static final java.lang.String STRUCTURE
See Also:
Constant Field Values

TITLE

public static final java.lang.String TITLE
See Also:
Constant Field Values

DEPENDENCY

public static final java.lang.String DEPENDENCY
See Also:
Constant Field Values

VERSION

public static final java.lang.String VERSION
See Also:
Constant Field Values

SCHEMA

public static final java.lang.String SCHEMA
See Also:
Constant Field Values

SCHEMALOCATION

public static final java.lang.String SCHEMALOCATION
See Also:
Constant Field Values

SCHEMAVERSION

public static final java.lang.String SCHEMAVERSION
See Also:
Constant Field Values

ISVISIBLE

public static final java.lang.String ISVISIBLE
See Also:
Constant Field Values

OLAT_MANIFEST_IDENTIFIER

public static final java.lang.String OLAT_MANIFEST_IDENTIFIER
See Also:
Constant Field Values

OLAT_ORGANIZATION_IDENTIFIER

public static final java.lang.String OLAT_ORGANIZATION_IDENTIFIER
See Also:
Constant Field Values
Constructor Detail

CPCore

public CPCore(org.dom4j.tree.DefaultDocument doc,
              VFSContainer rootDir)
Method Detail

buildTree

public void buildTree()
parses the document, builds manifest-datamodel-tree-structure


getElementByIdentifier

public org.dom4j.tree.DefaultElement getElementByIdentifier(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

addElement

public boolean addElement(org.dom4j.tree.DefaultElement newElement,
                          java.lang.String parentId,
                          int position)
adds an element as a child to the element with id parentId if the element with parentId is not found, it returns false if adding was successful, it returns true


addElement

public void addElement(org.dom4j.tree.DefaultElement newElement)
adds an element to the CP. Only accepts and elements

Parameters:
newElement -

addElementAfter

public boolean addElementAfter(org.dom4j.tree.DefaultElement newElement,
                               java.lang.String id)
adds an element to the cp. Adds it after the item with identifier "id"

Parameters:
newElement -
id -
Returns:

removeElement

public void removeElement(java.lang.String identifier,
                          boolean resourceFlag)
removes an element with identifier "identifier" from the manifest

Parameters:
identifier - the identifier if the element to remove
booleanFlag - indicates whether to remove linked resources as well...! (needed for moving elements)

moveElement

public void moveElement(java.lang.String nodeID,
                        java.lang.String newParentID,
                        int position)

copyElement

public java.lang.String copyElement(java.lang.String sourceID,
                                    java.lang.String targetID)
duplicates an element and inserts it after targetID

Parameters:
sourceID -
targetID -

findReferencesToResource

public org.dom4j.tree.DefaultElement findReferencesToResource(java.lang.String resourceIdentifier)
Searches for -elements or -elements which references to the resource with id "resourceIdentifier" if an element is found, search is aborted and the found element is returned

Parameters:
resourceIdentifier -
Returns:
the found element or null

getRootNode

public CPManifest getRootNode()
Returns the rootNode of the manifest

Returns:
CPManifest

getRootDir

public VFSContainer getRootDir()

buildDocument

public org.dom4j.tree.DefaultDocument buildDocument()
Returns the DefaultDocument of this CP

Returns:
the xml Document of this CP

getFirstOrganizationInManifest

public CPOrganization getFirstOrganizationInManifest()
returns the first element of this manifest Note: IMS standard allows multiple -elements

Returns:

getPageByItemID

public java.lang.String getPageByItemID(java.lang.String id)
Gets the linked page for the element with given id if no resource (page) is referenced, null is returned

Parameters:
id -
Returns:

getFirstPageToDisplay

public CPItem getFirstPageToDisplay()
Returns the first page within the given organization returns null if no page found (empty organization)

Returns:

getItemTitle

public java.lang.String getItemTitle(java.lang.String itemID)
returns the item of an element (with given identifier) in the manifest

Parameters:
itemID - the identifier of the item
Returns:
returns the title. returns null if element is not found, or element is not an

isOLATContentPackage

public boolean isOLATContentPackage()
Returns:
Returns a true if the CP was created with the OLAT CP editor or exported from an OLAT wiki. False otherwise.