se.kmr.scam.rdf.util
Class IMSCPUtil

java.lang.Object
  extended byse.kmr.scam.rdf.util.IMSCPUtil

public class IMSCPUtil
extends Object

Helper for IMS Content Packaging.

Title:

Description:

Copyright: Copyright (c) 2002

Company:

Version:
'$Revision $'
Author:
jand

Field Summary
protected static org.apache.log4j.Category LOG
          Log4j-logger
 
Constructor Summary
IMSCPUtil()
           
 
Method Summary
static boolean addItem(Model m, Resource parent, Resource item)
          Add sub-item to an IMS Container.
static Resource createManifest(Model m, String uri, String defaultUri)
          Create the default structure of an IMSCP Manifest, including an anonymous default IMSCP Hierarchy.
static Resource getContent(Model m, Resource item)
          Get the IMSCP.content-resource of an Item
static Resource getDefaultOrg(Model m)
          Fetch the default IMSCP Organization resource
static Resource getItemWithProperty(Model m, Resource parent, Property prop, RDFNode value)
          Get the sub-item (child) having the given Property-Value.
static Resource getManifest(Model m)
          Fetch the IMSCP.manifest resource
static Resource getParent(Model m, Resource res)
          Fetch IMS Container referencing res by RDF.li.
static boolean hasContainer(Model m)
          Does the model contain an IMS Container?
static boolean hasManifest(Model m)
          See if model contains an IMS.manifest
static boolean isContainer(Model m, Resource res)
          Is resource a IMSCP container, i.e.
static boolean isContainer(Resource res)
           
static boolean isContainer(Statement stm)
           
static boolean isContentItem(Model m, Resource res)
           
static boolean isFolder(Model m, Resource res)
           
static boolean isFolderLink(Model m, Resource res)
          Check if content-Resource is a "link" to a Folder, i.e. has a property SCAM.inModel and is an IMS Folder.
static boolean isLink(Model m, Resource res)
          Check if content-Resource is a "link", i.e. has a property SCAM.inModel.
static List listAllItems(Model m, Resource parent)
          List all ancestors of an IMS Container.
static List listContainers(Model m)
          List all IMS Containers
static List listItems(Model m, Resource parent)
          List sub-items of an IMS Container.
static List listNonContainers(Model m)
          List all resources that is NOT an IMS Container
static List listNonIMSResources(Model m)
          List all resources that is NOT an IMS Resource, i.e. does NOT have an RDF.type-object with IMSCP Namespace
static List listReferences(Model m, Resource res)
          List IMS Items referencing res by IMSCP.content .
static void main(String[] args)
           
static boolean removeItem(Model m, Resource parent, Resource item)
          Remove sub-item from an IMS Container.
static boolean removeParentRef(Model m, Resource child)
          Remove RDF.li parent reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static org.apache.log4j.Category LOG
Log4j-logger

Constructor Detail

IMSCPUtil

public IMSCPUtil()
Method Detail

isContainer

public static boolean isContainer(Model m,
                                  Resource res)
                           throws RDFException
Is resource a IMSCP container, i.e. IMSCP.item?

Parameters:
m - Model
res - Resource
Returns:
false if resource not found or non-container
Throws:
RDFException

isContainer

public static boolean isContainer(Resource res)
                           throws RDFException
Throws:
RDFException

isContainer

public static boolean isContainer(Statement stm)
                           throws RDFException
Throws:
RDFException

isFolder

public static boolean isFolder(Model m,
                               Resource res)
                        throws RDFException
Throws:
RDFException

isContentItem

public static boolean isContentItem(Model m,
                                    Resource res)
                             throws RDFException
Throws:
RDFException

createManifest

public static Resource createManifest(Model m,
                                      String uri,
                                      String defaultUri)
                               throws RDFException
Create the default structure of an IMSCP Manifest, including an anonymous default IMSCP Hierarchy.

Parameters:
m - Model
uri - The Manifest URI
defaultUri - The default hierarchy URI
Returns:
The Manifest resource
Throws:
RDFException
To do:
Anonymous default hierarchy?

hasManifest

public static boolean hasManifest(Model m)
                           throws RDFException
See if model contains an IMS.manifest

Parameters:
m - Model
Returns:
true if so
Throws:
RDFException

getManifest

public static Resource getManifest(Model m)
                            throws RDFException
Fetch the IMSCP.manifest resource

Parameters:
m - Model
Returns:
IMSCP.manifest or null if not found
Throws:
RDFException

