org.lexevs.registry.service
Class XmlRegistry

java.lang.Object
  extended by org.lexevs.registry.service.XmlRegistry
All Implemented Interfaces:
Registry

public class XmlRegistry
extends java.lang.Object
implements Registry

This class stores and provides access to information about loaded and tagged terminologies. Locking guidelines - any method that makes changes that are supposed to be written out to the xml file must first - get a lock on the main lock file. check for changes. read in the latest changes, if there are any. Then, make the changes, write out the xml file, and finally, release the lock on the lock file.

Version:
subversion $Revision: $ checked in on $Date: $
Author:
Dan Armbrust, Jesse Erdmann

Nested Class Summary
static class XmlRegistry.DBEntry
          The Class DBEntry.
static class XmlRegistry.HistoryEntry
          The Class HistoryEntry.
 
Nested classes/interfaces inherited from interface org.lexevs.registry.service.Registry
Registry.KnownTags, Registry.ResourceType
 
Constructor Summary
XmlRegistry(java.lang.String pathToRegistryFile)
          Instantiates a new xml registry.
XmlRegistry(SystemVariables systemVariables)
          Instantiates a new xml registry.
 
Method Summary
 void activate(AbsoluteCodingSchemeVersionReference codingScheme)
          Activate a code system.
 XmlRegistry.HistoryEntry addNewHistory(java.lang.String urn, java.lang.String dbURL, java.lang.String dbName, java.lang.String tablePrefix)
          Add a new history item to the registry.
 void addNewItem(RegistryEntry entry)
          Adds the new item.
 void addNewItem(java.lang.String urn, java.lang.String version, java.lang.String status, java.lang.String dbURL, java.lang.String tag, java.lang.String dbName, java.lang.String tablePrefix)
          Adds the new item.
 boolean containsCodingSchemeEntry(AbsoluteCodingSchemeVersionReference codingScheme)
          Contains coding scheme entry.
 boolean containsNonCodingSchemeEntry(java.lang.String uri)
          Contains non coding scheme entry.
 void deactivate(XmlRegistry.DBEntry entry)
          Deactivate.
 java.util.List<RegistryEntry> getAllRegistryEntries()
          Gets the all registry entries.
 java.util.List<RegistryEntry> getAllRegistryEntriesOfType(Registry.ResourceType type)
          Gets the all registry entries of type.
 java.util.List<RegistryEntry> getAllRegistryEntriesOfTypeAndURI(Registry.ResourceType type, java.lang.String uri)
          Gets the all registry entries of type and URI.
 java.util.List<RegistryEntry> getAllRegistryEntriesOfTypeURIAndVersion(Registry.ResourceType type, java.lang.String uri, java.lang.String version)
          Gets the all registry entries of type, URI and version.
 RegistryEntry getCodingSchemeEntry(AbsoluteCodingSchemeVersionReference codingScheme)
          Gets the coding scheme entry.
 javax.sql.DataSource getDataSource()
          Gets the data source.
 XmlRegistry.DBEntry getDBCodingSchemeEntry(AbsoluteCodingSchemeVersionReference codingScheme)
          Gets the dB coding scheme entry.
 XmlRegistry.DBEntry[] getDBEntries()
          Gets the db entries.
 java.util.Date getDeactivateDate(java.lang.String codingSchemeURN, java.lang.String version)
          Gets the deactivate date.
 java.util.List<RegistryEntry> getEntriesForUri(java.lang.String uri)
          Gets the entries for uri.
 XmlRegistry.DBEntry getEntry(java.lang.String codingSchemeURN, java.lang.String version)
          Gets the entry.
 XmlRegistry.HistoryEntry[] getHistoryEntries()
          Gets the history entries.
 XmlRegistry.HistoryEntry getHistoryEntry(java.lang.String urn)
          Gets the history entry.
 java.util.Date getLastUpdateDate(java.lang.String codingSchemeURN, java.lang.String version)
          Gets the last update date.
 java.util.Date getLastUpdateTime()
          Gets the last update time.
protected  LgLoggerIF getLogger()
          Gets the logger.
 java.lang.String getNextDBIdentifier()
          Gets the next db identifier.
 java.lang.String getNextHistoryIdentifier()
          Gets the next history identifier.
 RegistryEntry getNonCodingSchemeEntry(java.lang.String uri)
          Gets the non coding scheme entry.
