public abstract class DatabaseInformationModel extends Object
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.
com.pixelmed.database
Constructor and Description |
---|
DatabaseInformationModel(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.
|
Modifier and Type | Method and Description |
---|---|
protected 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 |
createAdditionalIndexes()
Create any additional indexes to optimize queries, for example for UIDs.
|
protected abstract String |
createPrimaryKeyForSelectedInformationEntity(InformationEntity ie)
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 |
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.
|
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.
|
protected void |
extendCreateStatementStringWithUserColumns(StringBuffer b,
InformationEntity ie)
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() |
ArrayList |
findAllAttributeValuesForAllRecordsForThisInformationEntity(InformationEntity ie)
For all records of an information entity, get the values of all the columns in the entity's database table.
|
ArrayList |
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.
|
ArrayList |
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.
|
ArrayList |
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.
|
ArrayList |
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.
|
Map |
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.
|
String |
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.
|
AttributeTag |
getAttributeTagFromDatabaseColumnName(String columnName)
Get the name of the DICOM element corresponding to the database table column.
|
abstract InformationEntity |
getChildTypeForParent(InformationEntity ie)
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,
AttributeList list)
For a particular instance of an information entity, find the next information entity lower down in the information model hierarchy.
|
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.
|
static String |
getDatabaseColumnNameFromDicomName(String descriptiveName)
Get the name of the table column corresponding to the DICOM element name.
|
String |
getDatabaseColumnNameFromDicomTag(AttributeTag tag)
Get the name of the table column corresponding to the DICOM tag.
|
abstract String |
getDescriptiveColumnName(InformationEntity ie)
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.
|
String |
getDicomNameFromDatabaseColumnName(String columnName)
Get the name of the DICOM element corresponding to the database table column.
|
InformationEntity |
getInformationEntityFromTag(AttributeTag tag)
Get the information entity in this information model for the specified tag
|
String |
getLocalFileNameColumnName(InformationEntity ie)
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.
|
String |
getLocalFileReferenceTypeColumnName(InformationEntity ie)
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.
|
String |
getLocalParentReferenceColumnName(InformationEntity ie)
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.
|
String |
getLocalPrimaryKeyColumnName(InformationEntity ie)
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.
|
String |
getLocalRecordInsertionTimeColumnName(InformationEntity ie)
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() . |
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 |
getOtherDescriptiveColumnName(InformationEntity ie)
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 |
getOtherOtherDescriptiveColumnName(InformationEntity ie)
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.
|
QueryResponseGeneratorFactory |
getQueryResponseGeneratorFactory()
Get a factory to manufacture a query response generator capable of performing a query and returning the results.
|
RetrieveResponseGeneratorFactory |
getRetrieveResponseGeneratorFactory()
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 |
getTableNameForInformationEntity(InformationEntity ie)
Get the table name for an information entity.
|
abstract String |
getUIDColumnNameForInformationEntity(InformationEntity ie)
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 |
isInformationEntityInModel(InformationEntity ie)
Is the entity in the information model ?
|
protected boolean |
isInformationEntityInModel(String ieName)
Is the named entity in the information model ?
|
String |
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).
|
protected HashMap additionalIndexMapOfColumnsToTables
protected Connection databaseConnection
protected String databaseRootName
protected static final String defaultDatabaseRootName
protected DicomDictionary dictionary
protected org.hsqldb.Server externalServerInstance
public static final String FILE_COPIED
public static final String FILE_REFERENCED
protected HashMap listsOfAttributesByInformationEntity
protected static final String localFileName
protected static final String localFileReferenceTypeColumnName
protected static final String localParentReferenceColumnName
protected static final String localPrimaryKeyColumnName
protected static final String localRecordInsertionTimeColumnName
protected static final String personNameCanonicalColumnNamePrefix
protected static final String personNameCanonicalColumnNameSuffix
protected static final String personNamePhoneticCanonicalColumnNamePrefix
protected static final String personNamePhoneticCanonicalColumnNameSuffix
protected InformationEntity rootInformationEntity
protected static final String userColumnName1
protected static final String userColumnName2
protected static final String userColumnName3
protected static final String userColumnName4
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.
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 tablesDicomException
- thrown if a connection to the database cannot be establishedpublic 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.
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 TreeModelDicomException
- thrown if a connection to the database cannot be establishedpublic 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.
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 tablesDicomException
- thrown if a connection to the database cannot be establishedpublic 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.
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 TreeModelDicomException
- thrown if a connection to the database cannot be establishedprotected 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.
b
- the buffer to append tovalue
- either NULL or the quoted escaped string value to appendpublic 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.
protected void createAdditionalIndexes() throws DicomException
Create any additional indexes to optimize queries, for example for UIDs.
Called after creating tables and default indexes.
DicomException
protected abstract String createPrimaryKeyForSelectedInformationEntity(InformationEntity ie)
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.
ie
- the InformationEntity
for which a key is requestedpublic void deleteRecord(InformationEntity ie, String localPrimaryKeyValue) throws DicomException
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.
ie
- the InformationEntity
that corresponds to the table containing the record to be deletedlocalPrimaryKeyValue
- primary key of the recordDicomException
- thrown if there are problems executing the database statementprotected 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.
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 TreeModelDicomException
- thrown if a connection to the database cannot be establishedprotected 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.
b
- the statement being constructedie
- the InformationEntity
for which a create table statement is being constructedprotected 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.
b
- the statement being constructedie
- the InformationEntity
for which a create table statement is being constructedprotected void extendCreateStatementStringWithUserColumns(StringBuffer b, InformationEntity ie)
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).
b
- the statement being constructedie
- the InformationEntity
for which a create table statement is being constructedprotected 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
.
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- the InformationEntity
for which an insert statement is being constructedDicomException
- thrown if there are problems extracting the DICOM attributesprotected 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
.
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- the InformationEntity
for which an insert statement is being constructedfileName
- the local filename, which may be non-null for INSTANCE
level insertionsfileReferenceType
- "C" for copied (i.e., delete on purge), "R" for referenced (i.e., do not delete on purge)DicomException
- thrown if there are problems extracting the DICOM attributesprotected 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
.
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- the InformationEntity
for which an insert statement is being constructedDicomException
- thrown if there are problems extracting the DICOM attributesprotected 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
.
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- the InformationEntity
for which an insert statement is being constructedDicomException
- thrown if there are problems extracting the DICOM attributesprotected 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
.
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- the InformationEntity
for which a select statement is being constructedDicomException
- thrown if there are problems extracting the DICOM attributesprotected 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
.
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- the InformationEntity
for which a select statement is being constructedDicomException
- thrown if there are problems extracting the DICOM attributesprotected 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 be StudyInstanceUID
, the series to be SeriesInstanceUID
and so on. A
match requested at the series level would then require PatientID
, StudyInstanceUID
and SeriesInstanceUID
to match what was in the supplied AttributeList
Called when inserting a new record for an instance of the entity.
Specific to each concrete information model extending DatabaseInformationModel
.
b
- the statement being constructedlist
- the DICOM attributes of a composite object, containing the attributes describing this instance of the entityie
- the InformationEntity
for which a select statement is being constructedDicomException
- thrown if there are problems extracting the DICOM attributespublic 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.
ie
- the InformationEntity
of the records to be returnedArrayList
of records, each value of which is a
TreeMap
of String
values indexed by String
upper case column namesDicomException
- thrown if the query failspublic 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.
ieWanted
- the InformationEntity
of the record level of the attribute to be returnedieParent
- the InformationEntity
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)ArrayList
of records, each value of which is a
TreeMap
of String
values indexed by String
upper case column namesDicomException
- thrown if the query failspublic 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.
ie
- the InformationEntity
of the records to be returnedkeyName
- the String
name of the key to be matchedkeyValue
- the String
value of the key to be matchedArrayList
of records, each value of which is a
TreeMap
of String
values indexed by String
upper case column namesDicomException
- thrown if the query failspublic 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).
ie
- the InformationEntity
of the records to be returnedlocalParentReference
- the string value of the unique key which identifies the instance of the parent entity (not including wildcards)ArrayList
of records, each value of which is a
TreeMap
of String
values indexed by String
upper case column namesDicomException
- thrown if the query failspublic 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 !
ie
- the InformationEntity
of the records to be returneduid
- the String
UID of the records to be returnedArrayList
of records, each value of which is a
TreeMap
of String
values indexed by String
upper case column namesDicomException
- thrown if the query failspublic 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.
ie
- the InformationEntity
of the record to be returnedlocalPrimaryKeyValue
- the string value of the unique key which identifies the instance of the entity (not including wildcards)TreeMap
of String
values indexed by String
upper case column namesDicomException
- thrown if the query failspublic 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.
ie
- the InformationEntity
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 returnedString
value, or an empty string if not foundDicomException
- thrown if the query failspublic AttributeTag getAttributeTagFromDatabaseColumnName(String columnName)
Get the name of the DICOM element corresponding to the database table column.
columnName
- the name of the database columnpublic abstract InformationEntity getChildTypeForParent(InformationEntity ie)
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.
ie
- the InformationEntity
that is the parent, such as a patient, study, etc.InformationEntity
that is the childpublic abstract InformationEntity getChildTypeForParent(InformationEntity ie, AttributeList list)
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.
ie
- the InformationEntity
that is the parent, such as a
patient, study, etc.list
- the AttributeList
that are the contents the instanceInformationEntity
that is the childpublic 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.
ie
- the InformationEntity
that is the parent, such as a
patient, study, etc.concatenation
- true if concatenations are to be considered in the modelInformationEntity
that is the childpublic static String getDatabaseColumnNameFromDicomName(String descriptiveName)
Get the name of the table column corresponding to the DICOM element name.
descriptiveName
- the name of the DICOM elementString
column name, or null if not knownpublic String getDatabaseColumnNameFromDicomTag(AttributeTag tag)
Get the name of the table column corresponding to the DICOM tag.
tag
- the tag of the DICOM elementString
column name, or null if not knownpublic abstract String getDescriptiveColumnName(InformationEntity ie)
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 the PatientName
.
ie
- the InformationEntity
, such as a
patient, study, etc.null
if there is no such columnpublic String getDicomNameFromDatabaseColumnName(String columnName)
Get the name of the DICOM element corresponding to the database table column.
columnName
- the name of the database columnString
descriptive name of the DICOM element, or null if not knownpublic InformationEntity getInformationEntityFromTag(AttributeTag tag)
tag
- public String getLocalFileNameColumnName(InformationEntity ie)
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.
ie
- the InformationEntity
, such as a
instance (e.g. an image)public String getLocalFileReferenceTypeColumnName(InformationEntity ie)
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.
ie
- the InformationEntity
, such as a
instance (e.g. an image)public String getLocalParentReferenceColumnName(InformationEntity ie)
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.
ie
- the InformationEntity
, such as a
patient, study, etc.public String getLocalPrimaryKeyColumnName(InformationEntity ie)
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.
ie
- the InformationEntity
, such as a
patient, study, etc.public String getLocalRecordInsertionTimeColumnName(InformationEntity ie)
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()
.
ie
- the InformationEntity
, such as a
patient, study, etc.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 an Image
, a Waveform
, etc.
ie
- the InformationEntity
, such as a
patient, study, etc.returnedAttributes
- the attributes from the selected row of the table for this instance of the entitypublic abstract String getOtherDescriptiveColumnName(InformationEntity ie)
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.
ie
- the InformationEntity
, such as a
patient, study, etc.null
if there is no such columnpublic abstract String getOtherOtherDescriptiveColumnName(InformationEntity ie)
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 the PatientID
.
ie
- the InformationEntity
, such as a
patient, study, etc.null
if there is no such columnpublic QueryResponseGeneratorFactory getQueryResponseGeneratorFactory()
Get a factory to manufacture a query response generator capable of performing a query and returning the results.
public RetrieveResponseGeneratorFactory getRetrieveResponseGeneratorFactory()
Get a factory to manufacture a retrieve response generator capable of performing a retrieve and returning the results.
public static String getSQLTypeFromDicomValueRepresentation(byte[] vr)
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.
vr
- the 2 letter DICOM Value Representation as an array of two ASCII bytes.public static String getTableNameForInformationEntity(InformationEntity ie)
Get the table name for an information entity.
ie
- the InformationEntity
that is the parent, such as a patient, study, etc.public abstract String getUIDColumnNameForInformationEntity(InformationEntity ie)
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.
ie
- the InformationEntity
, such as a
study, series, instance, etc.null
if there is no such columnpublic 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.
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)DicomException
- thrown if there are problems extracting the DICOM attributesprotected abstract boolean isInformationEntityInModel(InformationEntity ie)
Is the entity in the information model ?
Will be specific to a particular concrete information model.
protected boolean isInformationEntityInModel(String ieName)
Is the named entity in the information model ?
Will be specific to a particular concrete information model.
ieName
- a String name, whose case is ignored (e.g., a database table named for the corresponding information entity)public String toString()
Returns a string describing the structure (not the contents) of the database.
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.
ie
- the InformationEntity
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 setDicomException
- thrown if the update fails