from __future__ import annotations

from datetime import date, datetime
from typing import Any
from uuid import UUID, uuid4

from opensemantic.base.v1 import (
    DataTool,
    Device,
    Procedure,
    StrictParticipantsProcess,
    StrictParticipantsProcessType,
)
from opensemantic.core.v1 import (
    Category,
    Component,
    DataStatement,
    Description,
    DescriptionItem,
    DigitalDocument,
    Item,
    Keyword,
    LabelItem,
    LangCode,
    Location,
    Material,
    ObjectStatement,
    Person,
    PhysicalItem,
    PhysicalItemType,
    Process,
    Project,
    QuantityStatement,
    Tool,
    WikiFile,
)
from opensemantic.v1 import OswBaseModel
from pydantic.v1 import Field, constr

# generated by datamodel-codegen:
#   filename:  OSW182916df3eee472e88e7c8d114a7fe27.json


class MaterialType(PhysicalItemType):
    """
    Helps to create Material subcategories
    """

    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSWca99a9bb9ad24386b222d18a73c2af5e?action=raw&slot=jsonschema",
                {
                    "constituents": {
                        "@type": "@id",
                        "@id": "Property:HasStatement",
                        "@context": {
                            "property": "Property:HasProperty",
                            "type": "Property:HasValue",
                        },
                    }
                },
            ],
            "uuid": "182916df-3eee-472e-88e7-c8d114a7fe27",
            "title": "MaterialType",
            "title*": {"en": "Material Type"},
            "description": "Helps to create Material subcategories",
            "description*": {"en": "Helps to create Material subcategories"},
        }

    type: list[str] | None = ["Category:OSW182916df3eee472e88e7c8d114a7fe27"]
    constituents: list[Item] | None = Field(
        None,
        description_={"de": "Komponenten oder Teile"},
        title="Constituents",
        title_={"de": "Bestandteile"},
    )
    """
    Components or parts
    """


# generated by datamodel-codegen:
#   filename:  OSW31ca9a739cb24079b36824045c0832aa.json


# generated by datamodel-codegen:
#   filename:  OSW2afce49fe800460a95cf480cc0656757.json


class InChIItem(OswBaseModel):
    class Config:
        schema_extra = {"defaultProperties": ["inchi_id", "inchi_key"]}

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True})
    inchi_id: str = Field(..., title="InChI")
    inchi_key: str | None = Field(None, title="InChI key")


class ChemicalSubstanceType(MaterialType):
    """
    Helps to create subcategories of Chemical Substance.
    """

    class Config:
        schema_extra = {
            "@context": [
                {
                    "cas_numbers": {
                        "@id": "Property:HasCasNumber",
                        "@type": "xsd:string",
                    },
                    "inchi_id": {"@id": "Property:HasInchiId", "@type": "xsd:string"},
                    "inchi_key": {"@id": "Property:HasInchiKey", "@type": "xsd:string"},
                    "iupac_name": {
                        "@id": "Property:HasIupacName",
                        "@type": "xsd:string",
                    },
                    "molecular_weight": {
                        "@id": "Property:HasMolecularWeight",
                        "@type": "xsd:float",
                    },
                    "pubchem_cid": {
                        "@id": "Property:HasPubchemCid",
                        "@type": "xsd:string",
                    },
                    "pubchem_sid": {
                        "@id": "Property:HasPubchemSid",
                        "@type": "xsd:string",
                    },
                    "smiles_notation": {
                        "@id": "Property:HasSmilesNotation",
                        "@type": "xsd:string",
                    },
                    "sum_formula": {
                        "@id": "Property:HasSumFormula",
                        "@type": "xsd:string",
                    },
                },
                "/wiki/Category:OSW182916df3eee472e88e7c8d114a7fe27?action=raw&slot=jsonschema",
            ],
            "uuid": "2afce49f-e800-460a-95cf-480cc0656757",
            "title": "ChemicalSubstanceType",
            "title*": {
                "en": "Chemical Substance Type",
                "de": "Typ von Chemische Substanz",
            },
            "description": "Helps to create subcategories of Chemical Substance.",
            "description*": {
                "de": "Hilft dabei Subkategorien von chemischer Verbindung zu erzeugen."
            },
            "data_source_maps": [
                {
                    "id": "pubchem.ncbi.nlm.nih.gov",
                    "source": "https://pubchem.ncbi.nlm.nih.gov/rest/pug_view/data/compound/{{pubchem_cid}}/JSON",
                    "label": "PubChem",
                    "required": ["pubchem_cid"],
                    "object_map": {
                        "cas_numbers": "$..[?(@.TOCHeading=='CAS')].Information..Value.StringWithMarkup..String"
                    },
                }
            ],
            "defaultProperties": [
                "cas_numbers",
                "pubchem_cid",
                "iupac_name",
                "sum_formula",
                "molecular_weight",
            ],
        }

    type: list[str] | None = ["Category:OSW2afce49fe800460a95cf480cc0656757"]
    pubchem_cid: str | None = Field(
        None,
        description_={
            "de": "Die PubChem Compound Identifier (CID) ist eine eindeutige Identifikationsnummer, die von der PubChem-Datenbank für eine spezifische chemische Verbindung oder Substanz vergeben wird."
        },
        eval_template=[
            {
                "type": "mustache-wikitext",
                "mode": "render",
                "value": "[https://pubchem.ncbi.nlm.nih.gov/compound/{{pubchem_cid}} {{pubchem_cid}}]",
            }
        ],
        title="PubChem CID",
        title_={"de": "PubChem CID"},
    )
    """
    The PubChem Compound Identifier (CID) is a unique identifier assigned by the PubChem database to a specific chemical compound or substance.
    """
    cas_numbers: list[str] | None = Field(
        None,
        description_={
            "de": "Die CAS-Nummer (Chemical Abstracts Service) ist eine eindeutige Identifikationsnummer, die von der Chemical Abstracts Service für eine spezifische chemische Verbindung oder Substanz vergeben wird."
        },
        title="CAS Number",
        title_={"de": "CAS-Nummer"},
    )
    """
    The Chemical Abstracts Service (CAS) registry number is a unique identifier assigned by the Chemical Abstracts Service to a specific chemical compound or substance.
    """
    iupac_name: str | None = Field(
        None,
        description_={
            "de": "Der IUPAC-Name (International Union of Pure and Applied Chemistry) ist der systematische Name einer chemischen Substanz, wie er durch die IUPAC-Nomenklatur-Regeln definiert ist."
        },
        title="Preferred IUPAC name",
        title_={"de": "Bevorzugter IUPAC-Name"},
    )
    """
    The International Union of Pure and Applied Chemistry (IUPAC) name is the systematic name for a chemical substance, as defined by the IUPAC nomenclature rules.
    """
    pubchem_sid: str | None = Field(
        None,
        description_={
            "de": "Die PubChem Substance Identifier (SID) ist eine eindeutige Identifikationsnummer, die von der PubChem-Datenbank für eine spezifische chemische Substanz vergeben wird."
        },
        eval_template=[
            {
                "type": "mustache-wikitext",
                "mode": "render",
                "value": "[https://pubchem.ncbi.nlm.nih.gov/substance/{{pubchem_sid}} {{pubchem_sid}}]",
            }
        ],
        title="PubChem SID",
        title_={"de": "PubChem SID"},
    )
    """
    The PubChem Substance Identifier (SID) is a unique identifier assigned by the PubChem database to a specific chemical substance.
    """
    inchi: list[InChIItem] | None = Field(
        None,
        description_={
            "de": "Der International Chemical Identifier (InChI) ist ein Textbezeichner für chemische Stoffe, der eine Standardmethode zur Codierung molekularer Informationen bieten soll. Der verkürzte, 27 Zeichen umfassende InChIKey ist eine gehashte Version des vollständigen InChI"
        },
        eval_template=[
            {
                "type": "mustache-wikitext",
                "mode": "render",
                "value": "<ul>{{#inchi}}<li>InChI={{inchi_id}}, Key: {{inchi_key}}{{/inchi}}</ul>",
            }
        ],
        title="InChI",
    )
    """
    The International Chemical Identifier (InChI) is a textual identifier for chemical substances, designed to provide a standard way to encode molecular information. The condensed, 27 character InChIKey is a hashed version of the full InChI
    """
    smiles_notation: list[str] | None = Field(
        None,
        description_={
            "de": "Notation nach der SMILES-Formalsprache zur Beschreibung chemischer Strukturen. SMILES steht für Simplified Molecular Input Line Entry System."
        },
        title="SMILES notation",
        title_={"de": "SMILES-Notation"},
    )
    """
    Notation according to the SMILES formal language for describing chemical structures. SMILES stands for Simplified Molecular Input Line Entry System.
    """
    sum_formula: str | None = Field(
        None,
        description_={
            "de": "Die Summenformel ist eine Notation, die die Anzahl der Atome jedes Elements in einem Molekül angibt."
        },
        title="Summation formula",
        title_={"de": "Summenformel"},
    )
    """
    The sum formula is a notation that specifies the number of atoms of each element in a molecule.
    """
    molecular_weight: float | None = Field(
        None,
        description_={
            "de": "Das Molekulargewicht ist die Masse eines Moleküls, gemessen in Atommasseeinheiten (u)."
        },
        title="Molecular weight / g/mol",
        title_={"de": "Molekulargewicht / g/mol"},
    )
    """
    The molecular weight is the mass of a molecule, measured in atomic mass units (amu).
    """


