Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The things that you can override are the supported geometry typesparameters that the user can edit, the required geometry types and the parameters that the user can editmaximum number of geometry items the user can create and the required number of geometry items the user must create.

Code Block
xml
xml
titleBasic custom edit configuration example
linenumberstrue
<?xml version="1.0" encoding="UTF-8"?>

<config xmlns="urn:com.cohga.server.config#1.0" xmlns:edit="urn:com.cohga.spatial.edit#1.0">

  <edit:config id="custom.edit">
    <entity>graffiti</entity>
    <label>Grafitti</label>
    <description>Report graffiti for removal</description>
    <geometry>
     <supportedGeometry>point</supportedGeometry> <point minimum="1" maximum="1"/>
    <requiredGeometry>point<</requiredGeometry>geometry>
    <parameter id="description">
      <label>Description</label>
      <controlType>text-area</controlType>
      <column>DESCRIPTION</column>
    </parameter>
  </edit:config>

</config>

...

Unless explicitly set the types of geometry that a user can create for an entity, and also if the user can create an entity with no geometry, is defined by the underlying spatial tables, if you wish to override this then you do so with the supportedGeometry and requiredGeometry geometry settings.

Both supportedGeometry and requiredGeometry can be listed multiple times if more that one geometry type is supported/required, and the possible values for both of these are:

  • point
  • multipoint
  • linestring
  • multilinestring
  • polygon
  • multipolygon

...

The geometry settings determine the minimum and maximum number of each geometry type (point, linestring and polygon) that the user can create, as well as the total number of geometry items (of any type) that the user can create.

This is done by specifying point, linestring, polygon and/or geometry items, and for each one specify the minimum and maximum value for each. If no point, linestring or polygon setting is specified then the user will not be able to create those geometry types, unless geometry is specified in which case the user can create all geometry types.

Some examples of why you would want to set these values are (these assume that you can't change the underlying spatial table):

Spatial table allows nil geometry but you wish to enforce geometry creation
  • Add <requireGeometry>geometryType</requireGeometry> where geometryType matches the underlying spatial table

...

Code Block
xml
xml
linenumberstrue

<geometry minimum="1"/>

or

Code Block
xml
xml
linenumberstrue

<geometry>
  <polygon minimum="1"/>
</geometry>
Spatial table allows multi part geometry but you wish to enforce creation of single part geometry
  • Add <supportGeometry>geometryType</supportGeometry> where geometryType matches the underlying spatial table

...

Code Block
xml
xml
linenumberstrue

<geometry maximum="1"/>

or

Code Block
xml
xml
linenumberstrue

<geometry>
  <polygon maximum="1"/>
</geometry>
The spatial engine supports multiple geometry types in a single table, for example Oracle Spatial, and you wish to limit the geometry

...

Code Block
xml
xml
linenumberstrue

<geometry>
  <polygon/>
</geometry>

...

You want the user to specify 2 geometries, including 1 polygon and either a point or a line.

...

Code Block
xml
xml
linenumberstrue

<geometry minimum="2" maximum="2">
  <polygon minimum="1" maximum="1"/>
  <linestring/>
  <point/>
</geometry>

...

You want the user to specify 2 geometries, including 1 polygon and either a point, line or polygon.

...

Code Block
xml
xml
linenumberstrue

<geometry minimum="2" maximum="2">
  <polygon minimum="1"/>
  <linestring/>
  <point/>
</geometry>

...

You want the user to specify 1 or 2 geometries, including 1 polygon and optionally a point or line.

...

Code Block
xml
xml
linenumberstrue

<geometry maximum="2">
  <polygon minimum="1"/>
  <linestring/>
  <point/>
</geometry>

...

You want the user to specify between 2 and four points.

...

Code Block
xml
xml
linenumberstrue

<geometry>
  <point minimum="2" maximum="4"/>
</geometry>
Info

If minimum is not specified it defaults to 0.
If maximum is not specified there will be no upper limit.

Custom attributes

If the default attribute editing setup isn't suitable you can directly specify the attributes that the user can edit and how they appear to the user.

...

  • column is optional, if not provided then the field will still appear, but an attempt to write the entered value into the underlying spatial table will not be made. The user entered value can still be used by other means that will be covered later.
  • The controltype now supports 'textarea' which isn't available for search fields, it provides a multi-line text input field.
  • readonly, readonlyoninsert and readonlyonupdate aren't available for search field either, they're special marker that allow you to alter the ability of the user to change the value in a field. These are client side flags, and if set alter the display of the field so that the user cannot change the value, the field is still displayed, just not editable.
  • updatable specifies that one a value is set it can't be changed, this is similar to readonlyonupdate, and in fact readonlyonupdate will be set to true if updatable is set to false, but it also provides additional checks on the server to ensure that the value is not updated.
  • value can be used to set a value explicitly by directly supplying the value, or there are a number of formulas that are available.
    • entity() The name of the entity type being edited.
    • userid() The current username.
    • datetime() The current date/time.
    • operation() The type of operation being perform, will be one of the strings 'create', 'update' or 'delete'.
    • nextval() The value used for the column will be the previous largest value from the column plus one, the underlying column must be numeric.
    • geometry() A WKT (Well Known Text) representation of the geometry if available, otherwise null.
    • id() The value for the key field for the spatial table will be used if available, otherwise null.
    • auto() The value for the field is auto-generated by the database.the underlying column must be numeric.
    • geometry() A WKT (Well Known Text) representation of the geometry if available, otherwise null.
    • id() The value for the key field for the spatial table will be used if available, otherwise null.
    • auto() The value for the field is auto-generated by the database.
    • count() The number of geometry objects.
    • area() The area of the geometry.
    • length() The length of the geometry.
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.
The value will only contain the count, area and length for the geometries that match the table that the geometry is being written to, not the total, when used in an edit config item. But, when used in audit config item then count, area and length will be the total of all the geometries (if there are more than one).

Info
Custom parameter examples
Auditing changes

To record who created and who modifies an entity

Code Block
xml
xml
titleAuditing changes example
linenumberstrue

  <edit:config id="custom.edit">
    <entity>graffiti</entity>
    <label>Grafitti</label>
    <description>Report graffiti for removal</description>
    <supportedGeometry>point</supportedGeometry>
    <requiredGeometry>point</requiredGeometry>
    <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
xml
xml
titleId column example
linenumberstrue

  <edit:config id="custom.edit">
    <entity>graffiti</entity>
    <label>Grafitti</label>
    <description>Report graffiti for removal</description>
    <supportedGeometry>point</supportedGeometry>
    <requiredGeometry>point</requiredGeometry>
    <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
xml
xml
titleDrop down list example
linenumberstrue

  <edit:config id="custom.edit">
    <entity>graffiti</entity>
    <label>Grafitti</label>
    <description>Report graffiti for removal</description>
    <supportedGeometry>point</supportedGeometry>
    <requiredGeometry>point</requiredGeometry>
    <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 edit configurations can be setup with or without a column attribute. If there is a column specified then the value will be written to the corresponding column in the underlying spatial table, if there is no column specified then no value will be written during this phase. However, the value the user enters for the parameter, in both cases, is available to be written as part of an audit configuration.

Info

Code Block
xml
xml
titleWriting audit information to a separate table
linenumberstrue
  <edit:config id="custom.edit">
    <entity>graffiti</entity>
    <label>Grafitti</label>
    <description>Report graffiti for removal</description>
    <supportedGeometry>point</supportedGeometry>
    <requiredGeometry>point</requiredGeometry>
    <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>

...