From 3872abda8389dc1f1d021168ed57e8d62e7883a9 Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum Date: Thu, 24 Feb 2022 17:01:37 +0100 Subject: [PATCH 1/4] implement first step of issue description --- knora/dsplib/utils/onto_create_ontology.py | 1 + 1 file changed, 1 insertion(+) diff --git a/knora/dsplib/utils/onto_create_ontology.py b/knora/dsplib/utils/onto_create_ontology.py index 63ab3f6af..f6f917192 100644 --- a/knora/dsplib/utils/onto_create_ontology.py +++ b/knora/dsplib/utils/onto_create_ontology.py @@ -398,6 +398,7 @@ def create_ontology(input_file: str, project=project, label=ontology["label"], name=ontology_name).create() + context.add_context(new_ontology.name, new_ontology.id + ('#' if not new_ontology.id.endswith('#') else '')) last_modification_date = new_ontology.lastModificationDate if verbose: print(f"Created ontology '{ontology_name}'.") From 254bab93c1f735be81ac6047abf4f174a6a4a900 Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum Date: Thu, 24 Feb 2022 17:02:26 +0100 Subject: [PATCH 2/4] implement second step of issue description --- knora/dsplib/models/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knora/dsplib/models/helpers.py b/knora/dsplib/models/helpers.py index 25b7a4acd..f7a794fab 100644 --- a/knora/dsplib/models/helpers.py +++ b/knora/dsplib/models/helpers.py @@ -162,7 +162,7 @@ def __init__(self, context: Optional[dict[str, str]] = None): # add ontologies from context, if any if context: for prefix, onto in context.items(): - self._context[prefix] = OntoInfo(onto.removesuffix('#'), onto.endswith('#')) + self._context[prefix] = OntoInfo(onto.removesuffix('#'), True) # add standard ontologies (rdf, rdfs, owl, xsl) for k, v in self.base_ontologies.items(): From 990358c42732312b241934f968ea4295a683a65e Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum Date: Thu, 24 Feb 2022 17:26:42 +0100 Subject: [PATCH 3/4] adapt docs --- docs/dsp-tools-create-ontologies.md | 4 ++-- docs/dsp-tools-create.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/dsp-tools-create-ontologies.md b/docs/dsp-tools-create-ontologies.md index 61611afcf..e7226b5b7 100644 --- a/docs/dsp-tools-create-ontologies.md +++ b/docs/dsp-tools-create-ontologies.md @@ -905,5 +905,5 @@ it is necessary to reference entities that are defined elsewhere. The following [prefixes](dsp-tools-create.md#prefixes-object) and the prefix must be identical to the ontology's `name`. - A different ontology defined in the same file: Within one data model file, multiple ontologies can be defined. These will be created in the exact order they appear in the `ontologies` array. Once an ontology has been created, - it can be referenced by the following ontologies, provided it is added in the - [prefixes](dsp-tools-create.md#prefixes-object). + it can be referenced by the following ontologies via its name: `first-onto:hasName`. It is not necessary to add + `first-onto` to the prefixes. diff --git a/docs/dsp-tools-create.md b/docs/dsp-tools-create.md index 4cfc724f6..58d6bae06 100644 --- a/docs/dsp-tools-create.md +++ b/docs/dsp-tools-create.md @@ -66,8 +66,8 @@ full qualified IRI each time it is used. So, instead of writing a property calle } ``` -Note that prefixes can be defined for the ontologies defined in this file, but this is only necessary if the ontology -needs to be referred to explicitly by another ontology within the same file. +It is not necessary to define prefixes for the ontologies that are defined in this file. Ontologies in the same +file can refer to each other via their name. See also [here](./dsp-tools-create-ontologies.md#referencing-ontologies). ### "$schema" object From f3233d451b5245c69110ae4b8328bc4008a89aa4 Mon Sep 17 00:00:00 2001 From: Johannes Nussbaum Date: Thu, 24 Feb 2022 18:49:40 +0100 Subject: [PATCH 4/4] only set hashtag to true if onto ends with "#" or "/v2" --- knora/dsplib/models/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knora/dsplib/models/helpers.py b/knora/dsplib/models/helpers.py index f7a794fab..300e9eb3e 100644 --- a/knora/dsplib/models/helpers.py +++ b/knora/dsplib/models/helpers.py @@ -162,7 +162,7 @@ def __init__(self, context: Optional[dict[str, str]] = None): # add ontologies from context, if any if context: for prefix, onto in context.items(): - self._context[prefix] = OntoInfo(onto.removesuffix('#'), True) + self._context[prefix] = OntoInfo(onto.removesuffix('#'), onto.endswith('#') or onto.endswith('/v2')) # add standard ontologies (rdf, rdfs, owl, xsl) for k, v in self.base_ontologies.items():