protected  java.io.File getRegistryFile()
          Gets the registry file.
 SQLConnectionInfo getSQLConnectionInfoForCodeSystem(AbsoluteCodingSchemeVersionReference codingSchemeVersion)
          Gets the sQL connection info for code system.
 SQLConnectionInfo[] getSQLConnectionInfoForHistory(java.lang.String urn)
          Gets the sQL connection info for history.
 CodingSchemeVersionStatus getStatus(java.lang.String codingSchemeURN, java.lang.String version)
          Gets the status.
protected  java.lang.String getSupportedLexGridSchemaVersionForCodingScheme(AbsoluteCodingSchemeVersionReference ref)
          Gets the supported lex grid schema version for coding scheme.
protected  java.lang.String getSupportedLexGridSchemaVersionForHistory(java.lang.String uri)
          Gets the supported lex grid schema version for history.
 java.lang.String getTag(java.lang.String codingSchemeURN, java.lang.String version)
          Gets the tag.
 java.lang.String getVersionForTag(java.lang.String urn, java.lang.String tag)
          Gets the version for tag.
 boolean isActive(java.lang.String codingSchemeURN, java.lang.String version)
          Checks if is active.
 void remove(AbsoluteCodingSchemeVersionReference codingSchemeVersion)
          Removes the.
 void removeEntry(RegistryEntry entry)
          Removes the entry.
 void removeHistoryEntry(java.lang.String urn)
          Removes the history entry.
 void setDataSource(javax.sql.DataSource dataSource)
          Sets the data source.
 void setDeactivateDate(AbsoluteCodingSchemeVersionReference acsvr, java.util.Date date)
          Sets the deactivate date.
 void setDeactivateDateInternal(AbsoluteCodingSchemeVersionReference acsvr, java.util.Date date)
          Sets the deactivate date internal.
 void setStatusPending(XmlRegistry.DBEntry entry)
          Sets the status pending.
 void updateCodingSchemeEntryTag(AbsoluteCodingSchemeVersionReference codingScheme, java.lang.String newTag)
          Update coding scheme entry tag.
 void updateEntry(RegistryEntry entry)
          Update entry.
 void updateTag(AbsoluteCodingSchemeVersionReference codingScheme, java.lang.String newTag)
          Update tag.
 void updateURNVersion(AbsoluteCodingSchemeVersionReference oldURNVerison, AbsoluteCodingSchemeVersionReference newURNVerison)
          Activate a code system.
 void updateVersion(AbsoluteCodingSchemeVersionReference codingScheme, java.lang.String newVersion)
          Update version.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlRegistry

public XmlRegistry(SystemVariables systemVariables)
            throws java.lang.Exception
Instantiates a new xml registry.

Parameters:
systemVariables - the system variables
Throws:
java.lang.Exception - the exception

XmlRegistry

public XmlRegistry(java.lang.String pathToRegistryFile)
            throws java.lang.Exception
Instantiates a new xml registry.

Parameters:
pathToRegistryFile - the path to registry file
Throws:
java.lang.Exception - the exception
Method Detail

getLogger

protected LgLoggerIF getLogger()
Gets the logger.

Returns:
the logger

getRegistryFile

protected java.io.File getRegistryFile()
Gets the registry file.

Returns:
the registry file

getStatus

public CodingSchemeVersionStatus getStatus(java.lang.String codingSchemeURN,
                                           java.lang.String version)
Gets the status.

Parameters:
codingSchemeURN - the coding scheme urn
version - the version
Returns:
the status

isActive

public boolean isActive(java.lang.String codingSchemeURN,
                        java.lang.String version)
Checks if is active.

Parameters:
codingSchemeURN - the coding scheme urn
version - the version
Returns:
true, if is active

getSQLConnectionInfoForCodeSystem

public SQLConnectionInfo getSQLConnectionInfoForCodeSystem(AbsoluteCodingSchemeVersionReference codingSchemeVersion)
Gets the sQL connection info for code system.

Parameters:
codingSchemeVersion - the coding scheme version
Returns:
the sQL connection info for code system

getSQLConnectionInfoForHistory

public SQLConnectionInfo[] getSQLConnectionInfoForHistory(java.lang.String urn)
Gets the sQL connection info for history.

Parameters:
urn - the urn
Returns:
the sQL connection info for history

getTag

public java.lang.String getTag(java.lang.String codingSchemeURN,
                               java.lang.String version)
Gets the tag.

Parameters:
codingSchemeURN - the coding scheme urn
version - the version
Returns:
the tag

getDeactivateDate

public java.util.Date getDeactivateDate(java.lang.String codingSchemeURN,
                                        java.lang.String version)
Gets the deactivate date.

Parameters:
codingSchemeURN - the coding scheme urn
version - the version
Returns:
the deactivate date

setDeactivateDate

public void setDeactivateDate(AbsoluteCodingSchemeVersionReference acsvr,
                              java.util.Date date)
                       throws LBParameterException,
                              LBInvocationException
Sets the deactivate date.

Parameters:
acsvr - the acsvr
date - the date
Throws:
LBParameterException - the LB parameter exception
LBInvocationException - the LB invocation exception

setDeactivateDateInternal

public void setDeactivateDateInternal(AbsoluteCodingSchemeVersionReference acsvr,
                                      java.util.Date date)
                               throws LBParameterException,
                                      LBInvocationException
Sets the deactivate date internal.

Parameters:
acsvr - the acsvr
date - the date
Throws:
LBParameterException - the LB parameter exception
LBInvocationException - the LB invocation exception

getLastUpdateDate

public java.util.Date getLastUpdateDate(java.lang.String codingSchemeURN,
                                        java.lang.String version)
Gets the last update date.

Parameters:
codingSchemeURN - the coding scheme urn
version - the version
Returns:
the last update date

deactivate

public void deactivate(XmlRegistry.DBEntry entry)
                throws LBInvocationException,
                       LBParameterException
Deactivate.

Parameters:
entry - the entry
Throws:
LBInvocationException - the LB invocation exception
LBParameterException - the LB parameter exception

setStatusPending

public void setStatusPending(XmlRegistry.DBEntry entry)
                      throws LBInvocationException,
                             LBParameterException
Sets the status pending.

Parameters:
entry - the new status pending
Throws:
LBInvocationException - the LB invocation exception
LBParameterException - the LB parameter exception

activate

public void activate(AbsoluteCodingSchemeVersionReference codingScheme)
              throws LBInvocationException,
                     LBParameterException
Activate a code system.

Parameters:
codingScheme - the coding scheme
Throws:
LBInvocationException - the LB invocation exception
LBParameterException - the LB parameter exception

updateTag

public void updateTag(AbsoluteCodingSchemeVersionReference codingScheme,
                      java.lang.String newTag)
               throws LBInvocationException,
                      LBParameterException
Update tag.

Parameters:
codingScheme - the coding scheme
newTag - the new tag
Throws:
LBInvocationException - the LB invocation exception
LBParameterException - the LB parameter exception

updateVersion

public void updateVersion(AbsoluteCodingSchemeVersionReference codingScheme,
                          java.lang.String newVersion)
                   throws LBInvocationException,
                          LBParameterException
Update version.

Parameters:
codingScheme - the coding scheme
newVersion - the new version
Throws:
LBInvocationException - the LB invocation exception
LBParameterException - the LB parameter exception

getEntry

public XmlRegistry.DBEntry getEntry(java.lang.String codingSchemeURN,
                                    java.lang.String version)
                             throws LBParameterException
Gets the entry.

Parameters:
codingSchemeURN - the coding scheme urn
version - the version
Returns:
the entry
Throws:
LBParameterException - the LB parameter exception

getDBCodingSchemeEntry

public XmlRegistry.DBEntry getDBCodingSchemeEntry(AbsoluteCodingSchemeVersionReference codingScheme)
                                           throws LBParameterException
Gets the dB coding scheme entry.

Parameters:
codingScheme - the coding scheme
Returns:
the dB coding scheme entry
Throws:
LBParameterException - the LB parameter exception

addNewItem

public void addNewItem(java.lang.String urn,
                       java.lang.String version,
                       java.lang.String status,
                       java.lang.String dbURL,
                       java.lang.String tag,
                       java.lang.String dbName,
                       java.lang.String tablePrefix)
                throws java.lang.Exception
Adds the new item.

Parameters:
urn - the urn
version - the version
status - the status
dbURL - the db url
tag - the tag
dbName - the db name
tablePrefix - the table prefix
Throws:
java.lang.Exception - the exception

addNewHistory

public XmlRegistry.HistoryEntry addNewHistory(java.lang.String urn,
                                              java.lang.String dbURL,
                                              java.lang.String dbName,
                                              java.lang.String tablePrefix)
                                       throws java.lang.Exception
