Change the model: create constructors, classes, and restrictions

Change the model

In order to be able to manage SKOS concepts and concept schemes, we need to create classes that represent them in the model of our dataspace. Not only will they serve as RDF types of the instances, but will have constructors attached that define the default properties and their (data)types for that class.

Since a SKOS concept is an abstract thing which cannot be directly dereferenced over HTTP, its instance has to be paired with a document instance. In the model, this relationship is defined by creating a property restriction between the two respective classes. We therefore need to create 2 classes and a restriction.

Model is managed in the administration application of a dataspace. Head there by clicking the Settings in the action bar and then choosing Administration.

In order to edit the access control, model, or sitemap of a dataspace, you need to be an administrator, i.e. a member of the owners group.

Create a constructor

We will use the following SPARQL CONSTRUCT query as a constructor for our Concept class and save it in a file under queries/construct-concept.rq.

PREFIX :     <ns/domain#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd:  <http://www.w3.org/2001/XMLSchema#>

CONSTRUCT
{
?this skos:inScheme [ a :ConceptScheme ] ;
    skos:topConceptOf [ a :ConceptScheme ] ;
    skos:prefLabel [ a xsd:string ] ;
    skos:altLabel [ a xsd:string ] ;
    skos:hiddenLabel [ a xsd:string ] ;
    skos:notation [ a xsd:string ] ;
    skos:note [ a xsd:string ] ;
    skos:changeNote [ a xsd:string ] ;
    skos:definition [ a xsd:string ] ;
    skos:editorialNote [ a xsd:string ] ;
    skos:example [ a xsd:string ] ;
    skos:historyNote [ a xsd:string ] ;
    skos:scopeNote [ a xsd:string ] ;
    skos:semanticRelation [ a :Concept ] ;
    skos:broader [ a :Concept ] ;
    skos:narrower [ a :Concept ] ;
    skos:related [ a :Concept ] ;
    skos:broaderTransitive [ a :Concept ] ;
    skos:narrowerTransitive [ a :Concept ] ;
    skos:mappingRelation [ a :Concept ] ;
    skos:broadMatch [ a :Concept ] ;
    skos:narrowMatch [ a :Concept ] ;
    skos:relatedMatch [ a :Concept ] ;
    skos:exactMatch [ a :Concept ] ;
    skos:closeMatch [ a :Concept ] .
}
WHERE {}

In the administration application, follow these steps:

  1. Click the Create dropdown in the top-left corner
  2. Click on CONSTRUCT in the drop-down list that appears
  3. Fill out the mandatory fields in the form:
    Label
    Enter Construct concept
    IsDefinedBy
    Type Domain into the input (which provides autocomplete)
    Select Domain from the list — this is the ontology in which the query is defined
    Text
    Enter the SPARQL CONSTRUCT query string
  4. Click Save
pwd=$(realpath -s $PWD)

pushd . && cd "$SCRIPT_ROOT"/admin/model

./create-construct.sh \
-b "${base}admin/" \
-f "$cert_pem_file" \
-p "$cert_password" \
--uri "${base}ns/domain#ConstructConcept" \
--label "Construct concept" \
--slug construct-concept \
--query-file "$pwd/queries/construct-concept.rq"

popd

Follow the same steps for Concept scheme.

Read more about constructors.

Create a class

In the administration application, follow these steps to create a concept class:

  1. Click the Create dropdown in the top-left corner
  2. Click on Class in the drop-down list that appears
  3. Fill out the mandatory fields in the form:
    Label
    Enter Concept
    IsDefinedBy
    Type Domain into the input (which provides autocomplete)
    Select Domain from the list — this is the ontology in which the class is defined
    Constructor
    Type Construct concept into the input (which provides autocomplete)
    Select Construct concept from the list — this is the query we created beforehand
  4. Click Save

Now follow the same steps to create an item class (it does not require a constructor):

  1. Click the Create dropdown in the top-left corner
  2. Click on Class in the drop-down list that appears
  3. Fill out the mandatory fields in the form:
    Label
    Enter Concept item
    IsDefinedBy
    Type Domain into the input (which provides autocomplete)
    Select Domain from the list — this is the ontology in which the class is defined
  4. Click Save
pushd . && cd "$SCRIPT_ROOT"/admin/model

./create-class.sh \
-b "https://localhost:4443/admin/" \
-f certs/owner.p12.pem \
-p "${OWNER_KEY_PASSWORD}" \
--uri "https://localhost:4443/ns/domain#Concept" \
--label "Concept" \
--slug concept \
--constructor "https://localhost:4443/ns/domain#ConstructConcept" \
--sub-class-of "https://localhost:4443/ns/domain#TopicOfConceptItem" \
--path "{isPrimaryTopicOf.slug}/" \
--fragment "this"

./create-class.sh \
-b "https://localhost:4443/admin/" \
-f certs/owner.p12.pem \
-p "${OWNER_KEY_PASSWORD}" \
--uri "https://localhost:4443/ns/domain#ConceptItem" \
--label "Concept item" \
--slug concept-item \
--sub-class-of "https://localhost:4443/ns/default#Item" \
--sub-class-of "https://localhost:4443/ns/domain#ItemOfConceptContainer"

popd

Follow the same steps for Concept scheme.

Read more about classes.

Create a constraint

To control data quality, we probably want to make some of the instance properties mandatory. For example, a Concept instance should always have a skos:prefLabel value.

In the administration application, follow these steps:

  1. Click the Create dropdown in the top-left corner
  2. Click on Missing property value in the drop-down list that appears
  3. Fill out the fields in the form:
    Label
    Enter Missing skos:prefLabel
    IsDefinedBy
    Type Domain into the input (which provides autocomplete)
    Select Domain from the list — this is the ontology in which the query is defined
    Arg1
    Enter http://www.w3.org/2004/02/skos/core#prefLabel
  4. Click Save
pushd . && cd "$SCRIPT_ROOT"/admin/model

./create-property-constraint.sh \
-b "https://localhost:4443/admin/" \
-f certs/owner.p12.pem \
-p "${OWNER_KEY_PASSWORD}" \
--uri "https://localhost:4443/ns/domain#MissingPrefLabel" \
--label "Missing skos:prefLabel" \
--slug missing-pref-label \
--property "http://www.w3.org/2004/02/skos/core#prefLabel"

popd

Read more about constraints.

Clear ontologies

For changes made to application ontologies (both of the model and of the sitemap) to take effect, the ontologies need to be cleared from memory and reloaded from dataset. Follow these steps:

Head to the administration application by clicking the Settings in the action bar and then choosing Administration.

  1. Open Model / Ontologies / Domain
  2. Click Clear in the header of the ontology description
  3. Open Model / Ontologies / Namespace
  4. Click Clear in the header of the ontology description

Replace ${OWNER_KEY_PASSWORD} with its value from the .env file and execute the following commands:

pushd . && cd "$SCRIPT_ROOT"/admin

./clear-ontology.sh \
-f certs/owner.p12.pem \
-p "${OWNER_KEY_PASSWORD}" \
"https://localhost:4443/admin/model/ontologies/domain/"

./clear-ontology.sh \
-f certs/owner.p12.pem \
-p "${OWNER_KEY_PASSWORD}" \
"https://localhost:4443/admin/model/ontologies/namespace/"

popd
Date Created
17 March 2020 20:44
Maker
Martynas Jusevičius
Owner
Martynas Jusevičius