Class DatabaseInformationModel
- Direct Known Subclasses:
DicomDatabaseInformationModel
The DatabaseInformationModel
class is an abstract class that contains the core
functionality for storing, accessing and maintaining a persistent representation of selected attributes of composite
objects.
It hides an underlying SQL database implementation that stores the attributes of each entity in the information model in tables.
Abstract sub-classes, such as DicomDatabaseInformationModel
,
may refine the type of information model supported, since this base class is fairly generic and not dependent on any
particular DICOM information model. Concrete sub-classes define particular models by overriding the methods that
define the root entities and the relationship between entities, as well as the unique keys for each particular
entity.
In addition, the concrete sub-classes define which attributes of each entity will be included in the persistent
representation (the database tables), usually by means of a specialized sub-class of DicomDictionary
which contains the sub-set of relevant attributes and may change their mapping to information entities, such as
DicomDictionaryForPatientStudySeriesConcatenationInstanceModel
.
For example, an application might instantiate a PatientStudySeriesConcatenationInstanceModel
or a StudySeriesInstanceModel
, as follows:
final DatabaseInformationModel d = new PatientStudySeriesConcatenationInstanceModel("test");
Composite objects previously read into a AttributeList
from a
DICOM file in a persistent location could be inserted into the persistent representation (the database)
as follows, indicating in this case that the file was copied (and may later be deleted) rather than referenced:
d.insertObject(list,fileName,DatabaseInformationModel.FILE_COPIED);
External (unsecure) SQL access to the database is possible if a databaseServerName argument is supplied in the constructor, in which
case a tool like org.hsqldb.util.DatabaseManagerSwing
(described in detail at Hsqldb User Guide: Appendix F. Database Manager) can be used to query or manage the database. For example:
% java -cp lib/additional/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing --url "jdbc:hsqldb:hsql://hostname/databaseServerName"
where "hostname" is the name of the host (perhaps "localhost"), and "databaseServerName" is the name supplied in the constructor.
Note that the default username ("sa") and password (empty) are not secure.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected HashMap
protected Connection
protected String
protected static final String
protected DicomDictionary
protected org.hsqldb.Server
static final String
static final String
protected HashMap
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected InformationEntity
protected static final String
protected static final String
protected static final String
protected static final String
-
Constructor Summary
ConstructorsConstructorDescriptionDatabaseInformationModel
(String databaseFileName, InformationEntity rootInformationEntity, DicomDictionary dictionary) Instantiate a persistent information model using the named database.DatabaseInformationModel
(String databaseFileName, InformationEntity rootInformationEntity, DicomDictionary dictionary, String databaseRootName) Instantiate a persistent information model using the named database.DatabaseInformationModel
(String databaseFileName, String databaseServerName, InformationEntity rootInformationEntity, DicomDictionary dictionary) Instantiate a persistent information model using the named database allowing external SQL access.DatabaseInformationModel
(String databaseFileName, String databaseServerName, InformationEntity rootInformationEntity, DicomDictionary dictionary, String databaseRootName) Instantiate a persistent information model using the named database allowing external SQL access. -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
appendExactOrIsNullMatch
(StringBuffer b, String value) Append a check for a match against a string value, accounting for the need to use the "IS NULL" rather than "=" expression when wanting to explciitly have NULL match NULL rather to never match.void
close()
Close the underlying connection to the database and shutdown any external SQL server.protected void
Create any additional indexes to optimize queries, for example for UIDs.protected abstract String
Create a new unique key which may be used to identify a new instance of an entity.void
deleteRecord
(InformationEntity ie, String localPrimaryKeyValue) Delete a database record (a particular instance of an information entity).protected void
doCommonConstructorStuff
(String databaseFileName, String databaseServerName, InformationEntity rootInformationEntity, DicomDictionary dictionary, String databaseRootName) Instantiate a persistent information model using the named database.protected void
Extend a SQL CREATE TABLE statement in the process of being constructed with any additional attributes (columns) that the model requires.protected void
Extend a SQL CREATE TABLE statement in the process of being constructed with any derived attributes (columns) that the model requires.protected void
Extend a SQL CREATE TABLE statement in the process of being constructed with any user optional columns that the model requires.protected abstract void
extendInsertStatementStringWithAttributeNamesForSelectedInformationEntity
(StringBuffer b, AttributeList list, InformationEntity ie) Extend a SQL INSERT statement in the process of being constructed with the names of the attributes in the instance for the entity.protected abstract void
extendInsertStatementStringWithAttributeValuesForSelectedInformationEntity
(StringBuffer b, AttributeList list, InformationEntity ie, String fileName, String fileReferenceType) Extend a SQL INSERT statement in the process of being constructed with the values of the attributes in the instance for the entity.protected abstract void
extendInsertStatementStringWithDerivedAttributeNamesForSelectedInformationEntity
(StringBuffer b, AttributeList list, InformationEntity ie) Extend a SQL INSERT statement in the process of being constructed with the names of the derived attributes in the instance for the entity.protected abstract void
extendInsertStatementStringWithDerivedAttributeValuesForSelectedInformationEntity
(StringBuffer b, AttributeList list, InformationEntity ie) Extend a SQL INSERT statement in the process of being constructed with the values of the derived attributes in the instance for the entity.protected abstract void
extendInsertStatementStringWithPersonNameSearchColumnsForSelectedInformationEntity
(StringBuffer b, AttributeList list, InformationEntity ie) Extend a SQL INSERT statement in the process of being constructed with the names of the additional search columns derived from person name attributes in the instance for the entity.protected abstract void
extendInsertStatementStringWithPersonNameSearchValuesForSelectedInformationEntity
(StringBuffer b, AttributeList list, InformationEntity ie) Extend a SQL INSERT statement in the process of being constructed with the values of the additional search columns derived from person name attributes in the instance for the entity.protected abstract void
extendStatementStringWithMatchingAttributesForSelectedInformationEntity
(StringBuffer b, AttributeList list, InformationEntity ie) Extend a SQL SELECT statement in the process of being constructed with matching clauses for the unique keys of the entity and all its parents.protected void
finalize()
For all records of an information entity, get the values of all the columns in the entity's database table.findAllAttributeValuesForAllRecordsForThisInformationEntityWithMatchingParent
(InformationEntity ieWanted, InformationEntity ieParent, String parentMatchingAttribute, String parentMatchingValue) For all records of an information entity with all parents matching a particular attribute value, get the values of all attributes.findAllAttributeValuesForAllRecordsForThisInformationEntityWithSpecifiedKeyValue
(InformationEntity ie, String keyName, String keyValue) For all records of an information entity matching the specified key value, get the values of all the columns in the entity's database table.findAllAttributeValuesForAllRecordsForThisInformationEntityWithSpecifiedParent
(InformationEntity ie, String localParentReference) For all records of an information entity with the specified parent, get the values of all the columns in the entity's database table.findAllAttributeValuesForAllRecordsForThisInformationEntityWithSpecifiedUID
(InformationEntity ie, String uid) For all records of an information entity matching the specified UID, get the values of all the columns in the entity's database table.findAllAttributeValuesForSelectedRecord
(InformationEntity ie, String localPrimaryKeyValue) For a particular instance of an information entity, get the values of all the columns in the entity's database table.findSelectedAttributeValuesForSelectedRecord
(InformationEntity ie, String localPrimaryKeyValue, String key) For a particular instance of an information entity, get the value of the selected column in the entity's database table.getAttributeTagFromDatabaseColumnName
(String columnName) Get the name of the DICOM element corresponding to the database table column.abstract InformationEntity
For an information entity (regardless of a particular instance), find the next information entity lower down in the information model hierarchy in the general case.abstract InformationEntity
getChildTypeForParent
(InformationEntity ie, boolean concatenation) For a particular instance of an information entity, find the next information entity lower down in the information model hierarchy.abstract InformationEntity
For a particular instance of an information entity, find the next information entity lower down in the information model hierarchy.static String
getDatabaseColumnNameFromDicomName
(String descriptiveName) Get the name of the table column corresponding to the DICOM element name.Get the name of the table column corresponding to the DICOM tag.abstract String
For a particular information entity, find the name of the column in the entity's database table containing the first of three descriptive attributes for the entity.getDicomNameFromDatabaseColumnName
(String columnName) Get the name of the DICOM element corresponding to the database table column.Get the information entity in this information model for the specified tagFor a particular information entity, find the name of the column in the entity's database table containing the local file name of a stored object.For a particular information entity, find the name of the column in the entity's database table containing the reference type of a stored object.For a particular information entity, find the name of the column in the entity's database table containing the reference to an instance of the entity's parent.For a particular information entity, find the name of the column in the entity's database table containing the primary key of an instance of the entity.For a particular information entity, find the name of the column in the entity's database table containing the record insertion time recorded as the value returned bySystem.currentTimeMillis()
.abstract String
getNametoDescribeThisInstanceOfInformationEntity
(InformationEntity ie, Map returnedAttributes) For a particular instance of an information entity, find a descriptive name for the entity suitable for rendering.abstract String
For a particular information entity, find the name of the column in the entity's database table containing the second of three descriptive attributes for the entity.abstract String
For a particular information entity, find the name of the column in the entity's database table containing the third of three descriptive attributes for the entity.Get a factory to manufacture a query response generator capable of performing a query and returning the results.Get a factory to manufacture a retrieve response generator capable of performing a retrieve and returning the results.static String
getSQLTypeFromDicomValueRepresentation
(byte[] vr) Given a DICOM Value Representation, determine the appropriate corresponding SQL type to use.static String
Get the table name for an information entity.abstract String
For a particular information entity, find the name of the column in the entity's database table containing the DICOM UID for the entity.void
insertObject
(AttributeList list, String fileName, String fileReferenceType) Insert a DICOM composite object, and the relevant attributes of all the entities it contains, into the database.protected abstract boolean
Is the entity in the information model ?protected boolean
isInformationEntityInModel
(String ieName) Is the named entity in the information model ?toString()
Returns a string describing the structure (not the contents) of the database.void
updateSelectedRecord
(InformationEntity ie, String localPrimaryKeyValue, String key, String value) For a particular instance of an information entity, update the record in the database table with a new value for the specified attribute (column).
-
Field Details
-
FILE_COPIED
- See Also:
-
FILE_REFERENCED
- See Also:
-
defaultDatabaseRootName
- See Also:
-
localPrimaryKeyColumnName
- See Also:
-
localParentReferenceColumnName
- See Also:
-
localRecordInsertionTimeColumnName
- See Also:
-
localFileName
- See Also:
-
localFileReferenceTypeColumnName
- See Also:
-
personNameCanonicalColumnNamePrefix
- See Also:
-
personNameCanonicalColumnNameSuffix
- See Also:
-
personNamePhoneticCanonicalColumnNamePrefix
- See Also:
-
personNamePhoneticCanonicalColumnNameSuffix
- See Also:
-
userColumnName1
- See Also:
-
userColumnName2
- See Also:
-
userColumnName3
- See Also:
-
userColumnName4
- See Also:
-
rootInformationEntity
-
listsOfAttributesByInformationEntity
-
additionalIndexMapOfColumnsToTables
-
databaseConnection
-
externalServerInstance
protected org.hsqldb.Server externalServerInstance -
dictionary
-
databaseRootName
-
-
Constructor Details
-
DatabaseInformationModel
public DatabaseInformationModel(String databaseFileName, InformationEntity rootInformationEntity, DicomDictionary dictionary) throws DicomException Instantiate a persistent information model using the named database.
Will open a connection to the database, and create any tables if this is the first time, or re-use any persistent information if not.
- Parameters:
databaseFileName
- the file name of the underlying SQL database instance to be usedrootInformationEntity
- the top entity of the information model; specific to a particular model's constructordictionary
- used to decide which attributes to include for each entity when creating the tables- Throws:
DicomException
- thrown if a connection to the database cannot be established
-
DatabaseInformationModel
public DatabaseInformationModel(String databaseFileName, InformationEntity rootInformationEntity, DicomDictionary dictionary, String databaseRootName) throws DicomException Instantiate a persistent information model using the named database.
Will open a connection to the database, and create any tables if this is the first time, or re-use any persistent information if not.
- Parameters:
databaseFileName
- the file name of the underlying SQL database instance to be usedrootInformationEntity
- the top entity of the information model; specific to a particular model's constructordictionary
- used to decide which attributes to include for each entity when creating the tablesdatabaseRootName
- the name used for the root node of the database in TreeModel- Throws:
DicomException
- thrown if a connection to the database cannot be established
-
DatabaseInformationModel
public DatabaseInformationModel(String databaseFileName, String databaseServerName, InformationEntity rootInformationEntity, DicomDictionary dictionary) throws DicomException Instantiate a persistent information model using the named database allowing external SQL access.
Will open a connection to the database, and create any tables if this is the first time, or re-use any persistent information if not.
- Parameters:
databaseFileName
- the file name of the underlying SQL database instance to be useddatabaseServerName
- the name to use for external TCP access to database (such a server will not be started if this value is null or zero length)rootInformationEntity
- the top entity of the information model; specific to a particular model's constructordictionary
- used to decide which attributes to include for each entity when creating the tables- Throws:
DicomException
- thrown if a connection to the database cannot be established
-
DatabaseInformationModel
public DatabaseInformationModel(String databaseFileName, String databaseServerName, InformationEntity rootInformationEntity, DicomDictionary dictionary, String databaseRootName) throws DicomException Instantiate a persistent information model using the named database allowing external SQL access.
Will open a connection to the database, and create any tables if this is the first time, or re-use any persistent information if not.
- Parameters:
databaseFileName
- the file name of the underlying SQL database instance to be useddatabaseServerName
- the name to use for external TCP access to database (such a server will not be started if this value is null or zero length)rootInformationEntity
- the top entity of the information model; specific to a particular model's constructordictionary
- used to decide which attributes to include for each entity when creating the tablesdatabaseRootName
- the name used for the root node of the database in TreeModel- Throws:
DicomException
- thrown if a connection to the database cannot be established
-
-
Method Details
-
doCommonConstructorStuff
protected void doCommonConstructorStuff(String databaseFileName, String databaseServerName, InformationEntity rootInformationEntity, DicomDictionary dictionary, String databaseRootName) throws DicomException Instantiate a persistent information model using the named database.
Will open a connection to the database, and create any tables if this is the first time, or re-use any persistent information if not.
- Parameters:
databaseFileName
- the file name of the underlying SQL database instance to be used (or "mem:name" if the database is to be in-memory and not persisted)databaseServerName
- the name to use for external TCP access to database (such a server will not be started if this value is null or zero length)rootInformationEntity
- the top entity of the information model; specific to a particular model's constructordictionary
- used to decide which attributes to include for each entity when creating the tablesdatabaseRootName
- the name used for the root node of the database in TreeModel- Throws:
DicomException
- thrown if a connection to the database cannot be established
-
close
public void close()Close the underlying connection to the database and shutdown any external SQL server.
Prior to actually closing will also try to formally shutdown and compact the database.
-
finalize
protected void finalize() -
isInformationEntityInModel
Is the entity in the information model ?
Will be specific to a particular concrete information model.
- Returns:
- boolean the information entity is in the information model
-
isInformationEntityInModel
Is the named entity in the information model ?
Will be specific to a particular concrete information model.
- Parameters:
ieName
- a String name, whose case is ignored (e.g., a database table named for the corresponding information entity)- Returns:
- the name corresponds to an information entity that is in the information model
-
getDatabaseColumnNameFromDicomTag
Get the name of the table column corresponding to the DICOM tag.
- Parameters:
tag
- the tag of the DICOM element- Returns:
- a
String
column name, or null if not known
-
getDatabaseColumnNameFromDicomName
Get the name of the table column corresponding to the DICOM element name.
- Parameters:
descriptiveName
- the name of the DICOM element- Returns:
- the upper case
String
column name, or null if not known
-
getDicomNameFromDatabaseColumnName
Get the name of the DICOM element corresponding to the database table column.
- Parameters:
columnName
- the name of the database column- Returns:
- a
String
descriptive name of the DICOM element, or null if not known
-
getAttributeTagFromDatabaseColumnName
Get the name of the DICOM element corresponding to the database table column.
- Parameters:
columnName
- the name of the database column- Returns:
- the tag, or null if not known
-
createAdditionalIndexes
Create any additional indexes to optimize queries, for example for UIDs.
Called after creating tables and default indexes.
- Throws:
DicomException
-
extendCreateStatementStringWithAnyExtraAttributes
protected void extendCreateStatementStringWithAnyExtraAttributes(StringBuffer b, InformationEntity ie) Extend a SQL CREATE TABLE statement in the process of being constructed with any additional attributes (columns) that the model requires.
Called when creating the tables for a new database.
Specific to each concrete information model extending
DatabaseInformationModel
. Defaults to adding no extra columns if not overridden (i.e. it is not abstract).For example, there may be a DICOM attribute that is defined to be in a particular information entity in the dictionary (for example InstanceNumber is at the concatenation level), but for the convenience of the user of tree and table browsers it may be nice to replicate it into the tables for lower levels of the information model as well; hence this method might add InstanceNumber at the instance level. Once created, such attributes will automatically be included during database inserts. See also
PatientStudySeriesConcatenationInstanceModel
for example.- Parameters:
b
- the statement being constructedie
- theInformationEntity
for which a create table statement is being constructed
-
extendCreateStatementStringWithDerivedAttributes
protected void extendCreateStatementStringWithDerivedAttributes(StringBuffer b, InformationEntity ie) Extend a SQL CREATE TABLE statement in the process of being constructed with any derived attributes (columns) that the model requires.
Called when creating the tables for a new database.
Specific to each concrete information model extending
DatabaseInformationModel
. Defaults to adding no extra columns if not overridden (i.e. it is not abstract).For example, there may be dates and times derived from DICOM attributes.
- Parameters:
b
- the statement being constructedie
- theInformationEntity
for which a create table statement is being constructed
-
extendCreateStatementStringWithUserColumns
Extend a SQL CREATE TABLE statement in the process of being constructed with any user optional columns that the model requires.
Called when creating the tables for a new database.
Specific to each concrete information model extending
DatabaseInformationModel
. Defaults to adding four extra columns for each table if not overridden (i.e. it is not abstract).- Parameters:
b
- the statement being constructedie
- theInformationEntity
for which a create table statement is being constructed
-
deleteRecord
Delete a database record (a particular instance of an information entity).
For example, for the study entity, this would delete a particular study.
Does NOT delete its children, if any.
Does NOT delete any referenced files, if any.
- Parameters:
ie
- theInformationEntity
that corresponds to the table containing the record to be deletedlocalPrimaryKeyValue
- primary key of the record- Throws:
DicomException
- thrown if there are problems executing the database statement
-
insertObject
public void insertObject(AttributeList list, String fileName, String fileReferenceType) throws DicomException Insert a DICOM composite object, and the relevant attributes of all the entities it contains, into the database.
Such a composite object may contain information about the patient, study, series and instance and so on, and for each of these entities the appropriate records will be created in the appropriate tables
If records for any entities already exist (as they will often do when inserting multiple objects for the same patient or study, for example), they are matched based on the unique key for the appropriate level. They are not replaced and they are not updated, even if some of the attributes for that entity (other than the unique key) are different or additional. Even at the instance level (e.g. if an object with the same
SOPInstanceUID
is received), the first record will not be overwritten. Whether or not the application calling this method will have overwritten the corresponding file in the supplied argument or not is outside the scope of this class.The information is taken from the supplied
AttributeList
, which is presumed to have already been read from a file or obtained through some other means. The supplied filename is only used to fill in the appropriate instance level attribute.- Parameters:
list
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityfileName
- the name of a file where the object is stored and from whence it may later be readfileReferenceType
- "C" for copied (i.e., delete on purge), "R" for referenced (i.e., do not delete on purge)- Throws:
DicomException
- thrown if there are problems extracting the DICOM attributes
-
extendInsertStatementStringWithPersonNameSearchColumnsForSelectedInformationEntity
protected abstract void extendInsertStatementStringWithPersonNameSearchColumnsForSelectedInformationEntity(StringBuffer b, AttributeList list, InformationEntity ie) throws DicomException Extend a SQL INSERT statement in the process of being constructed with the names of the additional search columns derived from person name attributes in the instance for the entity.
Called when inserting a new record for an instance of the entity.
Specific to each concrete information model extending
DatabaseInformationModel
.- Parameters:
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- theInformationEntity
for which a select statement is being constructed- Throws:
DicomException
- thrown if there are problems extracting the DICOM attributes
-
extendInsertStatementStringWithPersonNameSearchValuesForSelectedInformationEntity
protected abstract void extendInsertStatementStringWithPersonNameSearchValuesForSelectedInformationEntity(StringBuffer b, AttributeList list, InformationEntity ie) throws DicomException Extend a SQL INSERT statement in the process of being constructed with the values of the additional search columns derived from person name attributes in the instance for the entity.
Called when inserting a new record for an instance of the entity.
Specific to each concrete information model extending
DatabaseInformationModel
.- Parameters:
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- theInformationEntity
for which a select statement is being constructed- Throws:
DicomException
- thrown if there are problems extracting the DICOM attributes
-
extendStatementStringWithMatchingAttributesForSelectedInformationEntity
protected abstract void extendStatementStringWithMatchingAttributesForSelectedInformationEntity(StringBuffer b, AttributeList list, InformationEntity ie) throws DicomException Extend a SQL SELECT statement in the process of being constructed with matching clauses for the unique keys of the entity and all its parents.
For example, a model might specify the unique key for the patient to be
PatientID
, the study to beStudyInstanceUID
, the series to beSeriesInstanceUID
and so on. A match requested at the series level would then requirePatientID
,StudyInstanceUID
andSeriesInstanceUID
to match what was in the suppliedAttributeList
Called when inserting a new record for an instance of the entity.
Specific to each concrete information model extending
DatabaseInformationModel
.- Parameters:
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- theInformationEntity
for which a select statement is being constructed- Throws:
DicomException
- thrown if there are problems extracting the DICOM attributes
-
extendInsertStatementStringWithAttributeNamesForSelectedInformationEntity
protected abstract void extendInsertStatementStringWithAttributeNamesForSelectedInformationEntity(StringBuffer b, AttributeList list, InformationEntity ie) throws DicomException Extend a SQL INSERT statement in the process of being constructed with the names of the attributes in the instance for the entity.
Called when inserting a new record for an instance of the entity.
Specific to each concrete information model extending
DatabaseInformationModel
.- Parameters:
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- theInformationEntity
for which an insert statement is being constructed- Throws:
DicomException
- thrown if there are problems extracting the DICOM attributes
-
extendInsertStatementStringWithAttributeValuesForSelectedInformationEntity
protected abstract void extendInsertStatementStringWithAttributeValuesForSelectedInformationEntity(StringBuffer b, AttributeList list, InformationEntity ie, String fileName, String fileReferenceType) throws DicomException Extend a SQL INSERT statement in the process of being constructed with the values of the attributes in the instance for the entity.
Called when inserting a new record for an instance of the entity.
Specific to each concrete information model extending
DatabaseInformationModel
.- Parameters:
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- theInformationEntity
for which an insert statement is being constructedfileName
- the local filename, which may be non-null forINSTANCE
level insertionsfileReferenceType
- "C" for copied (i.e., delete on purge), "R" for referenced (i.e., do not delete on purge)- Throws:
DicomException
- thrown if there are problems extracting the DICOM attributes
-
extendInsertStatementStringWithDerivedAttributeNamesForSelectedInformationEntity
protected abstract void extendInsertStatementStringWithDerivedAttributeNamesForSelectedInformationEntity(StringBuffer b, AttributeList list, InformationEntity ie) throws DicomException Extend a SQL INSERT statement in the process of being constructed with the names of the derived attributes in the instance for the entity.
Called when inserting a new record for an instance of the entity.
Specific to each concrete information model extending
DatabaseInformationModel
.- Parameters:
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- theInformationEntity
for which an insert statement is being constructed- Throws:
DicomException
- thrown if there are problems extracting the DICOM attributes
-
extendInsertStatementStringWithDerivedAttributeValuesForSelectedInformationEntity
protected abstract void extendInsertStatementStringWithDerivedAttributeValuesForSelectedInformationEntity(StringBuffer b, AttributeList list, InformationEntity ie) throws DicomException Extend a SQL INSERT statement in the process of being constructed with the values of the derived attributes in the instance for the entity.
Called when inserting a new record for an instance of the entity.
Specific to each concrete information model extending
DatabaseInformationModel
.- Parameters:
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- theInformationEntity
for which an insert statement is being constructed- Throws:
DicomException
- thrown if there are problems extracting the DICOM attributes
-
createPrimaryKeyForSelectedInformationEntity
Create a new unique key which may be used to identify a new instance of an entity.
Called when inserting a new record for an instance of the entity.
- Parameters:
ie
- theInformationEntity
for which a key is requested- Returns:
- string value of a unique key
-
updateSelectedRecord
public void updateSelectedRecord(InformationEntity ie, String localPrimaryKeyValue, String key, String value) throws DicomException For a particular instance of an information entity, update the record in the database table with a new value for the specified attribute (column).
For example, for the study entity, this would update an attribute of a particular study, for example the
StudyID
attribute.- Parameters:
ie
- theInformationEntity
of the record to be updatedlocalPrimaryKeyValue
- the string value of the unique key which identifies the instance of the entity (not including wildcards)key
- the string name of the attribute (column) to be set (updated)value
- the string value to set- Throws:
DicomException
- thrown if the update fails
-
findAllAttributeValuesForSelectedRecord
public Map findAllAttributeValuesForSelectedRecord(InformationEntity ie, String localPrimaryKeyValue) throws DicomException For a particular instance of an information entity, get the values of all the columns in the entity's database table.
For example, for the study entity, this would return the attributes for a particular study.
- Parameters:
ie
- theInformationEntity
of the record to be returnedlocalPrimaryKeyValue
- the string value of the unique key which identifies the instance of the entity (not including wildcards)- Returns:
- a
TreeMap
ofString
values indexed byString
upper case column names - Throws:
DicomException
- thrown if the query fails
-
findSelectedAttributeValuesForSelectedRecord
public String findSelectedAttributeValuesForSelectedRecord(InformationEntity ie, String localPrimaryKeyValue, String key) throws DicomException For a particular instance of an information entity, get the value of the selected column in the entity's database table.
- Parameters:
ie
- theInformationEntity
of the record to be returnedlocalPrimaryKeyValue
- the string value of the unique key which identifies the instance of the entity (not including wildcards)key
- the name of the attribute to be returned- Returns:
- a
String
value, or an empty string if not found - Throws:
DicomException
- thrown if the query fails
-
findAllAttributeValuesForAllRecordsForThisInformationEntity
public ArrayList findAllAttributeValuesForAllRecordsForThisInformationEntity(InformationEntity ie) throws DicomException For all records of an information entity, get the values of all the columns in the entity's database table.
For example, for the study entity, this would return the attributes for all the studies in the database.
- Parameters:
ie
- theInformationEntity
of the records to be returned- Returns:
- an
ArrayList
of records, each value of which is aTreeMap
ofString
values indexed byString
upper case column names - Throws:
DicomException
- thrown if the query fails
-
findAllAttributeValuesForAllRecordsForThisInformationEntityWithSpecifiedUID
public ArrayList findAllAttributeValuesForAllRecordsForThisInformationEntityWithSpecifiedUID(InformationEntity ie, String uid) throws DicomException For all records of an information entity matching the specified UID, get the values of all the columns in the entity's database table.
For example, for the study entity, this would return the attributes for all the studies with the specified UID in the database.
For the instance entity, this would return the attributes for all the instances with the specified UID in the database.
In an ideal world, this method should only ever return one record, since the DICOM model is predicated on UIDs being unique !
- Parameters:
ie
- theInformationEntity
of the records to be returneduid
- theString
UID of the records to be returned- Returns:
- an
ArrayList
of records, each value of which is aTreeMap
ofString
values indexed byString
upper case column names - Throws:
DicomException
- thrown if the query fails
-
findAllAttributeValuesForAllRecordsForThisInformationEntityWithSpecifiedKeyValue
public ArrayList findAllAttributeValuesForAllRecordsForThisInformationEntityWithSpecifiedKeyValue(InformationEntity ie, String keyName, String keyValue) throws DicomException For all records of an information entity matching the specified key value, get the values of all the columns in the entity's database table.
For example, for the study entity, this would return the attributes for all the studies with the specified key value in the database.
- Parameters:
ie
- theInformationEntity
of the records to be returnedkeyName
- theString
name of the key to be matchedkeyValue
- theString
value of the key to be matched- Returns:
- an
ArrayList
of records, each value of which is aTreeMap
ofString
values indexed byString
upper case column names - Throws:
DicomException
- thrown if the query fails
-
findAllAttributeValuesForAllRecordsForThisInformationEntityWithSpecifiedParent
public ArrayList findAllAttributeValuesForAllRecordsForThisInformationEntityWithSpecifiedParent(InformationEntity ie, String localParentReference) throws DicomException For all records of an information entity with the specified parent, get the values of all the columns in the entity's database table.
For example, for the series entity, this would return the attributes for all the series of a particular study (parent).
- Parameters:
ie
- theInformationEntity
of the records to be returnedlocalParentReference
- the string value of the unique key which identifies the instance of the parent entity (not including wildcards)- Returns:
- an
ArrayList
of records, each value of which is aTreeMap
ofString
values indexed byString
upper case column names - Throws:
DicomException
- thrown if the query fails
-
findAllAttributeValuesForAllRecordsForThisInformationEntityWithMatchingParent
public ArrayList findAllAttributeValuesForAllRecordsForThisInformationEntityWithMatchingParent(InformationEntity ieWanted, InformationEntity ieParent, String parentMatchingAttribute, String parentMatchingValue) throws DicomException For all records of an information entity with all parents matching a particular attribute value, get the values of all attributes.
For example, for the instance entity, this could return the instance local file name for all the series (parents) with a particular frame of reference UID.
- Parameters:
ieWanted
- theInformationEntity
of the record level of the attribute to be returnedieParent
- theInformationEntity
of the record level of the parent to be matchedparentMatchingAttribute
- the string name of the attribute of the parent whose value is to be matchedparentMatchingValue
- the string value of the attribute of the parent to be matched (not including wildcards)- Returns:
- an
ArrayList
of records, each value of which is aTreeMap
ofString
values indexed byString
upper case column names - Throws:
DicomException
- thrown if the query fails
-
getTableNameForInformationEntity
Get the table name for an information entity.
- Parameters:
ie
- theInformationEntity
that is the parent, such as a patient, study, etc.- Returns:
- the upper case name of the table as used in the database
-
getChildTypeForParent
For an information entity (regardless of a particular instance), find the next information entity lower down in the information model hierarchy in the general case.
For a patient, this might be a study.
For a series, this might be a concatenation or an instance, depending on the information model.
This method essentially returns the most complex model possible and is used when building the database table schema.
- Parameters:
ie
- theInformationEntity
that is the parent, such as a patient, study, etc.- Returns:
- the
InformationEntity
that is the child
-
getChildTypeForParent
public abstract InformationEntity getChildTypeForParent(InformationEntity ie, boolean concatenation) For a particular instance of an information entity, find the next information entity lower down in the information model hierarchy.
For a patient, this might be a study. For a series, this might be a concatenation or an instance, depending on both the information model and whether concatenations are to be considered in the model.
This method may return a simpler view than the more general method, and is used when traversing the database tables.
- Parameters:
ie
- theInformationEntity
that is the parent, such as a patient, study, etc.concatenation
- true if concatenations are to be considered in the model- Returns:
- the
InformationEntity
that is the child
-
getChildTypeForParent
For a particular instance of an information entity, find the next information entity lower down in the information model hierarchy.
For a patient, this might be a study. For a series, this might be a concatenation or an instance, depending on both the information model and the contents of the instance itself.
This method may return a simpler view than the more general method, and is used when traversing the database tables.
- Parameters:
ie
- theInformationEntity
that is the parent, such as a patient, study, etc.list
- theAttributeList
that are the contents the instance- Returns:
- the
InformationEntity
that is the child
-
getNametoDescribeThisInstanceOfInformationEntity
public abstract String getNametoDescribeThisInstanceOfInformationEntity(InformationEntity ie, Map returnedAttributes) For a particular instance of an information entity, find a descriptive name for the entity suitable for rendering.
For a patient, this might be the name
Patient
. For an instance, this will depend on the SOPClassUID, and might be anImage
, aWaveform
, etc.- Parameters:
ie
- theInformationEntity
, such as a patient, study, etc.returnedAttributes
- the attributes from the selected row of the table for this instance of the entity- Returns:
- a human-readable string name of the entity
-
getDescriptiveColumnName
For a particular information entity, find the name of the column in the entity's database table containing the first of three descriptive attributes for the entity.
For example, for an instance (e.g. an image), this might be the
InstanceNumber
. For a patient, this might be thePatientName
.- Parameters:
ie
- theInformationEntity
, such as a patient, study, etc.- Returns:
- the upper case string name of the column, or
null
if there is no such column
-
getOtherDescriptiveColumnName
For a particular information entity, find the name of the column in the entity's database table containing the second of three descriptive attributes for the entity.
For example, for an instance (e.g. an image), this might be the
InConcatenationNumber
. Frequently null for other entities.- Parameters:
ie
- theInformationEntity
, such as a patient, study, etc.- Returns:
- the upper case string name of the column, or
null
if there is no such column
-
getOtherOtherDescriptiveColumnName
For a particular information entity, find the name of the column in the entity's database table containing the third of three descriptive attributes for the entity.
For example, for an instance (e.g. an image), this might be the
ImageComments
. For a patient, this might be thePatientID
.- Parameters:
ie
- theInformationEntity
, such as a patient, study, etc.- Returns:
- the upper case string name of the column, or
null
if there is no such column
-
getUIDColumnNameForInformationEntity
For a particular information entity, find the name of the column in the entity's database table containing the DICOM UID for the entity.
For example, for an instance (e.g. an image), this might be the name of the column corresponding to the SOP Instance UID.
- Parameters:
ie
- theInformationEntity
, such as a study, series, instance, etc.- Returns:
- the upper case string name of the column, or
null
if there is no such column
-
getLocalPrimaryKeyColumnName
For a particular information entity, find the name of the column in the entity's database table containing the primary key of an instance of the entity.
- Parameters:
ie
- theInformationEntity
, such as a patient, study, etc.- Returns:
- the upper case string name of the column
-
getLocalFileNameColumnName
For a particular information entity, find the name of the column in the entity's database table containing the local file name of a stored object.
- Parameters:
ie
- theInformationEntity
, such as a instance (e.g. an image)- Returns:
- the upper case string name of the column
-
getLocalFileReferenceTypeColumnName
For a particular information entity, find the name of the column in the entity's database table containing the reference type of a stored object.
- Parameters:
ie
- theInformationEntity
, such as a instance (e.g. an image)- Returns:
- the upper case string name of the column
-
getLocalParentReferenceColumnName
For a particular information entity, find the name of the column in the entity's database table containing the reference to an instance of the entity's parent.
- Parameters:
ie
- theInformationEntity
, such as a patient, study, etc.- Returns:
- the upper case string name of the column
-
getLocalRecordInsertionTimeColumnName
For a particular information entity, find the name of the column in the entity's database table containing the record insertion time recorded as the value returned by
System.currentTimeMillis()
.- Parameters:
ie
- theInformationEntity
, such as a patient, study, etc.- Returns:
- the upper case string name of the column
-
getSQLTypeFromDicomValueRepresentation
Given a DICOM Value Representation, determine the appropriate corresponding SQL type to use.
For example, the DICOM AE VR should be represented as a CHAR(16), an SS as an INTEGER, and so on.
- Parameters:
vr
- the 2 letter DICOM Value Representation as an array of two ASCII bytes.- Returns:
- the string representing the SQL type.
-
appendExactOrIsNullMatch
Append a check for a match against a string value, accounting for the need to use the "IS NULL" rather than "=" expression when wanting to explciitly have NULL match NULL rather to never match.
- Parameters:
b
- the buffer to append tovalue
- either NULL or the quoted escaped string value to append
-
getQueryResponseGeneratorFactory
Get a factory to manufacture a query response generator capable of performing a query and returning the results.
- Returns:
- the response generator factory
-
getRetrieveResponseGeneratorFactory
Get a factory to manufacture a retrieve response generator capable of performing a retrieve and returning the results.
- Returns:
- the response generator factory
-
getInformationEntityFromTag
Get the information entity in this information model for the specified tag- Parameters:
tag
-
-
toString
Returns a string describing the structure (not the contents) of the database.
-