-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
227 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
## This is a generated file. Do not modify it manually! | ||
from __future__ import annotations | ||
from dataclasses import dataclass, field | ||
from dataclasses_json import config, dataclass_json | ||
from typing import List, Optional | ||
from uuid import uuid4 | ||
|
||
|
||
@dataclass_json | ||
@dataclass | ||
class Test: | ||
name: str | ||
number: Optional[float] = None | ||
test2: List[Test2] = field(default_factory=list) | ||
|
||
# JSON-LD fields | ||
id: str = field( | ||
metadata=config(field_name="@id"), | ||
default_factory=lambda: "tst:Test/" + str(uuid4()) | ||
) | ||
__type__: list[str] = field( | ||
metadata=config(field_name="@type"), | ||
default_factory = lambda: [ | ||
"tst:Test", | ||
], | ||
) | ||
__context__: dict[str, str | dict] = field( | ||
metadata=config(field_name="@context"), | ||
default_factory = lambda: { | ||
"tst": "https://www.github.com/my/repo/", | ||
"schema": "http://schema.org/", | ||
"name": "schema:hello", | ||
"number": "schema:one", | ||
"test2": "schema:something", | ||
} | ||
) | ||
|
||
@dataclass_json | ||
@dataclass | ||
class Test2: | ||
names: List[str] = field(default_factory=list) | ||
number: Optional[float] = None | ||
|
||
# JSON-LD fields | ||
id: str = field( | ||
metadata=config(field_name="@id"), | ||
default_factory=lambda: "tst:Test2/" + str(uuid4()) | ||
) | ||
__type__: list[str] = field( | ||
metadata=config(field_name="@type"), | ||
default_factory = lambda: [ | ||
"tst:Test2", | ||
], | ||
) | ||
__context__: dict[str, str | dict] = field( | ||
metadata=config(field_name="@context"), | ||
default_factory = lambda: { | ||
"tst": "https://www.github.com/my/repo/", | ||
"schema": "http://schema.org/", | ||
"names": "schema:hello", | ||
"number": "schema:one", | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# AUTOGENERATED! DO NOT EDIT! | ||
|
||
from __future__ import annotations | ||
from typing import Dict, List, Optional | ||
from uuid import uuid4 | ||
|
||
from lxml.etree import _Element | ||
from pydantic import PrivateAttr, model_validator | ||
from pydantic_xml import attr, element | ||
|
||
import sdRDM | ||
from sdRDM.base.listplus import ListPlus | ||
from sdRDM.tools.utils import elem2dict | ||
|
||
|
||
class Test( | ||
sdRDM.DataModel, | ||
search_mode="unordered", | ||
): | ||
name: str = attr( | ||
tag="name", | ||
json_schema_extra=dict(term = "schema:hello",) | ||
) | ||
|
||
number: Optional[float] = attr( | ||
default=None, | ||
tag="number", | ||
json_schema_extra=dict(term = "schema:one",) | ||
) | ||
|
||
test2: List[Test2] = element( | ||
default_factory=ListPlus, | ||
tag="SomeTest2", | ||
json_schema_extra=dict(term = "schema:something",) | ||
) | ||
|
||
_repo: str = PrivateAttr(default="https://www.github.com/my/repo/") | ||
|
||
|
||
def add_to_test2( | ||
self, | ||
names: List[str], | ||
number: Optional[float], | ||
**kwargs, | ||
): | ||
params = { | ||
|
||
"names": names, | ||
"number": number | ||
} | ||
|
||
self.test2.append( | ||
Test2(**params) | ||
) | ||
|
||
return self.test2[-1] | ||
|
||
class Test2( | ||
sdRDM.DataModel, | ||
search_mode="unordered", | ||
): | ||
names: List[str] = element( | ||
default_factory=ListPlus, | ||
tag="name", | ||
json_schema_extra=dict(term = "schema:hello",) | ||
) | ||
|
||
number: Optional[float] = attr( | ||
default=None, | ||
tag="number", | ||
json_schema_extra=dict(term = "schema:one",) | ||
) | ||
|
||
_repo: str = PrivateAttr(default="https://www.github.com/my/repo/") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix tst: <https://www.github.com/my/repo/> . | ||
@prefix schema: <http://schema.org/> . | ||
|
||
|
||
tst:TestShape | ||
a sh:NodeShape ; | ||
sh:targetClass md:Test ; | ||
|
||
sh:property [ | ||
sh:path schema:hello ; | ||
sh:datatype xsd:string ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
|
||
]; | ||
sh:property [ | ||
sh:path schema:one ; | ||
sh:datatype xsd:double ; | ||
sh:minCount 0 ; | ||
sh:maxCount 1 ; | ||
|
||
]; | ||
sh:property [ | ||
sh:path schema:something ; | ||
sh:node md:Test2Shape ; | ||
sh:minCount 0 ; | ||
|
||
]. | ||
|
||
tst:Test2Shape | ||
a sh:NodeShape ; | ||
sh:targetClass md:Test2 ; | ||
|
||
sh:property [ | ||
sh:path schema:hello ; | ||
sh:datatype xsd:string ; | ||
sh:minCount 0 ; | ||
|
||
]; | ||
sh:property [ | ||
sh:path schema:one ; | ||
sh:datatype xsd:double ; | ||
sh:minCount 0 ; | ||
sh:maxCount 1 ; | ||
|
||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
PREFIX tst: <https://www.github.com/my/repo/> | ||
PREFIX schema: <http://schema.org/> | ||
|
||
tst:Test { | ||
schema:hello xsd:string; | ||
schema:one xsd:double?; | ||
schema:something @tst:Test2*; | ||
} | ||
tst:Test2 { | ||
schema:hello xsd:string*; | ||
schema:one xsd:double?; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
|
||
<!-- Roots --> | ||
<xs:element name="Test" type="TestType"/> | ||
<xs:element name="Test2" type="Test2Type"/> | ||
|
||
<!-- Test Definition --> | ||
<xs:complexType name="TestType"> | ||
<xs:sequence> | ||
<xs:element name="test2" type="Test2Type" maxOccurs="unbounded" /> | ||
</xs:sequence> | ||
<xs:attribute name="name" type="xs:string" use="required" /> | ||
<xs:attribute name="number" type="xs:float" /> | ||
</xs:complexType> | ||
|
||
<!-- Test2 Definition --> | ||
<xs:complexType name="Test2Type"> | ||
<xs:sequence> | ||
<xs:element name="names" type="xs:string" maxOccurs="unbounded" /> | ||
</xs:sequence> | ||
<xs:attribute name="number" type="xs:float" /> | ||
</xs:complexType> | ||
|
||
</xs:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters