Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

A Data Definition represents a set of data that the Weave server can use in various ways, for example to provide a list of values for the user when entering data, or as a tabular dataset to display textual data about a selected entity.
Basically anywhere that Weave needs some textual data it will retrieve it via a data definition.

There are currently two types of data definitions. One that retrieves it's values from a database (via a Data Source) and one that has it's values embedded within it's configuration.

Namespace

urn:com.cohga.server.data.database#1.0

Tags

datadefinition

Properties

Name

Type

Required

Description

id

string

yes

Unique identifier

Sub-tags

Name

Type

Cardinality

datasourcedataconnection

urn:com.cohga.server.data.database#1.0:datasourcedataconnection

0..1

inlinedataconnection

urn:com.cohga.server.data.database#1.0:inlinedataconnection

0..1

Content

None

Notes

  • Only one of datasourcedataconnection or inlinedataconnection can be included.

datasourcedataconnection

Properties

Name

Type

Required

Description

datasource

ref urn:com.cohga.server.datasource.jdbc#1.0:datasource

yes

reference to the data source that this data definition should use to generate its data

table

string

yes

The name of the table that provides the data

key

string

no

If this data definition is generating data relating to an entity then this is the column name that contains the entities id

prefix

string

no

The prefix value will be inserted into the generated SQL statement immediately after the SELECT, for example DISTINCT

trim

boolean

no

If true the generated SQL will ensure that the id's are compared against a trimmed version of the id stored in the database, this helps with Pathway, where some tables store padded id's

Sub-tags

Name

Type

Cardinality

parameter

urn:com.cohga.server.data.database#1.0:parameter

1..n

cache

urn:com.cohga.server.cache#1.0:cache

0..1

Content

None

Notes

  • The cache settings are only used for data source data connections that have a key specified, since it's the key that's used as the cache index
  • If no cache tag is specified then the data will still be cached, but it will use the default cache configuration, to disable caching you need to set disable to true inside the cache definition

inlinedataconnection

Properties

None

Sub-tags

Name

Type

Cardinality

parameter

urn:com.cohga.server.data.database#1.0:parameter

1..n

row

urn:com.cohga.server.data.database#1.0:row

1..n

Content

None

parameter

Properties

Name

Type

Required

Description

column

string

yes

The name of the column within the table that this parameter references (can be an sql function also)

type

'string', 'numeric', 'date' or 'url'

no (default 'string')

An indicator of how the data should be displayed on the client

name

string

no (default lowercase value of column)

A unique identifier for the parameter

label

string

no (default 'pretty' value of column)

A user displayable label for the column

text

string

no

Only when type is 'url'. Specifies text to be displayed to the user instead of the actual url contents

textcolumn

string

no

Only when type is 'url'. Specifies the column that contains text to be displayed to the user instead of the actual url contents

Sub-tags

Name

Type

Cardinality

from

urn:com.cohga.server.data.database#1.0:from

0..n

where

urn:com.cohga.server.data.database#1.0:where

0..n

Content

None

Notes

  • If no label is specified then it will be generated by formatting the name, unless no name is supplied, then it will be generated by formatting the column
  • Formatting involves converting any _'s to spaces, converting the first letter and any letter after a space to upper case and converting every other letter to lower case, e.g. "BOMB_DISPOSAL_METHOD" becomes "Bomb Disposal Method"
  • Only one of text or textcolumn should be specified when type is 'url'

from

Properties

Name

Type

Required

Description

table

string

yes

An additional table to include in the generated SQL

Sub-tags

None

Content

None

where

Properties

Name

Type

Required

Description

clause

string

yes

An additional clause to include in the generated SQL

uppercase

boolean

no

If the clause uses parameter substitution should the value be converted to upper-case before being substituted

Sub-tags

None

Content

None

row

Properties

None

Sub-tags

Name

Type

Cardinality

cell

urn:com.cohga.server.data.database#1.0:cell

1..n

Content

None

Notes

  • The number of cells should match the number of parameters.

