PREFIX : <https://w3id.org/itsdata/time/v1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX cdm1: <https://w3id.org/citydata/part1/v1/>
PREFIX cdm2: <https://w3id.org/citydata/part2/v1/>
PREFIX its-core: <https://w3id.org/itsdata/core/v1/>
PREFIX its-sh: <https://w3id.org/itsdata/shacl/v1/>
PREFIX time: <http://www.w3.org/2006/time#>

:ScheduleSHACL a owl:Ontology;
    # Ontology metadata
    dcterms:title                  "Time Ontology for ITS - Schedule - SHACL Rules"@en;
    skos:definition                "This ontology defines the SHACL rules for concepts related to schedules within Intelligent Transportation Systems (ITS)."@en;
    dcterms:license                "http://creativecommons.org/licenses/by/4.0/";
    its-core:draft                 "true";
    
    #Provenance metadata
    dcterms:creator                "Kenneth Vaughn";
    dcterms:created                "Draft";
    dcterms:modified               "2026-04-23"^^xsd:date .

:CalendarWeekWithinMonthShape a sh:NodeShape ;
    sh:targetClass :CalendarWeekWithinMonth ;
    sh:property [
        sh:path :applicableWeek ;
        sh:minCount 1 ;
        sh:maxCount 6 ;
        sh:class :WeekCode ;
        sh:message "applicableWeek must be a code indicating the week of the month, clearly indicating when each week starts and ends." ;
    ] ;
    sh:property [
        sh:path :reverseInstance ;
        sh:node its-sh:MaxOneShape ;
        sh:datatype xsd:boolean ;
    ] .

:DateWithinMonthShape a sh:NodeShape ;
    sh:targetClass :DateWithinMonth ;
    sh:property [
        sh:path :applicableDayOfMonth ;
        sh:minCount 1 ;
        sh:maxCount 31 ;
        sh:datatype xsd:integer ;
        sh:minInclusive 1 ;
        sh:maxInclusive 31 ;
        sh:message "At least one and at most thirty-one values are allowed." ;
    ] .

:DayWeekMonthShape a sh:NodeShape ;
    sh:targetClass :DayWeekMonth ;
    sh:property [
        sh:path time:hasTRS ;
        sh:node its-sh:ExactlyOneShape ;
        sh:hasValue <http://www.opengis.net/def/uom/ISO-8601/0/Gregorian> ;
    ] ;
    sh:property [
        sh:path time:timeZone ;
        sh:node its-sh:ExactlyOneShape ;
    ] ;
    sh:property [
        sh:path :applicableDayOfWeek ;
        sh:minCount 1 ;
        sh:maxCount 7 ;
        skos:editorialNote  "DATEX II limited to 0..7";
        sh:class time:DayOfWeek ;
        sh:message "At least one and at most seven values are allowed." ;
    ] ;
    sh:property [
        sh:path :applicableMonth ;
        sh:minCount 1 ;
        sh:maxCount 12 ;
        skos:editorialNote  "DATEX II limited to 0..12";
        sh:class time:MonthOfYear ;
        sh:message "At least one and at most twelve values are allowed." ;
    ] .

:InstanceOfDayWithinMonthShape a sh:NodeShape ;
    sh:targetClass :InstanceOfDayWithinMonth ;
    sh:property [
        sh:path :applicableInstanceOfDayWithinMonth ;
        sh:minCount 1 ;
        sh:maxCount 5 ;
        sh:datatype xsd:nonNegativeInteger ;
        sh:message "At least one and at most five values are allowed." ;
    ] ;
    sh:property [
        sh:path :reverseInstance ;
        sh:node its-sh:MaxOneShape ;
        sh:datatype xsd:boolean ;
    ] .

:OverallPeriodShape a sh:NodeShape ;
    sh:targetClass :OverallPeriod ;
    sh:property [
        sh:path :overallStartTime ;
        sh:node its-sh:ExactlyOneShape ;
        sh:datatype xsd:dateTime ;
    ] ;
    sh:property [
        sh:path :overallEndTime ;
        sh:node its-sh:MaxOneShape ;
        sh:datatype xsd:dateTime ;
    ] ;
    sh:property [
        sh:path :validPeriod ;
        sh:class :Period ;
    ] ;
    sh:property [
        sh:path :exceptionPeriod ;
        sh:class :Period ;
    ] .
:PeriodShape a sh:NodeShape ;
    sh:targetClass :Period ;
    sh:property [
        sh:path :hasRecurringDayWeekMonthPeriod ;
        sh:node its-sh:MaxOneShape ;
        sh:class :DayWeekMonth ;
    ] ;
    sh:property [
        sh:path :hasRecurringSpecialDay ;
        sh:node its-sh:MaxOneShape ;
        sh:class :SpecialDay ;
    ] ;
    sh:property [
        sh:path :hasRecurringTimePeriodOfDay ;
        sh:node its-sh:MaxOneShape ;
        sh:class :TimePeriodOfDay ;
    ] ;
    sh:property [
        sh:path cdm1:hasName ;
        sh:node its-sh:MaxOneMultilingualShape ;
    ] ;
    sh:property [
        sh:path :endOfPeriod ;
        sh:node its-sh:MaxOneShape ;
        sh:datatype xsd:dateTime ;
    ] ;
    sh:property [
        sh:path :startOfPeriod ;
        sh:node its-sh:MaxOneShape ;
        sh:datatype xsd:dateTime ;
    ] .

:PublicHolidayShape a sh:NodeShape ;
    sh:targetClass :PublicHoliday ;
    sh:property [
        sh:path cdm1:hasName ;
        sh:node its-sh:ExactlyOneMultilingualShape ;
    ] .

:ScheduleShape a sh:NodeShape ;
    sh:targetClass :Schedule ;
    sh:property [
        sh:path :validityTimeSpecification ;
        sh:node its-sh:ExactlyOneShape ;
        sh:class :OverallPeriod ;
    ] ;
    sh:property [
        sh:path :isOverrunning ;
        sh:node its-sh:MaxOneShape ;
        sh:datatype xsd:boolean ;
    ] ;
    sh:property [
        sh:path :hasValidityStatus ;
        sh:node its-sh:ExactlyOneShape ;
        sh:class :ValidityStatusCode ;
    ] .
:SpecialDayShape a sh:NodeShape ;
    sh:targetClass :SpecialDay ;
    sh:property [
        sh:path :intersectWithApplicableDays ;
        sh:node its-sh:ExactlyOneShape ;
        sh:datatype xsd:boolean ;
    ] ;
    sh:property [
        sh:path :hasSpecialDayType ;
        sh:node its-sh:ExactlyOneShape ;
        sh:class :SpecialDayTypeCode ;
    ] ;
    sh:property [
        sh:path :hasPublicEventType ;
        sh:node its-sh:MaxOneShape ;
        sh:class :PublicEventCode ;
    ] ;
    sh:property [
        sh:path :applicableArea ;
        sh:node its-sh:MaxOneShape ;
        sh:class cdm2:NamedArea ;
    ] .
:TimePeriodOfDayShape a sh:NodeShape ;
    sh:targetClass :TimePeriodOfDay ;
    sh:property [
        sh:path :dailyStartTime ;
        sh:node its-sh:ExactlyOneShape ;
        sh:class :TimeOfDay ;
    ] ;
    sh:property [
        sh:path :dailyEndTime ;
        sh:node its-sh:ExactlyOneShape ;
        sh:class :TimeOfDay ;
    ] .