# generated by datamodel-codegen:
#   filename:  OSW0583b134c618484c9911a3dff145c7eb.json


class Amount(OswBaseModel):
    """
    The amount of the component
    """

    class Config:
        schema_extra = {
            "title": "Amount",
            "title*": {"en": "Amount", "de": "Menge"},
            "description": "The amount of the component",
            "description*": {"de": "Die Menge der Komponente"},
            "$comment": "$rework: add unit",
            "defaultProperties": [
                "component_amount_numerical_value",
                "component_amount_unit",
            ],
        }

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True})
    component_amount_numerical_value: float = Field(
        ..., title="Numerical value", title_={"de": "Numerischer Wert"}
    )
    component_amount_unit: str = Field(..., title="Unit", title_={"de": "Unit"})
    component_amount_value: str = Field(
        ...,
        options={"hidden": True},
        template="{{num_val}} {{unit}}",
        watch={
            "num_val": "input_components_item_root.component_amount.component_amount_numerical_value",
            "unit": "input_components_item_root.component_amount.component_amount_unit",
        },
    )


class LabelItem1(OswBaseModel):
    class Config:
        schema_extra = {
            "@context": {
                "rdf": "http://www.w3.org/2000/01/rdf-schema#",
                "text": {"@id": "@value"},
                "lang": {"@id": "@language"},
            },
            "title": "Label",
            "eval_template": [
                {"type": "wikitext", "mode": "store", "value": "{{{text}}}@{{{lang}}}"}
            ],
        }

    text: constr(min_length=1) = Field(
        ...,
        options={
            "input_width": "800px",
            "inputAttributes": {"placeholder": "Title of the entry"},
            "inputAttributes*": {"de": {"placeholder": "Titel dieses Eintrags"}},
        },
        title="Text",
        title_={"de": "Text"},
    )
    lang: LangCode | None = Field(
        LangCode.en,
        default_={"en": "en", "de": "de"},
        options={"input_width": "100px"},
        title="Lang code",
        title_={"de": "Sprache"},
    )


class Component1(OswBaseModel):
    class Config:
        schema_extra = {
            "title": "Component",
            "title*": {"de": "Komponente"},
            "headerTemplate": "{{ i1 }} - {{ self.component_id }}",
            "defaultProperties": [],
        }

    uuid: UUID = Field(
        ...,
        dynamic_template="{{_uuid_}}",
        field_comment="format uuid field are copied, if not set in copy_ignore",
        field_template="dynamic_template",
        options={"hidden": True, "dynamic_template": {"override": "empty"}},
        title="UUID",
        title_={"de": "UUID"},
    )
    component_id: str = Field(
        ...,
        description_={"de": "Wird automatisch generiert"},
        dynamic_template="Component{{patternformat '00' _array_index_}}",
        field_comment="Will be used as a visual reference for the user",
        options={
            "hidden": True,
            "dynamic_template": {"override": "always"},
            "grid_columns": 6,
        },
        propertyOrder=10,
        readOnly=True,
        title="ID",
        title_={"de": "ID"},
    )
    """
    Automatically generated
    """
    label: list[LabelItem1] | None = Field(
        None,
        description_={
            "de": "Bezeichnung der Funktion oder Rolle der Komponente in diesem spezifischen Kontext."
        },
        eval_template={
            "type": "mustache-wikitext",
            "mode": "render",
            "value": "{{=<% %>=}} {{#switch:{{USERLANGUAGECODE}} <%={{ }}=%> {{#label}} |{{lang}}={{text}} {{/label}} {{=<% %>=}} }}",
        },
        options={"grid_columns": 12},
        propertyOrder=20,
        title="Label",
        title_={"de": "Bezeichnung"},
    )
    """
    Designation of the function or role of the component in this specific context.
    """
    description: list[DescriptionItem] | None = Field(
        None,
        description_={
            "de": "Optional, zusätzliche Angaben zur Rolle oder Funktion der Komponente in diesem spezifischen Kontext."
        },
        eval_template={
            "type": "mustache-wikitext",
            "mode": "render",
            "value": "{{=<% %>=}} {{#switch:{{USERLANGUAGECODE}} <%={{ }}=%> {{#description}} |{{lang}}={{text}} {{/description}} {{=<% %>=}} }}",
        },
        options={"grid_columns": 12},
        propertyOrder=30,
        title="Description",
        title_={"de": "Beschreibung"},
    )
    """
    Optional, additional details on the role or function of the component in this specific context.
    """
    component_type: Category | None = Field(
        default_factory=lambda: Category.parse_obj(
            "Category:OSWe427aafafbac4262955b9f690a83405d"
        ),
        options={
            "autocomplete": {
                "$comment": "Tool",
                "query": "[[:Category:OSWe427aafafbac4262955b9f690a83405d]]OR[[SubClassOf::Category:OSWe427aafafbac4262955b9f690a83405d]]OR[[SubClassOf.SubClassOf::Category:OSWe427aafafbac4262955b9f690a83405d]]OR[[SubClassOf.SubClassOf.SubClassOf::Category:OSWe427aafafbac4262955b9f690a83405d]]OR[[SubClassOf.SubClassOf.SubClassOf.SubClassOf::Category:OSWe427aafafbac4262955b9f690a83405d]]OR[[SubClassOf.SubClassOf.SubClassOf.SubClassOf.SubClassOf::Category:OSWe427aafafbac4262955b9f690a83405d]]",
            },
            "grid_columns": 12,
        },
        propertyOrder=40,
        range="Category:Category",
        title="Component type",
        title_={"de": "Typ der Komponente"},
        x_oold_required_iri=True,
    )
    component_instance_property: str | None = Field(
        "Property:HasPart", options={"hidden": True}
    )
    component_instance: Tool | None = Field(
        None,
        options={
            "autocomplete": {
                "query": "[[HasType::$(component_type_)]]|?Display_title_of=label|?HasImage=image|?HasDescription=description"
            },
            "grid_columns": 12,
        },
        propertyOrder=50,
        range="Category:OSWe427aafafbac4262955b9f690a83405d",
        title="Instance",
        title_={"de": "Instanz"},
        watch={"component_type_": "component.component_type"},
        x_oold_required_iri=True,
    )


class MixingProcess(Process):
    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSWe5aa96bffb1c4d95be7fbd46142ad203?action=raw&slot=jsonschema"
            ],
            "uuid": "29355236-8bcf-4a36-8168-2671f8d47d8f",
            "title": "MixingProcess",
            "title*": {"en": "Mixing process", "de": "Mischprozess"},
            "description": "",
            "description*": {},
        }

    type: list[str] | None = ["Category:OSW293552368bcf4a3681682671f8d47d8f"]


