# Auto-generated from iotic-rdf-ontology repository, iotics/iotics. Edits will be overwritten!

PREFIX geo:     <http://www.opengis.net/ont/geosparql#>
PREFIX iotics:    <http://data.iotics.com/iotics#>
PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
PREFIX sf:      <http://www.opengis.net/ont/sf#>
PREFIX sh:      <http://www.w3.org/ns/shacl#>
PREFIX xsd:     <http://www.w3.org/2001/XMLSchema#>
# Copyright (c) 2022 Iotic Labs Ltd. All rights reserved.

###############################################################################
# IOTICS Resource Ontology - Validation Shapes                                #
###############################################################################



iotics:DefaultLocatedTwinShape
    a sh:NodeShape ;
    sh:description "Twins can have an optional default single-point location"@en ;
    sh:targetClass iotics:DigitalTwin ;
    sh:property [
        # subclass of geo:hasGeometry
        sh:path geo:hasDefaultGeometry ;
        sh:and (
            # subclass of geo:Geometry
            [ sh:class sf:Point ]
            [ sh:node iotics:WKTPointLocatedShape ]
        ) ;
        sh:minCount 0 ;
        sh:maxCount 1 ;
    ] .

iotics:WKTPointLocatedShape
    a sh:NodeShape ;
    sh:property [
        # subclass of geo:hasSerialization
        sh:path geo:asWKT ;
        sh:datatype geo:wktLiteral ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] .

iotics:NamedPointShape
    a sh:NodeShape ;
    sh:description "Points must have exactly one name, which must be a string with at least one non-whitespace character"@en ;
    sh:targetClass iotics:Point ;
    sh:property [
        sh:path iotics:pointName ;
        sh:datatype xsd:string ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
        sh:minLength  1 ;
        sh:pattern "\\S" ;
    ] .

iotics:LabelShape
    sh:description "Labels must be no longer than 128 chars, cannot start or end with whitespace, and must have unique languages."@en ;
    sh:datatype xsd:string ;
    sh:pattern "^\\S(.{0,126}\\S)?$" ;
    sh:uniqueLang true ;
    .

iotics:LabelledShape
    a sh:NodeShape ;
    sh:description "Labels must be between 1 and 128 characters long, and cannot start or end with whitespace."@en ;
    sh:targetClass iotics:DigitalTwin, iotics:Point ;
    sh:property [
        sh:path rdfs:label ;
        sh:node iotics:LabelShape
    ] .

iotics:CommentedShape
    a sh:NodeShape ;
    sh:description "Comments must be between 1 and 1024 characters long, and cannot start or end with whitespace. Newlines are ok."@en ;
    sh:targetClass iotics:DigitalTwin, iotics:Point, iotics:Value ;
    sh:property [
        sh:path rdfs:comment ;
        sh:datatype xsd:string ;
        sh:pattern "(?s)^\\S(.{0,1022}\\S)?$" ;
        sh:uniqueLang true;
    ] .

iotics:ValueShape
    a sh:NodeShape ;
    sh:description """Values must have exactly one valueKey property with the same restrictions as a label, and most one valueUnit
        property that is a URI not longer than 128 characters."""@en ;
    sh:targetClass iotics:Value ;
    sh:property [
        sh:path iotics:valueKey ;
        sh:node iotics:LabelShape ;
        sh:minCount 1 ;
        sh:maxCount 1 ;
    ] ;
    sh:property [
        sh:path iotics:valueUnit ;
        sh:datatype xsd:anyURI ;
        sh:maxCount 1 ;
        sh:maxLength 128 ;
    ] .


# Copyright (c) 2021 Iotic Labs Ltd. All rights reserved.

###############################################################################
# IOTICS Resource Ontology                                                    #
###############################################################################



## Base ontology for IOTICS Digital Twins and the data they share.

iotics:DigitalTwin
    a rdfs:Class ;
    rdfs:label "IOTICS Digital Twin"@en ;
    rdfs:comment "A virtual representation of a real asset, device, concept or person in an IOTICSpace"@en ;
    .

iotics:HostTwin
    a rdfs:Class ;
    rdfs:subClassOf iotics:DigitalTwin ;
    rdfs:label "IOTICS Host Twin"@en ;
    rdfs:comment "The Digital Twin of an IOTICS Host"@en ;
    .

