Skip to content

Commit

Permalink
Merge e3a3eff into 98b20bd
Browse files Browse the repository at this point in the history
  • Loading branch information
ppanero committed Oct 19, 2020
2 parents 98b20bd + e3a3eff commit 50d9405
Show file tree
Hide file tree
Showing 21 changed files with 431 additions and 421 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ recursive-include invenio_rdm_records *.json *.csv
recursive-include invenio_rdm_records *.po *.pot
recursive-include invenio_rdm_records *.png *.svg
recursive-include invenio_rdm_records *.html *.js *.less
recursive-include tests *.py *.csv
recursive-include tests *.py *.csv *.json
144 changes: 50 additions & 94 deletions invenio_rdm_records/records/jsonschemas/records/record-v1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
]
},

"language": {
"type": "string",
"minLength": 3,
"maxLength": 3
},

"longitude": {
"type": "number",
"minimum": -180,
Expand All @@ -77,24 +83,32 @@
"maximum": 90
},

"scheme": {
"description": "A scheme.",
"type": "string"
},

"identifier": {
"description": "An identifier.",
"type": "string"
},

"identifiers": {
"description": "Identifiers object (keys being scheme, value being the identifier).",
"type": "object",
"additionalProperties": {"$ref": "#/definitions/identifier"}
},

"internal-pid": {
"type": "object",
"description": "An internal persistent identifier object.",
"additionalProperties": false,
"required": ["pk", "pid_type", "obj_type", "status"],
"required": ["pk", "status"],
"properties": {
"pk": {
"description": "Primary key of the PID object.",
"type": "integer"
},
"pid_type": {
"description": "The persistent identifier type (e.g. doi or recid).",
"type": "string"
},
"obj_type": {
"description": "The type of the assigned object (e.g. rec).",
"type": "string"
},
"status": {
"description": "The status of the PID (from Invenio-PIDStore).",
"type": "string",
Expand All @@ -113,12 +127,9 @@
"type": "object",
"description": "An external persistent identifier object.",
"additionalProperties": false,
"required": ["id", "provider"],
"required": ["identifier", "provider"],
"properties": {
"identifier": {
"description": "The value of the persistent identifier.",
"type": "string"
},
"identifier": {"$ref": "#/definitions/identifier"},
"provider": {
"description": "The provider of the persistent identifier.",
"type": "string"
Expand All @@ -130,16 +141,6 @@
}
},

"identifiers": {
"description": "Identifiers object (keys being scheme, value being the identifier).",
"type": "object",
"additionalProperties": {"$ref": "#/definitions/identifier"}
},

"identifier": {
"description": "An identifier.",
"type": "string",
},

"resource_type": {
"type": "object",
Expand Down Expand Up @@ -211,10 +212,7 @@
"description": "TODO - Bucket id - what about third party storage systems?",
"type": "string"
},
"file_id": {
"description": "TODO - Identifier of the file. - same as for bucket",
"type": "string"
}
"file_id": {"$ref": "#/definitions/identifier"}
}
},

Expand Down Expand Up @@ -303,6 +301,7 @@
"type": "string"
},
"type": {"$ref": "#/definitions/titleType"},
"lang": {"ref": "#/definitions/language"}
},
"required": ["title"]
}
Expand All @@ -324,8 +323,8 @@
"additionalProperties": false,
"properties": {
"subject": {"type": "string"},
"identifier": {"type": "string"},
"scheme": {"type": "string"}
"identifier": {"$ref": "#/definitions/identifier"},
"scheme": {"$ref": "#/definitions/scheme"}
},
"required": ["subject"]
}
Expand Down Expand Up @@ -373,7 +372,7 @@
"languages": {
"description": "The primary languages of the resource. ISO 639-3 language code.",
"type": "array",
"items": {"$ref": "#/definitions/lang"}
"items": {"$ref": "#/definitions/language"}
},

