Skip to content
Permalink
Browse files
fix(schema-documentation): update schemas and documentation (DEV-61) (#…
…105)

* update schemas

* update documentation

* reformat docs

* update ontology.json to allow folder as Excel reference

* allow folder reference in list ontologies

* fix failing test

* get local schema for tests

* Update Resources.xlsx

* Remove Pulldown for listValues in documentation

* remove pulldown from list of gui elements

* Update BUILD.bazel

* Update dsp-tools-create.md

* adapt groups to new data model

* update group and project tests

* update longname when changed

* introduce prefixed names in schemas

* Update test_user.py

* Update dsp-tools-create.md

* Update GitHub actions
  • Loading branch information
irinaschubert committed Oct 12, 2021
1 parent 026ad00 commit 4d9c1e40423384914503222063bebdc09370bb94
@@ -7,4 +7,4 @@ Requests: https://docs.dasch.swiss/developers/dsp/contribution/#pull-request-gui
===REMOVE===

resolves DSP-
resolves DEV-
@@ -4,6 +4,8 @@ on:
push:
pull_request:
types: [opened]
schedule:
- cron: '0 8 * * *'

jobs:
test-integration:

Large diffs are not rendered by default.

@@ -4,6 +4,7 @@

from pystrict import strict

from knora.dsplib.models.langstring import LangString, LangStringParam, Languages
from .connection import Connection
from .helpers import Actions, BaseError
from .model import Model
@@ -50,8 +51,8 @@ class Group(Model):
name : str
Name of the group
description : str
A description of the group
descriptions : LangString
Group descriptions in a given language (Languages.EN, Languages.DE, Languages.FR, Languages.IT).
project : str | project
either the IRI of a project [get only, cannot be modified after creation of instance]
@@ -71,7 +72,7 @@ class Group(Model):

_id: str
_name: str
_description: str
_descriptions: LangString
_project: str
_selfjoin: bool
_status: bool
@@ -80,14 +81,14 @@ def __init__(self,
con: Connection,
id: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
descriptions: LangString = None,
project: Optional[Union[str, Project]] = None,
selfjoin: Optional[bool] = None,
status: Optional[bool] = None):
super().__init__(con)
self._id = str(id) if id is not None else None
self._name = str(name) if name is not None else None
self._description = description
self._descriptions = LangString(descriptions)
if project is not None and isinstance(project, Project):
self._project = project.id
else:
@@ -113,13 +114,13 @@ def name(self, value: str):
self._changed.add('name')

@property
def description(self):
return self._description
def descriptions(self) -> Optional[LangString]:
return self._descriptions

@description.setter
def description(self, value: Optional[str]):
self._description = value
self._changed.add('description')
@descriptions.setter
def descriptions(self, value: Optional[LangString]) -> None:
self._descriptions = LangString(value)
self._changed.add('descriptions')

@property
def project(self):
@@ -157,27 +158,27 @@ def has_changed(self) -> bool:
def fromJsonObj(cls, con: Connection, json_obj: Any):
id = json_obj.get('id')
if id is None:
raise BaseError('Group "id" is missing in JSON from knora')
raise BaseError('Group "id" is missing')
name = json_obj.get('name')
if name is None:
raise BaseError('Group "name" is missing in JSON from knora')
description = json_obj.get('description')
raise BaseError('Group "name" is missing')
descriptions = LangString.fromJsonObj(json_obj.get('descriptions'))
tmp = json_obj.get('project')
if tmp is None:
raise BaseError('Group "project" is missing in JSON from knora')
raise BaseError('Group "project" is missing')
project = tmp.get('id')
if project is None:
raise BaseError('Group "project" has no "id" in JSON from knora')
raise BaseError('Group "project" has no "id"')
selfjoin = json_obj.get('selfjoin')
if selfjoin is None:
raise BaseError("selfjoin is missing in JSON from knora")
raise BaseError("selfjoin is missing")
status = json_obj.get('status')
if status is None:
raise BaseError("Status is missing in JSON from knora")
raise BaseError("Status is missing")
return cls(con=con,
name=name,
id=id,
description=description,
descriptions=descriptions,
project=project,
selfjoin=selfjoin,
status=status)
@@ -188,8 +189,8 @@ def toJsonObj(self, action: Actions):
if self._name is None:
raise BaseError("There must be a valid name!")
tmp['name'] = self._name
if self._description is not None:
tmp['description'] = self._description
if not self._descriptions.isEmpty():
tmp['descriptions'] = self._descriptions.toJsonObj()
if self._project is None:
raise BaseError("There must be a valid project!")
tmp['project'] = self._project
@@ -202,8 +203,8 @@ def toJsonObj(self, action: Actions):
else:
if self._name is not None and 'name' in self._changed:
tmp['name'] = self._name
if self._description is not None and 'description' in self._changed:
tmp['description'] = self._description
if not self._descriptions.isEmpty() and 'descriptions' in self._changed:
tmp['descriptions'] = self._descriptions.toJsonObj()
if self._selfjoin is not None and 'selfjoin' in self._changed:
tmp['selfjoin'] = self._selfjoin
return tmp
@@ -245,7 +246,12 @@ def print(self):
print('Group Info:')
print(' Id: {}'.format(self._id))
print(' Name: {}'.format(self._name))
print(' Description: {}'.format(self._description))
if self._descriptions is not None:
print(' Descriptions:')
for descr in self._descriptions.items():
print(' {}: {}'.format(descr[0], descr[1]))
else:
print(' Descriptions: None')
print(' Project: {}'.format(self._project))
print(' Selfjoin: {}'.format(self._selfjoin))
print(' Status: {}'.format(self._status))
@@ -260,18 +266,18 @@ def print(self):
group.print()

