Skip to content

Commit

Permalink
Fix metadata schemas and default license
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekSuchanek committed Apr 26, 2024
1 parent 9604e79 commit 49da980
Show file tree
Hide file tree
Showing 20 changed files with 450 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/**
* The MIT License
* Copyright © 2017 DTL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package nl.dtls.fairdatapoint.database.mongo.migration.production;

import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Updates;
import io.mongock.api.annotations.ChangeUnit;
import io.mongock.api.annotations.Execution;
import io.mongock.api.annotations.RollbackExecution;
import lombok.SneakyThrows;
import nl.dtls.fairdatapoint.Profiles;
import nl.dtls.fairdatapoint.entity.schema.SemVer;
import nl.dtls.fairdatapoint.util.KnownUUIDs;
import org.bson.Document;
import org.springframework.context.annotation.Profile;
import org.springframework.data.mongodb.core.MongoTemplate;

import static java.lang.String.format;
import static nl.dtls.fairdatapoint.util.ResourceReader.loadClassResource;

@ChangeUnit(
id = "Migration_0016_FixSchemas",
order = "0016",
author = "migrationBot"
)
@Profile(Profiles.PRODUCTION)
public class Migration_0016_FixSchemas {
private static final String FIELD_VER_UUID = "versionUuid";
private static final String FIELD_LATEST = "latest";
private static final String FIELD_DEF = "definition";
private static final String COL_SCHEMAS = "metadataSchema";

private final MongoTemplate database;

public Migration_0016_FixSchemas(MongoTemplate template) {
this.database = template;
}

@Execution
public void run() {
updateSchema(KnownUUIDs.SCHEMA_V2_RESOURCE_UUID, "resource");
updateSchema(KnownUUIDs.SCHEMA_V1_CATALOG_UUID, "catalog");
updateSchema(KnownUUIDs.SCHEMA_V1_DATASET_UUID, "dataset");
updateSchema(KnownUUIDs.SCHEMA_V1_DISTRIBUTION_UUID, "distribution");
updateSchema(KnownUUIDs.SCHEMA_V1_DATASERVICE_UUID, "data-service");
updateSchema(KnownUUIDs.SCHEMA_V1_FDP_UUID, "fdp");
}

@SneakyThrows
private void updateSchema(String versionUuid, String name) {
final MongoCollection<Document> schemasCol = database.getCollection(COL_SCHEMAS);
String definition = loadClassResource(format("0016_shape-%s.ttl", name), getClass());
schemasCol.updateOne(
Filters.and(
Filters.eq(FIELD_VER_UUID, versionUuid),
Filters.eq(FIELD_LATEST, true)
),
Updates.set(FIELD_DEF, definition)
);
}

@RollbackExecution
public void rollback() {
// Rollback is not possible
}
}
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ repository:

metadataProperties:
language: ${FDP_METADATA_LANGUAGE:http://id.loc.gov/vocabulary/iso639-1/en}
license: ${FDP_METADATA_LICENSE:http://rdflicense.appspot.com/rdflicense/cc-by-nc-nd3.0}
license: ${FDP_METADATA_LICENSE:http://purl.org/NET/rdflicense/cc-zero1.0}
accessRightsDescription: ${FDP_METADATA_ACCESS_RIGHTS:This resource has no access restriction}

openapi:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
sh:datatype xsd:dateTime ;
sh:maxCount 1 ;
dash:viewer dash:LiteralViewer ;
sh:order 20 ;
], [
sh:path dct:modified ;
sh:datatype xsd:dateTime ;
sh:maxCount 1 ;
dash:viewer dash:LiteralViewer ;
sh:order 21 ;
], [
sh:path foaf:homePage ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:order 22 ;
], [
sh:path dcat:themeTaxonomy ;
sh:nodeKind sh:IRI ;
dash:viewer dash:LabelViewer ;
sh:order 23 ;
] .
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
sh:path dcat:endpointURL ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
sh:order 20 ;
] , [
sh:path dcat:endpointDescription ;
sh:nodeKind sh:Literal ;
sh:maxCount 1 ;
dash:editor dash:TextAreaEditor ;
dash:viewer dash:LiteralViewer ;
] .
sh:order 21 ;
] .
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,39 @@
sh:maxCount 1 ;
dash:editor dash:DatePickerEditor ;
dash:viewer dash:LiteralViewer ;
sh:order 20 ;
], [
sh:path dct:modified ;
sh:datatype xsd:dateTime ;
sh:maxCount 1 ;
dash:editor dash:DatePickerEditor ;
dash:viewer dash:LiteralViewer ;
sh:order 21 ;
], [
sh:path dcat:theme ;
sh:nodeKind sh:IRI ;
sh:minCount 1 ;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:order 22 ;
], [
sh:path dcat:contactPoint ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:order 23 ;
], [
sh:path dcat:keyword ;
sh:nodeKind sh:Literal ;
dash:editor dash:TextFieldEditor ;
dash:viewer dash:LiteralViewer ;
sh:order 24 ;
], [
sh:path dcat:landingPage ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:order 25 ;
] .
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,46 @@
sh:maxCount 1 ;
dash:editor dash:DatePickerEditor ;
dash:viewer dash:LiteralViewer ;
] , [
sh:order 20 ;
], [
sh:path dct:modified ;
sh:datatype xsd:dateTime ;
sh:maxCount 1 ;
dash:editor dash:DatePickerEditor ;
dash:viewer dash:LiteralViewer ;
] , [
sh:order 21 ;
], [
sh:path dcat:accessURL ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
] , [
sh:order 22 ;
], [
sh:path dcat:downloadURL ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
] , [
sh:order 23 ;
], [
sh:path dcat:mediaType ;
sh:nodeKind sh:Literal ;
sh:minCount 1 ;
sh:maxCount 1 ;
dash:editor dash:TextFieldEditor ;
dash:viewer dash:LiteralViewer ;
] , [
sh:order 24 ;
], [
sh:path dcat:format ;
sh:nodeKind sh:Literal ;
sh:maxCount 1 ;
dash:editor dash:TextFieldEditor ;
dash:viewer dash:LiteralViewer ;
] , [
sh:order 25 ;
], [
sh:path dcat:byteSize ;
sh:nodeKind sh:Literal ;
sh:maxCount 1 ;
dash:editor dash:TextFieldEditor ;
dash:viewer dash:LiteralViewer ;
sh:order 26 ;
] .
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,37 @@
sh:maxCount 1 ;
dash:editor dash:DatePickerEditor ;
dash:viewer dash:LiteralViewer ;
sh:order 40 ;
] , [
sh:path fdp:endDate ;
sh:datatype xsd:dateTime ;
sh:maxCount 1 ;
dash:editor dash:DatePickerEditor ;
dash:viewer dash:LiteralViewer ;
sh:order 41 ;
] , [
sh:path fdp:uiLanguage ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
sh:defaultValue <http://id.loc.gov/vocabulary/iso639-1/en>;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:order 42 ;
] , [
sh:path fdp:metadataIdentifier ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:order 43 ;
] , [
sh:path fdp:metadataIssued ;
sh:datatype xsd:dateTime ;
sh:maxCount 1 ;
dash:editor dash:DatePickerEditor ;
dash:viewer dash:LiteralViewer ;
] , [
sh:path fdp:metadataModified ;
sh:datatype xsd:dateTime ;
sh:maxCount 1 ;
dash:editor dash:DatePickerEditor ;
dash:viewer dash:LiteralViewer ;
] .
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@prefix dash: <http://datashapes.org/dash#> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

Expand All @@ -14,17 +14,20 @@
sh:minCount 1 ;
sh:maxCount 1 ;
dash:editor dash:TextFieldEditor ;
sh:order 1 ;
], [
sh:path dct:description ;
sh:nodeKind sh:Literal ;
sh:maxCount 1 ;
dash:editor dash:TextAreaEditor ;
sh:order 2 ;
], [
sh:path dct:publisher ;
sh:node :AgentShape ;
sh:minCount 1 ;
sh:maxCount 1 ;
dash:editor dash:BlankNodeEditor ;
sh:order 3 ;
], [
sh:path dcat:version ;
sh:name "version" ;
Expand All @@ -33,32 +36,38 @@
sh:maxCount 1 ;
dash:editor dash:TextFieldEditor ;
dash:viewer dash:LiteralViewer ;
sh:order 4 ;
], [
sh:path dct:language ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:defaultValue <http://id.loc.gov/vocabulary/iso639-1/en> ;
sh:order 5 ;
], [
sh:path dct:license ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:defaultValue <http://purl.org/NET/rdflicense/cc-zero1.0> ;
sh:order 6 ;
], [
sh:path dct:rights ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:order 7 ;
] .

:AgentShape a sh:NodeShape ;
sh:targetClass foaf:Agent ;
sh:property [
sh:path foaf:name;
sh:path foaf:name ;
sh:nodeKind sh:Literal ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:maxCount 1 ;
dash:editor dash:TextFieldEditor ;
] .
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@prefix : <http://fairdatapoint.org/> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:CatalogShape a sh:NodeShape ;
sh:targetClass dcat:Catalog ;
sh:property [
sh:path dct:issued ;
sh:datatype xsd:dateTime ;
sh:maxCount 1 ;
dash:viewer dash:LiteralViewer ;
sh:order 20 ;
], [
sh:path dct:modified ;
sh:datatype xsd:dateTime ;
sh:maxCount 1 ;
dash:viewer dash:LiteralViewer ;
sh:order 21 ;
], [
sh:path foaf:homePage ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
dash:editor dash:URIEditor ;
dash:viewer dash:LabelViewer ;
sh:order 22 ;
], [
sh:path dcat:themeTaxonomy ;
sh:nodeKind sh:IRI ;
dash:viewer dash:LabelViewer ;
sh:order 23 ;
] .
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@prefix : <http://fairdatapoint.org/> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dct: <http://purl.org/dc/terms/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

:DataServiceShape a sh:NodeShape ;
sh:targetClass dcat:DataService ;
sh:property [
sh:path dcat:endpointURL ;
sh:nodeKind sh:IRI ;
sh:maxCount 1 ;
sh:order 20 ;
] , [
sh:path dcat:endpointDescription ;
sh:nodeKind sh:Literal ;
sh:maxCount 1 ;
dash:editor dash:TextAreaEditor ;
dash:viewer dash:LiteralViewer ;
sh:order 21 ;
] .
Loading

0 comments on commit 49da980

Please sign in to comment.