class ChemicalSubstance(Material):
    """
    Chemical substance composed of many identical molecules
    """

    class Config:
        schema_extra = {
            "@context": [
                {
                    "mixing_process": {
                        "@id": "Property:HasSourceProcess",
                        "@type": "@id",
                    },
                    "source_process": {"@type": "@id"},
                },
                "/wiki/Category:OSW31ca9a739cb24079b36824045c0832aa?action=raw&slot=jsonschema",
            ],
            "uuid": "0583b134-c618-484c-9911-a3dff145c7eb",
            "title": "ChemicalSubstance",
            "title*": {"en": "Chemical substance", "de": "Chemische Substanz"},
            "description": "Chemical substance composed of many identical molecules",
            "description*": {
                "en": "Chemical substance composed of many identical molecules",
                "de": "Chemische Substanz, die aus vielen identischen Molekülen besteht",
            },
            "defaultProperties": ["quantity_statements", "mixing_process"],
        }

    type: list[str] | None = ["Category:OSW0583b134c618484c9911a3dff145c7eb"]
    source_process_: str | None = Field(
        "",
        description_={
            "de": "Leere Eigenschaft zur Bereitstellung einer Eval-Vorlage für eine Abfrage"
        },
        eval_template=[
            {
                "type": "mustache-wikitext",
                "mode": "render",
                "value": "{{=<% %>=}} {{#ask:[[HasOutput::{{FULLPAGENAME}}]]|format=plain}}",
            }
        ],
        options={"hidden": True},
        title="Source process",
        title_={"de": "Quellprozess"},
    )
    """
    Empty property to provide an eval template for a query
    """
    mixing_process: MixingSourceProcess | None = Field(
        None,
        description_={
            "de": "Prozess, der das Mischen der Komponenten zur Herstellung dieser chemischen Substanz beschreibt. Weitere Einzelheiten des Mischvorgangs können angegeben werden."
        },
        eval_template=[
            {
                "type": "mustache-wikitext",
                "mode": "render",
                "value": "{{=<% %>=}}<ul><%#mixing_process.input_components%><li><%component_amount.component_amount_numerical_value%> <%component_amount.component_amount_unit%> [[<%component_instance%>]] ({{#switch:{{USERLANGUAGECODE}}|en=Type|de=Typ|#default=Type}}: {{#ask:[[<%component_instance%>]]|?HasType=|format=plain|mainlabel=-}})</li><%/mixing_process.input_componentss%></ul>",
            }
        ],
        title="Mixing (Source process)",
        title_={"de": "Mischen (Ursprungsprozess)"},
    )
    """
    Process that describes the mixing of components to create this chemical substance. Addtional details of the mixing process can be stated.
    """


class MixingOfChemicalSubstances(MixingProcess):
    """
    The process of mixing two or more chemical substances, creating a mixture of chemical substances (also an instance of Chemical Substance)
    """

    class Config:
        schema_extra = {
            "@context": [
                {
                    "input_components": {
                        "@id": "Property:HasStatement",
                        "@type": "@id",
                        "@context": {
                            "component_instance_property": "Property:HasProperty",
                            "component_instance": "Property:HasObject",
                        },
                    },
                    "output_mixes": {"@id": "Property:HasOutput", "@type": "@id"},
                },
                "/wiki/Category:OSW293552368bcf4a3681682671f8d47d8f?action=raw&slot=jsonschema",
            ],
            "uuid": "b8435fab-afcb-48f9-8542-2448e9df5faa",
            "title": "MixingOfChemicalSubstances",
            "title*": {
                "en": "Mixing of chemical substances",
                "de": "Mischen von chemischen Substanzen",
            },
            "description": "The process of mixing two or more chemical substances, creating a mixture of chemical substances (also an instance of Chemical Substance)",
            "description*": {
                "en": "The process of mixing two or more chemical substances, creating a mixture of chemical substances (also an instance of Chemical Substance)",
                "de": "Der Prozess des Mischens von zwei oder mehr chemischen Substanz, wodurch ein Gemisch chemischer Substanzen entsteht (ebenso eine Instanz von Chemischer Substanz)",
            },
            "defaultProperties": ["input_components", "output_mixes"],
        }

    type: list[str] | None = ["Category:OSWb8435fabafcb48f985422448e9df5faa"]
    input: list[Item] | None = Field(None, options={"hidden": True})
    output: list[Item] | None = Field(None, options={"hidden": True})
    input_components: list[Component] | None = Field(
        None,
        description_={"de": "Inputs des Mischprozesses"},
        eval_template=[
            {
                "type": "mustache-wikitext",
                "mode": "render",
                "value": "{{=<% %>=}}<ul><%#input_components%><li><%component_amount.component_amount_numerical_value%> <%component_amount.component_amount_unit%> [[<%component_instance%>]] ({{#switch:{{USERLANGUAGECODE}}|en=Type|de=Typ|#default=Type}}: {{#ask:[[<%component_instance%>]]|?HasType=|format=plain|mainlabel=-}})</li><%/input_componentss%></ul>",
            }
        ],
        title="Input components",
        title_={"de": "Input-Komponenten"},
    )
    """
    Input of the mixing process
    """
    output_mixes: list[ChemicalSubstance] | None = Field(
        None,
        range="Category:OSW0583b134c618484c9911a3dff145c7eb",
        title="Output mixes",
        title_={"de": "Ergebnis-Mischungen"},
    )


class MixingSourceProcess(MixingOfChemicalSubstances):
    """
    Process that describes the mixing of components to create this chemical substance. Addtional details of the mixing process can be stated.
    """

    class Config:
        schema_extra = {
            "title": "Mixing (Source process)",
            "title*": {"de": "Mischen (Ursprungsprozess)"},
            "description": "Process that describes the mixing of components to create this chemical substance. Addtional details of the mixing process can be stated.",
            "description*": {
                "de": "Prozess, der das Mischen der Komponenten zur Herstellung dieser chemischen Substanz beschreibt. Weitere Einzelheiten des Mischvorgangs können angegeben werden."
            },
            "eval_template": [
                {
                    "type": "mustache-wikitext",
                    "mode": "render",
                    "value": "{{=<% %>=}}<ul><%#mixing_process.input_components%><li><%component_amount.component_amount_numerical_value%> <%component_amount.component_amount_unit%> [[<%component_instance%>]] ({{#switch:{{USERLANGUAGECODE}}|en=Type|de=Typ|#default=Type}}: {{#ask:[[<%component_instance%>]]|?HasType=|format=plain|mainlabel=-}})</li><%/mixing_process.input_componentss%></ul>",
                }
            ],
        }

    input_components: list[dict[str, Any]] | None = Field(None, propertyOrder=-10)
    type: list[str] | None = Field(None, options={"hidden": True})
    label: list[LabelItem] = Field(..., options={"hidden": True})
    description: list[Description] | None = Field(
        None, description_={"de": "Beschreibung des Mischprozesses"}, propertyOrder=-9
    )
    """
    Description of the mixing process.
    """
    output_mixes: list[ChemicalSubstance] = Field(
        ..., max_items=1, min_items=1, options={"hidden": True}, readonly=True
    )


# generated by datamodel-codegen:
#   filename:  OSW25ab317fa369435797b7a92c9fd3bde6.json


class SampleType(MaterialType):
    """
    Type of a sample, e.g., the type number specified by the manufacturer
    """

    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSW182916df3eee472e88e7c8d114a7fe27?action=raw&slot=jsonschema",
                {
                    "height": "Property:HasHeight",
                    "width": "Property:HasWidth",
                    "length": "Property:HasLength",
                    "weight": "Property:HasWeight",
                },
            ],
            "uuid": "25ab317f-a369-4357-97b7-a92c9fd3bde6",
            "title": "SampleType",
            "title*": {"en": "Sample type", "de": "Probentyp"},
            "description": "Type of a sample, e.g., the type number specified by the manufacturer",
            "description*": {
                "en": "Type of a sample, e.g., the type number specified by the manufacturer",
                "de": "Typ einer Probe, z.B. die Typennummer wie vom Hersteller angegeben",
            },
        }

    type: list[str] | None = ["Category:OSW25ab317fa369435797b7a92c9fd3bde6"]
    height: float | None = Field(
        None,
        description_={"de": "Höhe der Probe in mm"},
        title="Height / mm",
        title_={"de": "Höhe / mm"},
    )
    """
    Height of the sample in mm
    """
    width: float | None = Field(
        None,
        description_={"de": "Breite der Probe in mm"},
        title="Width / mm",
        title_={"de": "Breite / mm"},
    )
    """
    Width of the sample in mm
    """
    length: float | None = Field(
        None,
        description_={"de": "Länge der Probe in mm"},
        title="Length / mm",
        title_={"de": "Länge / mm"},
    )
    """
    Length of the sample in mm
    """
    weight: float | None = Field(
        None,
        description_={"de": "Gewicht der Probe in g"},
        title="Weight / g",
        title_={"de": "Gewicht / g"},
    )
    """
    Weight of the sample in g
    """


# generated by datamodel-codegen:
#   filename:  OSW5c6f6eaaa96e4f84ad6f2ea02fc18ce4.json


class WeatherCondition(OswBaseModel):
    class Config:
        schema_extra = {
            "title": "Weather condition",
            "title*": {"de": "Wetterbedingung"},
            "defaultProperties": ["weather_date", "weather_description"],
        }

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
    weather_date: date = Field(
        ...,
        options={"flatpicker": {}},
        title="Report date",
        title_={"de": "Berichtsdatum"},
    )
    weather_description: Any = Field(
        ..., title="Description", title_={"de": "Beschreibung"}
    )