Add a new history item to the registry. Returns the current existing information (if any exists)

Parameters:
urn - the urn
dbURL - the db url
dbName - the db name
tablePrefix - the table prefix
Returns:
the history entry
Throws:
java.lang.Exception - the exception

getVersionForTag

public java.lang.String getVersionForTag(java.lang.String urn,
                                         java.lang.String tag)
Gets the version for tag.

Parameters:
urn - the urn
tag - the tag
Returns:
the version for tag

getDBEntries

public XmlRegistry.DBEntry[] getDBEntries()
Gets the db entries.

Returns:
the entries

getHistoryEntries

public XmlRegistry.HistoryEntry[] getHistoryEntries()
Gets the history entries.

Returns:
the entries

getLastUpdateTime

public java.util.Date getLastUpdateTime()
Gets the last update time.

Specified by:
getLastUpdateTime in interface Registry
Returns:
the lastUpdateTime

remove

public void remove(AbsoluteCodingSchemeVersionReference codingSchemeVersion)
            throws InternalException,
                   LBInvocationException,
                   LBParameterException
Removes the.

Parameters:
codingSchemeVersion - the coding scheme version
Throws:
InternalException - the internal exception
LBInvocationException - the LB invocation exception
LBParameterException - the LB parameter exception

getHistoryEntry

public XmlRegistry.HistoryEntry getHistoryEntry(java.lang.String urn)
                                         throws LBParameterException
Gets the history entry.

Parameters:
urn - the urn
Returns:
the history entry
Throws:
LBParameterException - the LB parameter exception

removeHistoryEntry

public void removeHistoryEntry(java.lang.String urn)
                        throws InternalException,
                               LBInvocationException,
                               LBParameterException
Removes the history entry.

Parameters:
urn - the urn
Throws:
InternalException - the internal exception
LBInvocationException - the LB invocation exception
LBParameterException - the LB parameter exception

getNextDBIdentifier

public java.lang.String getNextDBIdentifier()
                                     throws LBInvocationException
Gets the next db identifier.

Specified by:
getNextDBIdentifier in interface Registry
Returns:
the lastUsedDBIdentifier
Throws:
LBInvocationException - the LB invocation exception
UnexpectedInternalError

getNextHistoryIdentifier

public java.lang.String getNextHistoryIdentifier()
                                          throws LBInvocationException
Gets the next history identifier.

Specified by:
getNextHistoryIdentifier in interface Registry
Returns:
the lastUsedDBIdentifier
Throws:
LBInvocationException - the LB invocation exception
UnexpectedInternalError

updateURNVersion

public void updateURNVersion(AbsoluteCodingSchemeVersionReference oldURNVerison,
                             AbsoluteCodingSchemeVersionReference newURNVerison)
                      throws LBInvocationException,
                             LBParameterException
Activate a code system.

Parameters:
oldURNVerison - the old urn verison
newURNVerison - the new urn verison
Throws:
LBInvocationException - the LB invocation exception
LBParameterException - the LB parameter exception

addNewItem

public void addNewItem(RegistryEntry entry)
                throws java.lang.Exception
Description copied from interface: Registry
Adds the new item.

Specified by:
addNewItem in interface Registry
Parameters:
entry - the entry
Throws:
java.lang.Exception - the exception

getAllRegistryEntries

public java.util.List<RegistryEntry> getAllRegistryEntries()
Description copied from interface: Registry
Gets the all registry entries.

Specified by:
getAllRegistryEntries in interface Registry
Returns:
the all registry entries

getAllRegistryEntriesOfType

public java.util.List<RegistryEntry> getAllRegistryEntriesOfType(Registry.ResourceType type)
Description copied from interface: Registry
Gets the all registry entries of type.

Specified by:
getAllRegistryEntriesOfType in interface Registry
Parameters:
type - the type
Returns:
the all registry entries of type

getAllRegistryEntriesOfTypeAndURI

public java.util.List<RegistryEntry> getAllRegistryEntriesOfTypeAndURI(Registry.ResourceType type,
                                                                       java.lang.String uri)
Description copied from interface: Registry
Gets the all registry entries of type and URI.

Specified by:
getAllRegistryEntriesOfTypeAndURI in interface Registry
Parameters:
type - the resource type
uri - the resource uri
Returns:
the all registry entries of type and URI

