Skip to content

Commit

Permalink
Merge pull request #123 from c3g/array-to-jsonfield
Browse files Browse the repository at this point in the history
ArrayField to JSONField
  • Loading branch information
zxenia committed May 19, 2020
2 parents 5cf5495 + fa7acf3 commit 73abf42
Show file tree
Hide file tree
Showing 7 changed files with 300 additions and 62 deletions.
69 changes: 69 additions & 0 deletions chord_metadata_service/chord/migrations/0011_auto_20200515_1657.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Generated by Django 2.2.12 on 2020-05-15 20:57

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('chord', '0010_auto_20200309_1945'),
]

operations = [
migrations.RemoveField(
model_name='dataset',
name='acknowledges',
),
migrations.RemoveField(
model_name='dataset',
name='alternate_identifiers',
),
migrations.RemoveField(
model_name='dataset',
name='citations',
),
migrations.RemoveField(
model_name='dataset',
name='creators',
),
migrations.RemoveField(
model_name='dataset',
name='dates',
),
migrations.RemoveField(
model_name='dataset',
name='dimensions',
),
migrations.RemoveField(
model_name='dataset',
name='distributions',
),
migrations.RemoveField(
model_name='dataset',
name='keywords',
),
migrations.RemoveField(
model_name='dataset',
name='licenses',
),
migrations.RemoveField(
model_name='dataset',
name='linked_field_sets',
),
migrations.RemoveField(
model_name='dataset',
name='primary_publications',
),
migrations.RemoveField(
model_name='dataset',
name='related_identifiers',
),
migrations.RemoveField(
model_name='dataset',
name='spatial_coverage',
),
migrations.RemoveField(
model_name='dataset',
name='types',
),
]
84 changes: 84 additions & 0 deletions chord_metadata_service/chord/migrations/0012_auto_20200515_1714.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Generated by Django 2.2.12 on 2020-05-15 21:14

import django.contrib.postgres.fields.jsonb
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('chord', '0011_auto_20200515_1657'),
]

operations = [
migrations.AddField(
model_name='dataset',
name='acknowledges',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The grant(s) which funded and supported the work reported by the dataset.'),
),
migrations.AddField(
model_name='dataset',
name='alternate_identifiers',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Alternate identifiers for the dataset.'),
),
migrations.AddField(
model_name='dataset',
name='citations',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The publication(s) that cite this dataset.'),
),
migrations.AddField(
model_name='dataset',
name='creators',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The person(s) or organization(s) which contributed to the creation of the dataset.'),
),
migrations.AddField(
model_name='dataset',
name='dates',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Relevant dates for the datasets, a date must be added, e.g. creation date or last modification date should be added.'),
),
migrations.AddField(
model_name='dataset',
name='dimensions',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The different dimensions (granular components) making up a dataset.'),
),
migrations.AddField(
model_name='dataset',
name='distributions',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The distribution(s) by which datasets are made available (for example: mySQL dump).'),
),
migrations.AddField(
model_name='dataset',
name='keywords',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Tags associated with the dataset, which will help in its discovery.'),
),
migrations.AddField(
model_name='dataset',
name='licenses',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The terms of use of the dataset.'),
),
migrations.AddField(
model_name='dataset',
name='linked_field_sets',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Data type fields which are linked together.'),
),
migrations.AddField(
model_name='dataset',
name='primary_publications',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The primary publication(s) associated with the dataset, usually describing how the dataset was produced.'),
),
migrations.AddField(
model_name='dataset',
name='related_identifiers',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='Related identifiers for the dataset.'),
),
migrations.AddField(
model_name='dataset',
name='spatial_coverage',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='The geographical extension and span covered by the dataset and its measured dimensions/variables.'),
),
migrations.AddField(
model_name='dataset',
name='types',
field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=list, help_text='A term, ideally from a controlled terminology, identifying the dataset type or nature of the data, placing it in a typology.'),
),
]
75 changes: 33 additions & 42 deletions chord_metadata_service/chord/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import uuid

from django.contrib.postgres.fields import JSONField, ArrayField
from django.contrib.postgres.fields import JSONField
from django.db import models
from django.utils import timezone

Expand Down Expand Up @@ -51,9 +51,7 @@ class Dataset(models.Model):
)

data_use = JSONField()

linked_field_sets = ArrayField(JSONField(), blank=True, default=list,
help_text="Data type fields which are linked together.")
linked_field_sets = JSONField(blank=True, default=list, help_text="Data type fields which are linked together.")

@property
def n_of_tables(self):
Expand All @@ -62,21 +60,17 @@ def n_of_tables(self):

# --------------------------- DATS model fields ---------------------------

