Aller au contenu

Data models

Ce contenu n’est pas encore disponible dans votre langue.

The models of the API are in api/madbot_api/core/models.py. Most use a UUID primary key and carry audit fields: created_by, last_edited_by, created_time and last_edited_time. The concepts page explains what each object means for the people who use madbot.

The full list of models is kept for developers and agents in docs/data-models-api.md.

Workspace
├── WorkspaceMember
├── Connection ──── Credential (in Vault), SharedConnectionParam
│ └── Data (tree) ──── DataAccessRight
└── Node (tree) ──── NodeMember
├── DataLink ──── Data
├── Sample ──── SampleBoundData ──── Data
└── Metadata
Submission ──── Connection
├── SubmissionMember, SubmissionSettings
├── SubmissionData ──── Data
├── SubmissionMetadataObject ──── SubmissionMetadata
├── SubmissionAssociation ──── SubmissionAssociationObject
└── ExternalIdentifier
ModelRole
WorkspaceThe container of a project. Every other object belongs to a workspace.
WorkspaceMemberA user’s membership of a workspace, with their role.
NodeAn element of the project tree. A tree node (django-tree-queries): parent, children, subtree.
NodeMemberA user’s membership of a node, with their role. A member of a node is also a member of its ancestors.
ModelRole
ConnectionA connection to a source or a repository, through a plugin, with its settings.
CredentialThe credentials of a user for a connection. The secrets themselves are in Vault.
DataA file or a folder of a source, seen through a connection. A tree node, like Node. Holds its size, media type and extension, and an enrichment status (see below).
DataAccessRightWhether a user can reach a data in its source.
DataLinkThe link between a node and a data.
DataAssociationA group of data that belong together, which can carry metadata.
SampleAn object the project studies, attached to a node. Its alias is unique among the samples of the node (constraint unique_sample_alias_per_node).
SampleBoundDataThe link between a sample and a data.

Data carries a status, in the vocabulary of Node. A data created by a batch of datalinks is in progress until the enrich_datalinks task has read it from its source, then active, or failed with an enrichment_error ({code, message}). enrichment_task_id is the last task that enriched it. The status belongs to the data, not to the datalink: what is read from the source (attributes, metadata, associations) is shared by every datalink of the data. A data that is not active can only be read and deleted.

ModelRole
RawSchemaA JSON schema: MadbotRawSchema for madbot’s own fields, PluginRawSchema for the fields of a plugin.
MetadataFieldThe definition of a field: MadbotMetadataField or PluginMetadataField.
MetadataMappingThe correspondence between fields of different sources.
MetadataA value of a field, on a node, a sample, a data or a data association. Validated against the JSON schema of its field.

Metadata are inherited down the node tree, and from samples to their data.

A Submission sends data and metadata to a repository through a Connection. Its status follows the steps of the submission:

StatusMeaning
draftBeing prepared.
generating metadataThe Celery task async_create_metadata_objects builds the metadata objects.
readyReady to submit.
submission in progressThe Celery task async_submit sends it.
submittedAccepted by the repository.
update availableDeposited, and an update can be sent to the repository.

A submission records its errors, and the last task that failed, to help diagnose it.

ModelRole
SubmissionMemberA user’s membership of a submission.
SubmissionSettingsThe settings of the submission plugin.
SubmissionDataA data included in the submission.
SubmissionMetadataObjectA metadata object of the target repository: a study, a sample…
SubmissionMetadata, SubmissionMetadataValueThe metadata of the submission and their values.
SubmissionAssociation, SubmissionAssociationObjectAssociations of objects inside the submission.
ExternalIdentifierAn identifier given by the repository after the deposit.
ModelRole
MadbotUserThe user. Extends Django’s user with an approval workflow and a profile (ORCID, ROR).
ApplicationUserParam, UserNotificationSettingsThe preferences of a user.
PersonalAccessTokenA token to call the API from a script.
ImpersonateIntent, ImpersonateSessionThe impersonation of a user by an administrator, and its audit trail.
AlertBannerA banner shown to the users, served by /api/alerts.

django-simple-history records the changes of the main models. When you add a field to a model that has a history, check whether the history should exclude it.