"identifiers": {
Expand All @@ -383,8 +382,8 @@
"type": "object",
"additionalProperties": false,
"properties": {
"identifier": {"type": "string"},
"scheme": {"type": "string"}
"identifier": {"$ref": "#/definitions/identifier"},
"scheme": {"$ref": "#/definitions/scheme"}
}
},
"uniqueItems": true
Expand All @@ -397,8 +396,8 @@
"type": "object",
"additionalProperties": false,
"properties": {
"identifier": {"type": "string"},
"scheme": {"type": "string"},
"identifier": {"$ref": "#/definitions/identifier"},
"scheme": {"$ref": "#/definitions/scheme"},
"relation": {"$ref": "#/definitions/relationType"},
"resource_type": {"$ref": "#/definitions/resource_type"}
}
Expand Down Expand Up @@ -435,14 +434,8 @@
"description": "The license name or license itself. Free text.",
"type": "string"
},
"identifier": {
"description": "An identifier for the license.",
"type": "string"
},
"scheme": {
"description": "An scheme for the identifier (e.g. spdx)",
"type": "string"
},
"identifier": {"$ref": "#/definitions/identifier"},
"scheme": {"$ref": "#/definitions/scheme"},
"url": {
"type": "string",
"format": "uri"
Expand All @@ -467,6 +460,7 @@
"type": "string"
},
"type": {"$ref": "#/definitions/descriptionType"},
"lang": {"ref": "#/definitions/language"}
}
}
},
Expand Down Expand Up @@ -509,8 +503,8 @@
"additionalProperties": false,
"properties": {
"name": {"type": "string"},
"identifier": {"type": "string"},
"scheme": {"type": "string"}
"identifier": {"$ref": "#/definitions/identifier"},
"scheme": {"$ref": "#/definitions/scheme"}
}
},
"award": {
Expand All @@ -519,8 +513,8 @@
"properties": {
"title": {"type": "string"},
"number": {"type": "string"},
"identifier": {"type": "string"},
"scheme": {"type": "string"}
"identifier": {"$ref": "#/definitions/identifier"},
"scheme": {"$ref": "#/definitions/scheme"}
}
}
}
Expand All @@ -538,34 +532,17 @@
"type": "string",
"description": "A reference string."
},
"identifier": {"type": "string"},
"scheme": {"type": "string"}
"identifier": {"$ref": "#/definitions/identifier"},
"scheme": {"$ref": "#/definitions/scheme"}
}
}
}
}
},

"metaext": {
"ext": {
"type": "object",
"description": "Configured additional metadata",
"propertyNames": {
"pattern": "^[A-Za-z][A-Za-z0-9_]*:[A-Za-z0-9_]+$"
},
"additionalProperties": {
"anyOf": [
{
"type": "array",
"items": {
"type": ["boolean", "number", "integer", "string"]
}
},
{"type": "boolean"},
{"type": "number"},
{"type": "integer"},
{"type": "string"}
]
}
"description": "Configured additional metadata"
},

"tombstone": {
Expand Down Expand Up @@ -596,8 +573,7 @@
"additionalProperties": false,
"properties": {
"created_by": {"$ref": "#/definitions/agent"},
"on_behalf_of": {"$ref": "#/definitions/agent"},
"contact": {"$ref": "#/definitions/agent"}
"on_behalf_of": {"$ref": "#/definitions/agent"}
}
},

Expand All @@ -617,11 +593,6 @@
"type": "boolean"
},

"contact": {
"description": "Enable the contact feature to contact owners.",
"type": "boolean"
},

"owned_by": {
"description": "List of user IDs that are owners of the record.",
"type": "array",
Expand Down Expand Up @@ -688,25 +659,10 @@
}
},

