Модель даних

Загальний опис

Модуль для організації роботи з конфігурацією моделі даних.

Надає наступний функціонал:
  • Отримання списку всіх бізнес-процесів регламенту

  • Дозволені CRUD операції над бізнес-процесами регламенту

Описання структури DataModelSnapshot

registry-regulation-management db-tables-management-er

Допустимі операції з об’єктами доменної моделі

Об’єкти моделі даних, що не були інтегровані в мастер версію регламенту реєстру, можуть бути змінені будь-яким чином не зважаючи на нижче вказані обмеження.

Допустимі операції з об’єктами доменної моделі, що ввійшли в мастер версію

Назва entity Create Update Delete

Table

Y

Y

N

Column

Y

Y

N

Index

Y

Y

Y

Constraint

Y

Y

Y

ForeignKey

Y

Y

Y

AccessRule

Y

Y

Y

Опис структури файлів на файловій системі

DataModelSnapshot model має наступну структуру файлів на файловій системі

tables management datamodel filestructure
  • Перелік таблиць визначається переліком файлів на файловій системі

  • Ім’я файлу таблиць відповідає назві таблиці та має наступний вигляд: <table-name>.json

  • Ім’я файлу role permission відповідає назві id role permission та має наступний вигляд: <role-id>.json

Загальна діаграма взаємодії компонентів системи під час редагування моделі даних регламенту реєстру

tables management component structure

Типи JSON документів:

DataModelSnapshot model - JSON документи, що відображають стан моделі даних регламенту реєстру

Diff Document - документ, що відображає різницю між двома станами моделі даних регламенту реєстру

History Document - документ, що відображає історію змін мастер версії або версії- кандидату регламенту реєстру

Основні принципи

  • RestAPI використовує структури даних описані json схемами DataModelSnapshot документів

  • Пайплайн перевірки конфігурації регламенту реєстру використовується для актуалізації DataModelSnapshot document’s в разі внесення змін няпряму в пуккше розробником реєстру

  • Зміни внесені через адміністративний портал знаходяться в окремому liquibase changeset. Ідентифікатор версії-кандидату є частиною liquibase changeset id атрибуту.

DataModelSnapshot entities json schema

Table JsonSchema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "$ref": "#/$defs/ddmTable",
  "$defs": {
    "required": [
      "ddmTables"
    ],
    "ddmTable": {
      "type": "object",
      "description": "Type of the table entity",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the table"
        },
        "historyFlag": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Flag that indicates if table history has to be saved"
        },
        "objectReference": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Flag that indicates if table is an object reference to a subject"
        },
        "description": {
          "type": "string",
          "description": "Description (remarks) of the table"
        },
        "columns": {
          "type": "object",
          "description": "Map of table columns",
          "additionalProperties": {
            "$ref": "#/$defs/ddmColumn"
          }
        },
        "foreignKeys": {
          "type": "object",
          "description": "Map of table foreign keys",
          "additionalProperties": {
            "$ref": "#/$defs/ddmForeignKey"
          }
        },
        "primaryKey": {
          "$ref": "#/$defs/ddmIndex",
          "description": "Table primary key"
        },
        "uniqueConstraints": {
          "type": "object",
          "description": "Map of table unique constraints (indices)",
          "additionalProperties": {
            "$ref": "#/$defs/ddmIndex"
          }
        },
        "indices": {
          "type": "object",
          "description": "Map of table other indices",
          "additionalProperties": {
            "$ref": "#/$defs/ddmIndex"
          }
        }
      },
      "required": [
        "name",
        "historyFlag",
        "objectReference",
        "description",
        "columns",
        "foreignKeys",
        "primaryKey",
        "uniqueConstraints",
        "indices"
      ]
    },
    "ddmColumn": {
      "type": "object",
      "description": "Type of the column entity",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the table column"
        },
        "description": {
          "type": "string",
          "description": "Description (remarks) of the table column"
        },
        "type": {
          "type": "string",
          "$comment": "Should be enum",
          "description": "Table column type"
        },
        "defaultValue": {
          "type": [
            "string",
            "null"
          ],
          "description": "Table column default value computed"
        },
        "notNullFlag": {
          "type": "boolean",
          "description": "Table column not null flag"
        },
        "tableName": {
          "type": "string",
          "description": "Table name"
        }
      },
      "required": [
        "name",
        "description",
        "type",
        "defaultValue",
        "notNullFlag",
        "tableName"
      ]
    },
    "ddmForeignKey": {
      "type": "object",
      "description": "Type of the foreign key entity",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the table foreign key"
        },
        "targetTable": {
          "type": "string",
          "description": "Name of the foreign key target table"
        },
        "sourceTable": {
          "type": "string",
          "description": "Name of the foreign key source table"
        },
        "columnPairs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ddmForeignKey/$nestedDefs/columnPair"
          }
        }
      },
      "required": [
        "name",
        "targetTable",
        "sourceTable",
        "columnPairs"
      ],
      "$nestedDefs": {
        "columnPair": {
          "type": "object",
          "description": "Type of the foreign key column pair entity",
          "properties": {
            "sourceColumnName": {
              "type": "string",
              "description": "Name of source column in foreign key relation"
            },
            "targetColumnName": {
              "type": "string",
              "description": "Name of target column in foreign key relation"
            }
          },
          "required": [
            "sourceColumnName",
            "targetColumnName"
          ]
        }
      }
    },
    "ddmIndex": {
      "type": "object",
      "description": "Type of the index entity",
      "properties": {
        "name": {
          "type": "string",
          "description": "Table index name"
        },
        "tableName": {
          "type": "string",
          "description": "Table name"
        },
        "columns": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ddmIndex/$nestedDefs/column"
          }
        }
      },
      "required": [
        "name",
        "tableName",
        "columns"
      ],
      "$nestedDefs": {
        "column": {
          "type": "object",
          "description": "Type of the index column entity",
          "properties": {
            "name": {
              "type": "string",
              "description": "Name of the index column"
            },
            "sorting": {
              "type": "string",
              "description": "Index column sorting",
              "enum": [
                "ASC",
                "DESC",
                "NONE"
              ]
            }
          },
          "required": [
            "name",
            "sorting"
          ]
        }
      }
    }
  }
}

