unepwcmc/SAPI — pull request #196 by agnessa (2014-02-06 13:56:04+00:00)
Title: Synonym secondary validations

This is to prevent the secondary validations that have to do with taxon concept (taxon + appendix + year, taxon + term, taxon + source + country) from reporting errors when trade reported under a synonym. The validations should instead be running on the accepted taxon concept.

So in order to facilitate that I added a taxon_concept_id column to the sandbox template. This column is automatically populated on upload and then after any subsequent modifications of sandbox shipments. Basically the bit of logic to resolve taxon concept that used to happen at the submit stage now happens still while in the sandbox.

With the taxon_concept_id in place, the queries that the secondary validators need to run should be slightly faster, because they will now be joining on an indexed numeric field rather than string.

In order to make things more consistant and obvious I renamed some of the views and validators so that they have 'taxon concept' in their name rather than 'species_name'.

Because a lot of renaming was going on, to test this you need to:
1. rake db:migrate
2. rake db:drop_sandboxes
3. Trade::ValidationRule.delete_all + create all the validation rules from the seeds file
4. run rebuild_valid_taxon_concept_appendix_year_mview() and rebuild_valid_taxon_concept_annex_year_mview()

WHAT REMAINS TO BE DONE:
Right now the error output in the front end still uses the reported species name. It should use the accepted taxon name (like discussed with Kelly)