class SamplingPoint(OswBaseModel):
    """
    The location where the sample(s) was taken, including details.
    """

    class Config:
        schema_extra = {
            "title": "Sampling point",
            "title*": {"de": "Probennahmestelle"},
            "description": "The location where the sample(s) was taken, including details.",
            "description*": {
                "de": "Der Ort an dem die Probe(n) genommen wurde, inklusive Details."
            },
            "propertyOrder": 60,
            "defaultProperties": ["source", "weather", "sampling_point_notes"],
        }

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
    source: str | None = Field(
        None,
        description_={
            "de": "Die Quelle der Probe. Dies kann eine Organisationseinheit, ein Ort oder ein physisches Objekt sein."
        },
        options={
            "autocomplete": {
                "$comment": "Organizational unit, Location, Physical item",
                "query": "[[Category:OSW3cb8cef2225e403092f098f99bc4c472]] OR [[Category:OSW3d238d05316e45a4ac95a11d7b24e36b]] OR [[Category:OSW37a57741ae2e4dd4b29b1172b6848be8]]",
            }
        },
        title="Source",
        title_={"en": "Source", "de": "Quelle"},
    )
    """
    The source of the sample. This can be an organizational unit, a location, or a physical item.
    """
    source_name: str | None = Field(
        None,
        description_={
            "de": "Es wird empfohlen, eine Quelle aus dem Autocomplete-Feld 'Quelle' auszuwählen oder zu erstellen."
        },
        title="Source (text)",
        title_={"de": "Quelle (Text)"},
    )
    """
    Its prefered to select or create a source from or in the autocomplete field 'Source'.
    """
    weather: list[WeatherCondition] | None = Field(
        None,
        description_={"de": "Beschreibung der relevanten Wetterbedingungen."},
        title="Weather",
        title_={"de": "Wetter"},
    )
    """
    Description of relevant weather conditions.
    """
    sampling_point_notes: str | None = Field(
        None,
        description_={
            "de": "Notizen zu Besonderheiten und der Umgebung der Probennahmestelle."
        },
        title="Notes",
        title_={"de": "Notizen"},
    )
    """
    Notes about specifics and the surrounding of the sampling point.
    """


class SamplingDetails(OswBaseModel):
    """
    Details about the sampling process.
    """

    class Config:
        schema_extra = {
            "title": "Sampling details",
            "title*": {"de": "Probennahme-Details"},
            "description": "Details about the sampling process.",
            "description*": {"de": "Details zum Prozess der Probennahme."},
            "propertyOrder": 90,
            "defaultProperties": [
                "sampling_type",
                "sampling_execution",
                "conservation_bool",
                "conservation_details",
            ],
        }

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
    sampling_type: str = Field(
        ...,
        description_={"de": "Die Methode, die zur Probenahme verwendet wurde."},
        title="Sampling type",
        title_={"de": "Art der Probennahme"},
    )
    """
    The method used to take the sample.
    """
    sampling_execution: str = Field(
        ...,
        description_={"de": "Beschreibung des Prozesses der Probennahme."},
        title="Sampling execution",
        title_={"de": "Durchführung der Probennahme"},
    )
    """
    Description of the sampling process.
    """
    conservation_bool: bool | None = Field(
        False,
        description_={"de": "Wurde die Probe konserviert?"},
        title="Conservation",
        title_={"de": "Konservierung"},
    )
    """
    Was the sample conserved?
    """
    conservation_details: str | None = Field(
        None,
        description_={
            "de": "Beschreibung der Konservierungsmethode. Leer lassen, wenn 'keine'."
        },
        title="Conservation details",
        title_={"de": "Details zur Konservierung"},
    )
    """
    Description of the conservation method. Leave empty if 'none'.
    """


class SampleTransport(OswBaseModel):
    """
    Details about the transport of the sample.
    """

    class Config:
        schema_extra = {
            "title": "Sample transport",
            "title*": {"de": "Proben-Transport"},
            "description": "Details about the transport of the sample.",
            "description*": {"de": "Details zum Transport der Probe."},
            "propertyOrder": 27,
            "defaultProperties": ["transport_description", "transport_notes"],
        }

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
    transport_description: str | None = Field(
        None,
        description_={"de": "Beschreibung des Transportprozesses."},
        title="Description",
        title_={"de": "Beschreibung"},
    )
    """
    Description of the transport process.
    """
    transport_notes: str | None = Field(
        None,
        description_={"de": "Notizen zum Transportprozess."},
        title="Notes",
        title_={"de": "Notizen"},
    )
    """
    Notes about the transport process.
    """


class TakenSample(OswBaseModel):
    class Config:
        schema_extra = {
            "title": "Taken sample",
            "title*": {"de": "Genommene probe"},
            "defaultProperties": ["sample_type", "sample_instance"],
        }

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
    sample_type: Category | None = Field(
        default_factory=lambda: Category.parse_obj(
            "Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3"
        ),
        options={
            "autocomplete": {
                "$comment": "Sample",
                "query": "[[:Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3]] OR [[SubClassOf::Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3]] OR [[SubClassOf.SubClassOf::Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3]] OR [[SubClassOf.SubClassOf.SubClassOf::Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3]] OR [[SubClassOf.SubClassOf.SubClassOf.SubClassOf::Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3]]OR [[SubClassOf.SubClassOf.SubClassOf.SubClassOf.SubClassOf::Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3]]",
            }
        },
        range="Category:Category",
        title="Type",
        title_={"de": "Typ"},
    )
    sample_instance_property: str | None = Field(
        "Property:HasOutput", options={"hidden": True}
    )
    sample_instance: Sample | None = Field(
        None,
        options={
            "autocomplete": {"$comment": "Sample", "query": "[[$(sample_type_)]]"}
        },
        range="Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3",
        title="Instance",
        title_={"de": "Instanz"},
        watch={"sample_type_": "sample_item.sample_type"},
        x_oold_required_iri=True,
    )


class Statement(OswBaseModel):
    class Config:
        schema_extra = {
            "@context": {
                "Property": "https://wiki-dev.open-semantic-lab.org/id/Property-3A",
                "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
                "subject*": "Property:HasSubject",
                "subject": "rdf:subject",
                "predicate*": "Property:HasProperty",
                "predicate": "rdf:predicate",
                "property*": "Property:HasProperty",
                "property": "rdf:predicate",
                "quantity*": "Property:HasProperty",
                "quantity": "rdf:predicate",
                "object*": "Property:HasObject",
                "object": "rdf:object",
                "value*": "Property:HasObject",
                "value": "rdf:object",
                "unit": "Property:HasUnit",
                "substatements": "Property:HasStatement",
                "label*": "Property:HasLabel",
                "label": "rdfs:label",
            },
            "headerTemplate": "... {{#if self.predicate}}{{self.predicate}}{{/if}}{{#if self.property}}{{self.property}}{{/if}}{{#if self.quantity}}{{self.quantity}}{{/if}} ...",
            "options": {"display_required_only": True},
        }

    __root__: ObjectStatement | DataStatement | QuantityStatement = Field(
        ...,
        field_context={
            "Property": "https://wiki-dev.open-semantic-lab.org/id/Property-3A",
            "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
            "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
            "subject*": "Property:HasSubject",
            "subject": "rdf:subject",
            "predicate*": "Property:HasProperty",
            "predicate": "rdf:predicate",
            "property*": "Property:HasProperty",
            "property": "rdf:predicate",
            "quantity*": "Property:HasProperty",
            "quantity": "rdf:predicate",
            "object*": "Property:HasObject",
            "object": "rdf:object",
            "value*": "Property:HasObject",
            "value": "rdf:object",
            "unit": "Property:HasUnit",
            "substatements": "Property:HasStatement",
            "label*": "Property:HasLabel",
            "label": "rdfs:label",
        },
        headerTemplate="... {{#if self.predicate}}{{self.predicate}}{{/if}}{{#if self.property}}{{self.property}}{{/if}}{{#if self.quantity}}{{self.quantity}}{{/if}} ...",
        options={"display_required_only": True},
    )


