1

Topic: occurrence attribute values

Hi

I've been trying to get my head round how this works - it looks like I can setup lots of attributes (count for example) relating to the occurrence, which is fine. But then if I set up another couple (sex and stage) then I seem to end up with three rows in the occ att val table with the same occ ID. Now, I assume that's what's to be expected but is there a handy wee SQL function which can then 'join' these attributes back into a single row so that when I look at the detail view of the occurrence entity I can have something like oav.count (already added that one) and oav.sex, oav.stage all in one record?

Or am I just doing something horribly wrong?

Ta

Iain

2

Re: occurrence attribute values

Hi Iain
You're on the right lines. The way we do it is built into the reporting engine though rather than an SQL function. If you look at one of the existing reports (library/occurrences/explore_list.xml for example) you will see the following 2 parameters:

  <param name='smpattrs' display='Sample attribute list' description='Comma separated list of sample attribute IDs to include' datatype='smpattrs' />
  <param name='occattrs' display='Occurrence attribute list' description='Comma separated list of occurrence attribute IDs to include' datatype='occattrs' />

These let us past a list of occurrence or sample attribute IDs to the report, then the report engine automatically builds the required query.

Alternatively you can do this manually with SQL, by left joining to the occurrence_attribute_values table to get each of the values for the record.

John van Breda
Biodiverse IT

3

Re: occurrence attribute values

Hi Iain,

An example from the client code of extracting all of the information about an occurrence, including all its attributes, can be found in the function data_entry_helper::preload_species_checklist_occurrences which uses several calls to the warehouse webservices to construct an occurrence object with all its constituent parts. The advantage of this is that it gets all the attributes without you having to tell it what they are.

Jim Bacon.

4 (edited by iain 16-04-2013 05:40:40)

Re: occurrence attribute values

Thanks for the info - I ended up going down the SQL route with a few left joins and it all seems to be doing the business - not convinced it's the most elegant solution but if it works...

It does make me wonder if I should be using reports for this sort of thing. I did have a look but couldn't immediatley see how to access reports through the web services - is it a case of firing a report name at Indicia and the return is some sort of XML output, or is a report more designed for some light bedtime reading?

EDIT: found this which I think points me in the right direction

http://code.google.com/p/indicia/wiki/Reporting

Ta

Iain

5

Re: occurrence attribute values

Iain, those Google Code hosted docs might well be a little out of date now. The latest and regularly updated docs are here:

Indicia Manual

The part on Reports specifically is here:

Indicia Manual: Developing Reports

Charles Roper
Digital Development Manager | Field Studies Council
http://www.field-studies-council.org | https://twitter.com/charlesroper | https://twitter.com/fsc_digital

6

Re: occurrence attribute values

Hi Charles

Thanks for the updated links - that'll keep me out of mischief for a day or two!

Ta

Iain