The data structure design for this application proceeds directly from the ERD discussed in the previous section. The generated Web pages are basically a taxonomic tree presented in outline form, with links to pages bearing all the photos of a single form.
Hence, the program will build a tree in which each node relates to a taxon, each taxon contains one or more forms, and each form contains one or more photos.
The tree is made of instances of a class named TaxonPhotoSet. Each instance represents all
the photos contained in a specific taxon. The root of
the tree is the TaxonPhotoSet instance
for Class Aves. Each instance may have one or more
TaxonPhotoSet children representing
child taxa for which there are photos in the catalog.
An instance of class FormPhotoSet
represents all the photos cataloged under a specific
form name. A TaxonPhotoSet instance is
a container for one or more FormPhotoSet
instances. For example, if the taxon Clangula hyemalis contains photos
under both the current name (Long-tailed Duck) and the
older name (Oldsquaw), the TaxonPhotoSet
for taxon Clangula
hyemalis will contain two FormPhotoSet objects, one under each name.
Each photo is represented by an ArchImage instance obtained from the image archiving system. Each ArchImage instance describes the size of the
image, and contains cataloging information from the
image cataloging system.
Here is the general flow of the program.
Create an empty TaxonPhotoSet
instance for the root taxon, Class Aves.
This instance will form the root of a taxonomic tree of
TaxonPhotoSet objects. This tree will
contain only nodes for taxa for which there are photos.
Using the index files named on the command line, work
through all the archived, catalogued photos. Each
photo may depict multiple forms: each form in the photo
is added to the tree separately, once for each form
name in the catalog entry. The photo's cataloging
information is represented by an ArchImage object.
When a photo is added under a given form name, we first
find the taxon to which the form is referred. Then
add TaxonPhotoSet nodes to the tree as
necessary to form a path from the root down to the
referred taxon—let's call this the leaf.
Next we make sure that the leaf TaxonPhotoSet contains a FormPhotoSet object for the name we're adding.
Then we add the photo to that FormPhotoSet.
To generate the Web pages, we traverse the tree of
TaxonPhotoSet objects in preorder, that
is, starting with the root, and recursively visiting
the children.
Each TaxonPhotoSet node visited is
rendered as a div element decorated with
a class name appropriate to its taxonomic rank.
If the node has photos for only one form, the taxonomic heading will itself be a link to the form page for that form. For taxa with multiple forms, however, each name appears on a separate line, each line a link to the form page for that form.
In either case, the program builds the form page when
it builds the link to that page. Each FormPhotoSet object corresponds to one form
page. The bulk of the content of each form page is the
table that displays the thumbnails and other photo
data.