# Copyright 2023 OASIS Open
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

@prefix dcterms:        <http://purl.org/dc/terms/> .
@prefix ldp:            <http://www.w3.org/ns/ldp#> .
@prefix oslc:           <http://open-services.net/ns/core#> .
@prefix rdf:            <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:           <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd:            <http://www.w3.org/2001/XMLSchema#> .

@prefix trs:            <http://open-services.net/ns/core/trs#> .
@prefix trspatch:       <http://open-services.net/ns/core/trspatch#> .

@prefix :               <http://open-services.net/ns/trs/shapes/3.0#> .


# OSLC Core Tracked Resource Sets Constraints

:
    a                        oslc:ResourceShapeConstraints ;
    rdfs:label               "Resource Shapes for OSLC TRS" ;
    dcterms:title            "Resource Shapes for OSLC TRS" ;
    dcterms:description      "Shapes for resources defined by OSLC TRS."^^rdf:XMLLiteral ;
    dcterms:publisher        <https://open-services.net/about/> ;
    dcterms:source           <https://docs.oasis-open-projects.org/oslc-op/trs/v3.0/os/trs-shapes.ttl> ;
    dcterms:isPartOf         <https://docs.oasis-open-projects.org/oslc-op/trs/v3.0/os/tracked-resource-set.html> ;
    dcterms:hasVersion       "OS" ;
    dcterms:license          <http://www.apache.org/licenses/LICENSE-2.0> ;
    dcterms:issued          "2023-07-23"^^<http://www.w3.org/2001/XMLSchema#date> ;
    dcterms:dateCopyrighted  "2012-2023" .

:TrackedResourceSetShape
    a                       oslc:ResourceShape ;
    dcterms:title           "The shape of a TrackedResourceSet" ;
    dcterms:description     "A Tracked Resource Set provides a representation of the current state of a set of Tracked Resources."^^rdf:XMLLiteral ;
    oslc:describes          trs:TrackedResourceSet ;
    oslc:property
        :type ,
        :base ,
        :changeLog .

:type
    a                       oslc:Property ;
    oslc:name               "type" ;
    oslc:propertyDefinition rdf:type ;
    oslc:occurs             oslc:One-or-many ;
    oslc:representation     oslc:Reference ;
    oslc:valueType          oslc:Resource ;
    oslc:range              rdfs:Class ;
    dcterms:description     """A resource type URI. {{A tracked resource set MUST have at least the resource type `trs:TrackedResourceSet`}}."""^^rdf:XMLLiteral .

:base
    a                       oslc:Property ;
    oslc:name               "base" ;
    oslc:propertyDefinition trs:base ;
    oslc:occurs             oslc:Exactly-one ;
    oslc:representation     oslc:Reference ;
    oslc:valueType          oslc:Resource ;
    oslc:range              trs:Base ;
    oslc:readOnly           true ;
    dcterms:description     """An enumeration of the resources in the Tracked Resource Set. {{This SHOULD be a reference to a separate resource, not returned inline with the Tracked Resource Set itself}}."""^^rdf:XMLLiteral .

:changeLog
    a                       oslc:Property ;
    oslc:name               "changeLog" ;
    oslc:propertyDefinition trs:changeLog ;
    oslc:occurs             oslc:Exactly-one ;
    oslc:representation     oslc:Inline ;
    oslc:valueType          oslc:AnyResource ;
    oslc:range              trs:ChangeLog ;
    oslc:readOnly           true ;
    dcterms:description     """A Change Log providing an ordered series of incremental adjustments to the Tracked Resource Set.
{{The Tracked Resource Set representation MUST contain the triples for the referenced Change Log
(i.e., via a blank node, or an inline named resource),
including the Change Events for the first page of changes}}."""^^rdf:XMLLiteral .

:BaseShape
    a                       oslc:ResourceShape ;
    dcterms:title           "The shape of a Base" ;
    dcterms:description     "A Base is an ldp:DirectContainer that enumerates the members of a Tracked Resource Set at the time the Base was computed."^^rdf:XMLLiteral ;
    oslc:describes          trs:Base ;
    oslc:property
        :btype ,
        :cutoffEvent ,
        :member ,
        :memberRelation .