class LaboratoryProcess(StrictParticipantsProcess):
    """
    Contains notes and data about experiments
    """

    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSWfa0d5710bc0f45819b61b65fc4fd9656?action=raw&slot=jsonschema",
                {
                    "analyzed_data_files": {
                        "@id": "Property:HasAnalyzedDataFile",
                        "@type": "@id",
                    },
                    "keywords": {"@id": "Property:HasKeyword"},
                    "prior_risk_assessment": {
                        "@id": "Property:HasRiskAssessment",
                        "@type": "@id",
                    },
                    "project": {"@id": "Property:HasProject", "@type": "@id"},
                    "raw_data_files": {
                        "@id": "Property:HasRawDataFile",
                        "@type": "@id",
                    },
                },
            ],
            "uuid": "0e7fab22-62fb-4427-ad0f-a454bc868a0d",
            "title": "LaboratoryProcess",
            "title*": {"de": "Laborprozess", "en": "Laboratory process"},
            "description": "Contains notes and data about experiments",
            "description*": {
                "de": "Enthält Notizen und Daten über Experimente",
                "en": "Contains notes and data about experiments",
            },
        }

    type: list[str] | None = ["Category:OSW0e7fab2262fb4427ad0fa454bc868a0d"]
    collection: bool | None = Field(
        None,
        description_={"de": "Stellt eine Sammlung von Laborbucheintragen dar."},
        title="Experiment-Collection",
        title_={"de": "Experiment/Versuchsreihe"},
    )
    display_id: bool | None = Field(
        None,
        description_={
            "de": "ID hinter dem Namen einblenden. Falls kein Name vorhanden ist wird immer die ID angezeigt."
        },
        title="Include ID in name",
        title_={"de": "ID im Namen anzeigen"},
    )
    """
    Display ID in name. If no name is present, the ID is always displayed
    """
    project: str | None = Field(
        None,
        description_={
            "de": "Zugeordnetes Projekt. Von diesem werden auch die Zugriffsrechte übernommen"
        },
        options={
            "autocomplete": {"category": "Category:OSWb2d7e6a2eff94c82b7f1f2699d5b0ee3"}
        },
        title="Project",
        title_={"de": "Projekt"},
    )
    """
    Associated project. Access rights are inherited from this project
    """
    raw_data_files: list[WikiFile] | None = Field(
        None,
        description_={"de": "Datei, die die Rohdaten des Tests enthält"},
        range="Category:OSW11a53cdfbdc24524bf8ac435cbf65d9d",
        title="Raw data file",
        title_={"de": "Rohdatendatei"},
    )
    """
    File containing the raw data of the test
    """
    analyzed_data_files: list[WikiFile] | None = Field(
        None,
        description_={"de": "Datei, die die analysierten Daten des Tests enthält"},
        range="Category:OSW11a53cdfbdc24524bf8ac435cbf65d9d",
        title="Analyzed data file",
        title_={"de": "Analysedatei"},
    )
    """
    File containing the analyzed data of the test
    """
    prior_risk_assessment: str | None = Field(
        None,
        options={
            "autocomplete": {
                "query": "[[Category:OSW11a53cdfbdc24524bf8ac435cbf65d9d]] [[-HasOutput.HasSchema::Category:OSW3886740859ae459588fee73d3bb3c83e]] |?Display_title_of=label"
            }
        },
        title="Prior Risk Assessment",
        title_={"de": "Vorangegangene Gefährdungsbeurteilung"},
    )


class Sample(Material):
    """
    Material sample created in the lab or collected in the field
    """

    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSW31ca9a739cb24079b36824045c0832aa?action=raw&slot=jsonschema",
                {
                    "components*": "Property:HasStatement",
                    "predicate": {"@type": "@id", "@id": "Property:HasProperty"},
                    "object": {"@type": "@id", "@id": "Property:HasObject"},
                    "substatements": {"@type": "@id", "@id": "Property:HasStatement"},
                    "quantity": {"@type": "@id", "@id": "Property:HasProperty"},
                    "value": "Property:HasObject",
                    "unit": "Property:HasUnit",
                },
            ],
            "uuid": "88894b63-a51d-46b0-8b5b-4b05a6b1b3c3",
            "title": "Sample",
            "title*": {"en": "Sample", "de": "Probe"},
            "description": "Material sample created in the lab or collected in the field",
            "description*": {
                "en": "Material sample created in the lab or collected in the field",
                "de": "Im Labor erstellte oder im Feld gesammelte Materialprobe",
            },
        }

    type: list[str] | None = ["Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3"]
    components: list[Component1] | None = Field(
        None,
        eval_template={
            "type": "mustache-wikitext",
            "mode": "render",
            "value": "{{#components}} [[{{object}}]] {{#substatements}} {{value}} {{/substatements}} {{/components}} <br>",
        },
        title="Components / Constituents",
        title_={"de": "Bestandteile"},
    )
    statements: list[Statement] | None = None


class Sampling(LaboratoryProcess):
    """
    Process of taking a sample, e.g., filling a container from a reservoir (river, lake, larger container)
    """

    class Config:
        schema_extra = {
            "@context": [
                {
                    "conservation_bool": {
                        "@id": "Property:HasConservation",
                        "@type": "xsd:boolean",
                    },
                    "conservation_details": {
                        "@id": "Property:HasConservationDetails",
                        "@type": "xsd:string",
                    },
                    "output_samples": {
                        "@id": "Property:HasStatement",
                        "@type": "@id",
                        "@context": {
                            "sample_instance": "Property:HasObject",
                            "sample_instance_property": "Property:HasProperty",
                        },
                    },
                    "persons_present": {"@id": "Property:HasWitness", "@type": "@id"},
                    "sample_transport": {
                        "@id": "Property:HasSampleTransport",
                        "@type": "@id",
                    },
                    "sampling_details": {
                        "@id": "Property:HasSamplingDetails",
                        "@type": "@id",
                    },
                    "sampling_execution": {
                        "@id": "Property:HasSamplingExecution",
                        "@type": "xsd:string",
                    },
                    "sampling_point": {
                        "@id": "Property:HasSamplingPoint",
                        "@type": "@id",
                    },
                    "sampling_point_notes": {
                        "@id": "Property:HasNotes",
                        "@type": "xsd:string",
                    },
                    "sampling_type": {
                        "@id": "Property:HasSamplingType",
                        "@type": "xsd:string",
                    },
                    "source": {"@id": "Property:HasSource", "@type": "@id"},
                    "source_name": {"@id": "Property:HasSource", "@type": "xsd:string"},
                    "transport_description": {
                        "@id": "Property:HasTransportDescription",
                        "@type": "xsd:string",
                    },
                    "transport_notes": {
                        "@id": "Property:HasTransportNotes",
                        "@type": "xsd:string",
                    },
                    "weather": {
                        "@id": "Property:HasWeather",
                        "@type": "@id",
                        "@context": [
                            {
                                "weather_date": {
                                    "@id": "Property:HasDate",
                                    "@type": "xsd:dateTime",
                                },
                                "weather_description": {
                                    "@id": "Property:HasDescription",
                                    "@type": "xsd:string",
                                },
                            }
                        ],
                    },
                },
                "/wiki/Category:OSW0e7fab2262fb4427ad0fa454bc868a0d?action=raw&slot=jsonschema",
            ],
            "uuid": "01b854aa-5d15-40cc-be02-bb98de641892",
            "title": "Sampling",
            "title*": {"en": "Sampling", "de": "Probennahme"},
            "description": "Process of taking a sample, e.g., filling a container from a reservoir (river, lake, larger container)",
            "description*": {
                "en": "Process of taking a sample, e.g., filling a container from a reservoir (river, lake, larger container)",
                "de": "Der Prozess der Probennahme, z.B. das Befüllen eines Behälters aus einem Reservoir (Fluss, See, größerer Behälter)",
            },
            "defaultProperties": [
                "output_samples",
                "sampling_point",
                "sampling_details",
                "sample_transport",
                "actionees",
                "persons_present",
                "project",
                "location",
                "tool",
                "start_date_time",
            ],
        }

    type: list[str] | None = ["Category:OSW5c6f6eaaa96e4f84ad6f2ea02fc18ce4"]
    start_date_time: datetime | None = Field(
        None,
        description_={"de": "Tag und Uhrzeit an dem die Probenahme begonnen wurde."},
        propertyOrder=10,
        title="Date and time",
        title_={"de": "Datum und Uhrzeit"},
    )
    """
    The date and time when the sampling was started.
    """
    actionees: list[Person] | None = Field(
        None,
        description_={"de": "Person(en), welche die Probe(n) nimmt"},
        propertyOrder=20,
        title="Sampler(s)",
        title_={"de": "Probennehmer:innen"},
    )
    """
    Person(s) taking the sample(s)
    """
    persons_present: list[str] | None = Field(
        None,
        description_={
            "de": "Person(en), welche während der Probennahme anwesend waren."
        },
        propertyOrder=30,
        title="Persons present",
        title_={"de": "Anwesende Personen"},
    )
    """
    Person(s) present during sampling.
    """
    project: str | None = Field(None, propertyOrder=40)
    location: Location | None = Field(
        None,
        description_={
            "de": "Wo die Proben entnommen wurden, z. B. in einem Raum, einem Gebäude, einem Gewässer oder an einem geografischen Ort."
        },
        propertyOrder=50,
    )
    """
    Where the samples where taken, e.g., a room, a building, a body of water or some geolocation.
    """
    sampling_point: SamplingPoint | None = Field(
        None,
        defaultProperties=["source", "weather", "sampling_point_notes"],
        description_={
            "de": "Der Ort an dem die Probe(n) genommen wurde, inklusive Details."
        },
        propertyOrder=60,
        title="Sampling point",
        title_={"de": "Probennahmestelle"},
    )
    """
    The location where the sample(s) was taken, including details.
    """
    input: list[Item] | None = Field(
        None,
        description_={
            "de": "Verbrauchsmaterialien, die für den Prozess der Probennahme verwendet wurden."
        },
        propertyOrder=70,
    )
    """
    Consumption materials used for the sampling process.
    """
    tool: list[Tool] | None = Field(
        None,
        description_={
            "de": "Werkzeuge und Hilfsmittel, die für den Prozess der Probennahme verwendet wurden."
        },
        propertyOrder=80,
    )
    """
    Tools used for the sampling process.
    """
    sampling_details: SamplingDetails | None = Field(
        None,
        defaultProperties=[
            "sampling_type",
            "sampling_execution",
            "conservation_bool",
            "conservation_details",
        ],
        description_={"de": "Details zum Prozess der Probennahme."},
        propertyOrder=90,
        title="Sampling details",
        title_={"de": "Probennahme-Details"},
    )
    """
    Details about the sampling process.
    """
    output: list[Item] | None = Field(None, options={"hidden": True})
    output_samples: list[TakenSample] | None = Field(
        None,
        description_={"de": "Output der Probenahme."},
        eval_template=[
            {
                "type": "mustache-wikitext",
                "mode": "render",
                "value": "{{=<% %>=}} <ul><%#output_samples%><li>[[<%sample_instance%>]] ({{#switch:{{USERLANGUAGECODE}}|en=Type|de=Typ|#default=Type}}: {{#ask:[[<%sample_instance%>]]|?HasType=|format=plain|mainlabel=-}})</li><%/output_samples%></ul>",
            }
        ],
        title="Output samples",
        title_={"de": "Output-Proben"},
    )
    """
    Output of the sampling process.
    """
    sample_transport: SampleTransport | None = Field(
        None,
        defaultProperties=["transport_description", "transport_notes"],
        description_={"de": "Details zum Transport der Probe."},
        propertyOrder=27,
        title="Sample transport",
        title_={"de": "Proben-Transport"},
    )
    """
    Details about the transport of the sample.
    """