getDefaultOrg

public static Resource getDefaultOrg(Model m)
                              throws RDFException
Fetch the default IMSCP Organization resource

Parameters:
m - Model
Returns:
IMSCP Container or null if not found
Throws:
RDFException

getParent

public static Resource getParent(Model m,
                                 Resource res)
                          throws RDFException
Fetch IMS Container referencing res by RDF.li.

Parameters:
m - Model
res - Resource (child)
Returns:
IMS Container (parent) of res
Throws:
RDFException

getItemWithProperty

public static Resource getItemWithProperty(Model m,
                                           Resource parent,
                                           Property prop,
                                           RDFNode value)
                                    throws RDFException
Get the sub-item (child) having the given Property-Value. If multiple items applies the first will be returned.

Parameters:
m - Model
parent - Parent Item
prop - Property to look for
value - Value of that property
Returns:
Item or null if not found
Throws:
RDFException

getContent

public static Resource getContent(Model m,
                                  Resource item)
                           throws RDFException
Get the IMSCP.content-resource of an Item

Parameters:
m - Model
item - Item
Returns:
content-Resource or null if not found
Throws:
RDFException

isFolderLink

public static boolean isFolderLink(Model m,
                                   Resource res)
                            throws RDFException
Check if content-Resource is a "link" to a Folder, i.e. has a property SCAM.inModel and is an IMS Folder.

Parameters:
m - Model
res - content-Resource
Returns:
true if Folder-link
Throws:
RDFException

isLink

public static boolean isLink(Model m,
                             Resource res)
                      throws RDFException
Check if content-Resource is a "link", i.e. has a property SCAM.inModel.

Parameters:
m - Model
res - content-Resource
Returns:
true if link
Throws:
RDFException

hasContainer

public static boolean hasContainer(Model m)
                            throws RDFException
Does the model contain an IMS Container?

Parameters:
m - Model
Returns:
true if so.
Throws:
RDFException

addItem

public static boolean addItem(Model m,
                              Resource parent,
                              Resource item)
                       throws RDFException
Add sub-item to an IMS Container.
Note: Parent must be an IMS Container.
Note: Verify that item is an IMS Container!

Parameters:
m - Model
parent - Parent IMS Container
item - New item.
Returns:
true if item could be added.
Throws:
RDFException - if parent/item is NOT IMS Containers

removeItem

public static boolean removeItem(Model m,
                                 Resource parent,
                                 Resource item)
                          throws RDFException
Remove sub-item from an IMS Container.

Parameters:
m - Model
parent - Parent IMS Container
item - New item.
Returns:
true if item could be removed.
Throws:
RDFException - if parent is NOT an IMS Container

listItems

public static List listItems(Model m,
                             Resource parent)
                      throws RDFException
List sub-items of an IMS Container.

Parameters:
m - Model
parent - IMS Container
Returns:
Collection of Resources
Throws:
RDFException

listAllItems

public static List listAllItems(Model m,
                                Resource parent)
                         throws RDFException
List all ancestors of an IMS Container. Recursive.

Parameters:
m - Model
parent - IMS Container
Returns:
Collection of Resources
Throws:
RDFException

listContainers

public static List listContainers(Model m)
                           throws RDFException
List all IMS Containers

Parameters:
m - Model
Returns:
Collection of Resources
Throws:
RDFException

listNonContainers

public static List listNonContainers(Model m)
                              throws RDFException
List all resources that is NOT an IMS Container

Parameters:
m - Model
Returns:
Collection of Resources
Throws:
RDFException

listNonIMSResources

public static List listNonIMSResources(Model m)
                                throws RDFException
List all resources that is NOT an IMS Resource, i.e. does NOT have an RDF.type-object with IMSCP Namespace

Parameters:
m - Model
Returns:
Collection of Resources
Throws:
RDFException
To do:
is this OK?

listReferences

public static List listReferences(Model m,
                                  Resource res)
                           throws RDFException
List IMS Items referencing res by IMSCP.content .

Parameters:
m - Model
res - Resource
Returns:
Collection of Resources
Throws:
RDFException - Description of the Exception

removeParentRef

public static boolean removeParentRef(Model m,
                                      Resource child)
                               throws RDFException
Remove RDF.li parent reference.

Parameters:
m - Model
child - Remove reference to this Item
Returns:
true if removed
Throws:
RDFException

main

public static void main(String[] args)


Copyright © 2003 SCAM. All Rights Reserved.