# Data model

This chapter is about the data model used in AsTeRICS Grid.

  1. Introduction
  2. Data models saved to database
  3. Data models not saved to database
  4. Common data model properties
  5. Full and short objects

Back to Overview

# Introduction

Since Javascript is not a typed language it’s not possible by default to define a data model in order to perform checks on valid properties and their types. For this reason the library ObjectModel (opens new window) is used which allows to define data models and perform dynamic checks on their validity.

# Data models saved to database

Data models defined for AsTeRICS Grid can be found in the folder src/js/model (opens new window). These are the used data models which are actually saved to database:

  • GridData: model for a grid, containing a list of GridElement objects
  • MetaData: model for global data, including InputConfig and e.g. the ID of the last opened grid to show at startup
  • Dictionary: saves the configuration of a predictionary (opens new window) wordlist, a dictionary shown in the manage dictionaries view
  • GridImage: saves the data of an imported image in higher resolution. This is used if a grid element is resized in order to save a new image with fitting size to it’s GridElement object.
  • EncryptedObject: contains any of the data model objects above serialized as JSON object and encrypted using the sjcl (opens new window) crypto library. In fact every object saved to database is an EncryptedObject containing one of the data model objects listed above.

# Data models not saved to database

These are the used data models which part of one of the data models above, but aren’t independently saved to database:

# Common data model properties

All data models have these properties in common:

  • id [String]: unique ID of the object
  • modelName [String]: name of the data model, same as the class filename defining it, e.g. GridData
  • modelVersion [String]: version of the data model using semantic versioning, e.g. 1.0.0

# Full and short objects

EncryptedObject has the following two additional properties:

  1. encryptedDataBase64: contains the encrypted version of the serialized JSON object this EncryptedObject actually holds
  2. encryptedDataBase64Short: contains the same encrypted serialized JSON object, but all properties longer than 500 characters are removed. This “short” version of the object can be used if not all data is needed, e.g. no image data of grids, but only short data items like the label. The property encryptedDataBase64Short is empty (null), if it’s the same as encryptedDataBase64 (no long properties) in order to save memory space.

The GridData data model contains a property isShortVersion which indicates that the current object includes only a short, stripped version of the data, if set to true. These short versions of GridData objects are used for the list of grids in the manage grids view since there the only properties that are needed are label and id.

← Previous Chapter Next Chapter →

Back to Overview