From 0c6fc51dcff247e6a4ed00e009c5effc0da81224 Mon Sep 17 00:00:00 2001 From: TobiasNx Date: Thu, 25 Feb 2021 11:56:55 +0100 Subject: [PATCH 1/3] First draft for project-Schema and new subSchemas (#440) --- examples/projects/valid/metafacture-fix.json | 3 +- .../valid/metafacture-playground.json | 3 +- schemas/develops.json | 56 ++++++++++++++++ schemas/funding.json | 44 ++++++++++++ schemas/project.json | 67 +++++++++++++++++++ test.sh | 2 + 6 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 schemas/develops.json create mode 100644 schemas/funding.json create mode 100644 schemas/project.json diff --git a/examples/projects/valid/metafacture-fix.json b/examples/projects/valid/metafacture-fix.json index 6e51fd49..be131527 100644 --- a/examples/projects/valid/metafacture-fix.json +++ b/examples/projects/valid/metafacture-fix.json @@ -7,7 +7,8 @@ "en": "Metafacture-Fix" }, "description": { - "en": "Implementation of the Fix language for Metafacture as an alternative to configuring data transformations with Metamorph" + "en": "Implementation of the Fix language for Metafacture as an alternative to configuring data transformations with Metamorph", + "de": "Das Projekt entwickelt und implementiert FIX als Metafacture Sprache. Diese soll als Alternative zu Metamorph für Datentransformation eingesetzt werden." }, "url": "https://github.com/metafacture/metafacture-fix" } \ No newline at end of file diff --git a/examples/projects/valid/metafacture-playground.json b/examples/projects/valid/metafacture-playground.json index 3a49459f..7ef63a43 100644 --- a/examples/projects/valid/metafacture-playground.json +++ b/examples/projects/valid/metafacture-playground.json @@ -7,7 +7,8 @@ "en": "Metafacture Playground" }, "description": { - "en": "This projects aims to provide a web application to play around with Metafactures languages Fix and Flux." + "en": "This projects aims to provide a web application to play around with Metafactures languages Fix and Flux.", + "de": "Dieses Projekt entwickelt eine Web-Applikation, mit der man interaktiv die Metafacture-Sprachen Fix und Flux austesten kann." }, "url": "https://github.com/metafacture/metafacture-playground" } \ No newline at end of file diff --git a/schemas/develops.json b/schemas/develops.json new file mode 100644 index 00000000..1d9acc20 --- /dev/null +++ b/schemas/develops.json @@ -0,0 +1,56 @@ +{ + "$id": "resource:/product.json", + "title": "product", + "description": "Schema to describe a product at lobid.", + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "Role" + }, + "roleName": { + "allOf": [ + { + "$ref": "localizedString.json" + }, + { + "enum": [ + "NewProduct", + "Enhancement for" + ] + } + ] + }, + "product": { + "type": "object", + "properties": { + "id": { + "$ref": "resource:/id.json" + }, + "name": { + "$ref": "resource:/name.json" + } + }, + "anyOf": [ + { + "required": [ + "id" + ] + }, + { + "required": [ + "name" + ] + } + ] + } + }, + "required": [ + "type", + "roleName", + "product" + ] + } +} \ No newline at end of file diff --git a/schemas/funding.json b/schemas/funding.json new file mode 100644 index 00000000..4848c774 --- /dev/null +++ b/schemas/funding.json @@ -0,0 +1,44 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "resource:/membership.json", + "title": "Funding", + "description": "Schema to describe a funder relation", + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "Role" + }, + "startDate": { + "$ref": "resource:/startDate.json" + }, + "endDate": { + "$ref": "resource:/endDate.json" + }, + "roleName": { + "$ref": "resource:/localizedString.json" + }, + "funder": { + "type": "object", + "properties": { + "id": { + "$ref": "resource:/id.json" + }, + "name": { + "$ref": "resource:/name.json" + } + }, + "required": [ + "id" + ] + } + }, + "required": [ + "type", + "roleName", + "member" + ] + } +} \ No newline at end of file diff --git a/schemas/project.json b/schemas/project.json new file mode 100644 index 00000000..0282ae03 --- /dev/null +++ b/schemas/project.json @@ -0,0 +1,67 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "resource:/project.json", + "title": "Project", + "description": "Schema to describe a project at lobid.", + "type": "object", + "properties": { + "id": { + "$ref": "resource:/id.json" + }, + "type": { + "type": "array", + "items": { + "type": "string", + "const": "Project" + } + }, + "alternateName": { + "$ref": "resource:/alternateName.json" + }, + "description": { + "$ref": "resource:/description.json" + }, + "name": { + "$ref": "resource:/name.json" + }, + "image": { + "$ref": "resource:/image.json" + }, + "starteDate": { + "$ref": "resource:/startDate.json" + }, + "endeDate": { + "$ref": "resource:/startDate.json" + }, + "funding": { + "$ref": "resource:/funding.json" + }, + "develops": { + "$ref": "resource:/developse.json" + }, + "projectTeam": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "$ref": "resource:/id.json" + }, + "type": { + "type": "string", + "const": "Organization" + } + }, + "required": [ + "id" + ] + } + } + }, + "required": [ + "id", + "name", + "type", + "description" + ] +} \ No newline at end of file diff --git a/test.sh b/test.sh index 35c20bae..93bd193e 100644 --- a/test.sh +++ b/test.sh @@ -8,6 +8,8 @@ ajv test -s schemas/product.json -r "schemas/*.json" -d "examples/product/valid/ ajv test -s schemas/product.json -r "schemas/*.json" -d "examples/product/invalid/*.json" --invalid ajv test -s schemas/group.json -r "schemas/*.json" -d "examples/group/valid/*.json" --valid ajv test -s schemas/group.json -r "schemas/*.json" -d "examples/group/invalid/*.json" --invalid +ajv test -s schemas/project.json -r "schemas/*.json" -d "examples/group/valid/*.json" --valid +ajv test -s schemas/project.json -r "schemas/*.json" -d "examples/group/invalid/*.json" --invalid if [ $? -eq 0 ] then From 49cb0ac889cd8c1e269b6fbd1351543edc77c817 Mon Sep 17 00:00:00 2001 From: Adrian Pohl Date: Thu, 25 Feb 2021 13:33:56 +0100 Subject: [PATCH 2/3] Update schema references, test files & test script ...so that tests pass. ref #440 --- examples/{projects => project}/valid/alma2lobid.json | 4 +++- .../{projects => project}/valid/lrmi-profile.json | 4 +++- .../{projects => project}/valid/metafacture-fix.json | 4 +++- .../valid/metafacture-playground.json | 4 +++- examples/{projects => project}/valid/oersi.json | 11 ++++++----- examples/{projects => project}/valid/rpb.json | 4 +++- schemas/develops.json | 2 +- schemas/funding.json | 2 +- schemas/project.json | 2 +- test.sh | 4 ++-- 10 files changed, 26 insertions(+), 15 deletions(-) rename examples/{projects => project}/valid/alma2lobid.json (93%) rename examples/{projects => project}/valid/lrmi-profile.json (94%) rename examples/{projects => project}/valid/metafacture-fix.json (94%) rename examples/{projects => project}/valid/metafacture-playground.json (94%) rename examples/{projects => project}/valid/oersi.json (83%) rename examples/{projects => project}/valid/rpb.json (94%) diff --git a/examples/projects/valid/alma2lobid.json b/examples/project/valid/alma2lobid.json similarity index 93% rename from examples/projects/valid/alma2lobid.json rename to examples/project/valid/alma2lobid.json index 3fbdbfb0..32a6c875 100644 --- a/examples/projects/valid/alma2lobid.json +++ b/examples/project/valid/alma2lobid.json @@ -1,7 +1,9 @@ { "@context": "https://schema.org/", "id": "https://github.com/hbz/lobid-resources/milestone/1", - "type": "Project", + "type": [ + "Project" + ], "name": { "de": "lobid/Alma-Migration", "en": "lobid/Alma Migration" diff --git a/examples/projects/valid/lrmi-profile.json b/examples/project/valid/lrmi-profile.json similarity index 94% rename from examples/projects/valid/lrmi-profile.json rename to examples/project/valid/lrmi-profile.json index a71487df..069d2357 100644 --- a/examples/projects/valid/lrmi-profile.json +++ b/examples/project/valid/lrmi-profile.json @@ -1,7 +1,9 @@ { "@context": "https://schema.org/", "id": "https://github.com/dini-ag-kim/lrmi-profile", - "type": "Project", + "type": [ + "Project" + ], "name": { "de": "LRMI-Metadatenprofil", "en": "LRMI Metadata Profile" diff --git a/examples/projects/valid/metafacture-fix.json b/examples/project/valid/metafacture-fix.json similarity index 94% rename from examples/projects/valid/metafacture-fix.json rename to examples/project/valid/metafacture-fix.json index be131527..9f8ebe01 100644 --- a/examples/projects/valid/metafacture-fix.json +++ b/examples/project/valid/metafacture-fix.json @@ -1,7 +1,9 @@ { "@context": "https://schema.org/", "id": "https://github.com/metafacture/metafacture-fix", - "type": "Project", + "type": [ + "Project" + ], "name": { "de": "Metafacture-Fix", "en": "Metafacture-Fix" diff --git a/examples/projects/valid/metafacture-playground.json b/examples/project/valid/metafacture-playground.json similarity index 94% rename from examples/projects/valid/metafacture-playground.json rename to examples/project/valid/metafacture-playground.json index 7ef63a43..77c82a92 100644 --- a/examples/projects/valid/metafacture-playground.json +++ b/examples/project/valid/metafacture-playground.json @@ -1,7 +1,9 @@ { "@context": "https://schema.org/", "id": "https://github.com/metafacture/metafacture-playground", - "type": "Project", + "type": [ + "Project" + ], "name": { "de": "Metafacture Playground", "en": "Metafacture Playground" diff --git a/examples/projects/valid/oersi.json b/examples/project/valid/oersi.json similarity index 83% rename from examples/projects/valid/oersi.json rename to examples/project/valid/oersi.json index f79a74bc..be6083e7 100644 --- a/examples/projects/valid/oersi.json +++ b/examples/project/valid/oersi.json @@ -1,15 +1,16 @@ { "@context": "https://schema.org/", "id": "https://oersi.de", - "type": "Project", + "type": [ + "Project" + ], "name": { "de": "OER Search Index", "en": "OER Search Index" }, - "alternateName": { - "de": "OERSI", - "en": "OERSI" - }, + "alternateName": [ + "OERSI" + ], "description": { "de": "Ein gemeinsames Projekt der TIB Hannover und des hbz zum Aufbau eines offenen Suchindex für Bildungsressourcen", "en": "Common project by TIB Hannover and hbz to create an open search index for educational resources" diff --git a/examples/projects/valid/rpb.json b/examples/project/valid/rpb.json similarity index 94% rename from examples/projects/valid/rpb.json rename to examples/project/valid/rpb.json index d7a60fe9..e7df37ac 100644 --- a/examples/projects/valid/rpb.json +++ b/examples/project/valid/rpb.json @@ -1,7 +1,9 @@ { "@context": "https://schema.org/", "id": "https://github.com/hbz/rpb", - "type": "Project", + "type": [ + "Project" + ], "name": { "de": "Rheinland-Pfälzische Bibliographie", "en": "Bibliography of Rhineland-Platinate" diff --git a/schemas/develops.json b/schemas/develops.json index 1d9acc20..e6460bb7 100644 --- a/schemas/develops.json +++ b/schemas/develops.json @@ -1,5 +1,5 @@ { - "$id": "resource:/product.json", + "$id": "resource:/develops.json", "title": "product", "description": "Schema to describe a product at lobid.", "type": "array", diff --git a/schemas/funding.json b/schemas/funding.json index 4848c774..2870e36f 100644 --- a/schemas/funding.json +++ b/schemas/funding.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "resource:/membership.json", + "$id": "resource:/funding.json", "title": "Funding", "description": "Schema to describe a funder relation", "type": "array", diff --git a/schemas/project.json b/schemas/project.json index 0282ae03..a7bb1dbb 100644 --- a/schemas/project.json +++ b/schemas/project.json @@ -37,7 +37,7 @@ "$ref": "resource:/funding.json" }, "develops": { - "$ref": "resource:/developse.json" + "$ref": "resource:/develops.json" }, "projectTeam": { "type": "array", diff --git a/test.sh b/test.sh index 93bd193e..9e7eadaf 100644 --- a/test.sh +++ b/test.sh @@ -8,8 +8,8 @@ ajv test -s schemas/product.json -r "schemas/*.json" -d "examples/product/valid/ ajv test -s schemas/product.json -r "schemas/*.json" -d "examples/product/invalid/*.json" --invalid ajv test -s schemas/group.json -r "schemas/*.json" -d "examples/group/valid/*.json" --valid ajv test -s schemas/group.json -r "schemas/*.json" -d "examples/group/invalid/*.json" --invalid -ajv test -s schemas/project.json -r "schemas/*.json" -d "examples/group/valid/*.json" --valid -ajv test -s schemas/project.json -r "schemas/*.json" -d "examples/group/invalid/*.json" --invalid +ajv test -s schemas/project.json -r "schemas/*.json" -d "examples/project/valid/*.json" --valid +ajv test -s schemas/project.json -r "schemas/*.json" -d "examples/project/invalid/*.json" --invalid if [ $? -eq 0 ] then From ea0f8d9c0fd3fb98d2d9a5f80cd35ca5a49eb1bc Mon Sep 17 00:00:00 2001 From: Adrian Pohl Date: Thu, 25 Feb 2021 16:24:05 +0100 Subject: [PATCH 3/3] Use "enhances" instead of "develops", update examples ...plus some smaller changes and fixed typos. ref #440 --- examples/project/valid/alma2lobid.json | 7 ++- examples/project/valid/metafacture-fix.json | 7 ++- .../project/valid/metafacture-playground.json | 7 ++- examples/project/valid/oersi.json | 5 +- schemas/develops.json | 56 ------------------- schemas/enhances.json | 20 +++++++ schemas/funding.json | 44 --------------- schemas/project.json | 32 +++-------- 8 files changed, 49 insertions(+), 129 deletions(-) delete mode 100644 schemas/develops.json create mode 100644 schemas/enhances.json delete mode 100644 schemas/funding.json diff --git a/examples/project/valid/alma2lobid.json b/examples/project/valid/alma2lobid.json index 32a6c875..3cd5fc6b 100644 --- a/examples/project/valid/alma2lobid.json +++ b/examples/project/valid/alma2lobid.json @@ -12,5 +12,10 @@ "en": "Switch lobid-resources ETL and indexing from Aleph to Alma Marc21 XML", "de": "Umstieg von Aleph- auf Alma-MARC21-Daten bei Transformation und Indexierung für lobid-resources" }, - "url": "https://github.com/hbz/lobid-resources/milestone/1" + "url": "https://github.com/hbz/lobid-resources/milestone/1", + "enhances": [ + { + "id": "https://lobid.org" + } + ] } \ No newline at end of file diff --git a/examples/project/valid/metafacture-fix.json b/examples/project/valid/metafacture-fix.json index 9f8ebe01..c554abe4 100644 --- a/examples/project/valid/metafacture-fix.json +++ b/examples/project/valid/metafacture-fix.json @@ -12,5 +12,10 @@ "en": "Implementation of the Fix language for Metafacture as an alternative to configuring data transformations with Metamorph", "de": "Das Projekt entwickelt und implementiert FIX als Metafacture Sprache. Diese soll als Alternative zu Metamorph für Datentransformation eingesetzt werden." }, - "url": "https://github.com/metafacture/metafacture-fix" + "url": "https://github.com/metafacture/metafacture-fix", + "enhances": [ + { + "id": "https://metafacture.org" + } + ] } \ No newline at end of file diff --git a/examples/project/valid/metafacture-playground.json b/examples/project/valid/metafacture-playground.json index 77c82a92..48268521 100644 --- a/examples/project/valid/metafacture-playground.json +++ b/examples/project/valid/metafacture-playground.json @@ -12,5 +12,10 @@ "en": "This projects aims to provide a web application to play around with Metafactures languages Fix and Flux.", "de": "Dieses Projekt entwickelt eine Web-Applikation, mit der man interaktiv die Metafacture-Sprachen Fix und Flux austesten kann." }, - "url": "https://github.com/metafacture/metafacture-playground" + "url": "https://github.com/metafacture/metafacture-playground", + "enhances": [ + { + "id": "https://metafacture.org" + } + ] } \ No newline at end of file diff --git a/examples/project/valid/oersi.json b/examples/project/valid/oersi.json index be6083e7..4c1488d9 100644 --- a/examples/project/valid/oersi.json +++ b/examples/project/valid/oersi.json @@ -15,5 +15,8 @@ "de": "Ein gemeinsames Projekt der TIB Hannover und des hbz zum Aufbau eines offenen Suchindex für Bildungsressourcen", "en": "Common project by TIB Hannover and hbz to create an open search index for educational resources" }, - "url": "https://oersi.de" + "url": "https://oersi.de", + "isBasedOn": { + "id": "https://metafacture.org" + } } \ No newline at end of file diff --git a/schemas/develops.json b/schemas/develops.json deleted file mode 100644 index e6460bb7..00000000 --- a/schemas/develops.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "$id": "resource:/develops.json", - "title": "product", - "description": "Schema to describe a product at lobid.", - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string", - "const": "Role" - }, - "roleName": { - "allOf": [ - { - "$ref": "localizedString.json" - }, - { - "enum": [ - "NewProduct", - "Enhancement for" - ] - } - ] - }, - "product": { - "type": "object", - "properties": { - "id": { - "$ref": "resource:/id.json" - }, - "name": { - "$ref": "resource:/name.json" - } - }, - "anyOf": [ - { - "required": [ - "id" - ] - }, - { - "required": [ - "name" - ] - } - ] - } - }, - "required": [ - "type", - "roleName", - "product" - ] - } -} \ No newline at end of file diff --git a/schemas/enhances.json b/schemas/enhances.json new file mode 100644 index 00000000..515f9742 --- /dev/null +++ b/schemas/enhances.json @@ -0,0 +1,20 @@ +{ + "$id": "resource:/enhances.json", + "title": "product", + "description": "Schema to describe a product at lobid.", + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "$ref": "resource:/id.json" + }, + "name": { + "$ref": "resource:/name.json" + } + }, + "required": [ + "id" + ] + } +} \ No newline at end of file diff --git a/schemas/funding.json b/schemas/funding.json deleted file mode 100644 index 2870e36f..00000000 --- a/schemas/funding.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "$id": "resource:/funding.json", - "title": "Funding", - "description": "Schema to describe a funder relation", - "type": "array", - "items": { - "type": "object", - "properties": { - "type": { - "type": "string", - "const": "Role" - }, - "startDate": { - "$ref": "resource:/startDate.json" - }, - "endDate": { - "$ref": "resource:/endDate.json" - }, - "roleName": { - "$ref": "resource:/localizedString.json" - }, - "funder": { - "type": "object", - "properties": { - "id": { - "$ref": "resource:/id.json" - }, - "name": { - "$ref": "resource:/name.json" - } - }, - "required": [ - "id" - ] - } - }, - "required": [ - "type", - "roleName", - "member" - ] - } -} \ No newline at end of file diff --git a/schemas/project.json b/schemas/project.json index a7bb1dbb..d7482dde 100644 --- a/schemas/project.json +++ b/schemas/project.json @@ -27,35 +27,17 @@ "image": { "$ref": "resource:/image.json" }, - "starteDate": { + "startDate": { "$ref": "resource:/startDate.json" }, - "endeDate": { - "$ref": "resource:/startDate.json" - }, - "funding": { - "$ref": "resource:/funding.json" + "endDate": { + "$ref": "resource:/endDate.json" }, - "develops": { - "$ref": "resource:/develops.json" + "enhances": { + "$ref": "resource:/enhances.json" }, - "projectTeam": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "$ref": "resource:/id.json" - }, - "type": { - "type": "string", - "const": "Organization" - } - }, - "required": [ - "id" - ] - } + "membership": { + "$ref": "resource:/membership.json" } }, "required": [