Versions Compared

Key

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

...

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 systems like Pathway, where some tables store padded id's

...

Name
keytablestring

Type

Cardinality

parameter

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

0..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 (see example below).
  • You can completely disable the caching (for all data definitions that don't have cache setting explicitly set) by setting the startup parameter weave.cache.default to true (in startup.cmd, startup.sh and/or weave-service.conf).
  • If no parameters are specified then the server will generate parameters based on the columns in the underlying table, in this case you should also not include any from tags since joins are not currently supported, where tags are ok though.

...

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

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

Examples

...


<data:datadefinition id="roadDetails">
	<datasourcedataconnection datasource="datasource.main" table="ROADS" key="RD_NAME" prefix="DISTINCT"/>
</data:datadefinition>
Note

In the following examples the || operator is used to concatenate strings, this operator is Oracle specific, and my require using a different operator for other databases, for example +

...


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

...

noAn optional database table that will be used to store entity keys temporarily when performing the required SQL to generate the data for this data connection. If this option isn't set then the SQL used to generate the data will create the data in batches, which can cause issues with sorting, optionally you can create a simple two column table, with an index on the userid column, and set this value to the name of this table, then Weave will insert the entity id's into this table temporarily and use this table in a SQL join when generating the data. This will resolve any sorting issues, and is more important if caching is also disabled for the data connection.
keycolumnstringnoThe column in keytable that contains the entity id, default is key
usercolumnstringnoThe column in keytable that contains the userid, default is userid

Sub-tags

Name

Type

Cardinality

parameter

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

0..n

cache

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

0..1

fromurn:com.cohga.server.data.database#1.0:from0..n
whereurn:com.cohga.server.data.database#1.0:where0..n
joinurn:com.cohga.server.data.database#1.0:join0..n

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 (see example below).
  • You can completely disable the caching (for all data definitions that don't have cache setting explicitly set) by setting the startup parameter weave.cache.default to true (in startup.cmd, startup.sh and/or weave-service.conf).
  • If no parameters are specified then the server will generate parameters based on the columns in the underlying table, in this case you should also not include any from tags since joins are not currently supported, where tags are ok though.

Anchor
parameter
parameter

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

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'

Anchor
from
from

from

Properties

Name

Type

Required

Description

table

string

yes

An additional table to include in the generated SQL

Sub-tags

None

Content

None

Anchor
where
where

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

join

Only available in 2.5.11 or later

properties

NameTypeRequiredDescription
tablestringyesThe table to join to
onstringyesThe clause used to join the table
typestringnoThe type of join to use

 

 

Examples

Code Block
xml
xml
titleBasic data definition where output is based on columns in the underlying table
linenumberstrue
<data:datadefinition id="roadDetails">
	<datasourcedataconnection datasource="datasource.main" table="ROADS" key="RD_NAME" prefix="DISTINCT"/>
</data:datadefinition>
Note

In the following examples the || operator is used to concatenate strings, this operator is Oracle specific, and my require using a different operator for other databases, for example +

Code Block
xml
xml
titleSample data definition with caching parameters explicitly set
linenumberstrue
<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>
Code Block
xml
xml
titleSample data definition with caching disabled
linenumberstrue
<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="altnamename" label="Alt. Name" column="ALTRD_NAME"/>
		<parameter name="altsuffixsuffix" label="Alt. Suffix" column="ALTRD_SUFFIX"/>
		<parameter name="alttypetype" label="Alt. Type" column="ALTRD_TYPE"/>
		<parameter type="integer"  name="altname" label="Alt. Name" column="ALT_NAME"/>
		<parameter name="classaltsuffix" label="ClassAlt. Suffix" column="CLASSALT_CODESUFFIX"/>
		<parameter type="url" name="planalttype" label="PlanAlt. Type" column="'http://imgsvr:8080/gis/documents/plan_'||PLANS.PLAN_CODE||'.pdf'" text="Open"/>
		<cache disable="trueALT_TYPE"/>
		<parameter type="integer" name="class" label="Class" column="CLASS_CODE"/>
		</datasourcedataconnection>
</data:datadefinition>
Code Block
xmlxml
titleSample data definition with caching parameters supplied by a cache configuration (so the cache definition can be reused)
linenumberstrue

<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 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>
Code Block
xml
xml
titleSample data definition with caching parameters supplied by a cache configuration (so the cache definition can be reused)
linenumberstrue
<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>
Code Block
xml
xml
titleA data definition for supplying a list of values (no key is defined), probably for a cascading input parameter for a search
linenumberstrue

<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>
Code Block
xml
xml
titleAnother data definition for supplying a list of values, probably for a triple field cascading input parameter for a search
linenumberstrue

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

...

Code Block
xml
xml
linenumberstrue

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

...

Code Block
xml
xml
linenumberstrue

<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

Code Block
xml
xml
linenumberstrue
<data:cache>
	<setting>value</setting>
	<setting>value</setting>
	<setting>value</setting>
</data:cache>

and create a cache definition that can be re-used

Code Block
xml
xml
linenumberstrue
<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>

Using a temporary table

Code Block
languagexml
titleUsing a temporary table
<data:datadefinition id="roadDetails">
	<datasourcedataconnection datasource="datasource.main" table="ROADS" key="RD_NAME" prefix="DISTINCT" keytable="ROADS_SELECTION" keycolumn="RD_NAME" usercolumn="UID">
		<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>

This example will utilise a temporary table called ROADS_SELECTION which contains two columns RD_NAME who's data type matches the RD_NAME column in the ROADS table, and UID which is a varchar column long enough to contain 32 random characters, and there should be an non-unique index on the UID column.

New Join Syntax

As of Weave 2.5.11 it's possible to specify a table join using join specific tag (rather than having to use from and where tags).

This is done with the join tag, which takes 3 parameters, table which is required and is the name of the table to join on, on which is also required and is the join clause, and finally type which isn't required and will specify the join type to use (will default to an inner join).

Note that there currently is no checking on the value specified for the type parameter, the valid specified for type will be placed directly into the generated SQL, so you should ensure that you're using a valid join type for your database ("inner", "left", "right", "full", etc).

Code Block
languagexml
titleJoin syntax example
<data:datadefinition id="roadDetails">
	<datasourcedataconnection datasource="datasource.main" table="ROADS" key="RD_NAME" prefix="DISTINCT">
		<join type="left" table="PLANS" on="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"/>
	</datasourcedataconnection>
</data:datadefinition>

The above example shows joining the PLANS table. Using the previous version of the roadDetails data definition would not return any rows where there was not a match between the ROADS and PLANS table, using the newer syntax it's possible to generate SQL that will return rows from ROADS even if there is no match in the PLANS table.

Note that the above configuration for the plan parameter is not currently smart enough to generate a value value for column, since it does not take into account the fact that the PLANS.PLAN_CODE value will be null if there is no matching row in the PLANS table. The column attribute should be updated to use the appropriate SQL syntax for your database rto check for a a null value and handle it accordingly (i.e.

...

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

...

generate a link to a "no plan available" page).

The SQL generated for the previous version (using from and where tags) would be of the form:

Code Block
languagesql
SELECT columns
FROM primary_table, secondary_table
WHERE primary_table.column = secondary_table.column

Using a join tag (without a type specified) the SQL generated would be of the form:

Code Block
languagesql
SELECT columns
FROM primary_table JOIN secondary_table ON primary_table.column = secondary_table.column

If the type were specified as "left" then the SQL generated would be of the form:

Code Block
SELECT columns
FROM primary_table left JOIN secondary_table ON primary_table.column = secondary_table.column