Class TdbRecord
- All Implemented Interfaces:
com.tietoenator.trip.jxp.internal.utils.DOMSink
- Direct Known Subclasses:
TdbGraphRecord
,TdbGridRecord
,TdbXmlRecord
-
Constructor Summary
ConstructorsConstructorDescriptionTdbRecord
(TdbSession session) Constructor, creates a blank record containerTdbRecord
(TdbSession session, TdbDatabaseDesign design, boolean createFields) Constructor, associates the new instance with the design provided.TdbRecord
(TdbSession session, TdbControlObject ob, boolean createFields) Constructor, associates the new instance with the item referenced by the provided Control objectTdbRecord
(TdbSession session, String name, boolean createFields) Constructor, associates the new instance with the named database or thesaurus -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a particular field template to the overall retrieval template.void
addToTemplate
(String name) Add a particular field by name to the overall retrieval template.void
addToTemplate
(String fieldName, String baseName) Add a particular field by name to the overall retrieval template.Create a new component (part record), link it to this recordvoid
clear
(boolean all) Clear any existing state from the TdbRecord instance.void
commit()
Commit the current record to the current database.copy
(TdbDatabaseDesign targetDatabase) Copies the current record to the specified database.Copies the current record to the specified database.void
delete()
Delete the current record from the current databasevoid
deleteComponent
(int index) Delete the identified component from the current record.void
deleteComponent
(String name) Delete the named component from the current record.void
get()
Retrieve the current record from the current databaseget
(TdbDataFormat format) Retrieve the current record from the current database.Retrieves the classification categories that have been assigned to this record.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.getComponent
(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.Get the name of the database for which this TdbRecord is validAn iterator of the field template objects in this TdbRecord.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
Returns true if changes to the record should be indexed on commit.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
Retrieve the raw rank assigned to this record
Ranks retrieved using this property are not normalized.int
Retrieve the current value of the record number field, if any.Retrieve the current value, if any, of the record name fieldReturns the time stamp for when the current record was stored.List of ASE routines to be called upon commit of a new record.boolean
Returns the change status for the record.boolean
Indicates if this record object represents a deleted record.boolean
Indicates if this record is a graph record.boolean
Indicates if this record is a TRIPxml record.void
lock()
Request an exclusive lock on this record.parts()
Retrieve the collection of part records (where applicable)void
removeFromTemplate
(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
(String name) Set the name of the database for which this TdbRecord is validvoid
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 fieldvoid
setRecordName
(String name) Set the value of the record name fieldvoid
setRecordNameField
(TdbFieldDesign field) Set the record name field, so that automatic assignment from the getRecordName() / setRecordName() methods happens appropriately.void
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
(String before, 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.List of ASE routines to be called upon commit of a modified record.Methods inherited from class com.tietoenator.trip.jxp.TdbMessageProvider
codeList, getLastCode, getLastMessage, hasMessages, messageList, resetMessages
Methods inherited from class com.tietoenator.trip.jxp.session.TdbSessionObject
cancel, getSession, isCancelable, setCancelable
-
Constructor Details
-
TdbRecord
Constructor, creates a blank record container- Parameters:
session
- Active session- Throws:
TdbException
-
TdbRecord
public TdbRecord(TdbSession session, TdbDatabaseDesign design, boolean createFields) throws TdbException Constructor, associates the new instance with the design provided.- Parameters:
session
- Active sessiondesign
- Database designcreateFields
- If true, the constructor will automatically create a retrieval template using all fields from the database design- Throws:
TdbException
-
TdbRecord
Constructor, associates the new instance with the named database or thesaurus- Parameters:
session
- Active sessionname
- Name of database or thesauruscreateFields
- If true, the constructor will automatically create a retrieval template using all fields from the database design- Throws:
TdbException
-
TdbRecord
Constructor, associates the new instance with the item referenced by the provided Control object- Parameters:
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 design- Throws:
TdbException
-
-
Method Details
-
getDatabaseName
Get the name of the database for which this TdbRecord is valid- Returns:
- The name of the database
-
setDatabaseName
Set the name of the database for which this TdbRecord is valid- Parameters:
name
- The name of the database
-
setRecordNameField
Set the record name field, so that automatic assignment from the getRecordName() / setRecordName() methods happens appropriately.- Parameters:
field
- A design object for the record name field
-
setPartNameField
Set the part name field, so that automatic assignment from the TdbComponent.getName() and TdbComponent.setName() methods happens appropriately.- Parameters:
field
- A design object for the part name field
-
setRecordNumberField
Set the record number field, so that automatic assignment from the getRecordId() method happens appropriately.- Parameters:
field
- A design object for the record number field
-
getRecordName
Retrieve the current value, if any, of the record name field- Returns:
- The value of the record name field, or an empty string if not known
- Throws:
TdbException
-
getIndexOnCommit
public boolean getIndexOnCommit()Returns true if changes to the record should be indexed on commit.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.
- Returns:
- True if the record should be indexed and false otherwise.
-
setIndexOnCommit
public void setIndexOnCommit(boolean enable) Sets flag indicating if changes to the record should be indexed on commit.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.
- Parameters:
enable
- True if the record should be indexed and false otherwise.
-
getTimeStamp
Returns the time stamp for when the current record was stored.- Returns:
- Java Date object with the record timestamp, or a dummy timestamp set to January 1st 1970 for new records not yet committed.
- Throws:
TdbException
-
setRecordName
Set the value of the record name field- Parameters:
name
- The value of the record name field- Throws:
TdbException
-
getRecordId
Retrieve the current value of the record number field, if any.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.
- Returns:
- The record number, if defined
- Throws:
TdbException
- See Also:
-
setRecordId
Establish the value of the record number field- Parameters:
id
- The record number- Throws:
TdbException
-
setRetrieveHead
public void setRetrieveHead(boolean head) Set whether retrieval operations using this instance should retrieve any fields from the head component.
By default, the head component is always retrieved, so applications should only use this property if they wish to retrieve a specific part component without retrieving the head.- Parameters:
head
- If set false, retrieval operations will not retrieve fields from the head record structure.
-
setRetrieveParts
public void setRetrieveParts(boolean parts) Set whether retrieval operations using this instance should retrieve part components at all.
By default, all part components are retrieved (where appropriate). Use this property to defeat this behavior when the application requires only the head record.- Parameters:
parts
- If set false, retrieval operations will not retrieve fields from the part record structure.
-
setPartId
public 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. Use this property to restrict the retrieval operation to a single part component. To reset the retrieval domain to all parts, set this property to zero.- Parameters:
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.
-
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. This is done so that applications may update in place and then simply call commit() to save any changes to the server. Care should be taken, however, in rollback scenarios as any changes that have been made to the head record representation are not recoverable natively from the TdbRecord itself. Such cancellation logic must be performed within the application.- Returns:
- A reference to the head record
-
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. This is done so that applications may update in place and then simply call commit() to save any changes to the server.
Care should be taken, however, in rollback scenarios as any changes that have been made to the part record representation are not recoverable natively from the TdbRecord itself. Such cancellation logic must be performed within the application.
- Returns:
- If there are no part records, the return value is an empty collection.
-
getCategories
Retrieves the classification categories that have been assigned to this record.- Returns:
- A collection of category names (may be an empty collection).
-
updateAseList
List of ASE routines to be called upon commit of a modified record.- Returns:
- List of TdbAseCall objects.
-
insertAseList
List of ASE routines to be called upon commit of a new record.- Returns:
- List of TdbAseCall objects.
-
getRank
public int getRank()Retrieve the rank assigned to this record
Ranks retrieved using this property are normalized, where appropriate, to a percentage range. This only has meaning for non-Boolean and fuzzy logic queries, although the value is reported for all queries.- Returns:
- Normalized rank
-
getRawRank
public int getRawRank()Retrieve the raw rank assigned to this record
Ranks retrieved using this property are not normalized. This only has meaning for non-Boolean queries, although the value is reported for all queries. In the context of non-Boolean queries, this value can be used to merge results from different databases, different query servers, etc. whereas the value reported bygetRank()
is specific to a single search operation and cannot be used to merge results.- Returns:
- Un-normalized rank
-
isXmlRecord
public boolean isXmlRecord()Indicates if this record is a TRIPxml record.- Returns:
- True if the record is an XML database record
-
isGraphRecord
public boolean isGraphRecord()Indicates if this record is a graph record.- Returns:
- True if the record is an graph database record
-
getNlpInfo
Provides access to an object that allows control and enabling of natural language processing behavior such as keyword and meta-data analysis. -
isDeleted
public boolean isDeleted()Indicates if this record object represents a deleted record.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.
- Returns:
- True if this record is a placeholder for a deleted record
- Since:
- TRIPjxp 3.2-0
- See Also:
-
isChanged
public boolean isChanged()Returns the change status for the record.- Returns:
- True if the record has uncommitted changes, otherwise false.
- Since:
- 8.0-4
-
addToTemplate
Add a particular field template to the overall 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.- Parameters:
tmpl
- The field template to add- Throws:
TdbException
-
addToTemplate
Add a particular field by name to the overall 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.- Parameters:
name
- The name of the field to add- Throws:
TdbException
-
addToTemplate
Add a particular field by name to the overall 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.- Parameters:
fieldName
- The name of the field to addbaseName
- The name of the base where is field defined- Throws:
TdbException
-
removeFromTemplate
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.- Parameters:
name
- The name of the field to remove
-
getFieldTemplates
An iterator of the field template objects in this TdbRecord.- Returns:
- An iterator over TdbFieldTemplate instances.
-
setTemplateMarkup
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. Fields added to the template after this call will not receive the markup modifications specified here.- Parameters:
before
- String to insert before hit termsafter
- String to insert after hit terms
-
lock
Request an exclusive lock on this record.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.
- Throws:
TdbException
- If lock request is unsuccessful.- See Also:
-
unlock
public void unlock()Releases an exclusive lock obtained on this record.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.
-
appendComponent
Create a new component (part record), link it to this record- Returns:
- The new component suitable for filling in with fields, etc.
-
getComponent
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. This is done so that applications may update in place and then simply call commit() to save any changes to the server. Care should be taken, however, in rollback scenarios as any changes that have been made to the component representation are not recoverable natively from the TdbRecord itself. Such cancellation logic must be performed within the application.- Parameters:
index
- The ID of the part to retrieve -- 0 is the head record- Returns:
- A reference to the requested component, if found, or else null
-
getComponent
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. This is done so that applications may update in place and then simply call commit() to save any changes to the server. Care should be taken, however, in rollback scenarios as any changes that have been made to the component representation are not recoverable natively from the TdbRecord itself. Such cancellation logic must be performed within the application.- Parameters:
name
- The name of the part to retrieve- Returns:
- A reference to the requested component, if found, or else null
- Throws:
TdbException
-
deleteComponent
Delete the identified component from the current record.
Attempts to delete the head component, i.e. the component with index 0, will fail with an INVALID_ARGS exception being thrown. Note that successful deletion is a local activity, and the resulting record must still be written to the server using the commit() method.- Parameters:
index
- The ID of the part to delete- Throws:
TdbException
-
deleteComponent
Delete the named component from the current record.
Note that successful deletion is a local activity, and the resulting record must still be written to the server using the commit() method.- Parameters:
name
- The name of the part to delete- Throws:
TdbException
-
get
Retrieve the current record from the current databasePrior 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.
This method causes network I/O.
- Throws:
TdbException
-
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. 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.
- Parameters:
format
- The format in which to retrieve data- Returns:
- An XML document containing the record, suitable for transformation or any other custom deserialization technique
- Throws:
TdbException
-
copy
Copies the current record to the specified database.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.
- Parameters:
targetDatabase
- Name of database to which the current record is to be copied.- Returns:
- TdbRecord instance representing an uncommitted copy.
- Throws:
TdbException
- If the copy operation failed
-
copy
Copies the current record to the specified database.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.
- Parameters:
targetDatabase
- Design for the database to which the current record is to be copied.- Returns:
- TdbRecord instance representing an uncommitted copy.
- Throws:
TdbException
- If the copy operation failed
-
commit
Commit the current record to the current database.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.
- Throws:
TdbException
-
delete
Delete the current record from the current databaseIn 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().
This method causes network I/O.
- Throws:
TdbException
-
clear
public void clear(boolean all) Clear any existing state from the TdbRecord instance.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.
- Parameters:
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.
-