alternate_identifiers = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="Alternate identifiers for the dataset.")
related_identifiers = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="Related identifiers for the dataset.")
dates = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="Relevant dates for the datasets, a date must be added, e.g. creation date or last "
"modification date should be added.")
alternate_identifiers = JSONField(blank=True, default=list, help_text="Alternate identifiers for the dataset.")
related_identifiers = JSONField(blank=True, default=list, help_text="Related identifiers for the dataset.")
dates = JSONField(blank=True, default=list, help_text="Relevant dates for the datasets, a date must be added, e.g. "
"creation date or last modification date should be added.")
# TODO: Can this be auto-synthesized? (Specified in settings)
stored_in = JSONField(blank=True, null=True, help_text="The data repository hosting the dataset.")
spatial_coverage = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="The geographical extension and span covered by the dataset and its "
"measured dimensions/variables.")
types = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="A term, ideally from a controlled terminology, identifying the dataset type or "
"nature of the data, placing it in a typology.")
spatial_coverage = JSONField(blank=True, default=list, help_text="The geographical extension and span covered "
"by the dataset and its measured dimensions/variables.")
types = JSONField(blank=True, default=list, help_text="A term, ideally from a controlled terminology, identifying "
"the dataset type or nature of the data, placing it in a "
"typology.")
# TODO: Can this be derived from / combined with DUO stuff?
availability = models.CharField(max_length=200, blank=True,
help_text="A qualifier indicating the different types of availability for a "
Expand All @@ -91,40 +85,37 @@ def n_of_tables(self):
privacy = models.CharField(max_length=200, blank=True,
help_text="A qualifier to describe the data protection applied to the dataset. This is "
"relevant for clinical data.")
distributions = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="The distribution(s) by which datasets are made available (for example: "
"mySQL dump).")
dimensions = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="The different dimensions (granular components) making up a dataset.")
primary_publications = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="The primary publication(s) associated with the dataset, usually "
"describing how the dataset was produced.")
citations = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="The publication(s) that cite this dataset.")
distributions = JSONField(blank=True, default=list, help_text="The distribution(s) by which datasets are made "
"available (for example: mySQL dump).")
dimensions = JSONField(blank=True, default=list, help_text="The different dimensions (granular components) "
"making up a dataset.")
primary_publications = JSONField(blank=True, default=list, help_text="The primary publication(s) associated with "
"the dataset, usually describing how the "
"dataset was produced.")
citations = JSONField(blank=True, default=list, help_text="The publication(s) that cite this dataset.")
citation_count = models.IntegerField(blank=True, null=True,
help_text="The number of publications that cite this dataset (enumerated in "
"the citations property).")
produced_by = JSONField(blank=True, null=True, help_text="A study process which generated a given dataset, if any.")
creators = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="The person(s) or organization(s) which contributed to the creation of the "
"dataset.")
creators = JSONField(blank=True, default=list, help_text="The person(s) or organization(s) which contributed to "
"the creation of the dataset.")
# TODO: How to reconcile this and data_use?
licenses = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="The terms of use of the dataset.")
licenses = JSONField(blank=True, default=list, help_text="The terms of use of the dataset.")
# is_about this field will be calculated based on sample field
# in tableOwnership
has_part = models.ManyToManyField("self", blank=True,
help_text="A Dataset that is a subset of this Dataset; Datasets declaring the "
"'hasPart' relationship are considered a collection of Datasets, the "
"aggregation criteria could be included in the 'description' field.")
acknowledges = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="The grant(s) which funded and supported the work reported by the dataset.")
keywords = ArrayField(JSONField(null=True, blank=True), blank=True, null=True,
help_text="Tags associated with the dataset, which will help in its discovery.")
has_part = models.ManyToManyField("self", blank=True, help_text="A Dataset that is a subset of this Dataset; "
"Datasets declaring the 'hasPart' relationship are "
"considered a collection of Datasets, the "
"aggregation criteria could be included in "
"the 'description' field.")
acknowledges = JSONField(blank=True, default=list, help_text="The grant(s) which funded and supported the work "
"reported by the dataset.")
keywords = JSONField(blank=True, default=list, help_text="Tags associated with the dataset, which will help in "
"its discovery.")
version = models.CharField(max_length=200, blank=True, default=version_default,
help_text="A release point for the dataset when applicable.")
extra_properties = JSONField(blank=True, null=True,
help_text="Extra properties that do not fit in the previous specified attributes.")
extra_properties = JSONField(blank=True, null=True, help_text="Extra properties that do not fit in the previous "
"specified attributes.")

# -------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 2.2.12 on 2020-05-15 20:13

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('phenopackets', '0008_auto_20200514_1541'),
]

operations = [
migrations.RemoveField(
model_name='biosample',
name='diagnostic_markers',
),
migrations.RemoveField(
model_name='disease',
name='disease_stage',
),
migrations.RemoveField(
model_name='disease',
name='tnm_finding',
),
migrations.RemoveField(
model_name='metadata',
name='external_references',
),
migrations.RemoveField(
model_name='metadata',
name='updates',
),
migrations.RemoveField(
model_name='phenotypicfeature',
name='modifier',
),
]

0 comments on commit 73abf42

Please sign in to comment.