Selection list of valid values

Selection list of valid values specifies a selection list of valid values for an attribute input field and is located in the attribute part of the class meta "selectionProvider". The list is formed in the form of an array of objects of the “key-value” type and is a selection list of values for the attribute with the “String”, “Real”, “Integer”, “Decimal”, and “Text” types.

You have three types of a selection list. Set the type in the ("type") field using one of the following keys:

  • "SIMPLE" - simple selection list;
  • "MATRIX" - matrix selection list.

Description of the structure fields

Structure of the selection list object

"selectionProvider": {
  "type": "SIMPLE",
  "list": [...],
  "matrix": [],
  "parameters": [],
  "hq": ""
},
Field Name Acceptable values Description
"type" Type "SIMPLE", "MATRIX", "HQL" Selection list type
"list" Simple type An array of objects of the “key-value” type Selection list of the “SIMPLE” type is stored here.
"matrix" Matrix An array of vectors. Each of vectors consists of: name, selection conditions and key-values. Selection list of the “MATRIX” type.
"parameters" Parameters of request An array of objects of the “key-value” type Parameters of request, to be realized
"hq" Request String of request in accordance with the handler format not used in the current version String of request, to be realized

The "list" field - an array of objects of the following structure:

"list": [
  {
    "key": "2001-03-23 09:00:00.000Z",
    "value": "Затопление орбитальной станции «Мир» (23 марта 2001 г. 09:00 мск)"
  },
  {
    "key": "1957-10-04 19:28:00.000Z",
    "value": "Запуск первого в мире искусственного спутника (4 октября 1957 г. в 19:28 гринвич)"
  },
  {
    "key": "1970-04-17 12:07:00.000Z",
    "value": "Завершение полёта «Аполлон-13» (17 апреля 1970 г. 12:07 Хьюстон)"
  }
],
Field Name Acceptable values Description
"key" Key Any value corresponding to the attribute type of the selection list When saving an object the key value is written in the DB
"value" Value Any string, but there may be problems if there are control sequences The value of this field is displayed in the user interface

The "matrix" field is an array of objects of the following structure:

  "matrix": [
    {
      "comment": "Оба отрицательные",
      "conditions": [
        {
          "property": "matrix_base_1",
          "operation": 5,
          "value": "0",
          "nestedConditions": []
        },
        {
          "property": "matrix_base_2",
          "operation": 5,
          "value": "0",
          "nestedConditions": []
        }
      ],
      "result": [
        {
          "key": "Оба отрицательные",
          "value": "Оба отрицательные"
        }
      ]
    },
    {
      "comment": "Оба неотрицательные",
      "conditions": [
        {
          "property": "matrix_base_1",
          "operation": 8,
          "value": "0",
          "nestedConditions": []
        },
        {
          "property": "matrix_base_2",
          "operation": 8,
          "value": "0",
          "nestedConditions": []
        }
      ],
      "result": [
        {
          "key": "Оба неотрицательные",
          "value": "Оба неотрицательные"
        }
      ]
    },
    {
      "comment": "Первое неотрицательное второе отрицательное",
      "conditions": [
        {
          "property": "matrix_base_1",
          "operation": 8,
          "value": "0",
          "nestedConditions": []
        },
        {
          "property": "matrix_base_2",
          "operation": 5,
          "value": "0",
          "nestedConditions": []
        }
      ],
      "result": [
        {
          "key": "Первое неотрицательное второе отрицательное",
          "value": "Первое неотрицательное второе отрицательное"
        }
      ]
    },
    {
      "comment": "Первое отрицательное, второе неотрицательное",
      "conditions": [
        {
          "property": "matrix_base_1",
          "operation": 5,
          "value": "0",
          "nestedConditions": []
        },
        {
          "property": "matrix_base_2",
          "operation": 8,
          "value": "0",
          "nestedConditions": []
        }
      ],
      "result": [
        {
          "key": "Первое отрицательное, второе неотрицательное",
          "value": "Первое отрицательное, второе неотрицательное"
        }
      ]
    }
  ],
  "parameters": [],
  "hq": ""
},

Each object of the "MATRIX" array contains the following mandatory fields:

Field Name Acceptable values Description
"comment" Comment Any string Comment to the vector
"conditions" Conditions Array of objects Defines the conditions under which the list of objects described in "result" of this vector is displayed
"result" Results Array of objects, similar to the structure of the "list" field Sets the selection list that is displayed when the conditions are set correctly in the "conditions" field

The "conditions" field of the "MATRIX" array

