Transfer version 1.1

transfer.com.sql
Class IDGenerator

WEB-INF.cftags.component
        extended by transfer.com.sql.IDGenerator

public class IDGenerator
extends WEB-INF.cftags.component

Generates IDs for a sequence


Constructor Summary
init(numeric changeFactor, Datasource datasource, XMLFileReader configReader, Utility utility)
          Constructor
 
Method Summary
private boolean checkHaveSequence(string name)
          Checks to see if the sequence is in the collection
private void createNewSequence(Object object)
          Creates a new sequence in the database if it doesn't exist
private void createSequenceTable()
          Creates the database table for you
private numeric getChangeFactor()
private numeric getCurrentIDFromSequence(string name)
          gets the Current ID from the sequence
private Datasource getDatasource()
 string getGUID()
          Returns a MS GUID, that is performant for indexing as per http://www.informit.com/articles/article.asp?p=25862
private numeric getIDFromSequence(Object object)
          Gets an ID from a given sequence
private numeric getMaxIDFromSequence(string name)
          gets the max ID from the sequence
 numeric getNumericID(Object object)
          Gets an numeric ID for a given object (synchronized)
private struct getSequenceCollection()
 uuid getUUID()
          Gets a UUID as an ID
private Utility getUtility()
private void increaseMaxIDForSequence(string name)
          Increases the MaxID for a sequence
private numeric incrementCurrentID(string name)
          retruns the currentID + 1 and increments it
private void initSequenceTable(XMLFileReader configReader)
          creates the sequence table, if it is needed
private void restoreSequence(Object object)
          restores a sequence from the DB
private numeric retrieveSequence(Object object, [boolean runOnce='false'], [boolean useBinding='true'])
          Retrives the current ID for the sequence
private void setChangeFactor(numeric ChangeFactor)
private void setCurrentIDFromSequence(string name, numeric currentID)
          Sets the Max ID for a sequence
private void setDatasource(Datasource Datasource)
private void setMaxIDFromSequence(string name, numeric maxID)
          Sets the Max ID for a sequence
private void setSequenceCollection(struct SequenceCollection)
private void setUtility(Utility Utility)
private any throw(string type, string message, [string detail=''])
          Throws an Exception
private void updateSequence(string name, numeric maxID)
          Updates the sequence in the db
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init(numeric changeFactor, Datasource datasource, XMLFileReader configReader, Utility utility)
Constructor

Parameters:
changeFactor - How many IDs to keep resident
datasource - Datasource for the applicaiton
configReader - The XML Reader for the config file
utility - The utility class
Method Detail

checkHaveSequence

private boolean checkHaveSequence(string name)
Checks to see if the sequence is in the collection

Parameters:
name - The name of the table

createNewSequence

private void createNewSequence(Object object)
Creates a new sequence in the database if it doesn't exist

Parameters:
object - The type of object to get the ID for

createSequenceTable

private void createSequenceTable()
Creates the database table for you


getChangeFactor

private numeric getChangeFactor()


getCurrentIDFromSequence

private numeric getCurrentIDFromSequence(string name)
gets the Current ID from the sequence

Parameters:
name - The name of the table

getDatasource

private Datasource getDatasource()


getGUID

public string getGUID()
Returns a MS GUID, that is performant for indexing as per http://www.informit.com/articles/article.asp?p=25862


getIDFromSequence

private numeric getIDFromSequence(Object object)
Gets an ID from a given sequence

Parameters:
object - The type of object to get the ID for

getMaxIDFromSequence

private numeric getMaxIDFromSequence(string name)
gets the max ID from the sequence

Parameters:
name - The name of the table

getNumericID

public numeric getNumericID(Object object)
Gets an numeric ID for a given object (synchronized)

Parameters:
object - The type of object to get the ID for

getSequenceCollection

private struct getSequenceCollection()


getUUID

public uuid getUUID()
Gets a UUID as an ID


getUtility

private Utility getUtility()


increaseMaxIDForSequence

private void increaseMaxIDForSequence(string name)
Increases the MaxID for a sequence

Parameters:
name - The name of the table

incrementCurrentID

private numeric incrementCurrentID(string name)
retruns the currentID + 1 and increments it

Parameters:
name - The name of the table

initSequenceTable

private void initSequenceTable(XMLFileReader configReader)
creates the sequence table, if it is needed

Parameters:
configReader - The XML Reader for the config file

restoreSequence

private void restoreSequence(Object object)
restores a sequence from the DB

Parameters:
object - The type of object to get the ID for

retrieveSequence

private numeric retrieveSequence(Object object, [boolean runOnce='false'], [boolean useBinding='true'])
Retrives the current ID for the sequence

Parameters:
object - The type of object to get the ID for
runOnce - Flag to see if this has been run recursively or not yet, to prevent infinite loop
useBinding - use the param bind

setChangeFactor

private void setChangeFactor(numeric ChangeFactor)

Parameters:
ChangeFactor

setCurrentIDFromSequence

private void setCurrentIDFromSequence(string name, numeric currentID)
Sets the Max ID for a sequence

Parameters:
name - The name of the table
currentID - The new currentID

setDatasource

private void setDatasource(Datasource Datasource)

Parameters:
Datasource

setMaxIDFromSequence

private void setMaxIDFromSequence(string name, numeric maxID)
Sets the Max ID for a sequence

Parameters:
name - The name of the table
maxID - The new maxID

setSequenceCollection

private void setSequenceCollection(struct SequenceCollection)

Parameters:
SequenceCollection

setUtility

private void setUtility(Utility Utility)

Parameters:
Utility

throw

private any throw(string type, string message, [string detail=''])
Throws an Exception

Parameters:
type - The type of exception
message - The message to accompany the exception
detail - The detail message for the exception

updateSequence

private void updateSequence(string name, numeric maxID)
Updates the sequence in the db

Parameters:
name - The name of the table
maxID - The new maxID

Transfer version 1.1