1

Topic: Unravelling where values come from...

I'm trying to decipher where precisely the values come from when using the [species] field within the MNHNL Dynamic 1 form.

After a lot of digging around I can only assume they are determined by the "Taxon Meaning ID" and are therefore pre-determined and unchangeable.  Is this correct?

The reason for asking is that I want to make some changes to the way the PlantTracker Species List is setup on the Warehouse.  Currently the "Taxon Name" field holds the common name and the "Common Name" field is empty.  I therefore want to put scientific name in the "Taxon Name" field and add common name field to the appropriate field.  Judging from the test warehouse experiments I've done these changes propagate to all records.

If I make these changes do I need to be aware of anything?  Any obvious problems with what I'm proposing?  As the records mainly come from our app I will check what needs to be done with the app code to adapt it to these changes.

I'm also interested in how iRecord displays names.  Does it pull out and display  "Taxon Name" | "Taxon Meaning ID"?  For our records it's currently just displaying Common Name and I'm again not clear where it's getting that from ("Taxon Name"??).  All other records are in the format of Scientific Name | Common Name so it would be good to follow suit.

Cheers,
Dave

2

Re: Unravelling where values come from...

Hi Dave,

On the one hand it is way more complicated than you imagine but on the other it is no problem! First a little bit of background on the data model which stores species in Indica.

  • When you create a species list you create a record in the taxon_lists table.

  • When you add species to that list you create entries in the taxa table. The taxon name, each common name, and each synonym is created as a new record in the taxa table.

  • At the same time, in order to say which taxa are in which taxon list, there is then a joining table called taxa_taxon_lists. Each taxa record has a matching record in this table. There is a field in the table called taxon_meaning_id which has the same value for all the records created for the species, indicating that they all refer to the same thing.

  • When you add an occurrence record, it is the id from the  taxa_taxon_list table that is stored to identify what the occurrence is.

The taxa_taxon_list table also stores a couple of additional pieces of information in fields.

  • preferred. This is the name you put in the Taxon Name text box when adding the species.

  • common_taxon_id. This looks like being the id in the taxa table of the first listed common name at time of saving a species. However, subsequent editing of the common names has consequences I wouldn't have predicted and may indicate flaws in the code.

Now, with that under your belt, let us move on to the dynamic form and the [species] control. This will behave in different ways according to what you have selected in the species options but you have chosen to select a single species from a dropdown list for PlantTracker.

Now, every control that Indicia outputs is defined by a template which a programmer can override. The options for a select control includes... whoops, link to out of date documentation... captionTemplate which is described as

Optional and only relevant when loading content from a data service call. Specifies the template used to build the caption, with each database field represented as {fieldname}.

If you look in the code for the dynamic form and search for "function get_control_species" you will see that the programmer has indeed used this and overridden it as follows.

        if ($args['species_names_filter']=='all')
          $indicia_templates['species_caption'] = '{taxon}';
        elseif ($args['species_names_filter']=='language')
          $indicia_templates['species_caption'] = '{taxon} - {preferred_name}';
        else
          $indicia_templates['species_caption'] = '{taxon} - {common}';
        $species_ctrl_opts['captionTemplate'] = 'species_caption';
      }

Not only have they overridden it but it may be in one of three forms according to the Species Names Filter option of the form. The entries in the list are also filtered according to this option.

The final part of the answer is that the call to the web services to retrieve the taxa_taxon_list information returns the information in the database view called list_taxa_taxon_lists so it is the fields in this view that replace the parts of the template between braces.

On iRecord, where a different form and different controls are being used the output may differ from on your recording form. However, you can bet that the principal name used is the preferred name and this is the one labelled 'Taxon Name' when adding a species.

In conclusion, you should be able to edit the names happily as you wish with the simple proviso that each species in your species list should continue to refer to the same organism. Provided that your app does not depend in any way on looking up a match beween species name and taxa_taxon_list_id in the database (and I doubt it would) it should also adapt with no changes needed.

When testing, remember you need to clear the cache on your website to see the effect in the species selector. You may want to set the Species Name Filter to continue to just offer options in English.

Jim Bacon