OPI Chapter 5: Updating a Thesaurus Database

advertisement

Chapter 5

Updating a Thesaurus Database

This chapter shows you how to modify data in a thesaurus database. It describes the following:

 how to perform a thesaurus transaction

 the various update operations

 browsing specific thesaurus relations

For information about a thesaurus database definition, see “General Setup.”

Thesaurus Updating Overview

With the functions mentioned in this section, you can add and modify relations in a thesaurus database. You can do any of the operations shown in the following table:

To Call add a thesaurus relation OpiAddThesRelation delete a thesaurus relation OpiDeleteThesRelation edit a thesaurus relation OpiEditThesRelation

72

Updating a Thesaurus Database

All the update activities listed above must be performed within a transaction. The procedure for using the transaction routines is shown below. For more information about transactions in general, see Database Loading and Maintenance.

Performing a Transaction on a Thesaurus

1.

Make sure the desired thesaurus database is already open, or open it now.

OpiOpenThesDb

2.

Start a thesaurus transaction.

OpiStartThesTrans

3.

Perform the desired update operation (for example, modify a relation).

4.

If the update is successful, complete the transaction.

OpiFinishThesTrans

Otherwise, abort the transaction.

OpiAbortThesTrans

5.

When finished with it, close the thesaurus database.

OpiCloseThesDB

Adding a Relation

To add a relation, follow the steps in the procedure below.

1.

If the thesaurus database is not yet open, open it.

OpiOpenThesDb

2.

Create the necessary objects: thesaurus and thesaurus relation.

OpiMakeThesaurus

OpiMakeThesRelation

3.

Add the new relation.

OpiAddThesRelation

4.

Set the value of an attribute in the thesaurus relation object.

OpiSetThesRelationAttr

(VBOpiSetThesRelationAttr) 1

Updating a Thesaurus Database

73

5.

Destroy the objects when you are finished with them.

OpiDestroyThesaurus

OpiDestroyThesRelation

1 Visual Basic users call this routine instead of the preceding one.

Deleting a Relation

To delete a relation, follow the steps in the procedure below.

1.

If the thesaurus database is not yet open, open it.

OpiOpenThesDb

2.

Create the necessary objects: thesaurus and thesaurus relation.

OpiMakeThesaurus

OpiMakeThesRelation

3.

Search the thesaurus for the desired terms and write these terms to the thesaurus object.

OpiBrowseExtended

4.

Delete the relation.

OpiDeleteThesRelation

5.

Repeat steps 3 - 4 until all the thesaurus terms in the databuff object have been processed.

6.

Destroy the objects when you are finished with them.

OpiDestroyThesaurus

OpiDestroyThesRelation

Adding or Editing a Relation by Referencing an Existing

Relation

To modify a relation, follow the steps in the procedure below.

1.

If the thesaurus database is not yet open, open it.

OpiOpenThesDb

74

Updating a Thesaurus Database

2.

Create the necessary objects: thesaurus and thesaurus relation. You need two thesaurus relation objects, one for the existing relation and one for the new, edited relation.

OpiMakeThesaurus

OpiMakeThesRelation

3.

Search the thesaurus for the desired terms and write these terms to the thesaurus object.

OpiBrowseExtended

4.

Transfer a relation from the thesaurus object to the relation object.

OpiGetThesRelation

5.

Make a copy of the existing relation.

OpiNewThesRelation

6.

Set the values desired for the new relation.

OpiSetThesRelationAttr

(VBOpiSetThesRelationAttr) 1

7.

Perform the edit on the relation.

OpiEditThesRelation

8.

Repeat steps 4 - 7 until all the thesaurus terms in the thesaurus object have been edited as desired.

9.

Destroy the objects when you are finished with them.

OpiDestroyThesaurus

OpiDestroyThesRelation

1 Visual Basic users call this routine instead of the preceding one.

Accessing Terms with OpiBrowseExtended

As an alternative to OpiBrowse (for information about accessing thesaurus terms, see

“Searching a Database.” ) you can use OpiBrowseExtended to browse thesaurus terms based on a specific relation-type, relation usage, or hierarchical relation. For example, with OpiBrowseExtended, you could have the system return specifically the narrow term relations and the scope notes for terms in the LOCATION index.

Updating a Thesaurus Database

75

Note: OpiBrowseExtended and OpiBrowse use their own separate sets of routines for transferring terms and attributes. You cannot mix these sets. For example, you cannot use OpiGetBrowseTermAttr with OpiBrowseExtended. The routines in each set are:

OpiBrowse uses OpiBrowseExtended uses

OpiMakeBrowseTerm OpiMakeThesRelation

OpiGetBrowseTerm OpiGetThesRelation

OpiGetBrowseTermAttr OpiGetThesRelAttr

To browse specific relations in a thesaurus, use the routines listed in the procedure below.

Browsing a Specific Relation

1.

Create the necessary objects: databuff and thesaurus relation.

OpiMakeDataBuff

OpiMakeThesRelation

2.

Search the thesaurus for the desired terms and write these terms to the databuff object.

OpiBrowseExtended

3.

Transfer a thesaurus term from the databuff object to the thesaurus relation object.

OpiGetThesRelation

4.

Transfer a specific thesaurus relation attribute to a specified location.

OpiGetThesRelationAttr

5.

Destroy the objects when you are finished with them.

OpiDestroyDataBuff

OpiDestroyThesRelation

76

Updating a Thesaurus Database

Download