new_group = Group(con=con,
name="KNORA-PY TEST",
description="Test project for knora-py",
name="GROUP TEST",
descriptions=LangString({Languages.EN: 'Test group description'}),
project="http://rdfh.ch/projects/00FF",
status=True,
selfjoin=False).create()
new_group.print()
print("iiiii")

new_group.name = "KNORA-PY TEST - modified"
new_group.name = "GROUP TEST - modified"
new_group = new_group.update()
new_group.print()

new_group.description = "gaga gaga gaga gaga gaga gaga gaga"
new_group.descriptions = LangString({Languages.DE: 'Beschreibung einer Gruppe'})
new_group = new_group.update()
new_group.print()

@@ -283,8 +289,8 @@ def print(self):
new_group = new_group.update()
new_group.print()

new_group.name = '-- KNORA-PY TEST --'
new_group.description = 'Final Test'
new_group.name = '-- GROUP TEST --'
new_group.descriptions = LangString({Languages.DE: 'Neue Beschreibung einer Gruppe'})
new_group.status = True
new_group = new_group.update()
new_group.print()
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="https://dasch.swiss/schema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="https://dasch.swiss/schema"
targetNamespace="https://dasch.swiss/schema"
elementFormDefault="qualified">

@@ -35,17 +35,61 @@
"$ref": "#/definitions/comment"
},
"nodes": {
"type": "array",
"items": {
"$ref": "#/definitions/node"
}
"oneOf": [
{
"type": "array",
"items": {
"$ref": "#/definitions/node"
}
},
{
"type": "object",
"$ref": "#/definitions/excelfileref"
},
{
"type": "object",
"$ref": "#/definitions/excelfolderref"
}
]
}
},
"required": [
"name",
"labels"
],
"additionalProperties": false
},
"excelfileref": {
"type": "object",
"properties": {
"file": {
"type": "string"
},
"worksheet": {
"type": "string"
},
"startrow": {
"type": "integer"
},
"startcol": {
"type": "integer"
}
},
"required": [
"file",
"worksheet"
]
},
"excelfolderref": {
"type": "object",
"properties": {
"folder": {
"type": "string"
}
},
"required": [
"folder"
]
}
},
"type": "object",
@@ -60,10 +104,22 @@
"$ref": "#/definitions/comment"
},
"nodes": {
"type": "array",
"items": {
"$ref": "#/definitions/node"
}
"oneOf": [
{
"type": "array",
"items": {
"$ref": "#/definitions/node"
}
},
{
"type": "object",
"$ref": "#/definitions/excelfileref"
},
{
"type": "object",
"$ref": "#/definitions/excelfolderref"
}
]
}
},
"required": [
@@ -4,7 +4,7 @@
"title": "JSON schema for DSP lists",
"description": "JSON schema for lists used in DSP ontologies",
"definitions": {
"label": {
"langstring": {
"type": "object",
"patternProperties": {
"^(en|de|fr|it)": {
@@ -13,23 +13,46 @@
},
"additionalProperties": false
},
"label": {
"$ref": "#/definitions/langstring"
},
"description": {
"$ref": "#/definitions/langstring"
},
"comment": {
"$ref": "#/definitions/langstring"
},
"excelfileref": {
"type": "object",
"patternProperties": {
"^(en|de|fr|it)": {
"properties": {
"file": {
"type": "string"
},
"worksheet": {
"type": "string"
},
"startrow": {
"type": "integer"
},
"startcol": {
"type": "integer"
}
},
"additionalProperties": false
"required": [
"file",
"worksheet"
]
},
"comment": {
"excelfolderref": {
"type": "object",
"patternProperties": {
"^(en|de|fr|it)": {
"properties": {
"folder": {
"type": "string"
}
},
"additionalProperties": false
"required": [
"folder"
]
},
"node": {
"type": "object",
@@ -44,10 +67,22 @@
"$ref": "#/definitions/comment"
},
"nodes": {
"type": "array",
"items": {
"$ref": "#/definitions/node"
}
"oneOf": [
{
"type": "array",
"items": {
"$ref": "#/definitions/node"
}
},
{
"type": "object",
"$ref": "#/definitions/excelfileref"
},
{
"type": "object",
"$ref": "#/definitions/excelfolderref"
}
]
}
},
"required": [
@@ -82,7 +117,7 @@
"prefixes": {
"type": "object",
"patternProperties": {
"^[\\w-]+$": {
"^[-\\w]+$": {
"format": "uri"
}
},
Loading

0 comments on commit 4d9c1e4

Please sign in to comment.