cell

Properties

None

Sub-tags

None

Content

The value to be used for this cell, or null if null should be returned as this cells value. Note that you can also use xsi:nil="true" if you have the xsi namespace setup as described in configuration.

Examples

Sample data definition with caching parameters explicitly set

<data:datadefinition id="roadDetails">
	<datasourcedataconnection datasource="datasource.main" table="ROADS" key="RD_NAME" prefix="DISTINCT">
		<from table="PLANS"/>
		<where clause="PLANS.ID=ROADS.PLAN_ID"/>
		<parameter name="name" label="Name" column="RD_NAME"/>
		<parameter name="suffix" label="Suffix" column="RD_SUFFIX"/>
		<parameter name="type" label="Type" column="RD_TYPE"/>
		<parameter name="altname" label="Alt. Name" column="ALT_NAME"/>
		<parameter name="altsuffix" label="Alt. Suffix" column="ALT_SUFFIX"/>
		<parameter name="alttype" label="Alt. Type" column="ALT_TYPE"/>
		<parameter type="integer" name="class" label="Class" column="CLASS_CODE"/>
		<parameter type="url" name="plan" label="Plan" column="'http://imgsvr:8080/gis/documents/plan_'|PLANS.PLAN_CODE|'.pdf'" text="Open"/>
		<cache>
			<maxElementsInMemory>500</maxElementsInMemory>
			<eternal>false</eternal>
			<timeToIdleSeconds>60</timeToIdleSeconds>
			<timeToLiveSeconds>300</timeToLiveSeconds>
			<overflowToDisk>true</overflowToDisk>
			<maxElementsOnDisk>20000</maxElementsOnDisk>
			<diskPersistent>false</diskPersistent>
			<diskExpiryThreadIntervalSeconds>120</diskExpiryThreadIntervalSeconds>
			<memoryStoreEvictionPolicy>LRU</memoryStoreEvictionPolicy>
		</cache>
	</datasourcedataconnection>
</data:datadefinition>

Sample data definition with caching disabled

<data:datadefinition id="roadDetails">
	<datasourcedataconnection datasource="datasource.main" table="ROADS" key="RD_NAME" prefix="DISTINCT">
		<from table="PLANS"/>
		<where clause="PLANS.ID=ROADS.PLAN_ID"/>
		<parameter name="name" label="Name" column="RD_NAME"/>
		<parameter name="suffix" label="Suffix" column="RD_SUFFIX"/>
		<parameter name="type" label="Type" column="RD_TYPE"/>
		<parameter name="altname" label="Alt. Name" column="ALT_NAME"/>
		<parameter name="altsuffix" label="Alt. Suffix" column="ALT_SUFFIX"/>
		<parameter name="alttype" label="Alt. Type" column="ALT_TYPE"/>
		<parameter type="integer" name="class" label="Class" column="CLASS_CODE"/>
		<parameter type="url" name="plan" label="Plan" column="'http://imgsvr:8080/gis/documents/plan_'|PLANS.PLAN_CODE|'.pdf'" text="Open"/>
		<cache disable="true"/>
	</datasourcedataconnection>
</data:datadefinition>

Sample data definition with caching parameters supplied by a cache configuration (so the cache definition can be reused)

<data:cache id="test.cache">
	<maxElementsInMemory>500</maxElementsInMemory>
	<eternal>false</eternal>
	<timeToIdleSeconds>60</timeToIdleSeconds>
	<timeToLiveSeconds>300</timeToLiveSeconds>
	<overflowToDisk>true</overflowToDisk>
	<maxElementsOnDisk>20000</maxElementsOnDisk>
	<diskPersistent>false</diskPersistent>
	<diskExpiryThreadIntervalSeconds>120</diskExpiryThreadIntervalSeconds>
	<memoryStoreEvictionPolicy>LRU</memoryStoreEvictionPolicy>
</data:cache>