:btype
    a                       oslc:Property ;
    oslc:name               "type" ;
    oslc:propertyDefinition rdf:type ;
    oslc:occurs             oslc:Zero-or-many ;
    oslc:representation     oslc:Reference ;
    oslc:valueType          oslc:Resource ;
    oslc:range              rdfs:Class ;
    dcterms:description     """A resource type URI. Clients can infer a resource type of <code>trs:Base</code>, or its superclass <code>ldp:DirectContainer</code>."""^^rdf:XMLLiteral .

:cutoffEvent
    a                       oslc:Property ;
    oslc:name               "cutoffEvent" ;
    oslc:propertyDefinition trs:cutoffEvent ;
    oslc:occurs             oslc:Exactly-one ;
    oslc:representation     oslc:Either ;
    oslc:valueType          oslc:AnyResource ;
    oslc:range              trs:Creation, trs:Modification, trs:Deletion ;
    oslc:readOnly           true ;
    dcterms:description     """The URI of an entry in the Change Log at and after which all changes have already been included in the Base."""^^rdf:XMLLiteral .

:member
    a                       oslc:Property ;
    oslc:name               "member" ;
    oslc:propertyDefinition ldp:member ;
    oslc:occurs             oslc:Zero-or-many ;
    oslc:representation     oslc:Reference ;
    oslc:valueType          oslc:Resource ;
    oslc:readOnly           true ;
    dcterms:description     """A Tracked Resource that is a member of the Tracked Resource Set.
<code>ldp:member</code> is the preferred predicate,
but the actual predicate is indicated by <code>ldp:hasMemberRelation</code>."""^^rdf:XMLLiteral .

:memberRelation
    a                       oslc:Property ;
    oslc:name               "hasMemberRelation" ;
    oslc:propertyDefinition ldp:hasMemberRelation ;
    oslc:occurs             oslc:Exactly-one ;
    oslc:representation     oslc:Reference ;
    oslc:valueType          oslc:Resource ;
    oslc:readOnly           true ;
    dcterms:description     """The membership predicate for this Base container."""^^rdf:XMLLiteral .

:ChangeLogShape
    a                       oslc:ResourceShape ;
    dcterms:title           "The shape of a ChangeLog" ;
    dcterms:description     "A Change Log describes what resources have been created, modified or deleted, and when."^^rdf:XMLLiteral ;
    oslc:describes          trs:ChangeLog ;
    oslc:property
        :change ,
        :previous .

:change
    a                       oslc:Property ;
    oslc:name               "change" ;
    oslc:propertyDefinition trs:change ;
    oslc:occurs             oslc:Zero-or-many ;
    oslc:representation     oslc:Inline ;
    oslc:valueType          oslc:Resource ;
    oslc:range              trs:Creation, trs:Modification, trs:Deletion ;
    oslc:readOnly           true ;
    dcterms:description     """An inline resource describing a change to a Tracked Resource.
{{Change Events MUST have URIs (i.e., they cannot be blank nodes) to allow clients to recognize entries they have seen before.}}
{{The URI is used to identify an event; it need not be dereferenceable, and MAY be a URN.}}
{{The URI of a Change Event MUST be guaranteed unique, even if order numbers get reused in the wake of a Server rollback}}."""^^rdf:XMLLiteral .

:previous
    a                       oslc:Property ;
    oslc:name               "previous" ;
    oslc:propertyDefinition trs:previous ;
    oslc:occurs             oslc:Zero-or-one ;
    oslc:representation     oslc:Either ;
    oslc:valueType          oslc:AnyResource ;
    oslc:range              trs:ChangeLog ;
    oslc:readOnly           true ;
    dcterms:description     """The continuation of the Change Log, containing the next group of chronologically earlier Change Events."""^^rdf:XMLLiteral .

:CreationEventShape
    a                       oslc:ResourceShape ;
    dcterms:title           "Creation Event" ;
    dcterms:description     "Represents the creation or modification of a resource at a point in time."^^rdf:XMLLiteral ;
    oslc:describes          trs:Creation ;
    oslc:property
        :changed ,
        :order ,
        :patchCreatedFrom ,
        :patchBeforeEtag ,
        :patchAfterEtag ,
        :patchRdfPatch .

:ModificationEventShape
    a                       oslc:ResourceShape ;
    dcterms:title           "Modification Event" ;
    dcterms:description     "Represents the creation or modification of a resource at a point in time."^^rdf:XMLLiteral ;
    oslc:describes          trs:Modification ;
    oslc:property
        :changed ,
        :order ,
        :patchCreatedFrom ,
        :patchBeforeEtag ,
        :patchAfterEtag ,
        :patchRdfPatch .

