Database Models

db.db

Instance of flask_sqlalchemy.SQLAlchemy that the models are registered to.

Processing Operations

class db.Operation(**kwargs)

flask_sqlalchemy.Model representing a processing operation

id

Database id (int)

tags

List of Tag objects associated with the operation

contacts

List of Contact objects associated with the operation

versions

List of OpVersion objects representing versions of the operation. Does not include drafts. Ordered by OpVersion.date_introduced.

draft

OpVersion object that represents the draft of a new version of the operation if there is one. None otherwise.

property current_version

Read-only view of the OpVersion that always refers to the most recent active version or the draft if no active version exists.

Cannot be used in queries.

class db.Tag(**kwargs)

flask_sqlalchemy.Model representing a tag for Operation objects

id

Database id (int)

label

Tag label displayed to the user

class db.Contact(**kwargs)

flask_sqlalchemy.Model representing a contact for Operation objects

id

Database id (int)

name

Display name of the contact. Could be a real name consisting of given and surname or a generic role name, must not be empty.

role

Display name of the contact’s role in the organisation. May be empty if no role is specified.

email

Contact’s email address. May be empty or a arbitrary string.

phone

Contact’s phone number. May be empty or a arbitrary string.

address

Contact’s office address. May be empty or a multi-line string.

class db.OpVersion(**kwargs)

flask_sqlalchemy.Model that represents versions of an db.Operation

id

Database id (int)

operation

Corresponding db.Operation

data_categories

List of OpVerCategory objects representing the proccessed data categories and affected subjects

date_introduced

datetime object representing the time when the version was activated or None if it is a draft

date_redeemed

datetime object representing the time when the version was redeemed or None if it is either active or a draft

title

Operation display name. Must not be empty.

description

Human-readable and short description. Must be a string but may be empty.

toms

Technical and organisational measures applied to ensure the protection of the subject’s data protection rights

reasons

Set of db.LegalReason enum members (see EncodedEnumSet)

external_controllers

Set of strings representing the names of external entities that are jointly responsible for the processing operation

The names must not contain commas (“,”), see EncodedTokenSet.

property subjects

Read-only view summarizing the subject of all data_categories as a set of str objects.

Cannot be used in queries.

property categories

Read-only view summarizing the name of all data_categories as a set of str objects.

Cannot be used in queries.

property accessors

Read-only view summarizing the accessors of all data_categories as a set of str objects.

Cannot be used in queries.

property recipients

Read-only view summarizing the recipients of all data_categories as a set of str objects.

Cannot be used in queries.

is_draft

True if the version is a draft, False if it is either currently active or redeemed.

is_redeemed

True if the version has been redeemed, False if it is either a draft or currently active.

is_active

True if the version is currently active, False if it is either a draft or has been redeemed.

class db.OpVerCategory(**kwargs)

flask_sqlalchemy.Model that represents a data category of a db.OpVersion object

id

Database id (int)

version

Corresponding OpVersion object

name

Data category name. Must not be empty. Should only name a single category.

subject
limit
is_special
accessors
recipients

Custom Column Types

class db.EncodedEnumSet(base_enum)

TypeDecorator to store set of Enum members in a single String column

Parameters

base_enum (Enum) – The enum whose members shall be stored

To work properly, columns must be defined using a MutableSet:

mycol = Column(MutableSet.as_mutable(EncodedEnumSet(MyEnum))

Values are encoded as a comma-separeted list of enum member values.

Assinging sets containing non-member items or adding such items will raise a ValueError exception. Equally, unknown values in the database will raise a ValueError exception upon accesss.

Note

When members of base_enum are added or removed, database migrations must be performed carefully to avoid incompatabilities. It is not recommended to remove members of the base_enum.

class db.EncodedTokenSet(*args, **kwargs)

TypeDecorator to store set of str objects in a single Text column

To work properly, columns must be defined using a MutableSet:

Column(MutableSet.as_mutable(EncodedTokenSet)

Values are encoded as a comma-separeted list of the set items. Therefore items must not include commas (“,”)!

Assinging sets containing invalid strings or adding such strings will raise a ValueError exception.