Field Name Acceptable values Description
"property" Attribute String only the latin characters with no spaces Class attribute, the field value of which is checked for compliance with the given condition of the given vector
"operation" Operation Operation code The operation according to which the determination is made
    0 - equal to (AND)  
    1 - not equal to (OR)  
    2 - empty (NOT)  
    3 - not empty (MIN FROM)  
    4 - (MAX FROM)  
    5 - < ()  
    6 - >  
    7 - <=  
    8 - >=  
    9 - IN /Similar/  
    10 - contains  
"value" Value Depends on the type of operation Second value for binary operations
"nestedConditions" Nested selection conditions Object, the structure is similar to the structure of the selection conditions object itself.  

NB: The operation code corresponds to different operation values, depending on whether the attribute is selected or not. If the "property" field is null, then a boolean condition is encoded, according to which the nested selection conditions are combined. (Indicated in parentheses in the table above)

Description

Selection list of the “SIMPLE” type

This selection list allows you to create a preset of field values hardwired into the application, thereby limiting the user’s choice.

For the field, it is mandatory to set the “Drop-down list [5]” view type.

It implies the ability to save data in the database in a type different from the type of data displayed to the user.

For example: If you set the date-time value selection list items in ISODate as the key fields, and the event description as the value field, then we will give the user the opportunity to select the event, but work with ISODate data inside the application.

NB: If an attribute with a selection list is allowed to have an empty value: `` “nullable”: true``, then an empty default value is added to the selection list!

{
  "orderNumber": 50,
  "name": "sp_date",
  "caption": "Сохраняем ключ дата-время",
  "type": 9,
  "size": null,
  "decimals": 0,
  "allowedFileTypes": null,
  "maxFileCount": 0,
  "nullable": true,
  "readonly": false,
  "indexed": false,
  "unique": false,
  "autoassigned": false,
  "hint": null,
  "defaultValue": null,
  "refClass": "",
  "itemsClass": "",
  "backRef": "",
  "backColl": "",
  "binding": "",
  "semantic": null,
  "selConditions": [],
  "selSorting": [],
  "selectionProvider": {
    "type": "SIMPLE",
    "list": [
      {
        "key": "2001-03-23T09:00:00.000Z",
        "value": "Затопление орбитальной станции «Мир» (23 марта 2001 г. 09:00 мск)"
      },
      {
        "key": "1957-10-04T19:28:00.000Z",
        "value": "Запуск первого в мире искусственного спутника (4 октября 1957 г. в 19:28 гринвич)"
      },
      {
        "key": "1970-04-17T12:07:00.000Z",
        "value": "Завершение полёта «Аполлон-13» (17 апреля 1970 г. 12:07 Хьюстон)"
      }
    ],
    "matrix": [],
    "parameters": [],
    "hq": ""
  },
  "indexSearch": false,
  "eagerLoading": false,
  "formula": null
}

Principle of formation:

You need to:

  1. choose the most appropriate attribute type,
  2. choose the identifiers of the type ("key") in order to operate with values in the DB as efficiently as possible if automated processing is required,
  3. set the phrase to each key, that will be displayed in the "value"field,
  4. make sure to set the “Drop-down list [5]” view type.

Selection list of the “MATRIX” type

All that falls under the conditions is the resulting selection list in matrix. If there is no conditions - the system will always apply the selection list. For the predictability of the application, respect two conditions:

  1. The vectors should not overlap each other.

  2. Array of values of the initial attribute, as the matrix base (an array of combinations of the initial (reference) attributes values) must be completely closed by the described vectors.

    The system takes the value of the reference field (s) and consistently applies the conditions of the vectors to this field. Each vector is the set of conditions and its own selection list. As soon as the system reaches the vector with satisfied conditions, it takes its selection list and defines the output in the UI. It is assumed that the system will find the corresponding vector for any value of the reference field.

Example 1: Matrix of two integer values

JSON of the class:

