org.vivoweb.harvester.util.repo
Class JenaRecordHandler

java.lang.Object
  extended by org.vivoweb.harvester.util.repo.RecordHandler
      extended by org.vivoweb.harvester.util.repo.JenaRecordHandler
All Implemented Interfaces:
java.lang.Iterable<Record>

public class JenaRecordHandler
extends RecordHandler

RecordHandler that stores data in a Jena Model

Author:
Christopher Haines (hainesc@ctrip.ufl.edu)

Field Summary
protected  com.hp.hpl.jena.rdf.model.Property dataType
          data type
protected  com.hp.hpl.jena.rdf.model.Property idType
          id type
protected  com.hp.hpl.jena.rdf.model.Property isA
          rdf:type
protected  com.hp.hpl.jena.rdf.model.Property metaCal
          metadata calendar
protected  com.hp.hpl.jena.rdf.model.Property metaMD5
          metadata md5
protected  com.hp.hpl.jena.rdf.model.Property metaOperation
          metadata operation
protected  com.hp.hpl.jena.rdf.model.Property metaOperator
          metadata operator
protected  com.hp.hpl.jena.rdf.model.Property metaRel
          metadata relation
protected  com.hp.hpl.jena.rdf.model.Property metaType
          metadata type
protected  JenaConnect model
          the jena model we are using to store records
protected  com.hp.hpl.jena.rdf.model.Property recType
          record type
protected static java.lang.String rhNameSpace
          namespace for recordhandlers
 
Constructor Summary
protected JenaRecordHandler()
          Default Constructor
  JenaRecordHandler(JenaConnect jena, java.lang.String dataFieldType)
          Constructor (w/ Given Model)
  JenaRecordHandler(java.lang.String configFile, java.lang.String dataFieldType)
          Constructor (w/ Model Config File)
 
Method Summary
protected  void addMetaData(Record rec, RecordMetaData rmd)
          Adds a metadata record
 boolean addRecord(Record rec, java.lang.Class<?> creator, boolean overwrite)
          Adds a record to the RecordHandler
 void close()
          Closes the recordhandler
protected  void delMetaData(java.lang.String recID)
          Deletes all metadata for a record
 void delRecord(java.lang.String recID)
          Delete the specified Record
 java.util.Set<java.lang.String> find(java.lang.String idText)
          Find records with idText in their id
 java.lang.String getRecordData(java.lang.String recID)
          Retrieve the data for a given record
protected  java.util.SortedSet<RecordMetaData> getRecordMetaData(java.lang.String recID)
          Retrieves all metadata for a given record
 java.util.Iterator<Record> iterator()
           
 void setParams(java.util.Map<java.lang.String,java.lang.String> params)
          Sets parameters from param list
 
Methods inherited from class org.vivoweb.harvester.util.repo.RecordHandler
addMetaData, addRecord, addRecord, addRecord, getLastMetaData, getParam, getRecord, isOverwriteDefault, needsProcessed, needsUpdated, parseConfig, parseConfig, parseConfig, parseConfig, parseConfig, parseConfig, parseConfig, setOverwriteDefault, setProcessed, setWritten
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected JenaConnect model
the jena model we are using to store records


rhNameSpace

protected static final java.lang.String rhNameSpace
namespace for recordhandlers

See Also:
Constant Field Values

recType

protected com.hp.hpl.jena.rdf.model.Property recType
record type


idType

protected com.hp.hpl.jena.rdf.model.Property idType
id type


dataType

protected com.hp.hpl.jena.rdf.model.Property dataType
data type


isA

protected com.hp.hpl.jena.rdf.model.Property isA
rdf:type


metaType

protected com.hp.hpl.jena.rdf.model.Property metaType
metadata type


metaRel

protected com.hp.hpl.jena.rdf.model.Property metaRel
metadata relation


metaCal

protected com.hp.hpl.jena.rdf.model.Property metaCal
metadata calendar


metaOperation

protected com.hp.hpl.jena.rdf.model.Property metaOperation
metadata operation