# generated by datamodel-codegen:
#   filename:  OSW88894b63a51d46b08b5b4b05a6b1b3c3.json


# generated by datamodel-codegen:
#   filename:  OSW29f0a4619cc243679e68b682d3bdb890.json


class GeoSample(Sample):
    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSW88894b63a51d46b08b5b4b05a6b1b3c3?action=raw&slot=jsonschema",
                {"location": {"@id": "Property:HasLocation", "@type": "@id"}},
            ],
            "uuid": "29f0a461-9cc2-4367-9e68-b682d3bdb890",
            "title": "GeoSample",
            "title*": {"en": "Geo Sample"},
            "description": "",
            "description*": {},
        }

    type: list[str] | None = ["Category:OSW29f0a4619cc243679e68b682d3bdb890"]
    location: str | None = Field(
        None,
        options={
            "autocomplete": {"category": "Category:OSW473d7a1ed48544d1be83b258b5810948"}
        },
        title="Sampling Site",
        title_={"de": "Entnahmeort"},
    )


# generated by datamodel-codegen:
#   filename:  OSW61d19dea4b9c4de8bcbde8036fc0e0a6.json


class LaboratoryProcessType(StrictParticipantsProcessType):
    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSW0b6e695c4bb74e9ea5aa7f5da3150653?action=raw&slot=jsonschema",
                {
                    "collection_default": {"@id": "Property:HasCollection"},
                    "keywords_default": {"@id": "Property:HasKeyword"},
                    "project_default": {"@id": "Property:HasProject", "@type": "@id"},
                    "project_default*": {"@id": "Property:BelongsTo", "@type": "@id"},
                },
            ],
            "uuid": "61d19dea-4b9c-4de8-bcbd-e8036fc0e0a6",
            "title": "LaboratoryProcessType",
            "title*": {"en": "Laboratory Process Type", "de": "Laborprozess-Typ"},
            "description": "",
            "description*": {},
        }

    type: list[str] | None = ["Category:OSW61d19dea4b9c4de8bcbde8036fc0e0a6"]
    collection_default: bool | None = Field(
        None,
        description_={"de": "Stellt eine Sammlung von Laborbucheinträgen dar."},
        title="Experiment Collection (default)",
        title_={"de": "Experiment/Versuchsreihe (Standardwert)"},
    )
    """
    This is a collection of ELN entries
    """
    display_id_default: bool | None = Field(
        None,
        description_={
            "de": "ID hinter dem Namen einblenden. Falls kein Name vorhanden ist wird immer die ID angezeigt."
        },
        title="Include ID in name (default)",
        title_={"de": "ID im Namen anzeigen (Standardwert)"},
    )
    """
    Show ID after the name. If there is no name, the ID is always displayed.
    """
    project_default: Project | None = Field(
        None,
        description_={
            "de": "Zugeordnetes Projekt. Von diesem werden auch die Zugriffsrechte übernommen"
        },
        range="Category:OSWb2d7e6a2eff94c82b7f1f2699d5b0ee3",
        title="Project (default)",
        title_={"de": "Projekt (Standardwert)"},
    )
    """
    Assigned project. The access rights are also taken from this project
    """
    keywords_default: list[Keyword] | None = Field(
        None,
        description_={"de": ""},
        range="Category:OSW09f6cdd54bc54de786eafced5f675cbe",
        title="Keywords (default)",
        title_={"de": "Schlagwörter (Standardwert)"},
    )


# generated by datamodel-codegen:
#   filename:  OSW0e7fab2262fb4427ad0fa454bc868a0d.json


# generated by datamodel-codegen:
#   filename:  OSW6cc7d1cc87dc4fa8935d5b3d2a9b55c5.json


class DUT(OswBaseModel):
    class Config:
        schema_extra = {
            "title": "DUT",
            "title*": {"de": "Testobjekt"},
            "defaultProperties": ["dut_type", "dut_default"],
            "eval_template": [
                {
                    "type": "wikitext",
                    "mode": "render",
                    "value": "{{#switch:{{USERLANGUAGECODE}}|en=Type|de=Typ|#default=Type}}: [[:{{{dut_type}}}]] {{#if: {{{dut_default|}}} | ({{#switch:{{USERLANGUAGECODE}}|en=default|de=Default|#default=default}}: [[{{{dut_default}}}]]) | ({{#switch:{{USERLANGUAGECODE}}|en=no default|de=Kein Default|#default=no default}})}}",
                }
            ],
        }

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
    dut_type: str | None = Field(
        None,
        options={
            "autocomplete": {
                "$comment": "todo: we need an any-subcategory-of shortcut",
                "query": "[[:Category:OSW37a57741ae2e4dd4b29b1172b6848be8]]OR[[SubClassOf::Category:OSW37a57741ae2e4dd4b29b1172b6848be8]]OR[[SubClassOf.SubClassOf::Category:OSW37a57741ae2e4dd4b29b1172b6848be8]]OR[[SubClassOf.SubClassOf.SubClassOf::Category:OSW37a57741ae2e4dd4b29b1172b6848be8]]OR[[SubClassOf.SubClassOf.SubClassOf.SubClassOf::Category:OSW37a57741ae2e4dd4b29b1172b6848be8]]OR[[SubClassOf.SubClassOf.SubClassOf.SubClassOf.SubClassOf::Category:OSW37a57741ae2e4dd4b29b1172b6848be8]]",
            }
        },
        title="Type",
        title_={"de": "Typ"},
    )
    dut_default: PhysicalItem | None = Field(
        None,
        options={"autocomplete": {"query": "[[$(dut_type_w)]]"}},
        range="Category:OSW37a57741ae2e4dd4b29b1172b6848be8",
        title="Default",
        title_={"de": "Standardwert"},
        watch={"dut_type_w": "dut_.dut_type"},
    )