{
  "isStruct": false,
  "key": [
    "id"
  ],
  "semantic": "",
  "name": "selection_provider_matrix_dc",
  "version": "",
  "caption": "\"MATRIX\" от двух оснований",
  "ancestor": null,
  "container": null,
  "creationTracker": "",
  "changeTracker": "",
  "history": 0,
  "journaling": false,
  "compositeIndexes": [],
  "properties": [
    {
      "orderNumber": 10,
      "name": "id",
      "caption": "Идентификатор",
      "type": 12,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": false,
      "readonly": false,
      "indexed": false,
      "unique": true,
      "autoassigned": true,
      "hint": null,
      "defaultValue": null,
      "refClass": "",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": null,
      "indexSearch": false,
      "eagerLoading": false,
      "formula": null
    },
    {
      "orderNumber": 20,
      "name": "matrix_base_1",
      "caption": "Первое целое основание матрицы",
      "type": 6,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": true,
      "readonly": false,
      "indexed": false,
      "unique": false,
      "autoassigned": false,
      "hint": null,
      "defaultValue": null,
      "refClass": "",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": null,
      "indexSearch": false,
      "eagerLoading": false,
      "formula": null
    },
    {
      "orderNumber": 30,
      "name": "matrix_base_2",
      "caption": "Второе целое основание матрицы",
      "type": 6,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": true,
      "readonly": false,
      "indexed": false,
      "unique": false,
      "autoassigned": false,
      "hint": null,
      "defaultValue": null,
      "refClass": "",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": null,
      "indexSearch": false,
      "eagerLoading": false,
      "formula": null
    },
    {
      "orderNumber": 40,
      "name": "selection_provider_matrix",
      "caption": "Список выбора типа \"MATRIX\"",
      "type": 0,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": true,
      "readonly": false,
      "indexed": false,
      "unique": false,
      "autoassigned": false,
      "hint": null,
      "defaultValue": null,
      "refClass": "",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": {
        "type": "MATRIX",
        "list": [],
        "matrix": [
          {
            "comment": "Оба отрицательные",
            "conditions": [
              {
                "property": "matrix_base_1",
                "operation": 5,
                "value": "0",
                "nestedConditions": []
              },
              {
                "property": "matrix_base_2",
                "operation": 5,
                "value": "0",
                "nestedConditions": []
              }
            ],
            "result": [
              {
                "key": "Оба отрицательные",
                "value": "Оба отрицательные"
              }
            ]
          },
          {
            "comment": "Оба неотрицательные",
            "conditions": [
              {
                "property": "matrix_base_1",
                "operation": 8,
                "value": "0",
                "nestedConditions": []
              },
              {
                "property": "matrix_base_2",
                "operation": 8,
                "value": "0",
                "nestedConditions": []
              }
            ],
            "result": [
              {
                "key": "Оба неотрицательные",
                "value": "Оба неотрицательные"
              }
            ]
          },
          {
            "comment": "Первое неотрицательное второе отрицательное",
            "conditions": [
              {
                "property": "matrix_base_1",
                "operation": 8,
                "value": "0",
                "nestedConditions": []
              },
              {
                "property": "matrix_base_2",
                "operation": 5,
                "value": "0",
                "nestedConditions": []
              }
            ],
            "result": [
              {
                "key": "Первое неотрицательное второе отрицательное",
                "value": "Первое неотрицательное второе отрицательное"
              }
            ]
          },
          {
            "comment": "Первое отрицательное, второе неотрицательное",
            "conditions": [
              {
                "property": "matrix_base_1",
                "operation": 5,
                "value": "0",
                "nestedConditions": []
              },
              {
                "property": "matrix_base_2",
                "operation": 8,
                "value": "0",
                "nestedConditions": []
              }
            ],
            "result": [
              {
                "key": "Первое отрицательное, второе неотрицательное",
                "value": "Первое отрицательное, второе неотрицательное"
              }
            ]
          }
        ],
        "parameters": [],
        "hq": ""
      },
      "indexSearch": false,
      "eagerLoading": false,
      "formula": null
    }
  ]
}

Procedure of development

Divide all possible combinations of attribute pairs - "matrix_base_1" and "matrix_base_2" into 4 vectors. Each field can be either negative or non-negative. See the scheme below:

Разбиваем на вектора

Choose vectors and their conditions:

  1. Both negative: (matrix_base_1 < 0) && (matrix_base_2 < 0)
  2. Both non-negative: (matrix_base_1 >= 0) && (matrix_base_2 >= 0)
  3. First non-negative, second negative: (matrix_base_1 >= 0) && (matrix_base_2 < 0)
  4. First negative, second non-negative: (matrix_base_1 < 0) && (matrix_base_2 >= 0)
  5. If in the 3 and 4 conditions the equality to zero is not correctly set, there will be drop-down elements and overlapping of vectors as a result.

In the example above, for each vector the selection list is limited to one item, but there may be more.

Example 2: matrix of free real value with compound conditions