"system": {
"type": "object",
"description": "System information.",
"properties": {
"notes": {
"type": "array",
"items":{
"type": "object",
"properties": {
"created_by": {"$ref": "#/definitions/agent-user"},
"note": {"type": "string"},
"timestamp": {
"description": "ISO8601 formatted date time stamp.",
"type": "string",
"format": "date-time"
}
}
}
}
"notes": {
"type": "array",
"items":{
"type": "string"
}
}
}
Expand Down
33 changes: 10 additions & 23 deletions invenio_rdm_records/services/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@
from invenio_drafts_resources.services.records.schema import RecordSchema
from marshmallow import EXCLUDE, INCLUDE, Schema, fields, missing

from .access import AccessSchemaV1
from .communities import CommunitiesSchemaV1
from .files import FilesSchemaV1
from .metadata import MetadataSchemaV1
from .pids import PIDSSchemaV1
from .relations import RelationsSchemaV1
from .stats import StatsSchemaV1
from .access import AccessSchema
from .metadata import MetadataSchema
from .pids import PIDSchema


# NOTE: Use this one for system fields only
Expand All @@ -35,7 +31,7 @@ class NestedAttribute(fields.Nested, AttributeAccessorFieldMixin):
"""Nested object attribute field."""


class RDMRecordSchemaV1(RecordSchema):
class RDMRecordSchema(RecordSchema):
"""Record schema."""

class Meta:
Expand All @@ -51,24 +47,15 @@ class Meta:
'files': 'read_files',
}

# schema_version = fields.Interger(dump_only=True)
# revision = fields.Integer(attribute='revision_id', dump_only=True)
# id = fields.Str(attribute='recid', dump_only=True)
# concept_id = fields.Str(attribute='conceptrecid', dump_only=True)
id = fields.Str()
conceptid = fields.Str()
metadata = NestedAttribute(MetadataSchema)
access = NestedAttribute(AccessSchema)
pids = fields.List(NestedAttribute(PIDSchema))
created = fields.Str(dump_only=True)
updated = fields.Str(dump_only=True)

# status = fields.Str(dump_only=True)

metadata = NestedAttribute(MetadataSchemaV1)
access = NestedAttribute(AccessSchemaV1)
# files = NestedAttribute(FilesSchemaV1, dump_only=True)
# communities = NestedAttribute(CommunitiesSchemaV1)
# pids = NestedAttribute(PIDSSchemaV1)
# stats = NestedAttribute(StatsSchemaV1, dump_only=True)
# relations = NestedAttribute(RelationsSchemaV1, dump_only=True)


__all__ = (
'RDMRecordSchemaV1',
'RDMRecordSchema',
)
25 changes: 17 additions & 8 deletions invenio_rdm_records/services/schemas/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,33 @@
"""RDM record schemas."""

import arrow
from invenio_records_rest.schemas.fields import DateString, SanitizedUnicode
from marshmallow import Schema, ValidationError, fields, validate, validates, \
validates_schema
from marshmallow_utils.fields import EDTFDateString, SanitizedUnicode

from .utils import validate_entry


class AccessSchemaV1(Schema):
class AccessConditionSchema(Schema):
"""Access condition schema.
Conditions under which access to files are granted.
"""

condition = fields.String()
default_link_validity = fields.Integer()


class AccessSchema(Schema):
"""Access schema."""

metadata_restricted = fields.Bool(required=True)
files_restricted = fields.Bool(required=True)
owners = fields.List(
metadata = fields.Bool(required=True)
files = fields.Bool(required=True)
owned_by = fields.List(
fields.Integer, validate=validate.Length(min=1), required=True)
created_by = fields.Integer(required=True)
embargo_date = DateString()
contact = SanitizedUnicode(data_key="contact", attribute="contact")
access_right = SanitizedUnicode(required=True)
embargo_date = EDTFDateString()
access_condition = fields.Nested(AccessConditionSchema)

@validates('embargo_date')
def validate_embargo_date(self, value):
Expand Down

0 comments on commit 50d9405

Please sign in to comment.