Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve prefix handling in json ontos (DEV-572) #164

Merged
merged 4 commits into from Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/dsp-tools-create-ontologies.md
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions docs/dsp-tools-create.md
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion knora/dsplib/models/helpers.py
Expand Up @@ -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('#'), onto.endswith('#') or onto.endswith('/v2'))

# add standard ontologies (rdf, rdfs, owl, xsl)
for k, v in self.base_ontologies.items():
Expand Down
1 change: 1 addition & 0 deletions knora/dsplib/utils/onto_create_ontology.py
Expand Up @@ -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}'.")
Expand Down