public class TdbRecord extends TdbMessageProvider implements com.tietoenator.trip.jxp.internal.utils.DOMSink
Constructor and Description |
---|
TdbRecord(TdbSession session)
Constructor, creates a blank record container
|
TdbRecord(TdbSession session,
java.lang.String name,
boolean createFields)
Constructor, associates the new instance with the named database or thesaurus
|
TdbRecord(TdbSession session,
TdbControlObject ob,
boolean createFields)
Constructor, associates the new instance with the item referenced by
the provided Control object
|
TdbRecord(TdbSession session,
TdbDatabaseDesign design,
boolean createFields)
Constructor, associates the new instance with the design provided.
|
Modifier and Type | Method and Description |
---|---|
void |
addToTemplate(java.lang.String name)
Add a particular field by name to the overall retrieval template.
|
void |
addToTemplate(java.lang.String fieldName,
java.lang.String baseName)
Add a particular field by name to the overall retrieval template.
|
void |
addToTemplate(TdbFieldTemplate tmpl)
Add a particular field template to the overall retrieval template.
|
TdbComponent |
appendComponent()
Create a new component (part record), link it to this record
|
void |
clear(boolean all)
Clear any existing state from the TdbRecord instance.
|
void |
commit()
Commit the current record to the current database.
|
TdbRecord |
copy(java.lang.String targetDatabase)
Copies the current record to the specified database.
|
TdbRecord |
copy(TdbDatabaseDesign targetDatabase)
Copies the current record to the specified database.
|
void |
delete()
Delete the current record from the current database
In order to call this method successfully, the calling application must first establish the database name and record id to be deleted, using the methods setDatabaseName() and setRecordId(). |
void |
deleteComponent(int index)
Delete the identified component from the current record.
|
void |
deleteComponent(java.lang.String name)
Delete the named component from the current record.
|
void |
get()
Retrieve the current record from the current database
Prior to calling this method, the calling application must have established context using the setDatabaseName() method along with one of the setRecordName() or setRecordId() methods. |
org.w3c.dom.Document |
get(TdbDataFormat format)
Retrieve the current record from the current database.
|
java.util.List<java.lang.String> |
getCategories()
Retrieves the classification categories that have been assigned to this record.
|
TdbComponent |
getComponent(int index)
Retrieve the identified component (0 is head, >= 1 is part)
Note that by design, the components retrieved by this method are "live" and any updates on them are performed directly on the component representation maintained within the TdbRecord instance. |
TdbComponent |
getComponent(java.lang.String name)
Retrieve the named component
Note that by design, the components retrieved by this method are "live" and any updates on them are performed directly on the component representation maintained within the TdbRecord instance. |
java.lang.String |
getDatabaseName()
Get the name of the database for which this TdbRecord is valid
|
java.util.Iterator<TdbFieldTemplate> |
getFieldTemplates()
An iterator of the field template objects in this TdbRecord.
|
TdbComponent |
getHead()
Get the values that comprise the head record
Note that by design, the component retrieved is "live" and any updates on it are performed directly on the head record representation maintained within the TdbRecord instance. |
boolean |
getIndexOnCommit()
Returns true if changes to the record should be indexed on commit.
|
TdbNlpInfo |
getNlpInfo()
Provides access to an object that allows control and enabling of
natural language processing behavior such as keyword and meta-data
analysis.
|
int |
getRank()
Retrieve the rank assigned to this record
Ranks retrieved using this property are normalized, where appropriate, to a percentage range. |
int |
getRawRank()
Retrieve the raw rank assigned to this record
Ranks retrieved using this property are not normalized. |
int |
getRecordId()
Retrieve the current value of the record number field, if any.
|
java.lang.String |
getRecordName()
Retrieve the current value, if any, of the record name field
|
java.util.Date |
getTimeStamp()
Returns the time stamp for when the current record was stored.
|
java.util.List<TdbAseCall> |
insertAseList()
List of ASE routines to be called upon commit of a new record.
|
boolean |
isChanged()
Returns the change status for the record.
|
boolean |
isDeleted()
Indicates if this record object represents a deleted record.
|
boolean |
isGraphRecord()
Indicates if this record is a graph record.
|
boolean |
isXmlRecord()
Indicates if this record is a TRIPxml record.
|
void |
lock()
Request an exclusive lock on this record.
|
java.util.List<TdbComponent> |
parts()
Retrieve the collection of part records (where applicable)
Note that by design, the components retrieved from this collection are "live" and any updates on them are performed directly on the part record representation maintained within the TdbRecord instance. |
void |
removeFromTemplate(java.lang.String name)
Remove a field from the retrieval template
In order to perform a valid retrieval operation, calling applications must establish a retrieval template consisting of all fields (whether in the head record or part record) that should be retrieved, and optionally applying retrieval characteristics to that field. |
void |
setDatabaseName(java.lang.String name)
Set the name of the database for which this TdbRecord is valid
|
void |
setIndexOnCommit(boolean enable)
Sets flag indicating if changes to the record should be indexed on commit.
|
void |
setPartId(int id)
Set a specific part component Id to be retrieved
In certain application contexts, it is useful to retrieve a single part component at a time, for example in the face of extremely large part components during operations that may be aborted at any time. |
void |
setPartNameField(TdbFieldDesign field)
Set the part name field, so that automatic assignment from the
TdbComponent.getName() and TdbComponent.setName() methods happens
appropriately.
|
void |
setRecordId(int id)
Establish the value of the record number field
|
void |
setRecordName(java.lang.String name)
Set the value of the record name field
|
void |
setRecordNameField(TdbFieldDesign field)
Set the record name field, so that automatic assignment from the
getRecordName() / setRecordName() methods happens appropriately.
|
void |
setRecordNumberField(TdbFieldDesign field)
Set the record number field, so that automatic assignment from the
getRecordId() method happens appropriately.
|
void |
setRetrieveHead(boolean head)
Set whether retrieval operations using this instance should retrieve
any fields from the head component.
|
void |
setRetrieveParts(boolean parts)
Set whether retrieval operations using this instance should retrieve
part components at all.
|
void |
setTemplateMarkup(java.lang.String before,
java.lang.String after)
Set a common hit term markup scheme for the entire template; this can only
be performed after all field templates have been added to the retrieval
template, as it modifies field template instances that are currently part
of the retrieval template.
|
void |
unlock()
Releases an exclusive lock obtained on this record.
|
java.util.List<TdbAseCall> |
updateAseList()
List of ASE routines to be called upon commit of a modified record.
|
codeList, getLastCode, getLastMessage, hasMessages, messageList, resetMessages
cancel, getSession, isCancelable, setCancelable
public TdbRecord(TdbSession session) throws TdbException
session
- Active sessionTdbException
public TdbRecord(TdbSession session, TdbDatabaseDesign design, boolean createFields) throws TdbException
session
- Active sessiondesign
- Database designcreateFields
- If true, the constructor will automatically create a
retrieval template using all fields from the database designTdbException
public TdbRecord(TdbSession session, java.lang.String name, boolean createFields) throws TdbException
session
- Active sessionname
- Name of database or thesauruscreateFields
- If true, the constructor will automatically create a
retrieval template using all fields from the database designTdbException
public TdbRecord(TdbSession session, TdbControlObject ob, boolean createFields) throws TdbException
session
- Active sessionob
- Control object reference for the item with which to associate
this record, normally a database or thesaurus.createFields
- If true, the constructor will automatically create a
retrieval template using all fields from the database designTdbException
public java.lang.String getDatabaseName()
public void setDatabaseName(java.lang.String name)
name
- The name of the databasepublic void setRecordNameField(TdbFieldDesign field)
field
- A design object for the record name fieldpublic void setPartNameField(TdbFieldDesign field)
field
- A design object for the part name fieldpublic void setRecordNumberField(TdbFieldDesign field)
field
- A design object for the record number fieldpublic java.lang.String getRecordName() throws TdbException
TdbException
public boolean getIndexOnCommit()
Indexing a record as it is committed is a form of synchronous indexing which is supported with TRIPsystem version 7.0 and later.
If you index synchronously, best practise is to regularly schedule a regular index batch job (for large databases, preferably on the server console). Not doing this may degrade performance over time.
public void setIndexOnCommit(boolean enable)
Indexing a record as it is committed is a form of synchronous indexing which is supported with TRIPsystem version 7.0 and later.
If you index synchronously, best practise is to regularly schedule a regular index batch job (for large databases, preferably on the server console). Not doing this may degrade performance over time.
enable
- True if the record should be indexed and false otherwise.public java.util.Date getTimeStamp() throws TdbException
TdbException
public void setRecordName(java.lang.String name) throws TdbException
name
- The value of the record name fieldTdbException
public int getRecordId() throws TdbException
If the isDeleted property is true, the returned record ID will be zero if connected to TRIPsystem 7.1 and older, and to the likely ID of the deleted record if connected to TRIPsystem 7.2 and later.
TdbException
TdbRecord.isDeleted()
public void setRecordId(int id) throws TdbException
id
- The record numberTdbException
public void setRetrieveHead(boolean head)
head
- If set false, retrieval operations will not retrieve fields
from the head record structure.public void setRetrieveParts(boolean parts)
parts
- If set false, retrieval operations will not retrieve fields
from the part record structure.public void setPartId(int id)
id
- To restrict retrieval operations to a single part record, set
this value to a non-zero number. To reset to all parts, set this value
to zero.public TdbComponent getHead()
public java.util.List<TdbComponent> parts()
public java.util.List<java.lang.String> getCategories()
public java.util.List<TdbAseCall> updateAseList()
public java.util.List<TdbAseCall> insertAseList()
public int getRank()
public int getRawRank()
public boolean isXmlRecord()
public boolean isGraphRecord()
public TdbNlpInfo getNlpInfo()
public boolean isDeleted()
If this property is true in sessions against TRIPsystem 7.2 and later, the record ID property will be set to the likely ID of the deleted record.
If this property is true in sessions against older versions of TRIPsystem, the record ID property will be zero.
TdbRecord.getRecordId()
public boolean isChanged()
public void addToTemplate(TdbFieldTemplate tmpl) throws TdbException
tmpl
- The field template to addTdbException
public void addToTemplate(java.lang.String name) throws TdbException
name
- The name of the field to addTdbException
public void addToTemplate(java.lang.String fieldName, java.lang.String baseName) throws TdbException
fieldName
- The name of the field to addbaseName
- The name of the base where is field definedTdbException
public void removeFromTemplate(java.lang.String name)
name
- The name of the field to removepublic java.util.Iterator<TdbFieldTemplate> getFieldTemplates()
public void setTemplateMarkup(java.lang.String before, java.lang.String after)
before
- String to insert before hit termsafter
- String to insert after hit termspublic void lock() throws TdbException
If this method is successful, the record will be locked for update from other users until the commit() method is called.
If, once locked, the update is aborted before commit() is called, the lock must be released by a call to Clear(). If this is not done, the lock will remain in effect for the remainder of the lifetime of the session.
This method can only be called on TdbRecord instances that represent existing records. If called on a TdbRecord instance that does not have record ID or record name associated with it, a TdbException will be thrown with code set to TdbException.INVALID_ARGS.
This method requires TRIPsystem 7.0-3 or later.
TdbException
- If lock request is unsuccessful.TdbRecord.clear(boolean)
,
TdbRecord.unlock()
public void unlock()
This method is used to cancel an exclusive lock obtained on this record. It can also be used to roll back a copied but not yet committed record. Note that an exclusive lock is automatically released by commit(), in which case the Unlock method does not have to be called.
This method requires TRIPsystem 7.0-3 or later.
public TdbComponent appendComponent()
public TdbComponent getComponent(int index)
index
- The ID of the part to retrieve -- 0 is the head recordpublic TdbComponent getComponent(java.lang.String name) throws TdbException
name
- The name of the part to retrieveTdbException
public void deleteComponent(int index) throws TdbException
index
- The ID of the part to deleteTdbException
public void deleteComponent(java.lang.String name) throws TdbException
name
- The name of the part to deleteTdbException
public void get() throws TdbException
TdbException
public org.w3c.dom.Document get(TdbDataFormat format) throws TdbException
Prior to calling this method, the calling application must have established context using the setDatabaseName() method along with one of the setRecordName() or setRecordId() methods. The application must also make use of the addToTemplate() method to request one or more fields to be retrieved as part of the operation. Optionally, calling applications can restrict the domain of retrieval to either just the head record or just one or more part records by using the setRetrieveHead(), setRetrieveParts() and setPartId() methods.
The result of the retrieval generated by this method is not deserialized internally into a sequence of fields and components. The content of this object following a call to this method is blank.
Values for any string fields requested are returned inline encoded as base64. This may result in a very large response document and may cause session timeout or lack of enough memory resources to complete processing. Make sure to exclude any unnecessary STRING fields from retrieval.
This method causes network I/O.
format
- The format in which to retrieve dataTdbException
public TdbRecord copy(java.lang.String targetDatabase) throws TdbException
The target database must have the same design as the source database.
The copy operation is done fully on the server-side. All field values from the source record will be copied to the target record, regardless of what field values have been fetched from the source record prior to the copy operation.
The copy operation will not commit the record; this must be done separately after the copy operation has completed successfully. This allows the application to modify the target record prior to commit.
After a successful call to this method, the current TdbRecord instance will refer to the target record.
If the copy operation succeeds but later should be rolled back instead of committed, it is critical that the application calls the unlock() method or the clear(boolean) method with 'true' as argument in order to release server-side resources held for the uncommitted target record. Failure to do this may cause memory leaks and in the case of database designs with record name fields, retained record locks.
If the database has a record name field and the target database is the same as the source database, the record name must be set to a new value on the returned copy before commit.
The TdbRecord returned will not have any of the field values locally; all values are copied on the server. If you wish to modify or assign new values to fields in the copy, use the TdbComponent.createField(TdbFieldDesign) method to add field objects to hold the new or modified values for the copy.
This method requires TRIPsystem 7.0-4 or later, alternatively version 6.2-11 or later of the TRIPsystem 6.2 series.
targetDatabase
- Name of database to which the current record is to be copied.TdbException
- If the copy operation failedpublic TdbRecord copy(TdbDatabaseDesign targetDatabase) throws TdbException
The target database must have the same design as the source database.
The copy operation is done fully on the server-side. All field values from the source record will be copied to the target record, regardless of what field values have been fetched from the source record prior to the copy operation.
The copy operation will not commit the record; this must be done separately after the copy operation has completed successfully. This allows the application to modify the target record prior to commit.
After a successful call to this method, the current TdbRecord instance will refer to the target record.
If the copy operation succeeds but later should be rolled back instead of committed, it is critical that the application calls the unlock() method or the clear(boolean) method with 'true' as argument in order to release server-side resources held for the uncommitted target record. Failure to do this may cause memory leaks and in the case of database designs with record name fields, retained record locks.
If the database has a record name field and the target database is the same as the source database, the record name must be set to a new value on the returned copy before commit.
The TdbRecord returned will not have any of the field values locally; all values are copied on the server. If you wish to modify or assign new values to fields in the copy, use the TdbComponent.createField(TdbFieldDesign) method to add field objects to hold the new or modified values for the copy.
This method requires TRIPsystem 7.0-4 or later, alternatively version 6.2-11 or later of the TRIPsystem 6.2 series.
targetDatabase
- Design for the database to which the current record is to be copied.TdbException
- If the copy operation failedpublic void commit() throws TdbException
This method will either insert a new record to the database, or update an existing record. The decision as to whether to insert or update depends on the state of the current record. If the record was retrieved using any of the get() methods, or if the record's ID has been set using the setDatabaseName() and setRecordId() methods, then an update will be performed. Failing these conditions, an insert will be performed.
If an exclusive lock has been obtained on this record, the lock will be automatically released upon successful completion of the commit operation.
When used with TRIPsystem 7.0 and later, it is possible to index a record synchronously upon committing it. To do this, call the setIndexOnCommit() method with 'true' as argument before calling commit(). However, it should be noted that best practise is to defer indexing until it is absolutely needed, thereby allowing many records to be indexed in one go, resulting in a better index structure in the long run.
If you index synchronously, best practise is to regularly schedule a regular index batch job (for large databases, preferably on the server console). Not doing this may degrade performance over time.
If the record is new and the insertAseList list contains names of ASE procedures that exist on the server, these procedures will be called in sequence after the data has been added to the in-memory record control, but before it is actually committed to disk.
If the record is updated and the updateAseList list contains names of ASE procedures that exist on the server, these procedures will be called in sequence after the modifications have been done in the in-memory the record control, but before it is actually committed to disk.
The insertAseList and updateAseList behavior requires TRIPsystem version 6.2-4 or later. To index on commit, TRIPsystem 7.0 or later is required.
This method causes network I/O.
TdbException
public void delete() throws TdbException
TdbException
public void clear(boolean all)
If this method is called before commit() and an exclusive lock exists on this record, the lock will be released by this method if the parameter 'all' is set to true.
all
- If true, all state is cleared, including the database with
which the record is associated, the record name/ID, etc. If false, the
record structure is initialized, but the basic state of the record's
association is maintained.