class Tester(OswBaseModel):
    class Config:
        schema_extra = {
            "title": "Tester",
            "title*": {"de": "Tester"},
            "defaultProperties": [
                "tester_type",
                "tester_default",
                "tester_channel_default",
            ],
            "eval_template": [
                {
                    "type": "wikitext",
                    "mode": "render",
                    "$comment": "eval_template of tester_channel_default generates a string with trailing seperator, e.g. '1;2;3;'. To replace all but the last ';' with an ',' we apply #arraymap, with splits a string and merges the parts without a trailing seperator.",
                    "value": "{{#switch:{{USERLANGUAGECODE}}|en=Type|de=Typ|#default=Type}}: [[:{{{tester_type}}}]] {{#if: {{{tester_default|}}} | ({{#switch:{{USERLANGUAGECODE}}|en=default|de=Default|#default=default}}: [[{{{tester_default}}}]]{{#if: {{{tester_channel_default|}}} |, Ch: {{#arraymap:{{{tester_channel_default|}}}|;|x|x|, <nowiki />}} | |}}) | ({{#switch:{{USERLANGUAGECODE}}|en=no default|de=Kein Default|#default=no default}})}}",
                }
            ],
        }

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
    tester_type: str | None = Field(
        None,
        options={
            "autocomplete": {
                "$comment": "todo: we need an any-subcategory-of shortcut",
                "query": "[[:Category:OSWf0fe562f422d49c6877490b3dfee2f3f]]OR[[SubClassOf::Category:OSWf0fe562f422d49c6877490b3dfee2f3f]]OR[[SubClassOf.SubClassOf::Category:OSWf0fe562f422d49c6877490b3dfee2f3f]]OR[[SubClassOf.SubClassOf.SubClassOf::Category:OSWf0fe562f422d49c6877490b3dfee2f3f]]OR[[SubClassOf.SubClassOf.SubClassOf.SubClassOf::Category:OSWf0fe562f422d49c6877490b3dfee2f3f]]OR[[SubClassOf.SubClassOf.SubClassOf.SubClassOf.SubClassOf::Category:OSWf0fe562f422d49c6877490b3dfee2f3f]]",
            }
        },
        title="Type",
        title_={"de": "Typ"},
    )
    tester_default: Device | None = Field(
        None,
        options={"autocomplete": {"query": "[[$(tester_type_w)]]"}},
        range="Category:OSWf0fe562f422d49c6877490b3dfee2f3f",
        title="Default",
        title_={"de": "Standardwert"},
        watch={"tester_type_w": "tester_.tester_type"},
    )
    tester_channel_default: list[str] | None = Field(
        None,
        description_={"de": "Kanal/Kanäle, mit dem der Test durchgeführt wurde/wird"},
        eval_template=[
            {
                "type": "mustache-wikitext",
                "mode": "render",
                "value": "{{#tester_channel_default}}{{.}};{{/tester_channel_default}}",
            }
        ],
        title="Channel(s) (default)",
        title_={"de": "Kanal/Kanäle (Standardwert)"},
    )
    """
    Channel(s) used to perform the test
    """


class Procedure1(DigitalDocument):
    """
    Combination of several instructions or commands into a sequence or program
    """

    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSWafcac83979f4472298b6acdc01981728?action=raw&slot=jsonschema",
                {
                    "approver": {"@id": "Property:HasApprover", "@type": "@id"},
                    "contact": {"@id": "Property:HasContact", "@type": "@id"},
                    "creator": {"@id": "Property:HasCreator", "@type": "@id"},
                    "orderer": {"@id": "Property:HasOrderer", "@type": "@id"},
                    "procedure_files": {"@id": "Property:HasFile", "@type": "@id"},
                },
            ],
            "uuid": "e21775c8-dd60-4739-885d-fc24c32cc548",
            "title": "Procedure",
            "title*": {"en": "Procedure", "de": "Prozedure"},
            "description": "Combination of several instructions or commands into a sequence or program",
            "description*": {
                "en": "Combination of several instructions or commands into a sequence or program",
                "de": "Zusammenstellung mehrerer Anweisungen oder Befehle zu einer Abfolge oder Programm",
            },
            "defaultProperties": ["procedure_files"],
        }

    type: list[str] | None = ["Category:OSWe21775c8dd604739885dfc24c32cc548"]
    creator: str | None = Field(
        None,
        options={
            "autocomplete": {"category": "Category:OSW44deaa5b806d41a2a88594f562b110e9"}
        },
        title="Creator",
        title_={"de": "Ersteller"},
    )
    orderer: str | None = Field(
        None,
        description_={
            "de": "Interne(r) oder externe(r) Auftraggeber*in/Kund*in/anordnende Person oder Organisationseinheit"
        },
        options={
            "autocomplete": {
                "query": "[[Category:OSW44deaa5b806d41a2a88594f562b110e9]] OR [[HasType::Category:OSW3cb8cef2225e403092f098f99bc4c472]] |?Display_title_of=label"
            }
        },
        title="Orderer",
        title_={"de": "Auftraggeber*in"},
    )
    """
    Internal or external orderer/customer (person or organizational unit)
    """
    contact: str | None = Field(
        None,
        description_={"de": "Kontakt seitens Auftraggeber"},
        options={
            "autocomplete": {"category": "Category:OSW44deaa5b806d41a2a88594f562b110e9"}
        },
        title="Contact",
        title_={"de": "Ansprechpartner"},
    )
    """
    Contact person on the orderer side
    """
    approver: list[str] | None = Field(
        None,
        description_={
            "de": "Person oder Organisationseinheit, die das Ergebnis des Auftrag validiert und genehmigt"
        },
        title="Approver",
        title_={"de": "Genehmiger*in"},
    )
    """
    Person or organizational unit that validates the result of the process and approves
    """
    procedure_files: list[str] | None = Field(
        None,
        description_={
            "de": "Datei, welche die Prozedur enthält, normalerweise in einem herstellerspezifischen Format"
        },
        eval_template={
            "type": "mustache-wikitext",
            "mode": "render",
            "value": "{{=<% %>=}} <%={{ }}=%>  {{#procedure_files}}{{{.}}};{{/procedure_files}} {{=<% %>=}} <%={{ }}=%>",
        },
        options={"collapsed": True},
        title="Procedure file(s)",
        title_={"de": "Prozedur-Datei(en)"},
    )
    """
    File containing the procedure, usually in a vendor specific format
    """


class AnalyticalLaboratoryProcessType(LaboratoryProcessType):
    class Config:
        schema_extra = {
            "@context": [
                {
                    "device_under_test": {
                        "@id": "Property:HasStatement",
                        "@context": {
                            "dut_type": {"@id": "Property:HasDutType", "@type": "@id"},
                            "dut_default": {"@id": "Property:HasDut", "@type": "@id"},
                        },
                    },
                    "tester": {
                        "@id": "Property:HasStatement",
                        "@context": {
                            "tester_type": {
                                "@id": "Property:HasToolType",
                                "@type": "@id",
                            },
                            "tester_default": {
                                "@id": "Property:HasTool",
                                "@type": "@id",
                            },
                            "tester_channel_default": {
                                "@id": "Property:HasChannel",
                                "@type": "xsd:string",
                            },
                        },
                    },
                    "test_procedure": {
                        "@id": "Property:HasStatement",
                        "@context": {
                            "procedure_type": {
                                "@id": "Property:HasProcedureType",
                                "@type": "@id",
                            },
                            "tester_default": {
                                "@id": "Property:HasProcedure",
                                "@type": "@id",
                            },
                        },
                    },
                },
                "/wiki/Category:OSW61d19dea4b9c4de8bcbde8036fc0e0a6?action=raw&slot=jsonschema",
            ],
            "uuid": "6cc7d1cc-87dc-4fa8-935d-5b3d2a9b55c5",
            "title": "AnalyticalLaboratoryProcessType",
            "title*": {
                "en": "Analytical Laboratory Process Type",
                "de": "Analytischer Laborprozess-Typ",
            },
            "description": "",
            "description*": {},
            "defaultProperties": ["device_under_test", "tester", "test_procedure"],
        }

    type: list[str] | None = ["Category:OSW6cc7d1cc87dc4fa8935d5b3d2a9b55c5"]
    device_under_test: list[DUT] | None = Field(
        None,
        description_={"de": "Getestete(s) Objekt(e) (DUT)"},
        title="Device(s) under test (default)",
        title_={"de": "Testobjekt(e) (Standardwert)"},
    )
    """
    Tested device(s) (DUT)
    """
    tester: list[Tester] | None = Field(
        None,
        description_={"de": "Für den Test eingesetzte(s) Gerät(e)"},
        title="Tester(s) (default)",
        title_={"de": "Tester (Standardwert)"},
    )
    """
    Device(s) used for testing
    """
    test_procedure: list[Procedure] | None = Field(
        None,
        title="Test procedure(s) (default)",
        title_={"de": "Testprozedur(en) (Standardwert)"},
    )


