maito.integration
Class IntegratorHelper

java.lang.Object
  extended by maito.integration.IntegratorHelper

public class IntegratorHelper
extends java.lang.Object

Author:
Tuomas Tanner, Oskari Saarekas This software is released under the GNU GPL license

Constructor Summary
IntegratorHelper(java.util.Properties docs, java.util.Properties actors, java.util.Properties quickName)
           
 
Method Summary
static java.lang.String createDocID(Record rec)
          Creates an ID for a document-type resource.
 void createRelation(java.sql.Connection con, java.lang.String subject, java.lang.String object, java.lang.String roleType, boolean reversed)
          Creates a relation between two resources, and saves it in the DB's ResourceRelation table, unless one already exists.
static java.lang.String getFirstVal(java.util.Vector v)
          Returns the first String of a Vector, or null if not possible
 Resource getResource(java.sql.Connection con, java.lang.String resourceType, java.lang.String subType, java.lang.String newResID, java.lang.String canoName)
          Retrieves a Resource (by types and canoName) from the DB, or creates a new Resource if none exist.
 void integrateDocument(java.sql.Connection con, java.lang.String sourceID, Record rec)
           
 void integrateNameQuickFormat(java.sql.Connection con, java.lang.String sourceID, Record rec)
           
 void resolveDocumentReferences(java.sql.Connection con, Record rec, java.lang.String sourceID)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegratorHelper

public IntegratorHelper(java.util.Properties docs,
                        java.util.Properties actors,
                        java.util.Properties quickName)
Method Detail

integrateDocument

public void integrateDocument(java.sql.Connection con,
                              java.lang.String sourceID,
                              Record rec)
                       throws IntegrationException
Parameters:
sourceID - ID of the source of the parameter record
rec - the Record to be integrated
Throws:
IntegrationException

integrateNameQuickFormat

public void integrateNameQuickFormat(java.sql.Connection con,
                                     java.lang.String sourceID,
                                     Record rec)
                              throws IntegrationException
Parameters:
sourceID - ID of the source of the parameter record
rec - the Record representing a single record in the quickformat sourcefile
Throws:
IntegrationException

resolveDocumentReferences

public void resolveDocumentReferences(java.sql.Connection con,
                                      Record rec,
                                      java.lang.String sourceID)
                               throws IntegrationException
Parameters:
sourceID - ID of the source of the parameter record
records - a Vector filled with Records to be processed
Throws:
IntegrationException

getResource

public Resource getResource(java.sql.Connection con,
                            java.lang.String resourceType,
                            java.lang.String subType,
                            java.lang.String newResID,
                            java.lang.String canoName)
                     throws IntegrationException
Retrieves a Resource (by types and canoName) from the DB, or creates a new Resource if none exist. If a new Resource is created, parameters are used to pre-fill some fields.

Parameters:
con - Connection to the DB. Make sure it's not null!
resourceType - Actor, Channel, Document or Role
subType - detailed type of the resource. Make sure it corresponds to the DB table column specifications!
newResID - ID of the resource if a new one is created. Note: if the ID is already in use, a number will be automatically appended to create a unique ID
canoName - Canonized name
Throws:
IntegrationException

createRelation

public void createRelation(java.sql.Connection con,
                           java.lang.String subject,
                           java.lang.String object,
                           java.lang.String roleType,
                           boolean reversed)
                    throws IntegrationException
Creates a relation between two resources, and saves it in the DB's ResourceRelation table, unless one already exists. The specified role resource is created, unless one already exists. Role types 'NONE' and 'BIBREF' are special values for Channel/Document and Document/Document relations respectively. These should be pre-inserted in the DB during the DB table setup.

Parameters:
con - Connection to the DB. Make sure it's not null!
subject - ID of the resource that points
object - ID of the resource that is being pointed
roleType - type of the relation, must be one of the enumerated values for DB's Role.type column
reversed - set true to reverse the direction of the relation (subject becomes object and vice versa)
Throws:
IntegrationException

createDocID

public static java.lang.String createDocID(Record rec)
Creates an ID for a document-type resource. The ID is derived from the fields of the parameter-Record


getFirstVal

public static java.lang.String getFirstVal(java.util.Vector v)
Returns the first String of a Vector, or null if not possible