iotics:advertises
    a rdf:Property ;
    rdfs:label "Advertises"@en ;
    rdfs:comment "This property lists (advertises) what mechanisms (points) the Digital Twin has to interact with other Twins"@en ;
    rdfs:domain iotics:DigitalTwin ;
    rdfs:range iotics:Point ;
    .

iotics:updatedAt
    a rdf:Property ;
    rdfs:label "updatedAt"@en ;
    rdfs:comment """The date on which an IOTICS Digital Twin, or any of its feeds
        or inputs was updated, including updates which do not otherwise modify the
        Digital Twin, its feeds or inputs. Also applies to Circles.
        """@en ;
    rdfs:domain iotics:DigitalTwin, iotics:Circle ;
    rdfs:range xsd:dateTime ;
    .

iotics:Point
    a rdfs:Class ;
    rdfs:label "IOTICS Point"@en ;
    rdfs:comment """A means by which an IOTICS Digital Twin may interact with other twins, either outbound or inbound.
        Metadata describing the payload of the point is available when the point is described and therefore separate to the
        payload data. Interactions with the point are brokered and secured according to policies controlled by the twin."""@en ;
    .

iotics:pointName
    # we need to capture here the restructions:
    # - a twin can't have two different feeds with the same pointName
    # - a feed can't have two or more  pointName properties
	a rdf:Property ;
    rdfs:label "IOTICS Point name"@en ;
    rdfs:comment "The name of the point. This must be unique per Digital Twin (for a given point type, e.g. Feed)."@en ;
	rdfs:domain iotics:Point ;
	rdfs:range xsd:string ;
	.

iotics:Feed
    a rdfs:Class ;
    rdfs:subClassOf iotics:Point ;
    rdfs:label "IOTICS Data Feed"@en ;
    rdfs:comment """A feed of data advertised by an IOTICS Digital Twin, used by the twin to broadcast values.
        Authorised twins following this feed receive data when published"""@en ;
    .

iotics:storesLast
    a rdf:Property ;
    rdfs:label "Stores last published payload"@en ;
    rdfs:comment "Whether most recent published payload might be available on this feed."@en ;
    rdfs:domain iotics:Feed ;
    rdfs:range xsd:boolean ;
    .

iotics:Input
    a rdfs:Class ;
    rdfs:subClassOf iotics:Point ;
    rdfs:label "IOTICS Input"@en ;
    rdfs:comment """By advertising an input, an IOTICS Digital Twin allows authorised twins to send messages whose meaning
    might be described by the properties of the input itself and of its payload.
    For example, inputs can be used to send commands to change the state of the underlying asset or to send messages
    that can be interpreted by the twin to implement request/response exchanges."""@en ;
    .

iotics:Value
    a rdfs:Class ;
    rdfs:label "IOTICS Payload Value"@en ;
    rdfs:comment "A semantic description of a Value used by Points when communicating data"@en ;
    .

iotics:valueKey
    a rdf:Property ;
    rdfs:subPropertyOf rdfs:label ;
    rdfs:label "Value Key"@en ;
    rdfs:comment "Unique identifier for this Value among those offered by its Point."@en ;
    rdfs:domain iotics:Value ;
    .

iotics:valueType
    a rdf:Property ;
    rdfs:label "Value Type"@en ;
    rdfs:comment "The xsd datatype of the Value, e.g. xsd:decimal. See https://www.w3.org/TR/rdf11-concepts/#xsd-datatypes"@en ;
    rdfs:domain iotics:Value ;
    # is there a way to restrct the range to some ontology that captures the xsd data types?
    .

iotics:valueUnit
    a rdf:Property ;
    rdfs:label "Value Unit"@en ;
    rdfs:comment "The unit of the value, e.g. obo:UO_0000027 representing Celsius degrees"@en ;
    rdfs:domain iotics:Value ;
    .

iotics:presents
    a rdf:Property ;
    rdfs:label "Presents"@en ;
    rdfs:comment """The property defining what values compose the payload of this point. For example, a feed for a weather station
        may have a payload with two values representing temperature and pressure defined as iotics:Value resources."""@en ;
    rdfs:domain iotics:Point ;
    rdfs:range iotics:Value ;
    .

iotics:Circle
    a rdf:Class
    rdfs:label "IOTICS Circle"@en ;
    rdfs:comment """A collection of access control (allow list) rules. Both data and metadata rule can be defined, scoped
        to any number of hosts. A circle can be applied to one or more twins. (see http://data.iotics.com/public#isInCircle)
        """@en ;
    .