# Auto generated from None by pythongen.py version: 0.2.1
# Generation date: 2019-09-19 07:02
# Schema: synopsis2
#
# id: http://example.org/sample/example1
# description:
# license:

from typing import Optional, List, Union, Dict, ClassVar
from dataclasses import dataclass
from biolinkml.utils.metamodelcore import empty_list, empty_dict, bnode
from biolinkml.utils.yamlutils import YAMLRoot
from biolinkml.utils.formatutils import camelcase, underscore, sfx
from rdflib import Namespace, URIRef
from biolinkml.utils.metamodelcore import Bool

metamodel_version = "1.4.1"


# Namespaces
EX = Namespace('http://example.org/model/')
FOAF = Namespace('http://xmlns.com/foaf/0.1/')
XSD = Namespace('http://www.w3.org/2001/XMLSchema#')
DEFAULT_ = EX


# Types
class String(str):
    type_class_uri = XSD.string
    type_class_curie = "xsd:string"
    type_name = "string"
    type_model_uri = EX.String


class Int(int):
    type_class_uri = XSD.integer
    type_class_curie = "xsd:integer"
    type_name = "int"
    type_model_uri = EX.Int


class Boolean(Bool):
    type_class_uri = XSD.boolean
    type_class_curie = "xsd:boolean"
    type_name = "boolean"
    type_model_uri = EX.Boolean


# Class references
class PersonId(str):
    pass


class FriendlyPersonId(PersonId):
    pass


@dataclass
class Person(YAMLRoot):
    """
    A person, living or dead
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = EX.Person
    class_class_curie: ClassVar[str] = "ex:Person"
    class_name: ClassVar[str] = "person"
    class_model_uri: ClassVar[URIRef] = EX.Person

    id: Union[str, PersonId]
    last_name: str
    first_name: List[str] = empty_list()
    age: Optional[int] = None
    living: Optional[Bool] = None
    knows: List[Union[str, PersonId]] = empty_list()

    def __post_init__(self):
        if self.id is None:
            raise ValueError(f"id must be supplied")
        if not isinstance(self.id, PersonId):
            self.id = PersonId(self.id)
        if self.last_name is None:
            raise ValueError(f"last_name must be supplied")
        self.knows = [v if isinstance(v, PersonId)
                      else PersonId(v) for v in self.knows]
        super().__post_init__()


@dataclass
class FriendlyPerson(Person):
    """
    Any person that knows someone
    """
    _inherited_slots: ClassVar[List[str]] = []

    class_class_uri: ClassVar[URIRef] = EX.FriendlyPerson
    class_class_curie: ClassVar[str] = "ex:FriendlyPerson"
    class_name: ClassVar[str] = "friendly_person"
    class_model_uri: ClassVar[URIRef] = EX.FriendlyPerson

    id: Union[str, FriendlyPersonId] = None
    last_name: str = None
    knows: List[Union[str, PersonId]] = empty_list()

    def __post_init__(self):
        if self.id is None:
            raise ValueError(f"id must be supplied")
        if not isinstance(self.id, FriendlyPersonId):
            self.id = FriendlyPersonId(self.id)
        if not isinstance(self.knows, list) or len(self.knows) == 0:
            raise ValueError(f"knows must be a non-empty list")
        self.knows = [v if isinstance(v, PersonId)
                      else PersonId(v) for v in self.knows]
        super().__post_init__()

<img src="http://yuml.me/diagram/nofunky;dir:TB/class/[Person]<knows 0..*- [Person|id:string;first_name:string *;last_name:string;age:int %3F;living:boolean %3F], [FriendlyPerson|id(i):string;first_name(i):string *;last_name(i):string;age(i):int %3F;living(i):boolean %3F]- knows 1..*>[Person], [Person]^-[FriendlyPerson]"/>

-----
http://yuml.me/diagram/nofunky;dir:TB/class/[Person]<knows 0..*- [Person|id:string;first_name:string *;last_name:string;age:int %3F;living:boolean %3F], [FriendlyPerson|id(i):string;first_name(i):string *;last_name(i):string;age(i):int %3F;living(i):boolean %3F]- knows 1..*>[Person], [Person]^-[FriendlyPerson]

{
   "_comments": "Auto generated from None by jsonldcontextgen.py version: 0.1.1\nGeneration date: 2019-09-19 07:02\nSchema: synopsis2\n\nid: http://example.org/sample/example1\ndescription: \nlicense: \n",
   "@context": {
      "_comments": null,
      "type": "@type",
      "foaf": "http://xmlns.com/foaf/0.1/",
      "xsd": "http://www.w3.org/2001/XMLSchema#",
      "@vocab": "http://example.org/model/",
      "age": {
         "@type": "xsd:integer",
         "@id": "foaf:age"
      },
      "first_name": {
         "@id": "foaf:firstName"
      },
      "id": "@id",
      "knows": {
         "@type": "@id",
         "@id": "foaf:knows"
      },
      "last_name": {
         "@id": "foaf:lastName"
      },
      "living": {
         "@type": "xsd:boolean"
      },
      "@base": "http://example.org/context/"
   }
}
BASE <http://example.org/model/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>


<String> xsd:string

<Int> xsd:integer

<Boolean> xsd:boolean

<FriendlyPerson> CLOSED {
    (  $<FriendlyPerson_tes> (  &<Person_tes> ;
          rdf:type [ <Person> ] ? ;
          <knows> @<Person> +
       ) ;
       rdf:type [ <FriendlyPerson> ]
    )
}

<Person>  (
    CLOSED {
       (  $<Person_tes> (  foaf:firstName @<String> * ;
             foaf:lastName @<String> ;
             foaf:age @<Int> ? ;
             <living> @<Boolean> ? ;
             foaf:knows @<Person> *
          ) ;
          rdf:type [ <Person> ]
       )
    } OR @<FriendlyPerson>
)



Person(id='42', last_name='smith', first_name=['Joe', 'Bob'], age=43, living=None, knows=[])
{
   "id": "42",
   "last_name": "smith",
   "first_name": [
      "Joe",
      "Bob"
   ],
   "age": 43,
   "living": null,
   "knows": [],
   "type": "Person",
   "_comments": "Auto generated from None by jsonldcontextgen.py version: 0.1.1\nGeneration date: 2019-09-19 07:02\nSchema: synopsis2\n\nid: http://example.org/sample/example1\ndescription: \nlicense: \n",
   "@context": {
      "_comments": null,
      "type": "@type",
      "foaf": "http://xmlns.com/foaf/0.1/",
      "xsd": "http://www.w3.org/2001/XMLSchema#",
      "@vocab": "http://example.org/model/",
      "age": {
         "@type": "xsd:integer",
         "@id": "foaf:age"
      },
      "first_name": {
         "@id": "foaf:firstName"
      },
      "id": "@id",
      "knows": {
         "@type": "@id",
         "@id": "foaf:knows"
      },
      "last_name": {
         "@id": "foaf:lastName"
      },
      "living": {
         "@type": "xsd:boolean"
      },
      "@base": "http://example.org/context/"
   }
}
@prefix : <http://example.org/model/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/context/42> a :Person ;
    foaf:age 43 ;
    foaf:firstName "Bob",
        "Joe" ;
    foaf:lastName "smith" .


  Shape: http://example.org/sample/example1/Person not found in Schema
