Technical Overview: Form Storage -- SDMX CrossSectional: Difference between revisions

From IHRIS Wiki
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is a form storage mechanism designed to read data from an SDMX-HD code list file.  This form storage mechanism is present in version >= 4.0.5.
This is a form storage mechanism designed to read data from an SDMX-HD code list file.  This form storage mechanism is present in version >= 4.0.6.


This is a read-only form storage mechanism.   
This is a read-only form storage mechanism.   




'''This form storage mechanism requires PHP 5.3 or greater'''
==Form Storage Options==
==Form Storage Options==


Line 10: Line 12:
It has the following structure:
It has the following structure:


*file:  Required scalar node.  The SDMX file that the data should be read from.  This can either be an absolutely given file path, or a relative file path.  If it is a relative file path, then it uses the SDMXHD [[File Search Paths | file search]] category.
*file:  Required scalar node.  The SDMX file that the data should be read from.  This can either be an absolutely given file path, a relative file path, or the URL of a  stream handled by php.  If it is a relative file path, then it uses the SDMXHD [[File Search Paths | file search]] category. The file can also be a path to a scalar node in magic data as indicated by 'mdn://path/in/magic/data'
*namespace: Optional scalar node. defaults to 'ns'.   
*namespace: Optional scalar node. defaults to 'ns'.   
*id: Optional parent node.  The data defining how to associate an id <'''namespace''':OBS_VALUE/>.
*parent: optional parent node.  The data defining how to associate a parent id DOM Node.
**attribute: Optional scalar node.  The name of the attribute which contains the id.  If not set the id is the numeric document order of OBS_VALUE nodes starting at 1.
**attribute: Required scalar node.  The name of the attribute which contains the parent.  If neither 'query' or this is set, there is not parent data. 'query' takes precendence.
**eval. Optional scalar node.  If set it is a php function called on the id.
**eval: Optional scalar node.  If set it is a code php code which modifies the id, stored in the $val variable. For example '$val = strtoupper($val);'
**form_prepended: Optional scalar node. Defaults to true. If true, it means the form name (with a |) has been prepended to the id. If id_eval is also set, and this is true, the form is prepended before passing to the eval.
**map_data: Optional parent node. .It is used to map the given field via a SDMX-HD Code List that is in the system
*parent: optional parent node.  The data defining how to associate a parent id per line of this file.
***list: Required scalar node.  The list that we want this field to take values in
**enabled: Optional scalar node. If present and evaluates to false, it means getParent() should return the trivial parent id, '0'.
***codelist: Required scalar node: The name of the SDMX-HD code list which this attribute takes values in, in other words the value we wish to map from.
**index: If set, and ''use_header'' or ''has_header'' is false, it is the numeric index of the column that this data is saved in.
***mapping_form: Optional scalar node. The name of the form which contains the mapping data between the SDMX-HD Code List and the list we wish to map to. If the module '''Lists-LinkTo-List''' is enabled and the value is not set then it defaults to ''list_linkto_list_XXXX'' where XXXX is the form storage mechanism of the listIf set, the form should subclass I2CE_ListLink_List.
**header: Applies if ''use_header'' and ''has_header'' are true.  If set it is the header name of index of the column that this data is saved inBy default it is "parent"
 
*fields: Optional parent node.  Specifies how the data of the your form is associate to a row of your table.  Each child of this node is the name of a field $field of your form.  By default, all fields of a form are populated, and are all assumed to come from the column with that field name  "$form+$field"
*fields: Optional parent node.  Specifies how the data of the your form is associate to a row of your table.  Each child of this node is the name of a field $field of your form.   
**$field:  Optional parent node with the following child nodes.   
**$field:  Optional parent node with the following child nodes.   
***enabled: Optional scalar node.  If present and evaluates to false, it means we should not populate this field.
***attribute: Required scalar node.  The name of the attribute which contains the parent. If neither 'query' nor this is set, there is not data. 'query' takes precendence
***index: If set, and ''use_header'' or ''has_header'' is false, it is the numeric index of the column that this data is saved in.
***eval: Optional scalar node. If set it is a code php code which modifies the id, stored in the $val variableFor example '$val = strtoupper($val);'
***header: Applies if ''use_header'' and ''has_header'' are true.   If set it is the header name of index of the column that this data is saved inBy default it is "$field"
***map_data: Optional parent node.It is used to map the given field via a SDMX-HD Code List that is in the system
 
****list: Required scalar nodeThe list that we want this field to take values in
==Global Options==
****codelist: Required scalar node: The name of the SDMX-HD code list which this attribute takes values in, in other words the value we wish to map from.
There are global options for SDMX-HD form storage. They are specified at:
****mapping_form: Optional scalar node. The name of the form which contains the mapping data between the SDMX-HD Code List and the list we wish to map to.  If the module '''Lists-LinkTo-List''' is enabled and the value is not set then it defaults to ''list_linkto_list_XXXX''  where XXXX is the form storage mechanism of the list.  If set, the form should subclass I2CE_ListLink_List.
  /modules/forms/storage_options/SDMX-HD