<data:datadefinition id="roadDetails">
	<datasourcedataconnection datasource="datasource.main" table="ROADS" key="RD_NAME" prefix="DISTINCT">
		<from table="PLANS"/>
		<where clause="PLANS.ID=ROADS.PLAN_ID"/>
		<parameter name="name" label="Name" column="RD_NAME"/>
		<parameter name="suffix" label="Suffix" column="RD_SUFFIX"/>
		<parameter name="type" label="Type" column="RD_TYPE"/>
		<parameter name="altname" label="Alt. Name" column="ALT_NAME"/>
		<parameter name="altsuffix" label="Alt. Suffix" column="ALT_SUFFIX"/>
		<parameter name="alttype" label="Alt. Type" column="ALT_TYPE"/>
		<parameter type="integer" name="class" label="Class" column="CLASS_CODE"/>
		<parameter type="url" name="plan" label="Plan" column="'http://imgsvr:8080/gis/documents/plan_'|PLANS.PLAN_CODE|'.pdf'" text="Open"/>
		<cache id="test.cache"/>
	</datasourcedataconnection>
</data:datadefinition>

A data definition for supplying a list of values (no key is defined), probably for a cascading input parameter for a search

<data:datadefinition id="suburbRoads">
	<datasourcedataconnection datasource="datasource.main" table="PROPERTY" prefix="DISTINCT">
		<parameter name="suburb" label="Suburb" column="PRSUB_NAME"/>
		<parameter name="roadname" label="Road Name" column="PRROD_NAME"/>
	</datasourcedataconnection>
</data:datadefinition>

Another data definition for supplying a list of values, probably for a triple field cascading input parameter for a search

<data:datadefinition id="suburbRoadType">
	<datasourcedataconnection datasource="datasource.main" table="PROPERTY" prefix="DISTINCT">
		<parameter name="suburb" label="Suburb" column="PRSUB_NAME"/>
		<parameter name="roadname" label="Road Name" column="PRROD_NAME"/>
		<parameter name="roadtype" label="Road Type" column="PRROD_TYPE"/>
	</datasourcedataconnection>
</data:datadefinition>

A simple inline data definition

<data:datadefinition id="connectionType">
	<inlinedataconnection>
		<parameter type="string" name="key" label="Key" />
		<parameter type="string" name="label" label="Label" />
		<row>
			<cell>U</cell>
			<cell>Unverfied</cell>
		</row>
		<row>
			<cell>V</cell>
			<cell>Verified</cell>
		</row>
	</inlinedataconnection>
</data:datadefinition>

A simple inline data definition using null

<data:datadefinition id="customerType">
	<inlinedataconnection>
		<parameter type="string" name="label" label="Label" />
		<parameter type="string" name="key" label="Key" />
		<row>
			<cell>Domestic</cell>
			<cell>D</cell>
		</row>
		<row>
			<cell>Commercial</cell>
			<cell>C</cell>
		</row>
		<row>
			<cell>Unknown</cell>
			<cell>null</cell>
		</row>
	</inlinedataconnection>
</data:datadefinition>

More on Caching

To disable the caching all together you'd do the following

<data:datadefinition id="...">
	<datasourcedataconnection ...>
		...
		<cache disable="true"/>
	</datasourcedataconnection>
</data:datadefinition>

To modify the default caching options

<data:datadefinition id="...">
		<datasourcedataconnection ...>
		...
		<cache>
			<setting>value</setting>
			<setting>value</setting>
			<setting>value</setting>
		</cache>
	</datasourcedataconnection>
</data:datadefinition>

Where the <settings> you can change are identified at caching

You can set the default cache settings with

<data:cache>
	<setting>value</setting>
	<setting>value</setting>
	<setting>value</setting>
</data:cache>

and create a cache definition that can be re-used

<data:cache id="test">
	<setting>value</setting>
	<setting>value</setting>
	<setting>value</setting>
</data:cache>

<data:datadefinition id="...">
	<datasourcedataconnection ...>
		...
		<cache id="test"/>
	</datasourcedataconnection>
</data:datadefinition>
  • No labels