...
Note |
---|
When geometry is being written to multiple spatial tables the count(), area() and length() functions will behave differently when used in an edit config item versus an edit audit item. |
Info |
Custom parameter examples
...
Auditing changes
...
To record who created and who modifies an entity
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<edit:config id="custom.edit">
<entity>graffiti</entity>
<label>Grafitti</label>
<description>Report graffiti for removal</description>
<geometry>
<point minimum="1" maximum="1"/>
</geometry>
<parameter id="description">
<label>Description</label>
<controlType>text-area</controlType>
<column>DESCRIPTION</column>
</parameter>
<!-- Hidden parameters to record audit information -->
<parameter id="createdby">
<hidden>true</hidden>
<column>CREATEDBY</column
<value>userid()</value>
<updatable>false</updatable>
</parameter>
<parameter id="createdon">
<hidden>true</hidden>
<column>CREATEDON</column>
<value>datetime()</value>
<updatable>false</updatable>
</parameter>
<parameter id="modifiedby">
<hidden>true</hidden>
<column>MODIFIEDBY</column
<value>userid()</value>
</parameter>
<parameter id="modifiedon">
<hidden>true</hidden>
<column>MODIFIEDON</column>
<value>datetime()</value>
</parameter>
</edit:config>
|
In this example the audit information is stored in the spatial table itself, so the table must already contain the CREATEDBY
, CREATEDON
, MODIFIEDBY
and MODIFIEDON
fields and they need to by character fields for the 'by' fields and timestamps for the 'on' fields.
Also, the about configuration assumes that there is an additional column that's used to identify the records, the id column, but that the column is auto-generated by the database and is not user editable.
...
Setting an id field
...
Specifying an field as an id field to be created by using the maximum value from the column.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<edit:config id="custom.edit">
<entity>graffiti</entity>
<label>Grafitti</label>
<description>Report graffiti for removal</description>
<geometry>
<point minimum="1" maximum="1"/>
</geometry>
<parameter id="id">
<hidden>true</hidden>
<column>ID</column>
<value>nextval()</value>
</parameter>
<parameter id="description">
<label>Description</label>
<controlType>text-area</controlType>
<column>DESCRIPTION</column>
</parameter>
</edit:config>
|
This example sets an id field that's hidden from the user and it's created from the existing values in the table. This is not an optimal solution to generating new key values, and it would be much better to use the functionality provided by the underlying database (sequences, auto-generate, identity, etc).
...
Drop down lists
...
Specifying that the value for a field is chosen from a list. Here we have a static list, status, included directly in the configuration, and a dynamic list populated from a data definition, reporter.
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<edit:config id="custom.edit">
<entity>graffiti</entity>
<label>Grafitti</label>
<description>Report graffiti for removal</description>
<geometry>
<point minimum="1" maximum="1"/>
</geometry>
<parameter id="id">
<hidden>true</hidden>
<column>ID</column>
<value>nextval()</value>
</parameter>
<parameter id="description">
<label>Description</label>
<controlType>text-area</controlType>
<column>DESCRIPTION</column>
</parameter>
<parameter id="status">
<label>Status</label>
<controlType>list-box</controlType>
<column>STATUS</column>
<defaultValue>N</defaultValue>
<list value="N" label="New"/>
<list value="V" label="Verified"/>
<list value="S" label="Scheduled"/>
<list value="R" label="Removed"/>
</parameter>
<parameter id="reporter">
<label>Reporter</label>
<controlType>list-box</controlType>
<dataSet>staff</dataSet>
<allowNewValues>true</allowNewValues>
<column>REPORTEDBY</column>
</parameter>
</edit:config>
|
Writing to other tables
Note |
---|
Currently only writing new record to a separate database table is supported, that is you can not currently update an existing record in an external database table. |
So far all attribute values entered by the user were written directly to the underlying spatial table, it's also possible to write values, including those entered by the user and those available via value formulas, to another database table. This can be done by creating an audit
edit configuration item and attaching it to an existing edit configuration item.
The audit
configuration specified a datasource and table to write the values to plus a list of parameters that correspond to the columns in the table.
The columns can derive their values either from the values entered by the user as a parameter in the original edit
configuration or as a formula using a value
tag or as a hard coded value.
Info |
---|
Parameters in |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<edit:config id="custom.edit"> <entity>graffiti</entity> <label>Grafitti</label> <description>Report graffiti for removal</description> <geometry> <point minimum="1" maximum="1"/> </geometry> <parameter id="id" hidden="true" label="Id" column="ID" value="auto()"/> <parameter id="description" label="Description" controlType="text-area" column="DESCRIPTION"/> </edit:config> <edit:audit id="custom.audit"> <edit>custom.edit</edit> <datasource>datasource.main</datasource> <table>EDIT_AUDIT</table> <parameter column="ID" value="id()"/> <parameter column="DESC" parameter="description"/> <parameter column="USER" value="userid()"/> <parameter column="MODIFIED" value="datetime()"/> </edit:audit> |
...