Compare commits

..

No commits in common. "ec1c45be63f3594e2d1ccd5fb140f7612c8552cd" and "d4422ad19edd54efde9ac4932c5134f21ad4b31b" have entirely different histories.

12 changed files with 98 additions and 248 deletions

View file

@ -4,12 +4,12 @@
- [**rdfs:domain**](#rdfsdomain) - [**rdfs:domain**](#rdfsdomain)
- [owner is **a** type](#owner-is-a-type) - [owner is **a** type](#owner-is-a-type)
- [owner is a **owl:unionOf** types](#owner-is-a-owlunionof-types) - [owner is a **owl:unionOf** types](#owner-is-a-owlunionof-types)
- [**rdfs:subClassOf**](#rdfssubclassof)
- [Further infos](#further-infos) - [Further infos](#further-infos)
- [RDF/S](#rdfs) - [RDF/S](#rdfs)
- [range (https://www.w3.org/TR/rdf12-schema/#ch\_range)](#range-httpswwww3orgtrrdf12-schemach_range) - [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) - [type (https://www.w3.org/TR/rdf12-schema/#ch\_type)](#type-httpswwww3orgtrrdf12-schemach_type)
# receipts to transform ttl to spec # receipts to transform ttl to spec
## **a** ## **a**
@ -25,10 +25,13 @@ as:id a owl:DatatypeProperty ,
Maps to Maps to
```clojure ```clojure
(s/def ::DatatypeProperty any?)
(s/def ::FunctionalProperty any?)
(s/def ::id (s/def ::id
(s/and (s/and
::owl/DeprecatedProperty ::DeprecatedProperty
::owl/FunctionalProperty)) ::FunctionalProperty))
``` ```
Der token `a` in einer ttl Definition entspricht dem RDF-Prädikat `rdf:type`. Siehe: Der token `a` in einer ttl Definition entspricht dem RDF-Prädikat `rdf:type`. Siehe:
@ -51,10 +54,12 @@ as:id rdfs:range xsd:anyURI ;
Maps to Maps to
```clojure ```clojure
(s/def ::anyURI p/uri-string?)
(s/def ::id (s/def ::id
(s/and (s/and
... ...
::xsd/anyURI)) ::anyURI))
``` ```
## **rdfs:domain** ## **rdfs:domain**
@ -63,7 +68,7 @@ Maps to
### owner is **a** type ### owner is **a** type
We ignore this. 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.
Example in namespace activitypub2 Example in namespace activitypub2
```ttl ```ttl
@ -72,6 +77,10 @@ as:id rdfs:domain [a owl:Class;]
Maps to Maps to
```clojure ```clojure
(s/def
::Class
(s/merge ::owl/Class
(s/keys :opt-un [::id])))
``` ```
### owner is a **owl:unionOf** types ### owner is a **owl:unionOf** types
@ -85,35 +94,12 @@ as:id rdfs:domain [owl:unionOf (as:Link as:Object)]
Maps to Maps to
```clojure ```clojure
(s/def ::Object (sh/map-spec (s/keys :opt-un [::id ...]))) (s/def ::Object (s/keys :opt-un [::id ...]))
(s/def ::Link (sh/map-spec (s/keys :opt-un [::id]))) (s/def ::Link (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 # Further infos
## RDF/S ## RDF/S

View file

@ -1,32 +0,0 @@
```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
```

View file

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

View file

@ -0,0 +1,7 @@
(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)

View file

@ -1,91 +1,59 @@
(ns org.domaindrivenarchitecture.activity-pub-poc.activitystreams2 (ns org.domaindrivenarchitecture.activity-pub-poc.activitystreams2
(:require [clojure.spec.alpha :as s] (:require [clojure.spec.alpha :as s]
[orchestra.core :refer [defn-spec]] [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.owl :as owl]
[org.domaindrivenarchitecture.activity-pub-poc.xsd :as xsd])) [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
;http://www.w3.org/ns/activitystreams#Object ::owl/FunctionalProperty
;TODO: definition in progress ::owl/DeprecatedProperty
(s/def ::Object ::xsd/anyURI))
(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 ;http://www.w3.org/ns/activitystreams#attachment
(s/def ::attachment (s/def ::attachment
(s/and (s/and
::owl/ObjectProperty ::owl/ObjectProperty
::owl/Class ::Class
::Object ::Link
::Link)) ::Object))
;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 ;http://www.w3.org/ns/activitystreams#result
(s/def ::result (s/def ::result
(s/and (s/and
::owl/ObjectProperty ::owl/ObjectProperty
::Class
::Object ::Object
::Link)) ::Link))
;http://www.w3.org/ns/activitystreams#object ;http://www.w3.org/ns/activitystreams#Activity
(s/def ::object ;TODO: definition in progress
(s/and (s/def ::Activity
::owl/ObjectProperty (s/and ::Object
::owl/Class (s/keys :opt-un [::result])))
::Object
::Link))
;http://www.w3.org/ns/activitystreams#actor ;http://www.w3.org/ns/activitystreams#Object
(s/def ::actor ;TODO: definition in progress
(s/and (s/def ::Object (s/keys :opt-un [::id ::attachment]))
::owl/ObjectProperty
::owl/Class
::Object ;http://www.w3.org/ns/activitystreams#Link
::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#Like
(s/def ::Like ::Activity)

View file

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

View file

@ -1,20 +0,0 @@
(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)))

View file

@ -0,0 +1,31 @@
(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))
; )

View file

@ -1,63 +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 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"})))

View file

@ -12,14 +12,3 @@
(is (not (sut/functional? []))) (is (not (sut/functional? [])))
(is (not (sut/functional? nil))) (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 {})))

View file

@ -1,11 +0,0 @@
(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))))