Skip to main content

type

Create a custom data type for your private data

Syntax

declaredType = (versioned)? type (extends declaredType)?
(comment)?
(typeProperty | typeExpression | typeMethod )*
end

typeProperty: propertyName as type ( (qualifier)? )
(matches regex)?
(default defaultValue)?

typeExpression: propertyName as expression

typeMethod: propertyName as function( (param (,param)*)? )
functionBody
end

Description

An explanation of the syntax:

  • declaredType is the id of the type
  • The versioned option makes all objects of this type versioned
  • The extends option allows you to extend another type, creating a specialisation of that type
  • The comment on the first line after the declaration becomes the description of this type
  • A property on the type can be one of:
    • property
    • expression
    • method
  • The type of the property can be one of:
    • dimension - This is a special property type that is used by GUI applications, e.g. the web portal to filter objects based on a value of this property. A dimension is generally used as a property that has a very low uniqueness, e.g. like country or source
    • string - A simple string property
    • number - A generic number, can be integer or decimal
    • scalar - A generic scalar value, can be string, numeric or boolean
    • date - A date or datetime value
    • boolean - A true/false value
    • list - A list of objects - the type of object can be restricted using a qualifier
    • object - A generic object
    • duration - A timespan value, e.g. 4 days
    • geometry - A geometric shape
    • timeseries - A timeseries value
    • curve - A curve value
    • specific type - Any public or private type declaration
  • The property can have a qualifier used to limit the type, e.g. if the type is a list and you want to restrict the list elements to dates
Versioning

If you specify the versioned option when defining the type, then all objects of this type will be versioned. This means any updates to that object where a value of a property has changed will cause a new version to be created and the existing version is archived. More details about data versioning can be found here.

Extending

By default, all types extend the #Object type which has the following properties defined:

  • name - string
  • description - string
  • classification - dimension
  • geolocation - geometry

However, you can elect to extend any public or your own private type in order to create a specialised version of that type, which will give you a type hierarchy. A simple example of why you would want to do this is shown below:

Type Hierarchy

The diagram below shows a simple type hierarchy, starting with #Object we create a generic Person type which adds the properties PhoneNumber and Email. We then extend the Person object into 2 specialised types: Student and Professor which add some more specific properties.

With this type hierarchy, we can add Student objects and Professor objects, but we can also list all Person objects showing all students and professors, so if I knew someones email address and seached in Person, it would find the person irrespective of whether they are a student or a professor.

For more examples and in-depth descriptions, see the section Data Modelling.

Examples

Example of a type hierarchy:

Widget = versioned type
price as Number()
end

Cable = versioned type extends Widget
length as Number()
end

Switch = versioned type extends Widget
ports as Number()
end