{
  "isStruct": false,
  "metaVersion": "2.0.7",
  "key": [
    "id"
  ],
  "semantic": "",
  "name": "selection_provider_matrix_real",
  "version": "",
  "caption": "\"MATRIX\" с векторами \u003c, \u003e, \u003c\u003d, \u003e\u003d, \u003d от действительного",
  "ancestor": null,
  "container": null,
  "creationTracker": "",
  "changeTracker": "",
  "history": 0,
  "journaling": false,
  "compositeIndexes": null,
  "properties": [
    {
      "orderNumber": 10,
      "name": "id",
      "caption": "Идентификатор",
      "type": 12,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": false,
      "readonly": false,
      "indexed": false,
      "unique": true,
      "autoassigned": true,
      "hint": null,
      "defaultValue": null,
      "refClass": "",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": null,
      "indexSearch": false,
      "eagerLoading": false,
      "formula": null
    },
    {
      "orderNumber": 20,
      "name": "matrix_base",
      "caption": "Действительное основание для списка выбора матричного типа",
      "type": 7,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": true,
      "readonly": false,
      "indexed": false,
      "unique": false,
      "autoassigned": false,
      "hint": null,
      "defaultValue": null,
      "refClass": "",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": null,
      "indexSearch": false,
      "eagerLoading": false,
      "formula": null
    },
    {
      "orderNumber": 30,
      "name": "selection_provider_matrix",
      "caption": "Список выбора со сложными условиями",
      "type": 6,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": false,
      "readonly": false,
      "indexed": false,
      "unique": false,
      "autoassigned": false,
      "hint": null,
      "defaultValue": null,
      "refClass": "",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": {
        "type": "MATRIX",
        "list": [],
        "matrix": [
          {
            "comment": "matrix_base \u003c 3",
            "conditions": [
              {
                "property": "matrix_base",
                "operation": 5,
                "value": [
                  "3"
                ],
                "nestedConditions": []
              }
            ],
            "result": [
              {
                "key": "1",
                "value": "Сохраним 1 при основании меньше 3"
              },
              {
                "key": "2",
                "value": "Сохраним 2 при основании меньше 3"
              }
            ]
          },
          {
            "comment": "matrix_base \u003d 3",
            "conditions": [
              {
                "property": "matrix_base",
                "operation": 0,
                "value": [
                  "3"
                ],
                "nestedConditions": []
              }
            ],
            "result": [
              {
                "key": "3",
                "value": "Сохраним 3 при основании 3"
              }
            ]
          },
          {
            "comment": "matrix_base \u003e 3 и matrix_base \u003c\u003d 15",
            "conditions": [
              {
                "property": "matrix_base",
                "operation": 6,
                "value": [
                  "3"
                ],
                "nestedConditions": []
              },
              {
                "property": "matrix_base",
                "operation": 7,
                "value": [
                  "15"
                ],
                "nestedConditions": []
              }
            ],
            "result": [
              {
                "key": "5",
                "value": "Сохраним 5 при основании \u003e 3 и \u003c\u003d 15"
              },
              {
                "key": "10",
                "value": "Сохраним 10 при основании \u003e 3 и \u003c\u003d 15"
              },
              {
                "key": "15",
                "value": "Сохраним 15 при основании \u003e 3 и \u003c\u003d 15"
              }
            ]
          },
          {
            "comment": "matrix_base \u003e\u003d16",
            "conditions": [
              {
                "property": "matrix_base",
                "operation": 8,
                "value": [
                  "16"
                ],
                "nestedConditions": []
              }
            ],
            "result": [
              {
                "key": "50",
                "value": "Сохраним 50 при основании \u003e\u003d 16"
              },
              {
                "key": "100",
                "value": "Сохраним 100 при основании \u003e\u003d16"
              },
              {
                "key": "1000",
                "value": "Сохраним 1000 при основании \u003e\u003d16"
              },
              {
                "key": "5000",
                "value": "Сохраним 5000 при основании \u003e\u003d16"
              }
            ]
          },
          {
            "comment": "matrix_base \u003e 15 и matrix_base \u003c 16",
            "conditions": [
              {
                "property": "matrix_base",
                "operation": 6,
                "value": [
                  "15"
                ],
                "nestedConditions": []
              },
              {
                "property": "matrix_base",
                "operation": 5,
                "value": [
                  "16"
                ],
                "nestedConditions": []
              }
            ],
            "result": [
              {
                "key": "0",
                "value": "Сохраним 0, если основание где-то между 15 и 16"
              }
            ]
          }
        ],
        "parameters": [],
        "hq": ""
      },
      "indexSearch": false,
      "eagerLoading": false,
      "formula": null
    }
  ]
}

Vectors and their conditions:

  1. matrix_base < 3
  2. matrix_base = 3
  3. (matrix_base > 3) && (matrix_base <= 15)
  4. matrix_base >= 16
  5. (matrix_base > 15) && (matrix_base < 16)