class TestProcedure(Procedure1):
    """
    A combination of several instructions or command to test something, e.g. a device for a certain capability
    """

    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSWe21775c8dd604739885dfc24c32cc548?action=raw&slot=jsonschema"
            ],
            "uuid": "e2d16d21-532a-40cf-a0ab-e577629d5c37",
            "title": "TestProcedure",
            "title*": {"en": "Test procedure", "de": "Testprozedure"},
            "description": "A combination of several instructions or command to test something, e.g. a device for a certain capability",
            "description*": {
                "en": "A combination of several instructions or command to test something, e.g. a device for a certain capability",
                "de": "Eine Kombination aus mehreren Anweisungen oder Befehlen, um etwas zu testen, z. B. ein Gerät auf eine bestimmte Fähigkeit",
            },
        }

    type: list[str] | None = ["Category:OSWe2d16d21532a40cfa0abe577629d5c37"]


# generated by datamodel-codegen:
#   filename:  OSWfa914762adaa4665a63b6a77c3ea6eed.json


class TestSetup(OswBaseModel):
    class Config:
        schema_extra = {
            "defaultPropertiers": ["tester_instance", "tester_name", "tester_channel"]
        }

    uuid: UUID = Field(default_factory=uuid4, options={"hidden": True}, title="UUID")
    tester_instance: Device | None = Field(
        None,
        range="Category:OSWf0fe562f422d49c6877490b3dfee2f3f",
        title="Tester",
        x_oold_required_iri=True,
    )
    tester_instance_property: str | None = Field(
        "Property:HasTool", options={"hidden": True}
    )
    tester_name: str | None = Field(
        None,
        description_={
            "de": "Nur verwenden, wenn der Tesrer nicht referenziert werden kann."
        },
        title="Tester (name, alternatively)",
        title_={"de": "Tester (Name, alternativ)"},
    )
    """
    Use only if tester can't be referenced.
    """
    tester_channel: list[str] | None = Field(
        None,
        description_={"de": "Kanal/Kanäle, mit dem der Test durchgeführt wurde/wird"},
        title="Channel(s)",
        title_={"de": "Kanal/Kanäle"},
    )
    """
    Channel(s) used to perform the test
    """


class AnalyticalLaboratoryProcess(LaboratoryProcess):
    class Config:
        schema_extra = {
            "@context": [
                {
                    "device_under_test": {"@id": "Property:HasDut", "@type": "@id"},
                    "test_procedure": {
                        "@id": "Property:HasStatement",
                        "@context": {
                            "test_procedure_instance_property": "Property:HasProperty",
                            "test_procedure_instance": "Property:HasObject",
                            "test_procedure_instance*": {
                                "@id": "Property:HasProcedure",
                                "@type": "@id",
                            },
                            "test_procedure_subcategory": {
                                "@id": "Property:HasProcedureType",
                                "@type": "@id",
                            },
                        },
                    },
                    "test_procedure_name": {
                        "@id": "Property:HasProcedure",
                        "@type": "xsd:string",
                    },
                    "tester": {
                        "@id": "Property:HasStatement",
                        "@context": {
                            "tester_instance_property": "Property:HasProperty",
                            "tester_instance": "Property:HasObject",
                            "tester_instance*": {
                                "@id": "Property:HasTool",
                                "@type": "@id",
                            },
                            "tester_name": "Property:HasObject",
                            "tester_name*": {
                                "@id": "Property:HasTool",
                                "@type": "xsd:string",
                            },
                            "tester_channel": {
                                "@id": "Property:HasChannel",
                                "@type": "xsd:string",
                            },
                        },
                    },
                },
                "/wiki/Category:OSW0e7fab2262fb4427ad0fa454bc868a0d?action=raw&slot=jsonschema",
            ],
            "uuid": "fa914762-adaa-4665-a63b-6a77c3ea6eed",
            "title": "AnalyticalLaboratoryProcess",
            "title*": {
                "en": "Analytical Laboratory Process",
                "de": "Analytischer Laborprozess",
            },
            "description": "",
            "description*": {},
            "defaultProperties": [
                "device_under_test",
                "tester",
                "test_procedure",
                "test_procedure_name",
            ],
        }

    type: list[str] | None = ["Category:OSWfa914762adaa4665a63b6a77c3ea6eed"]
    device_under_test: list[PhysicalItem] | None = Field(
        None,
        description_={"de": "Getestete(s) Objekt(e)"},
        range="Category:OSW37a57741ae2e4dd4b29b1172b6848be8",
        title="Device(s) under test (DUT)",
        title_={"de": "Testobjekt(e) (DUT)"},
    )
    """
    Tested device(s)
    """
    tester: list[TestSetup] | None = Field(
        None,
        description_={
            "de": "Gerät(e) und Kanal, mit dem der Test durchgeführt wurde/wird"
        },
        title="Test setup(s)",
        title_={"de": "Test-Setup(s)"},
    )
    """
    Device(s) and channel(s) used to perform the test
    """
    test_procedure: list[Procedure] | None = Field(
        None, title="Test procedure(s)", title_={"de": "Testprozedur(en)"}
    )
    test_procedure_name: set[str] | None = Field(
        None,
        description_={
            "de": "Sollte nur verwendet werden, wenn die Testprozedur nicht referenziert werden kann!"
        },
        title="Test procedure(s) (name)",
        title_={"de": "Testprozedur(en) (Name)"},
    )
    """
    Should only be used if the testprocedure can't be referenced!
    """


# generated by datamodel-codegen:
#   filename:  OSW293552368bcf4a3681682671f8d47d8f.json


# generated by datamodel-codegen:
#   filename:  OSWb8435fabafcb48f985422448e9df5faa.json


# generated by datamodel-codegen:
#   filename:  OSWe2d16d21532a40cfa0abe577629d5c37.json


# generated by datamodel-codegen:
#   filename:  OSWe0572f2791844010962886b892970b4d.json


class ControlledEnvironment(Device):
    class Config:
        schema_extra = {
            "@context": [
                "/wiki/Category:OSWf0fe562f422d49c6877490b3dfee2f3f?action=raw&slot=jsonschema"
            ],
            "uuid": "e0572f27-9184-4010-9628-86b892970b4d",
            "title": "ControlledEnvironment",
            "title*": {"en": "Controlled environment", "de": "Kontrollierte Umgebung"},
            "description": "",
            "description*": {},
        }

    type: list[str] | None = ["Category:OSWe0572f2791844010962886b892970b4d"]


# generated by datamodel-codegen:
#   filename:  OSW156137fa74914572ad2998f7f6594bca.json


class DataDevice(Device, DataTool):
    class Config:
        schema_extra = {"title": "DataDevice"}

    type: list[str] | None = ["Category:OSW156137fa74914572ad2998f7f6594bca"]


AnalyticalLaboratoryProcess.update_forward_refs()
AnalyticalLaboratoryProcessType.update_forward_refs()
ChemicalSubstance.update_forward_refs()
ChemicalSubstanceType.update_forward_refs()
Component1.update_forward_refs()
ControlledEnvironment.update_forward_refs()
DUT.update_forward_refs()
DataDevice.update_forward_refs()
GeoSample.update_forward_refs()
LaboratoryProcess.update_forward_refs()
LaboratoryProcessType.update_forward_refs()
MaterialType.update_forward_refs()
MixingOfChemicalSubstances.update_forward_refs()
MixingProcess.update_forward_refs()
MixingSourceProcess.update_forward_refs()
Procedure1.update_forward_refs()
Sample.update_forward_refs()
SampleType.update_forward_refs()
Sampling.update_forward_refs()
TakenSample.update_forward_refs()
TestProcedure.update_forward_refs()
TestSetup.update_forward_refs()
Tester.update_forward_refs()
