Merge pull request 'object-or-refernce' (#1) from object-or-refernce into main

Reviewed-on: #1
main
jem 10 months ago
commit ec1c45be63

@ -4,12 +4,12 @@
- [**rdfs:domain**](#rdfsdomain)
- [owner is **a** type](#owner-is-a-type)
- [owner is a **owl:unionOf** types](#owner-is-a-owlunionof-types)
- [**rdfs:subClassOf**](#rdfssubclassof)
- [Further infos](#further-infos)
- [RDF/S](#rdfs)
- [range (https://www.w3.org/TR/rdf12-schema/#ch\_range)](#range-httpswwww3orgtrrdf12-schemach_range)
- [type (https://www.w3.org/TR/rdf12-schema/#ch\_type)](#type-httpswwww3orgtrrdf12-schemach_type)
# receipts to transform ttl to spec
## **a**
@ -25,13 +25,10 @@ as:id a owl:DatatypeProperty ,
Maps to
```clojure
(s/def ::DatatypeProperty any?)
(s/def ::FunctionalProperty any?)
(s/def ::id
(s/and
::DeprecatedProperty
::FunctionalProperty))
::owl/DeprecatedProperty
::owl/FunctionalProperty))
```
Der token `a` in einer ttl Definition entspricht dem RDF-Prädikat `rdf:type`. Siehe:
@ -54,12 +51,10 @@ as:id rdfs:range xsd:anyURI ;
Maps to
```clojure
(s/def ::anyURI p/uri-string?)
(s/def ::id
(s/and
...
::anyURI))
::xsd/anyURI))
```
## **rdfs:domain**
@ -68,7 +63,7 @@ Maps to
### owner is **a** type
It is added to the owner. That's the way to model properties. If the owner is membe of an other namespace, we create a subclass with same name in the namespce in scope and enhance the subclass.
We ignore this.
Example in namespace activitypub2
```ttl
@ -77,10 +72,6 @@ as:id rdfs:domain [a owl:Class;]
Maps to
```clojure
(s/def
::Class
(s/merge ::owl/Class
(s/keys :opt-un [::id])))
```
### owner is a **owl:unionOf** types
@ -94,12 +85,35 @@ as:id rdfs:domain [owl:unionOf (as:Link as:Object)]
Maps to
```clojure
(s/def ::Object (s/keys :opt-un [::id ...]))
(s/def ::Object (sh/map-spec (s/keys :opt-un [::id ...])))
(s/def ::Link (s/keys :opt-un [::id]))
(s/def ::Link (sh/map-spec (s/keys :opt-un [::id])))
```
## **rdfs:subClassOf**
*its* value a **rdfs:subClassOf** *the class*
If subClassOf links to an other definition we map range same as **a**.
Example:
```ttl
as:Activity rdfs:subClassOf as:Object ;
```
Maps to
```clojure
(s/def ::Object ...)
(s/def ::Activity
(s/and
...
::Object
...))
```
# Further infos
## RDF/S

@ -0,0 +1,32 @@
```ttl
as:id a owl:DatatypeProperty ,
owl:FunctionalProperty,
owl:DeprecatedProperty ;
rdfs:label "id"@en ;
rdfs:range xsd:anyURI ;
rdfs:domain [
a owl:Class ;
owl:unionOf (as:Link as:Object)
] .
```
This ttl def can be written as rdf N-Triples:
```
as:id rdf:type owl:DatatypeProperty .
as:id rdf:type owl:FunctionalProperty .
as:id rdf:type owl:DeprecatedProperty .
as:id rdfs:label "id"@en .
as:id rdfs:range xsd:anyURI .
as:id rdfs:domain _:do .
_:do rdf:type owl:Class .
_:do owl:unionOf (as:Link as:Object) .
---
_:Object as:id "http://an.uri"
_:Object as:type _:do
```

@ -2,6 +2,6 @@
(def resource-path "src/main/resources/")
(def activitystreams-ttl (str resource-path "activitystreams_2.0_owl.ttl"))
(def activitystreams-ttl (str resource-path "activitystreams_2.0.ttl"))
(def rdf-schema-ttl (str resource-path "rdf_schema_1.1.ttl"))
(def rdf-syntax-ttl (str resource-path "rdf_syntax_ns_22.ttl"))

@ -1,7 +0,0 @@
(ns org.domaindrivenarchitecture.activity-pub-poc.xsd
(:require [clojure.spec.alpha :as s]))
; http://www.datypic.com/sc/xsd/t-xsd_anyURI.html
; TODO: Find out correct definition!
(defn anyUri? [input]
false)

@ -1,59 +1,91 @@
(ns org.domaindrivenarchitecture.activity-pub-poc.activitystreams2
(:require [clojure.spec.alpha :as s]
[orchestra.core :refer [defn-spec]]
[org.domaindrivenarchitecture.activity-pub-poc.spec-helper :as sh]
[org.domaindrivenarchitecture.activity-pub-poc.owl :as owl]
[org.domaindrivenarchitecture.activity-pub-poc.xsd :as xsd]))
(defn-spec
is-functional-property? boolean?
"Checks whether spec is a FunctionalProperty."
[spec keyword?]
(some #(clojure.string/includes? % "FunctionalProperty") (s/describe spec)))
;http://www.w3.org/ns/activitystreams#id
(s/def
::id (s/and ::owl/DatatypeProperty
::owl/FunctionalProperty
::owl/DeprecatedProperty
::xsd/anyURI))
;=======================
;http://www.w3.org/ns/activitystreams#Object
;TODO: definition in progress
(s/def ::Object
(s/and
::owl/Class
(sh/map-spec (s/keys :opt-un [::id ::type ::attachment]))))
;http://www.w3.org/ns/activitystreams#Link
;TODO: definition in progress
(s/def ::Link
(s/and
::owl/Class
(sh/map-spec (s/keys :opt-un [::id ::type]))))
;http://www.w3.org/ns/activitystreams#Activity
;TODO: Define more properties necessary for Like
(s/def ::Activity
(s/and
::owl/Class
::Object
(sh/map-spec (s/keys :opt-un [::result ::object ::actor]))))
;http://www.w3.org/ns/activitystreams#Relationship
;We only have this class, since the property "object" is in the domain "Activity" and "Relationship"
; TODO: What means: "as:Relationship a rdf:Statement". Relevant for spec?
(s/def ::Relationship
(s/and
::owl/Class
::Object
(sh/map-spec (s/keys :opt-un [::object]))))
;http://www.w3.org/ns/activitystreams#Like
(s/def ::Like
(s/and
::owl/Class
::Activity))
;http://www.w3.org/ns/activitystreams#attachment
(s/def ::attachment
(s/def ::attachment
(s/and
::owl/ObjectProperty
::Class
::Link
::Object))
::owl/Class
::Object
::Link))
;http://www.w3.org/ns/activitystreams#id
(s/def ::id
(s/and ::owl/DatatypeProperty
::owl/FunctionalProperty
::owl/DeprecatedProperty
::xsd/anyURI))
;https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type
;TODO: this can not be found in the ttl / namespace. Where is this exactly defined?
(s/def ::type
any?;::xsd/anyURI
)
;http://www.w3.org/ns/activitystreams#result
(s/def ::result
(s/and
::owl/ObjectProperty
::Class
::Object
::Link))
;http://www.w3.org/ns/activitystreams#Activity
;TODO: definition in progress
(s/def ::Activity
(s/and ::Object
(s/keys :opt-un [::result])))
;http://www.w3.org/ns/activitystreams#Object
;TODO: definition in progress
(s/def ::Object (s/keys :opt-un [::id ::attachment]))
;http://www.w3.org/ns/activitystreams#Link
;TODO: definition in progress
(s/def ::Link (s/keys :opt-un [::id]))
;TODO: There is no as:Class! Why do we need this?
(s/def
::Class
(s/merge ::owl/Class
(s/keys :opt-un [::id])))
;http://www.w3.org/ns/activitystreams#object
(s/def ::object
(s/and
::owl/ObjectProperty
::owl/Class
::Object
::Link))
;http://www.w3.org/ns/activitystreams#Like
(s/def ::Like ::Activity)
;http://www.w3.org/ns/activitystreams#actor
(s/def ::actor
(s/and
::owl/ObjectProperty
::owl/Class
::Object
::Link))

@ -3,6 +3,7 @@
is realized in deep implemented."
(:require
[clojure.spec.alpha :as s]
[org.domaindrivenarchitecture.activity-pub-poc.predicates :as p]
[orchestra.core :refer [defn-spec]]))
; Properties:https://www.w3.org/TR/owl-ref/#Property
@ -11,7 +12,11 @@
;http://www.w3.org/2002/07/owl#Class
;https://www.w3.org/TR/owl-ref/#Class-def
(s/def ::Class any?)
(defn-spec owl-class? boolean?
[elem any?]
(or (p/uri-string? elem)
(coll? elem)))
(s/def ::Class owl-class?)
;http://www.w3.org/2002/07/owl#DatatypeProperty
(s/def ::DatatypeProperty any?)

@ -0,0 +1,20 @@
(ns org.domaindrivenarchitecture.activity-pub-poc.spec-helper
"A swallow spec translation implementation of owl. Inheritance of FunctionalProperty
is realized in deep implemented."
(:require
[clojure.spec.alpha :as s]
[orchestra.core :refer [defn-spec]]))
(defn-spec map-spec s/spec?
"Spec that applies only for map values."
[spec s/spec?]
(s/and
(s/or
:no-map #(not (map? %))
:map spec)))
(defn-spec
is-functional-property? boolean?
"Checks whether spec is a FunctionalProperty."
[spec s/spec?]
(some #(clojure.string/includes? % "FunctionalProperty") (s/describe spec)))

@ -1,31 +0,0 @@
(ns org.domaindrivenarchitecture.activity-pub-poc.activitystreams2-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[clojure.spec.alpha :as s]
[org.domaindrivenarchitecture.activity-pub-poc.activitystreams2 :as sut]))
(deftest shoult-test-spec-for-having-functional-property
(is (sut/is-functional-property? ::sut/id))
(is (not (sut/is-functional-property? ::sut/Like))))
(deftest id-test
(is (s/valid? ::sut/id "https://social.bla/alyssa/status/RANDOMHASH"))
(is (not (s/valid? ::sut/id nil)))
(is (not (s/valid? ::sut/id 2)))
(is (not (s/valid? ::sut/id "no-uri")))
(is (not (s/valid? ::sut/id ["https://social.bla/alyssa/status/RANDOMHASH", "https://social.bla/alyssa/status/RANDOMHASH2"])))
)
(deftest result-test
(is (s/valid? ::sut/result "https://social.bla/alyssa/result/RANDOMHASH"))
(is (s/valid? ::sut/result {:type "http://www.types.example/flightstatus", :name "On Time"}))
(is (s/valid? ::sut/result {:type "Link" :href "http://www.target.de"}))
(is (not (s/valid? ::sut/result nil)))
(is (not (s/valid? ::sut/result 47)))
)
;(deftest attachment-test
; (is (s/valid? ::sut/attachment))
; )

@ -0,0 +1,63 @@
(ns org.domaindrivenarchitecture.activity-pub-poc.activitystreams2-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[clojure.spec.alpha :as s]
[org.domaindrivenarchitecture.activity-pub-poc.activitystreams2 :as sut]))
(deftest id-test
(is (s/valid? ::sut/id "https://social.bla/alyssa/status/RANDOMHASH"))
(is (not (s/valid? ::sut/id nil)))
(is (not (s/valid? ::sut/id 2)))
(is (not (s/valid? ::sut/id "no-uri")))
(is (not (s/valid? ::sut/id ["https://social.bla/alyssa/status/RANDOMHASH", "https://social.bla/alyssa/status/RANDOMHASH2"]))))
(deftest object-test
(is (s/valid? ::sut/object "http://example.org/posts/1"))
(is (s/valid? ::sut/object {:type "Note",
:content "A simple note"}))
(is (s/valid? ::sut/object ["http://example.org/posts/1",
{:type "Note",
:summary "A simple note",
:content "That is a tree."}])))
(deftest result-test
(is (s/valid? ::sut/result "https://social.bla/alyssa/result/RANDOMHASH"))
(is (s/valid? ::sut/result {:type "http://www.types.example/flightstatus", :name "On Time"}))
(is (s/valid? ::sut/result {:type "Link" :href "http://www.target.de"}))
(is (not (s/valid? ::sut/result nil)))
(is (not (s/valid? ::sut/result 47))))
(deftest attachment-test
(is (s/valid? ::sut/attachment
[{:type "Image",
:content "This is what he looks like.",
:url "http://example.org/cat.jpeg"}])))
(deftest actor-test
(is (s/valid? ::sut/actor "http://sally.example.org"))
(is (s/valid? ::sut/actor {:type "Person",
:id "http://sally.example.org",
:summary "Sally"}))
(is (s/valid? ::sut/actor ["http://joe.example.org",
{:type "Person",
:id "http://sally.example.org",
:name "Sally"}])))
(deftest Activity-test
(is (s/valid? ::sut/Activity
{:type "Activity",
:summary "Sally did something to a note",
:actor {:type "Person",
:name "Sally"},
:object {:type "Note",
:name "A Note"}})))
(deftest Like-test
(is (s/valid? ::sut/Like
{:summary "Sally liked a note",
:type "Like",
:actor {:type "Person",
:name "Sally"},
:object "http://example.org/notes/1"})))

@ -11,4 +11,15 @@
(is (sut/functional? ["str"]))
(is (not (sut/functional? [])))
(is (not (sut/functional? nil)))
(is (not (sut/functional? [1 2]))))
(is (not (sut/functional? [1 2]))))
(deftest owl-class-predicate
(is (sut/owl-class? "http://some.uri"))
(is (sut/owl-class? {:as "class-definition"}))
(is (sut/owl-class? []))
(is (not (sut/owl-class? "str")))
(is (not (sut/owl-class? nil))))
(deftest class-test
(is (s/valid? ::sut/Class "https://social.bla/alyssa/status/RANDOMHASH"))
(is (s/valid? ::sut/Class {})))

@ -0,0 +1,11 @@
(ns org.domaindrivenarchitecture.activity-pub-poc.spec-helper-test
(:require
[clojure.test :refer [deftest is are testing run-tests]]
[clojure.spec.test.alpha :as st]
[clojure.spec.alpha :as s]
[org.domaindrivenarchitecture.activity-pub-poc.activitystreams2 :as as2]
[org.domaindrivenarchitecture.activity-pub-poc.spec-helper :as sut]))
(deftest shoult-test-spec-for-having-functional-property
(is (sut/is-functional-property? ::as2/id))
(is (not (sut/is-functional-property? ::as2/Like))))
Loading…
Cancel
Save