Skip to content

Creating RecordTypes

Recordtypes are basically SHACL Nodeshapes, but restricted by Memorix. Our code base has a SHACL file that defines the restraints in use for Recordtypes.

A recordtype consists of the following parts:
- Prefixes
- Groups
- Recordtype definition
- Information components
- Fields (properties)

Prefixes

Start by adding the prefixes for external ontologies that you will be referencing in the recordtype:

1
2
3
4
5
6
7
8
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix html: <http://www.w3.org/1999/xhtml/> .

Then add the relevant Memorix specific prefixes, where the last one in this example is for the recordtype that we are creating:

1
2
3
4
@prefix memorix: <http://memorix.io/ontology#> .
@prefix vocabularies: </resources/vocabularies/> .
@prefix recordtypes: </resources/recordtypes/> .
@prefix image: </resources/recordtypes/Image#> .

Groups

Every field an a recordtype needs to be in a group. It is recommended to define the groups before defining the recordtype and referencing them in the fields:

1
2
3
4
5
image:contentDescriptionGroup
  rdf:type   sh:PropertyGroup ;
  rdfs:label "Content description"@en ;
  sh:order   1.0
.

Recordtype definition

1
2
3
4
5
6
7
8
9
recordtypes:Image
  a memorix:Recordtype, sh:NodeShape ;
  rdfs:label "Image"@en ;
  rdfs:comment "Image description"@en ;
  dc:identifier "Image" ;
  sh:closed true ;
  sh:ignoredProperties ( rdf:type ) ;
  sh:targetClass recordtypes:Image ;
.

Information components

A recordtype can have some extra information about Depots, Fonds, Files and Assets. This information is provided by adding a memorix:hasInformationComponent. For example to link images in the ui we need to add the DigitalAssetComponent and to link a depot location to the record we need the DepotLocationComponent. To add both this would look something like this:

recordtypes:Image
  a memorix:Recordtype, sh:NodeShape ;
  rdfs:label "Image"@en ;
  rdfs:comment "Image description"@en ;
  dc:identifier "Image" ;
  sh:closed true ;
  sh:ignoredProperties ( rdf:type ) ;
  sh:targetClass recordtypes:Image ;
  memorix:hasInformationComponent
    [  rdf:type  memorix:DepotLocationComponent ;
       rdf:type  memorix:DigitalAssetComponent ;
    ] ;
.

Fields (properties)

1
2
3
4
5
6
7
8
9
sh:property [
    rdfs:label "Image type"@en ;
    rdfs:comment "The type of image."@en ;
    sh:path image:documentType ;
    sh:maxCount 1 ;
    sh:order 1.0 ;
    sh:group image:contentDescriptionGroup ;
    sh:datatype xsd:string ;
  ] ;

Summary

All the above will result in the following recordtype containing one group and one field:

@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix html: <http://www.w3.org/1999/xhtml/> .
@prefix memorix: <http://memorix.io/ontology#> .
@prefix vocabularies: </resources/vocabularies/> .
@prefix recordtypes: </resources/recordtypes/> .
@prefix image: </resources/recordtypes/Image#> .

image:contentDescriptionGroup
  rdf:type   sh:PropertyGroup ;
  rdfs:label "Content description"@en ;
  sh:order   1.0
.

recordtypes:Image
  a memorix:Recordtype, sh:NodeShape ;
  rdfs:label "Image"@en ;
  rdfs:comment "Image description"@en ;
  dc:identifier "Image" ;
  sh:closed true ;
  sh:ignoredProperties ( rdf:type ) ;
  sh:targetClass recordtypes:Image ;

  sh:property [
    rdfs:label "Image type"@en ;
    rdfs:comment "The type of image."@en ;
    sh:path image:documentType ;
    sh:maxCount 1 ;
    sh:order 1.0 ;
    sh:group image:contentDescriptionGroup ;
    sh:datatype xsd:string ;
  ] ;
.