:DeletionEventShape
    a                       oslc:ResourceShape ;
    dcterms:title           "Deletion Event" ;
    dcterms:description     "Represents the deletion of resource at a point in time."^^rdf:XMLLiteral ;
    oslc:describes          trs:Deletion ;
    oslc:property
        :changed ,
        :order .

:changed
    a                       oslc:Property ;
    oslc:name               "changed" ;
    oslc:propertyDefinition trs:changed ;
    oslc:occurs             oslc:Exactly-one ;
    oslc:representation     oslc:Reference ;
    oslc:valueType          oslc:Resource ;
    oslc:readOnly           true ;
    dcterms:description     """The resource that has been created, modified, or deleted."""^^rdf:XMLLiteral .

:order
    a                       oslc:Property ;
    oslc:name               "order" ;
    oslc:propertyDefinition trs:order ;
    oslc:occurs             oslc:Exactly-one;
    oslc:valueType          xsd:integer ;
    oslc:readOnly           true ;
    dcterms:description     """A non-negative integer number indicating the sequence in time of the Change Event.}} {{There MAY be gaps in the sequence}}, but {{a more recently available Change Event MUST have a larger number than any previously avalable Change Event as accessed by GET on the change log}}."""^^rdf:XMLLiteral .

:patchCreatedFrom
    a                       oslc:Property ;
    oslc:name               "createdFrom" ;
    oslc:propertyDefinition trspatch:createdFrom ;
    oslc:occurs             oslc:Zero-or-one;
    oslc:representation     oslc:Reference ;
    oslc:valueType          oslc:Resource ;
    oslc:readOnly           true ;
    dcterms:description     """{{This property MUST NOT be present unless the <code>trspatch:rdfPatch</code> property is also present}}, indicating this change event is annotated with a patch.
This property, when present, identifies the antecedent resource to be used to define the "before" state of the patch. If omitted, the antecedent resource is the resource referenced in the <code>trs:changed</code> property."""^^rdf:XMLLiteral .

:patchBeforeEtag
    a                       oslc:Property ;
    oslc:name               "beforeETag" ;
    oslc:propertyDefinition trspatch:beforeETag ;
    oslc:occurs             oslc:Zero-or-one;
    oslc:valueType          xsd:string ;
    oslc:readOnly           true ;
    dcterms:description     """This property, when present, gives the initial HTTP entity tag of the antecedent resource for a patch event. This is the entity-tag value that would be returned in the HTTP ETag response header if the antecedent resource had been retrieved immediately before the change.
If this property is missing, or if the entity-tag value does not match the current state of the antecedent resource, the patch should be ignored and the event treated as a normal modification event."""^^rdf:XMLLiteral .

:patchAfterEtag
    a                       oslc:Property ;
    oslc:name               "afterETag" ;
    oslc:propertyDefinition trspatch:afterETag ;
    oslc:occurs             oslc:Zero-or-one;
    oslc:valueType          xsd:string ;
    oslc:readOnly           true ;
    dcterms:description     """This property, when present, gives the final HTTP entity tag of the resource referenced in the <code>trs:changed property</code> - the entity-tag value that would have been returned in the HTTP ETag response header if the resource had been retrieved immediately after the change.
Clients can use this as the expected <code>trspatch:beforeETag</code> value in a chain of patch events for a tracked resource."""^^rdf:XMLLiteral .

:patchRdfPatch
    a                       oslc:Property ;
    oslc:name               "rdfPatch" ;
    oslc:propertyDefinition trspatch:rdfPatch ;
    oslc:occurs             oslc:Zero-or-one;
    oslc:valueType          xsd:string ;
    oslc:readOnly           true ;
    dcterms:description     """This property, when present, describes a patch to be applied to the antecedent resource’s RDF representation. A patch cannot describe a change to the non-RDF contents of a resource.
The result of applying the patch describes the representation of the resource referenced in the <code>trs:changed</code> property immediately after this change event.
This property is used with <code>trs:Modification</code> and <code>trs:Creation Change Events</code>; it is not meaningful for <code>trs:Deletion</code> Change Events. The format of the patch property is defined at <a href="tracked-resource-set.html#trs-patch">TRS Patch</a>."""^^rdf:XMLLiteral .
