Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Part of the client side editing sub-system is implemented as a 'plugin' for the map view, so the first thing that needs to be done when enabling the editing sub-system is to register the edit plugin with the map view in the client configuration.

Code Block
xml
xml
titleAdding edit plugin to client
linenumberstruexml
<?xml version="1.0" encoding="UTF-8"?>

<config xmlns="urn:com.cohga.server.config#1.0" xmlns:client="urn:com.cohga.html.client#1.0">

  <client:config id="edit">
    <!-- more config items here -->

    <view id="com.cohga.html.client.map.mapView">
      <label>Map</label>
      <location>center</location>

      <!-- Register the edit plugin with the map view -->
      <plugin id="weave.edit"/>

      <!-- map config items here -->
    </view>

    <!-- more config items here -->
  </client:config>

</config>

...

When performing an edit a view panel is required to enter/change the attributes associated with the entity being edited. This view is provided by the com.cohga.client.panel.edit view and so also needs to be added to the client configuration.

Code Block
xml
xml
titleAdding edit view to client
linenumberstruexml
<?xml version="1.0" encoding="UTF-8"?>

<config xmlns="urn:com.cohga.server.config#1.0" xmlns:client="urn:com.cohga.html.client#1.0">

  <client:config id="edit">
    <!-- more config items here -->

    <!-- Add the Edit panel to the client -->
    <view id="com.cohga.client.panel.edit">
      <label>Edit</label>
      <location>west</location>
    </view>

    <view id="com.cohga.html.client.map.mapView">
      <label>Map</label>
      <location>center</location>

      <!-- Register the edit plugin with the map view -->
      <plugin id="weave.edit"/>

      <!-- more config items here -->
    </view>

    <!-- more config items here -->
  </client:config>

</config>

...

The most basic edit configuration interrogates the underlying spatial tables for the information it requires. (e.g. to determine what attributes are associated with the entity or what spatial geometries (point, line or polygon) the user is allowed to create)

Code Block
xml
xml
titleSimple edit configuration example
linenumberstruexml
<?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="simple.edit">
    <entity>graffiti</entity>
    <label>Graffiti</label>
    <description>Report graffiti for removal</description>
  </edit:config>

</config>

...

The things that you can override are the parameters that the user can edit, the maximum 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
linenumberstruexml
<?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>
      <point minimum="1" maximum="1"/>
    </geometry>
    <parameter id="description">
      <label>Description</label>
      <controlType>text-area</controlType>
      <column>DESCRIPTION</column>
    </parameter>
  </edit:config>

</config>

...

Spatial table allows nil geometry but you wish to enforce geometry creation
Code Block
xml
xml
linenumberstruexml
<geometry minimum="1"/>

or

Code Block
xml
xml
linenumberstruexml
<geometry>
  <polygon minimum="1"/>
</geometry>
Spatial table allows multi part geometry but you wish to enforce creation of single part geometry
Code Block
xml
xml
linenumberstruexml
<geometry maximum="1"/>

or

Code Block
xml
xml
linenumberstruexml
<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
linenumberstruexml
<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
linenumberstruexml
<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
linenumberstruexml
<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
linenumberstruexml
<geometry maximum="2">
  <polygon minimum="1"/>
  <linestring/>
  <point/>
</geometry>
You want the user to specify between 2 and four points.
Code Block
xml
xml
linenumberstruexml
<geometry>
  <point minimum="2" maximum="4"/>
</geometry>

...

To record who created and who modifies an entity

Code Block
xml
xml
titleAuditing changes example
linenumberstruexml
  <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>

...

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
linenumberstruexml
  <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>

...

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
linenumberstruexml
  <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>
Check Boxes and Radio Buttons
Code Block
xml
xml
titleCheck box and radio button example
linenumberstruexml
  <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="checkbox">
      <label>Check Box</label>
      <controlType>checkbox</controlType>
      <column>CHECKBOX</column>
      <trueValue>Y</trueValue>
      <falseValue xsi:nil="true"/>
    </parameter>
    <parameter id="radiobutton">
      <label>Radio Button</label>
      <controlType>radiobutton</controlType>
      <column>RADIOBUTTON</column>
      <defaultValue>value2</defaultValue>
      <list>
        <label>Label 1</label>
        <value>value1</value>
      </list>
      <list>
        <label>Label 2</label>
        <value>value2</value>
      </list>
      <list>
        <label>Label 3</label>
        <value>value3</value>
      </list>
    </parameter>
  </edit:config>

...

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.

Code Block
xml
xml
titleWriting audit information to a separate table
linenumberstruexml
  <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"/>
  </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>

...

The following resources item can be used to replace the text for all of the items

Code Block
xml
xml
linenumbersfalsexml
<client:resources>
	<edit>
		<create>
			<text>Create</text>
			<tooltip>Create a new entity</tooltip>
			<notify>Entity successfully created</notify>
		</create>
		<update>
			<text>Update</text>
			<tooltip>Edit the selected entity</tooltip>
			<notify>Entity successfully edited</notify>
		</update>
		<delete>
			<text>Delete</text>
			<tooltip>Delete the selected entity</tooltip>
			<notify>Entity successfully deleted</notify>
		</delete>
		<submit>
			<text>Submit</text>
			<tooltip>Submit changes</tooltip>
		</submit>
		<cancel>
			<text>Cancel</text>
			<tooltip>Cancel changes</tooltip>
		</cancel>
		<polygon>
			<text>Polygon</text>
			<tooltip>Add a polygon</tooltip>
		</polygon>
		<line>
			<text>Line</text>
			<tooltip>Add a line</tooltip>
		</line>
		<point>
			<text>Point</text>
			<tooltip>Add a point</tooltip>
		</point>
		<modify>
			<text>Modify</text>
			<tooltip>Click on an item to modify it</tooltip>
		</modify>
		<remove>
			<text>Remove</text>
			<tooltip>Remove the currently selected item</tooltip>
		</remove>
		<reset>
			<text>Reset</text>
			<tooltip>Reset the form fields</tooltip>
		</reset>
		<import>
			<text>Import</text>
			<tooltip>Import geometry from another entity</tooltip>
			<error>
				<tooManyGeometries>There are too many geometries in the source</tooManyGeometries>
				<tooManyPoints>There are too many points in the source</tooManyPoints>
				<tooManyLinestrings>There are too many lines in the source</tooManyLinestrings>
				<tooManyPolygons>There are too many polygons in the source</tooManyPolygons>
			</error>
		</import>
	</edit>
</client:resources>