GCRC / nunaliit

Nunaliit Atlas Framework
BSD 3-Clause "New" or "Revised" License
46 stars 15 forks source link

nunaliit schemas-for-inreach command ignores form versioning #964

Open ahayes opened 3 years ago

ahayes commented 3 years ago

Currently the nunaliit schemas-for-inreach command outputs JSON containing all the definition objects for schemas related to a inreach_forms.xml file found in the config folder.

In the XML document, forms have an id number, a title, and a prefix. By convention, a best practice for building forms would have the prefix include a version number to uniquely identify a form. The inreach form XML in the example below shows and example of the syntax. The form id which functions as more of an index in the file and cannot be assumed to be consistent over time. The title may well remain consistent despite changes to the form fields. The prefix contains a unique form identifier with an abreviation representing the atlas, the form title, and the version (in this case 1). The schema IDs for each form should be based on the entire prefix to permit versioning of forms and with new versions resulting in new matching schemas.

<form id="9">
<title>Weather Conditions</title>
<destination>tv@example.com</destination>
<prefix>EX-WC-1-</prefix>
<delimiter>|</delimiter>
<field id="1">
<name>Observed</name>
<type>PickList</type> 
<value>Blowing snow</value>
<value>White out</value>
<value>Blizzard</value>
<value>Flat light</value>
<value>Ice fog</value>
<value>Fog</value>
<value>Excellent visibility</value>
<value>Good visibility</value>
<value>Fair visibility</value>
<value>Poor visibility</value>
<value>Bad visibility</value>
<value>Zero visibility</value>
<value>Falling snow</value>
<value>Rain</value>
<value>Freezing rain</value>
<value>Other (put in notes)</value>
<required>Y</required>
</field>
<field id="2">
<name>Notes</name>
<type>Text</type>
<length>140</length>
<required>N</required>
<default></default>
</field>
</form>

The schema IDs for each form should be based on the entire prefix to permit versioning of forms with matching schemas.

alexgao1 commented 1 year ago

Reverted with: https://github.com/GCRC/nunaliit/pull/1174
Versioning of schemas requires that all existing schemas to be updated as well in addition to every reference to affected schemas in the client side code. It would also require references to the old schemas that don't use the versioning be added everywhere as well.

This is because adding the new IDs for schemas with prefix + title needs the inReach processing servlet to also check for that instead of only checking title. The servlet could be changed to query for the existence of a particular schema then check the alternative (check if prefix+title exists, otherwise check if it's title only), but is not ideal to be querying the database for every inReach message processed. Caching them is also difficult because there is no indication if it was updated with the executable.