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

fix(schema-documentation): update schemas and documentation (DEV-61) #105

Merged
merged 22 commits into from Oct 12, 2021
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
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Expand Up @@ -7,4 +7,4 @@ Requests: https://docs.dasch.swiss/developers/dsp/contribution/#pull-request-gui

===REMOVE===

resolves DSP-
resolves DEV-
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -4,6 +4,8 @@ on:
push:
pull_request:
types: [opened]
schedule:
- cron: '0 8 * * *'

jobs:
test-integration:
Expand Down
450 changes: 169 additions & 281 deletions docs/dsp-tools-create.md

Large diffs are not rendered by default.

68 changes: 37 additions & 31 deletions knora/dsplib/models/group.py
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand All @@ -71,7 +72,7 @@ class Group(Model):

_id: str
_name: str
_description: str
_descriptions: LangString
_project: str
_selfjoin: bool
_status: bool
Expand All @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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()

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions knora/dsplib/schemas/data.xsd
@@ -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">

Expand Down
72 changes: 64 additions & 8 deletions knora/dsplib/schemas/lists-only.json
Expand Up @@ -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",
Expand All @@ -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": [
Expand Down
61 changes: 48 additions & 13 deletions knora/dsplib/schemas/lists.json
Expand Up @@ -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)": {
Expand All @@ -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",
Expand All @@ -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": [
Expand Down Expand Up @@ -82,7 +117,7 @@
"prefixes": {
"type": "object",
"patternProperties": {
"^[\\w-]+$": {
"^[-\\w]+$": {
"format": "uri"
}
},
Expand Down