metaOperator

protected com.hp.hpl.jena.rdf.model.Property metaOperator
metadata operator


metaMD5

protected com.hp.hpl.jena.rdf.model.Property metaMD5
metadata md5

Constructor Detail

JenaRecordHandler

protected JenaRecordHandler()
Default Constructor


JenaRecordHandler

public JenaRecordHandler(JenaConnect jena,
                         java.lang.String dataFieldType)
Constructor (w/ Given Model)

Parameters:
jena - the model to use
dataFieldType - rdf Predicate (including namespace) that describes data type

JenaRecordHandler

public JenaRecordHandler(java.lang.String configFile,
                         java.lang.String dataFieldType)
                  throws java.io.IOException
Constructor (w/ Model Config File)

Parameters:
configFile - the model config file
dataFieldType - rdf Predicate (including namespace) that describes data type
Throws:
java.io.IOException - error connecting
Method Detail

addRecord

public boolean addRecord(Record rec,
                         java.lang.Class<?> creator,
                         boolean overwrite)
                  throws java.io.IOException
Description copied from class: RecordHandler
Adds a record to the RecordHandler

Specified by:
addRecord in class RecordHandler
Parameters:
rec - record to add
creator - the creator
overwrite - when set to true, will automatically overwrite existing records
Returns:
true if added, false if not needed (aka record already existed and was the same)
Throws:
java.io.IOException - error adding

delRecord

public void delRecord(java.lang.String recID)
               throws java.io.IOException
Description copied from class: RecordHandler
Delete the specified Record

Specified by:
delRecord in class RecordHandler
Parameters:
recID - id of record to delete
Throws:
java.io.IOException - i/o error

getRecordData

public java.lang.String getRecordData(java.lang.String recID)
                               throws java.lang.IllegalArgumentException,
                                      java.io.IOException
Description copied from class: RecordHandler
Retrieve the data for a given record

Specified by:
getRecordData in class RecordHandler
Parameters:
recID - id of record to retrieve
Returns:
data from record
Throws:
java.lang.IllegalArgumentException - id not found
java.io.IOException - error reading

iterator

public java.util.Iterator<Record> iterator()

setParams

public void setParams(java.util.Map<java.lang.String,java.lang.String> params)
               throws java.io.IOException
Description copied from class: RecordHandler
Sets parameters from param list

Specified by:
setParams in class RecordHandler
Parameters:
params - map of parameters
Throws:
java.io.IOException - error

addMetaData

protected void addMetaData(Record rec,
                           RecordMetaData rmd)
                    throws java.io.IOException
Description copied from class: RecordHandler
Adds a metadata record

Specified by:
addMetaData in class RecordHandler
Parameters:
rec - record to add metadata for
rmd - the metadata record
Throws:
java.io.IOException - error adding meta data

delMetaData

protected void delMetaData(java.lang.String recID)
                    throws java.io.IOException
Description copied from class: RecordHandler
Deletes all metadata for a record

Specified by:
delMetaData in class RecordHandler
Parameters:
recID - record id to delete metadata for
Throws:
java.io.IOException - error deleting metadata

getRecordMetaData

protected java.util.SortedSet<RecordMetaData> getRecordMetaData(java.lang.String recID)
                                                         throws java.io.IOException
Description copied from class: RecordHandler
Retrieves all metadata for a given record

Specified by:
getRecordMetaData in class RecordHandler
Parameters:
recID - id of record to retrieve metadata for
Returns:
the metadata map
Throws:
java.io.IOException - error retrieving record metadata

close

public void close()
           throws java.io.IOException
Description copied from class: RecordHandler
Closes the recordhandler

Specified by:
close in class RecordHandler
Throws:
java.io.IOException - error closing

find

public java.util.Set<java.lang.String> find(java.lang.String idText)
Description copied from class: RecordHandler
Find records with idText in their id

Specified by:
find in class RecordHandler
Parameters:
idText - the text to find
Returns:
list of ids that match