getAllRegistryEntriesOfTypeURIAndVersion

public java.util.List<RegistryEntry> getAllRegistryEntriesOfTypeURIAndVersion(Registry.ResourceType type,
                                                                              java.lang.String uri,
                                                                              java.lang.String version)
Description copied from interface: Registry
Gets the all registry entries of type, URI and version.

Specified by:
getAllRegistryEntriesOfTypeURIAndVersion in interface Registry
Parameters:
type - the resource type
uri - the resource uri
version - the verion
Returns:
the all registry entries of type and URI

getEntriesForUri

public java.util.List<RegistryEntry> getEntriesForUri(java.lang.String uri)
                                               throws LBParameterException
Description copied from interface: Registry
Gets the entries for uri.

Specified by:
getEntriesForUri in interface Registry
Parameters:
uri - the uri
Returns:
the entries for uri
Throws:
LBParameterException - the LB parameter exception

getNonCodingSchemeEntry

public RegistryEntry getNonCodingSchemeEntry(java.lang.String uri)
                                      throws LBParameterException
Description copied from interface: Registry
Gets the non coding scheme entry.

Specified by:
getNonCodingSchemeEntry in interface Registry
Parameters:
uri - the uri
Returns:
the non coding scheme entry
Throws:
LBParameterException - the LB parameter exception

containsCodingSchemeEntry

public boolean containsCodingSchemeEntry(AbsoluteCodingSchemeVersionReference codingScheme)
Description copied from interface: Registry
Contains coding scheme entry.

Specified by:
containsCodingSchemeEntry in interface Registry
Parameters:
codingScheme - the coding scheme
Returns:
true, if successful

getCodingSchemeEntry

public RegistryEntry getCodingSchemeEntry(AbsoluteCodingSchemeVersionReference codingScheme)
                                   throws LBParameterException
Description copied from interface: Registry
Gets the coding scheme entry.

Specified by:
getCodingSchemeEntry in interface Registry
Parameters:
codingScheme - the coding scheme
Returns:
the coding scheme entry
Throws:
LBParameterException - the LB parameter exception

removeEntry

public void removeEntry(RegistryEntry entry)
                 throws LBParameterException
Description copied from interface: Registry
Removes the entry.

Specified by:
removeEntry in interface Registry
Parameters:
entry - the entry
Throws:
LBParameterException - the LB parameter exception

updateEntry

public void updateEntry(RegistryEntry entry)
Description copied from interface: Registry
Update entry.

Specified by:
updateEntry in interface Registry
Parameters:
entry - the entry

containsNonCodingSchemeEntry

public boolean containsNonCodingSchemeEntry(java.lang.String uri)
Description copied from interface: Registry
Contains non coding scheme entry.

Specified by:
containsNonCodingSchemeEntry in interface Registry
Parameters:
uri - the uri
Returns:
true, if successful

getSupportedLexGridSchemaVersionForCodingScheme

protected java.lang.String getSupportedLexGridSchemaVersionForCodingScheme(AbsoluteCodingSchemeVersionReference ref)
                                                                    throws LBInvocationException
Gets the supported lex grid schema version for coding scheme.

Parameters:
ref - the ref
Returns:
the supported lex grid schema version for coding scheme
Throws:
LBInvocationException - the LB invocation exception

getSupportedLexGridSchemaVersionForHistory

protected java.lang.String getSupportedLexGridSchemaVersionForHistory(java.lang.String uri)
                                                               throws LBInvocationException
Gets the supported lex grid schema version for history.

Parameters:
uri - the uri
Returns:
the supported lex grid schema version for history
Throws:
LBInvocationException - the LB invocation exception

getDataSource

public javax.sql.DataSource getDataSource()
Gets the data source.

Returns:
the data source

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Sets the data source.

Parameters:
dataSource - the new data source

updateCodingSchemeEntryTag

public void updateCodingSchemeEntryTag(AbsoluteCodingSchemeVersionReference codingScheme,
                                       java.lang.String newTag)
                                throws LBParameterException
Update coding scheme entry tag.

Parameters:
codingScheme - the coding scheme
newTag - the new tag
Throws:
LBParameterException - the LB parameter exception

Copyright: (c) 2004-2006 Mayo Foundation for Medical Education and Research (MFMER). All rights reserved. MAYO, MAYO CLINIC, and the triple-shield Mayo logo are trademarks and service marks of MFMER.