Using database views
An alternative to retrieve documents is using a Domino view. VA Smalltalk Domino Connection fully supports the capabilities of Domino views. The AbtLnDatabaseView class and some related classes (mainly subclasses of AbtLnTreeNode) provide the means to model a view as a graph. You already have some experience with the directed graph model of AbtLnDatabaseView if you tried the samples in the previous chapters. What follows is a more complete description of how views are modeled in Domino Connection classes.
From the perspective of a user, a view is a hierarchical list: it is multi-columned and displays categories and response documents which can be expanded or collapsed. The column definitions determine what is shown in the columns; the selection formula controls which documents are shown.
Logically, views are sorted lists of compiled indices, the result of complex pre-executed queries. Indices help you access documents rapidly, even when large amounts of data are involved.
Technically, views are files which lie within the storage space of a database, in which partial information from documents and unique document IDs are administered.
The Smalltalk classes present a collection based model which arranges the view entries in form a tree. A virtual root node is introduced for consistency of the model. Categories and documents as well as response documents are represented by nodes in the tree. All nodes of the same hierarchy level are contained in a collection.
The following graphic shows how to understand the model:
View hierarchy
Here is a code sample that shows how to navigate from the virtual root node of a view hierarchy down to a document. You will open a document at this point and display the contents of a document's Body field. You will learn more about documents in Using the Domino Form part (AbtNotesFormPart).
Note:
For this code sample, you use the vasample.nsf database which is located in the \sample directory of your VA Smalltalk install directory. Do not forget to copy the sample databases to a directory called \vasample in your local data directory. If you do not copy the files, you have to modify the sample code below to match your database location. Also we assume that you did not delete the documents in this database. We will refer to categories that are present in the database at the time of installation.
| localConnection sampleDatabase sampleView rootNode selectedCategoryNode|
"Initialize your runtime environment"
AbtLnEnvironment startUp.
"Create a local connection"
localConnection := AbtLnConnection local.
"Open the test database"
sampleDatabase := localConnection
openDatabase:'VASAMPLE\VASAMPLE.NSF'.
"Open the sampleDatabases view named 'By Category'"
sampleView := sampleDatabase openViewRebuild: 'By Category'.
"Expand the virtual root node to receive all the first category nodes
- and select the category named: 'A note for beginners' "
selectedCategoryNode := sampleView root
children detect:
[ :node | node category = 'A note for beginners' ].
"Expand the first level category nodes to get the next level nodes
which are in this case documents and print some of the view
information onto the Transcript window"
selectedCategoryNode children do: :node |
Transcript nextPutAll: (node asNote fill at: 'Body'); cr.
].
"Close view, database and runtime environment"
sampleView close.
sampleDatabase close.
AbtLnEnvironment shutDown.
Note:
The sample shows how to explicitly close the view and the database before shutting down AbtLnEnvironment. It is not really necessary to do that because the shutDown message will close all open databases and views anyway. Despite that, it is a good practice to close open databases and views when they are not needed during an application. Open databases and views will consume considerable amounts of memory.
This iterative approach is best suited for highly structured views with deep categorization and response hierarchies. The method is time-consuming though, if the accessed hierarchy levels contain huge numbers of nodes (for example a flat view which would yield all document nodes in the first level collection). The current version of Domino Connection adds a new protocol to allow quick results in sorted views with large numbers of documents.
Last modified date: 06/22/2018