Once you have your data source, the next step is to add that data source as a new class in fm_IDL.xml.
You will need to add the following attributes for the class definition
id. You should follow a consistent naming convention for your class names that won't create conflicts in the future with any standard classes added in future upgrades. Evergreen normally names each class with the first letter of each word in the schema and table names. You may want to add a local prefix or suffix to your local class names.
controller=”open-ils.cstore”
oils_obj:fieldmapper=”extend_reporter::long_name_of_view”
oils_persist.readonly=”true”
reporter:core=”true” (if you want this to show up as a “core” reporting source)
reporter:label. This is the name that will appear on the data source list in the Evergreen reporter.
oils_persist:source_definition. If this is an IDL-only view, add the SQL query here. You don't need this attribute if your class is based on a PostgreSQL view or table.
oils_persist:tablename="schemaname.viewname or tablename" If this class is based on a PostgreSQL view or table, add the table name here. You don't need this attribute is your class is an IDL-only view.
For each column in the view or query output, add field element and set the following attributes. The fields should be wrapped with <field> </field>
reporter:label. This is the name that appears in the Evergreen reporter.
name. This should match the column name in the view or query output.
reporter:datatype (which can be id, bool, money, org_unit, int, number, interval, float, text, timestamp, or link)
For each linking field, add a link element with the following attributes. The elements should be wrapped with <link> </link>
field (should match field.name)
reltype (“has_a”, “might_have”, or “has_many”)
map (“”)
key (name of the linking field in the foreign table)
class (ID of the IDL class of the table that is to be linked to)
The following example is a class definition for the example view that was created in the previous section.
<class id="erpstats" controller="open-ils.reporter-store" oils_obj:fieldmapper="extend_reporter::patronstats" oils_persist:tablename="extend_reporter.patronstats" oils_persist:readonly="true" reporter:label="Patron Statistics" reporter:core="true"> <fields oils_persist:primary="id"> <field reporter:label="Patron ID" name="id" reporter:datatype="link" /> <field reporter:label="Patron Type" name="ptype" reporter:datatype="text" /> <field reporter:label="Reg Lib" name="reg_lib" reporter:datatype="text" /> <field reporter:label="Boro/Twp" name="boro_twp" reporter:datatype="text" /> <field reporter:label="Gender" name="gender" reporter:datatype="text" /> <field reporter:label="Age Group" name="age_group" reporter:datatype="text" /> <field reporter:label="Age" name="age" reporter:datatype="int" /> <field reporter:label="Home Lib ID" name="home_lib_id" reporter:datatype="link" /> <field reporter:label="Home Lib Code" name="home_lib_code" reporter:datatype="text" /> <field reporter:label="Home Lib" name="home_lib" reporter:datatype="text" /> <field reporter:label="Create Date" name="create_date" reporter:datatype="timestamp" /> <field reporter:label="Expire Date" name="expire_date" reporter:datatype="timestamp" /> <field reporter:label="Balance Owed" name="balance_owed" reporter:datatype="money" /> </fields> <links> <link field="id" reltype="has_a" key="id" map="" class="au"/> <link field="home_lib_id" reltype="has_a" key="id" map="" class="aou"/> </links> </class>
fm_IDL.xml is used by other core Evergreen DAO services, including cstore and permacrud. So changes to this file can affect the entire Evergreen application, not just reporter. After making changes fm_IDL.xml, it is a good idea to ensure that it is valid XML by using a utility such as xmllint – a syntax error can render much of Evergreen nonfunctional. Set up a good change control system for any changes to fm_IDL.xml. You will need to keep a separate copy of you local class definitions so that you can reapply the changes to fm_IDL.xml after Evergreen upgrades.