DATA - DataViews – cavaliba.com
Description: Reference

`CTRL K`

Documentation
Data
DATA - DataViews

# DATA - DataViews

A DataView describes a subset of a DataClass to be presented to the users in the Web Interface.

You can define multiple DataViews per DataClass for different type of users.

## DataView objects

DataViews are implemented as regular DataClass objects and can thus be managed from the Web UI, REST API, console CLI, import/export, etc.

DataViews

    # optional Role definitions to manage DataView authorizations
    _role:role_data_view_ro:
        displayname: Role data:data_view:ro
        subgroups:
          - admin_cavaliba

    _role:role_data_view_rw:
        displayname: Role data:data_view:rw
        subgroups:
          - admin_cavaliba

    _role:role_data_view_admin:
        displayname: Role data:data_view:admin
        subgroups:
          - admin_cavaliba

    # DataView definition as a specific Data Schema structure

    _schema:data_view:
        _displayname: Data Views
        _is_enabled: yes
        _icon: fa-table
        _order: 810
        _page: Internal
        _role_show: role_data_view_ro
        _role_access: role_data_view_ro
        _role_read: role_data_view_ro
        _role_create: role_data_view_rw
        _role_update: role_data_view_rw
        _role_delete: role_data_view_rw
        _role_onoff: role_data_view_rw
        _role_import: role_data_view_admin
        _role_export: role_data_view_admin
        description:
            #_action: create_or_update
            displayname: Description
            order: 100
            dataformat: string
            dataformat_ext: ""
            cardinal_min: 0
            cardinal_max: 1
            default : ""
        # DataClass on which a DataView operates
        classname:
            displayname: classname
            cardinal_min: 0
            cardinal_max: 1
            order: 110
            dataformat: string
        # nested YAML structure with columns and operations on columns
        content:
            displayname: content
            cardinal_min: 0
            cardinal_max: 1
            order: 120
            dataformat: text
            dataformat_ext: yaml

## Common Dataview attributes

The classname attribute defines the DataClass on which the DataView will operate.

keyname, displayname and last_update are common attributes to all DataClass. They can be omitted from the DataViews columns. If none is requested , Cavaliba adds keyname by default.

## content attribute

The content attribute in each DataView object is a list of columns to be displayed and operators to apply on each of these columns. It is a YAML columns array which preserves order. Each column name starts with a `-`.

    columns:
        - columnA
        - columnB
        (...)
        - columnX:
            from: my_original_long_column_name

The from option defines a source field which provides content for that column. An invalid from value will create an empty column. The intended use of the column/from pattern is to provide a way to provide nicer (custome, translated, compact, …) column names to users.

Some new operators may be added in the future, like aggregate values or computed values from other columns.

Example:

    columns:
       - ZipAgain:
           from: zipcode

## Full DataView Example

The follwing YAML snippet create a DataView on the site objects to present some relevant geographical informations.

It says:

- create a user available DataView for the DataClass site objects.
- show a table with the following columns: address, region, …
- some of the columns will have a different name than the underlying DataClass attribute

    data_view:site_postal:
      #_action: create_or_update
      classname: site
      is_enabled: true
      displayname: MySiteView_postal
      description: This View displays Geographical information about sites
      content: |
        columns:
          - site name:
              from: keyname
          - address
          - zipcode
          - city:
          - region
               from: state_or_region
          - country
          - code
               from: iso_code

Pipeline DATA - Enumerate