Table Document example

{
  "name": "application_type",
  "historyFlag": null,
  "objectReference": null,
  "description": "Довідник типів заяв",
  "columns": {
    "name": {
      "name": "name",
      "description": "Тип заяви",
      "type": "text",
      "defaultValue": null,
      "notNullFlag": true,
      "tableName": "application_type"
    },
    "application_type_id": {
      "name": "application_type_id",
      "description": "Ідентифікатор типів заяв",
      "type": "uuid",
      "defaultValue": "uuid_generate_v4()",
      "notNullFlag": true,
      "tableName": "application_type"
    },
    "constant_code": {
      "name": "constant_code",
      "description": "Символьна константа",
      "type": "text",
      "defaultValue": null,
      "notNullFlag": true,
      "tableName": "application_type"
    }
  },
  "foreignKeys": {},
  "primaryKey": {
    "name": "pk_application_type_id",
    "columns": [
      {
        "name": "application_type_id",
        "sorting": "ASC"
      }
    ],
    "tableName": "application_type"
  },
  "uniqueConstraints": {
    "application_type_name_key": {
      "name": "application_type_name_key",
      "columns": [
        {
          "name": "name",
          "sorting": "ASC"
        }
      ],
      "tableName": "application_type"
    }
  },
  "indices": {}
}

Role permissions JsonSchema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "$ref": "#/$defs/ddmRolePermission",
  "$defs": {
    "required": [
      "ddmRolePermissions"
    ],
    "ddmRolePermission": {
      "type": "object",
      "description": "Type of the role permission entity",
      "properties": {
        "permissionId": {
          "type": "integer",
          "description": "Id of the role permission"
        },
        "roleName": {
          "type": "string",
          "description": "Role name to which permission is granted"
        },
        "objectName": {
          "type": "string",
          "description": "Table name on which permission is granted"
        },
        "columnName": {
          "type": [
            "string",
            "null"
          ],
          "description": "Column name on which permission is granted. If null permission is granted on whole table"
        },
        "operation": {
          "type": "string",
          "description": "Operation that is granted to a role on an object",
          "enum": [
            "SELECT",
            "INSERT",
            "UPDATE",
            "DELETE"
          ]
        }
      },
      "required": [
        "permissionId",
        "roleName",
        "objectName",
        "columnName",
        "operation"
      ]
    }
  }
}

Role permissions document example

{
  "permissionId": 1,
  "roleName": "isAuthenticated",
  "objectName": "laboratory",
  "columnName": "edrpou",
  "operation": "SELECT"
}