This has the structure:
*closeFile: defaults to falseIf true, we close the file between access.  Otherwise, we allow PHP to handle closing the file resource at the end of the script's call.
 
==Form Definition==
To use SDMX-HD storage for a form use the following configuration.  Replace $form, $form_name, $file_location and $CL_ID with the appropriate values.
<source lang="xml">
<configurationGroup name="$form">
  <displayName>SDMX-HD Code List: $form</displayName>
  <description>The SDMX-HD Code List: $form_name</description>
  <configuration name="class" values="single">
    <value>I2CE_SimpleList</value>
  </configuration>
  <configuration name="display" values="single" locale="en_US">
    <value>$form_name</value>
  </configuration>
  <configuration name="storage" values="single">
    <value>SDMXHD</value>
  </configuration>
  <configurationGroup name="storage_options" path="storage_options/SDMXHD">
    <configuration name="file" values="single">
      <values>$file_location</value>
    </configuration>
    <configuration name="CodeListID" values="single">
      <value>$CL_ID</value>
    </configuration>
  </configurationGroup>
</configurationGroup>
</source>
 
An example for gender may be:


<source lang="xml">
[[Category:Developer Resources]]
<configurationGroup name="cl_gender">
  <displayName>SDMX-HD Code List: cl_gender</displayName>
  <description>The SDMX-HD Code List: Gender</description>
  <configuration name="class" values="single">
    <value>I2CE_SimpleList</value>
  </configuration>
  <configuration name="display" values="single" locale="en_US">
    <value>Gender</value>
  </configuration>
  <configuration name="storage" values="single">
    <value>SDMXHD</value>
  </configuration>
  <configurationGroup name="storage_options" path="storage_options/SDMXHD">
    <configuration name="file" values="single">
      <values>CL_GENDER+SDMX-HD+1.0.xml</value>
    </configuration>
    <configuration name="CodeListID" values="single">
      <value>CL_GENDER</value>
    </configuration>
  </configurationGroup>
</configurationGroup>
</source>

Latest revision as of 20:11, 1 March 2019

This is a form storage mechanism designed to read data from an SDMX-HD code list file. This form storage mechanism is present in version >= 4.0.6.

This is a read-only form storage mechanism.


This form storage mechanism requires PHP 5.3 or greater

Form Storage Options

The options specifying a SDMX Cross Sectional storage for $form are stored at:

/modules/forms/forms/$form/storage_options/SDMX_CrossSectional

It has the following structure:

  • file: Required scalar node. The SDMX file that the data should be read from. This can either be an absolutely given file path, a relative file path, or the URL of a stream handled by php. If it is a relative file path, then it uses the SDMXHD file search category. The file can also be a path to a scalar node in magic data as indicated by 'mdn://path/in/magic/data'
  • namespace: Optional scalar node. defaults to 'ns'.
  • parent: optional parent node. The data defining how to associate a parent id DOM Node.
    • attribute: Required scalar node. The name of the attribute which contains the parent. If neither 'query' or this is set, there is not parent data. 'query' takes precendence.
    • eval: Optional scalar node. If set it is a code php code which modifies the id, stored in the $val variable. For example '$val = strtoupper($val);'
    • map_data: Optional parent node. .It is used to map the given field via a SDMX-HD Code List that is in the system
      • list: Required scalar node. The list that we want this field to take values in
      • codelist: Required scalar node: The name of the SDMX-HD code list which this attribute takes values in, in other words the value we wish to map from.
      • mapping_form: Optional scalar node. The name of the form which contains the mapping data between the SDMX-HD Code List and the list we wish to map to. If the module Lists-LinkTo-List is enabled and the value is not set then it defaults to list_linkto_list_XXXX where XXXX is the form storage mechanism of the list. If set, the form should subclass I2CE_ListLink_List.
  • fields: Optional parent node. Specifies how the data of the your form is associate to a row of your table. Each child of this node is the name of a field $field of your form.
    • $field: Optional parent node with the following child nodes.
      • attribute: Required scalar node. The name of the attribute which contains the parent. If neither 'query' nor this is set, there is not data. 'query' takes precendence
      • eval: Optional scalar node. If set it is a code php code which modifies the id, stored in the $val variable. For example '$val = strtoupper($val);'
      • map_data: Optional parent node. .It is used to map the given field via a SDMX-HD Code List that is in the system
        • list: Required scalar node. The list that we want this field to take values in
        • codelist: Required scalar node: The name of the SDMX-HD code list which this attribute takes values in, in other words the value we wish to map from.
        • mapping_form: Optional scalar node. The name of the form which contains the mapping data between the SDMX-HD Code List and the list we wish to map to. If the module Lists-LinkTo-List is enabled and the value is not set then it defaults to list_linkto_list_XXXX where XXXX is the form storage mechanism of the list. If set, the form should subclass I2CE_ListLink_List.