commit
ec1c45be63
@ -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
|
||||
```
|
@ -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))
|
||||
|
@ -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"})))
|
@ -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…
Reference in New Issue