org.ispheres.server.core
Class Collection

java.lang.Object
  extended by org.ispheres.server.core.Collection

public class Collection
extends java.lang.Object

A Collection is an iSphere representation of a group of objects which are similar. That is to say objects in a collection are of the same type and are typically about the same subject domain.

Author:
Clinton Freeman mochumbo@users.sourceforge.net, Jonathan Mezach

Constructor Summary
Collection(java.io.File collectionPath, java.io.File collectionConfig, int collectionId, MetadataObject iSphereMetadata)
          Creates an empty collection.
 
Method Summary
 int add(MetadataObject localMetadata, DigitalObject digitalObject)
          create a new record from the MetadataObject and the ISphereObject and add it to the collection.
 void consistancyCheck(LogFile logfile)
          Check if the Collection passes the consistancy check.
 MetadataObject getCollectionMetadata()
          Returns the metadata which describes this collection.
 Schema getLocalSchema()
          This function returns the local schema of the collection.
 MetadataObject getMetadata(int sri, boolean universalSchema)
          Fetches a metadata object from the collection - the returned metadata object is in the local schema.
 DigitalObject getObject(int sri)
          Fetches a digital object from the collection..
 java.lang.Class getObjectType()
          Returns the type of ISphere object held in this collection.
 int getResultCount(java.lang.String searchTerm)
          Returns the amount of results that will be returned when calling search with the specified searchterm.
 DigitalObject getTransformedObject(int sri, TransformInterface[] transforms)
          Retrieves a transformed version of the object at the specified simple repository index.
 void remove(int sri)
          Remove an element from the srm, it removes the metadata object, the digital object.
 MetadataObject[] search(java.lang.String searchTerm, int start, int max, boolean universalSchema)
          Searches the local repository for objects that match the specified metadata.
 void setMetadata(int sri, MetadataObject m)
          Update an already existing record with new metadata.
 void setObject(int sri, DigitalObject o)
          Update an existing record with a new object.
 void tearDown()
          Shutdown the SimpleRepositoryModel.
 void writeConfiguration(org.w3c.dom.Element root)
          Writes out the configuration of the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Collection

public Collection(java.io.File collectionPath,
                  java.io.File collectionConfig,
                  int collectionId,
                  MetadataObject iSphereMetadata)
           throws java.io.IOException
Creates an empty collection.

Parameters:
collectionPath - The path at which the collection is located.
collectionConfig - The configuration filename that is used to configure the collection.
collectionId - The unique identifier of the collection within the iSphere.
iSphereMetadata - The metadata that is associated with the iSphere that contains the collection.
Throws:
java.io.IOException - Thrown when the configuration file could not be read.
Method Detail

add

public final int add(MetadataObject localMetadata,
                     DigitalObject digitalObject)
              throws ISphereException,
                     FatalException
create a new record from the MetadataObject and the ISphereObject and add it to the collection.

Parameters:
localMetadata - The metadata of the digital object being added to the collection. The metadata should be in the local schema.
digitalObject - The digital object being inserted into the local repository.
Returns:
The simple repository index of the newly inserted record.
Throws:
ISphereException - if the record is not added.
FatalException - if orphaned data is left in the connector.

consistancyCheck

public final void consistancyCheck(LogFile logfile)
                            throws java.io.IOException
Check if the Collection passes the consistancy check.

Parameters:
logfile - the LogFile to write to.
Throws:
java.io.IOException - if could not write to the LogFile.

getCollectionMetadata

public final MetadataObject getCollectionMetadata()
Returns the metadata which describes this collection.

Returns:
The metadata describing this collection.

getLocalSchema

public final Schema getLocalSchema()
This function returns the local schema of the collection.

Returns:
The schema of the local repository.

getMetadata

public final MetadataObject getMetadata(int sri,
                                        boolean universalSchema)
                                 throws ISphereException
Fetches a metadata object from the collection - the returned metadata object is in the local schema.

Parameters:
sri - The simple repository index of the object you wish to fetch.
universalSchema - If true this function will return the metadata in the universal schema, otherwise the local schema will be used.
Returns:
A metadata object in the local schema.
Throws:
ISphereException - When unable to read from the local repository.

getObject

public final DigitalObject getObject(int sri)
                              throws ISphereException
Fetches a digital object from the collection..

Parameters:
sri - The simple repository index of the object you wish to fetch.
Returns:
A valid ISphereObject
Throws:
ISphereException - When unable to read from the local repository.

getObjectType

public final java.lang.Class getObjectType()
Returns the type of ISphere object held in this collection.

Returns:
The type of class that is held in the collection.

remove

public final void remove(int sri)
                  throws ISphereException,
                         FatalException
Remove an element from the srm, it removes the metadata object, the digital object.

Parameters:
sri - The index of the record that is to be removed from the simple repository model
Throws:
ISphereException - if the item is not removed
FatalException - if orphaned data is left in the connector

getResultCount

public final int getResultCount(java.lang.String searchTerm)
                         throws ISphereException
Returns the amount of results that will be returned when calling search with the specified searchterm.

Parameters:
searchTerm - A String specifying what to search for.
Returns:
An int specifying the amount of results that will be returned by a search for the specified search term.
Throws:
ISphereException - Thrown when the result count cannot be retrieved

search

public final MetadataObject[] search(java.lang.String searchTerm,
                                     int start,
                                     int max,
                                     boolean universalSchema)
                              throws ISphereException
Searches the local repository for objects that match the specified metadata.

Parameters:
searchTerm - A term to search for.
start - The starting index in the results to start returning MetadataObjects from.
max - The maximum number of results to return.
universalSchema - If true return the results in the universal schema, otherwise return them in the local.
Returns:
An array of MetadataObjects that match the specified requirements.
Throws:
ISphereException - Thrown when the local repository could not be searched.

setMetadata

public final void setMetadata(int sri,
                              MetadataObject m)
                       throws ISphereException
Update an already existing record with new metadata.

Parameters:
sri - The index of the record whose metadata we wish to change.
m - The metadata to replace the old metadata with.
Throws:
ISphereException - If unable to write to the local repository.

setObject

public final void setObject(int sri,
                            DigitalObject o)
                     throws ISphereException
Update an existing record with a new object.

Parameters:
sri - The index of the record whose object we wish to change.
o - The new object to replace the old object with.
Throws:
ISphereException - if unable to write to the local repository.

getTransformedObject

public final DigitalObject getTransformedObject(int sri,
                                                TransformInterface[] transforms)
                                         throws ISphereException,
                                                TransformException
Retrieves a transformed version of the object at the specified simple repository index.

Parameters:
sri - An int specifying the simple repository index of the record to perform the transformation on.
transforms - An array of TransformInterfaces that holds the information for each of the transformations to perform.
Returns:
An ISphereObject to which the specified transformations have been performed.
Throws:
ISphereException - Thrown when the object could not be retrieved from the local repository, or when the transformation could not be a.
TransformException - Thrown when the transformations as defined by the transforms parameter cannot be performed.

writeConfiguration

public final void writeConfiguration(org.w3c.dom.Element root)
                              throws ISphereException
Writes out the configuration of the collection. It will first write out the location of the collection and its config file to the specified root element and will then write its own configuration to a seperate file.

Parameters:
root - The root collections element to which this collections location should be added.
Throws:
ISphereException - Thrown when the configuration

tearDown

public final void tearDown()
Shutdown the SimpleRepositoryModel.



Copyright © 2004-2005 The Archaeological Computing Laboratory, University of Sydney. All Rights Reserved.