Skip to content

Commit

Permalink
feat: make comments optional for new properties and resources (DEV-502)…
Browse files Browse the repository at this point in the history
… (#158)

* make comments optional

* adapt test data and schema

* lists still need comments

* proper handling of empty comments

* proper handling of empty comments
  • Loading branch information
jnussbaum committed Feb 21, 2022
1 parent 8a8c9d0 commit 9c30746
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 23 deletions.
7 changes: 4 additions & 3 deletions knora/dsplib/models/resourceclass.py
Expand Up @@ -700,8 +700,6 @@ def resolve_resref(resref: str):
superclasses = [{"@id": "knora-api:Resource"}]
else:
superclasses = list(map(resolve_resref, self._superclasses))
if self._comment is None or self._comment.isEmpty():
self._comment = LangString({"en": "[no comment provided]"})
if self._label is None or self._label.isEmpty():
self._label = LangString("no label available")
tmp = {
Expand All @@ -712,11 +710,14 @@ def resolve_resref(resref: str):
"@id": resid,
"@type": "owl:Class",
"rdfs:label": self._label.toJsonLdObj(),
"rdfs:comment": self._comment.toJsonLdObj(),
"rdfs:subClassOf": superclasses
}],
"@context": self._context.toJsonObj(),
}
if self._comment:
tmp["@graph"][0]["rdfs:comment"] = self._comment.toJsonLdObj()
print(tmp)

elif action == Actions.Update:
tmp = {
"@id": ontid, # self._ontology_id,
Expand Down
4 changes: 0 additions & 4 deletions knora/dsplib/utils/onto_create_ontology.py
Expand Up @@ -426,8 +426,6 @@ def create_ontology(input_file: str,
res_comment = res_class.get("comments")
if res_comment:
res_comment = LangString(res_comment)
else:
res_comment = LangString({"en": "[no comment provided]"})
# if no cardinalities are submitted, don't create the class
if not res_class.get("cardinalities"):
print(f"ERROR while trying to add cardinalities to class '{res_name}'. No cardinalities submitted. At"
Expand Down Expand Up @@ -505,8 +503,6 @@ def create_ontology(input_file: str,
prop_comment = prop_class.get("comments")
if prop_comment:
prop_comment = LangString(prop_comment)
else:
prop_comment = LangString({"en": "[no comment provided]"})

new_prop_class = None
try:
Expand Down
20 changes: 4 additions & 16 deletions testdata/test-onto.json
Expand Up @@ -31,9 +31,6 @@
"name": "a",
"labels": {
"en": "a_label with a\"post'rophes"
},
"comments": {
"en": "no comment"
}
},
{
Expand All @@ -60,9 +57,6 @@
"name": "c",
"labels": {
"en": "c_label"
},
"comments": {
"en": "no comment"
}
}
]
Expand Down Expand Up @@ -95,9 +89,6 @@
"name": "notUsedNode_1",
"labels": {
"en": "nodeLabel_1"
},
"comments": {
"en": "no comment"
}
}
]
Expand Down Expand Up @@ -186,6 +177,10 @@
"labels": {
"en": "Text"
},
"comments": {
"en": "properties can optionally have comments",
"de": "Properties können Kommentare haben"
},
"gui_element": "SimpleText",
"gui_attributes": {
"maxlength": 255,
Expand Down Expand Up @@ -358,10 +353,6 @@
"labels": {
"en": "TestThing"
},
"comments": {
"en": "A thing to test things",
"de": "Ein Ding um allerlei Dinge zu testen."
},
"cardinalities": [
{
"propname": ":hasText",
Expand Down Expand Up @@ -441,9 +432,6 @@
"labels": {
"en": "Another Test Thing"
},
"comments": {
"en": "Another thing for testing things."
},
"cardinalities": [
{
"propname": ":hasText",
Expand Down

0 comments on commit 9c30746

Please sign in to comment.