From 06a1864b2f6da254ff1c6897cbd4a986686635d8 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Wed, 26 Jul 2023 09:18:49 +0200 Subject: [PATCH 01/24] more tests and investigation --- .../activity_pub_poc/activitystreams2.cljc | 40 +++++++++++++------ .../activitystreams2_test.clj | 19 +++++++-- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 093e800..4d85c19 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -17,14 +17,6 @@ ::owl/DeprecatedProperty ::xsd/anyURI)) -;http://www.w3.org/ns/activitystreams#attachment -(s/def ::attachment - (s/and - ::owl/ObjectProperty - ::Class - ::Link - ::Object)) - ;http://www.w3.org/ns/activitystreams#result (s/def ::result (s/and @@ -33,26 +25,48 @@ ::Object ::Link)) +;http://www.w3.org/ns/activitystreams#attachment +(s/def ::attachment + (s/and + ::owl/ObjectProperty + ::Class + ::Link + ::Object)) + +;http://www.w3.org/ns/activitystreams#Relationship +;TODO: definition in progress +(s/def ::Relationship + (s/and (s/keys :opt-un [::object]))) + ;http://www.w3.org/ns/activitystreams#Activity ;TODO: definition in progress (s/def ::Activity (s/and ::Object - (s/keys :opt-un [::result]))) + (s/keys :opt-un [::result + ::object]))) -;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#object +(s/def ::object + (s/and + ::owl/ObjectProperty + ::Class + (s/or ::Object + ::Link))) +;http://www.w3.org/ns/activitystreams#object +(s/def ::Object + (s/keys :opt-un [::id ::Class])) ;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? +;Answer jem: I do not want to enhance owl/Class inline from here. (s/def ::Class (s/merge ::owl/Class - (s/keys :opt-un [::id]))) + (s/keys :opt-un [::id ::object]))) ;http://www.w3.org/ns/activitystreams#Like diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj index c9109ac..72a6d86 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj @@ -14,16 +14,27 @@ (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"]))) - ) + (is (not (s/valid? ::sut/id ["https://social.bla/alyssa/status/RANDOMHASH", "https://social.bla/alyssa/status/RANDOMHASH2"])))) + +;TODO: where does the ability for a link reference come from ? +(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 class-test + (is (s/valid? ::sut/Class "https://social.bla/alyssa/status/RANDOMHASH"))) (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))) -) + (is (not (s/valid? ::sut/result 47)))) ;(deftest attachment-test -- 2.45.2 From 33404eb853299efec0be660c0cbea27b12a28eb6 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 11:13:47 +0200 Subject: [PATCH 02/24] some rudimentary model of class --- .../domaindrivenarchitecture/activity_pub_poc/owl.cljc | 8 +++++++- .../activity_pub_poc/owl_test.cljc | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl.cljc index 7e0ccf6..0113755 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl.cljc @@ -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,12 @@ ;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) + (map? elem) + (vector? elem))) +(s/def ::Class owl-class?) ;http://www.w3.org/2002/07/owl#DatatypeProperty (s/def ::DatatypeProperty any?) diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl_test.cljc index 427751f..ab12947 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl_test.cljc +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl_test.cljc @@ -11,4 +11,11 @@ (is (sut/functional? ["str"])) (is (not (sut/functional? []))) (is (not (sut/functional? nil))) - (is (not (sut/functional? [1 2])))) \ No newline at end of file + (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)))) -- 2.45.2 From 56a4642800510dadd50e5d55087606719e63bf40 Mon Sep 17 00:00:00 2001 From: Clemens Date: Fri, 28 Jul 2023 12:02:47 +0200 Subject: [PATCH 03/24] Added ttl to rdf example --- doc/id_ttl_to_rdf.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 doc/id_ttl_to_rdf.md diff --git a/doc/id_ttl_to_rdf.md b/doc/id_ttl_to_rdf.md new file mode 100644 index 0000000..d771931 --- /dev/null +++ b/doc/id_ttl_to_rdf.md @@ -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 +``` \ No newline at end of file -- 2.45.2 From 19b050f51745d22828b605ef775081369c8a44b9 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 12:04:10 +0200 Subject: [PATCH 04/24] non working id test --- src/main/resources/activitystreams_2.0_owl.ttl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/activitystreams_2.0_owl.ttl b/src/main/resources/activitystreams_2.0_owl.ttl index 7fffc1c..ab6c6a8 100644 --- a/src/main/resources/activitystreams_2.0_owl.ttl +++ b/src/main/resources/activitystreams_2.0_owl.ttl @@ -477,6 +477,8 @@ as:id a owl:DatatypeProperty , owl:DeprecatedProperty ; rdfs:label "id"@en ; rdfs:range xsd:anyURI ; + rdfs:domain as:Link, + as:Object; rdfs:domain [ a owl:Class ; owl:unionOf (as:Link as:Object) -- 2.45.2 From 26fac9b467860ebfaf1f07f349a2d50c620ee80c Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 12:04:57 +0200 Subject: [PATCH 05/24] non working id test --- .../org/domaindrivenarchitecture/activity_pub_poc/xsd.clj | 7 ------- .../activity_pub_poc/activitystreams2.cljc | 5 +++-- 2 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/xsd.clj diff --git a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/xsd.clj b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/xsd.clj deleted file mode 100644 index abbad0e..0000000 --- a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/xsd.clj +++ /dev/null @@ -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) \ No newline at end of file diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 4d85c19..29ff3a8 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -65,8 +65,9 @@ ;Answer jem: I do not want to enhance owl/Class inline from here. (s/def ::Class - (s/merge ::owl/Class - (s/keys :opt-un [::id ::object]))) + (s/and ::owl/Class + )) + ;(s/keys :opt-un [::id ::object]))) ;http://www.w3.org/ns/activitystreams#Like -- 2.45.2 From 97eb76b8d393de4117014f194c757b3a5c5df34d Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 13:15:19 +0200 Subject: [PATCH 06/24] ignore domain .. a in mapping --- doc/Translate_ttl_to_spec.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/doc/Translate_ttl_to_spec.md b/doc/Translate_ttl_to_spec.md index 4512cd1..9ffa058 100644 --- a/doc/Translate_ttl_to_spec.md +++ b/doc/Translate_ttl_to_spec.md @@ -9,7 +9,6 @@ - [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** @@ -68,21 +67,13 @@ 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 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 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. -- 2.45.2 From 3e84e78c153421475478ede0eb7b0a6af2bdb8a8 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 13:17:00 +0200 Subject: [PATCH 07/24] undo not intended commit --- src/main/resources/activitystreams_2.0_owl.ttl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/resources/activitystreams_2.0_owl.ttl b/src/main/resources/activitystreams_2.0_owl.ttl index ab6c6a8..7fffc1c 100644 --- a/src/main/resources/activitystreams_2.0_owl.ttl +++ b/src/main/resources/activitystreams_2.0_owl.ttl @@ -477,8 +477,6 @@ as:id a owl:DatatypeProperty , owl:DeprecatedProperty ; rdfs:label "id"@en ; rdfs:range xsd:anyURI ; - rdfs:domain as:Link, - as:Object; rdfs:domain [ a owl:Class ; owl:unionOf (as:Link as:Object) -- 2.45.2 From 572d42f6ea80991e6296589484dd048442a444f0 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 13:31:48 +0200 Subject: [PATCH 08/24] fix the tests - transormation description in progress --- .../activity_pub_poc/activitystreams2.cljc | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 29ff3a8..9d2d0c1 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -50,24 +50,33 @@ (s/and ::owl/ObjectProperty ::Class - (s/or ::Object - ::Link))) + ::Object + ::Link)) ;http://www.w3.org/ns/activitystreams#object -(s/def ::Object - (s/keys :opt-un [::id ::Class])) +(defmulti object-type map?) +(defmethod object-type true [_] + (s/and ::Class + (s/keys :opt-un [::id]))) +(defmethod object-type false [_] + (s/and ::Class)) +(s/def ::Object object-type) ;http://www.w3.org/ns/activitystreams#Link ;TODO: definition in progress -(s/def ::Link (s/keys :opt-un [::id])) +(defmulti link-type map?) +(defmethod link-type true [_] + (s/and ::Class + (s/keys :opt-un [::id]))) +(defmethod link-type false [_] + (s/and ::Class)) +(s/def ::Link link-type) ;TODO: There is no as:Class! Why do we need this? ;Answer jem: I do not want to enhance owl/Class inline from here. (s/def ::Class - (s/and ::owl/Class - )) - ;(s/keys :opt-un [::id ::object]))) + (s/and ::owl/Class)) ;http://www.w3.org/ns/activitystreams#Like -- 2.45.2 From ada20747269b05f5d9c437b6540cee0afd42b340 Mon Sep 17 00:00:00 2001 From: Clemens Date: Fri, 28 Jul 2023 14:28:45 +0200 Subject: [PATCH 09/24] fix merge conflicts --- doc/Translate_ttl_to_spec.md | 23 ++++ .../activity_pub_poc/activitystreams2.cljc | 110 +++++++++++++----- 2 files changed, 102 insertions(+), 31 deletions(-) diff --git a/doc/Translate_ttl_to_spec.md b/doc/Translate_ttl_to_spec.md index 9ffa058..8b09efe 100644 --- a/doc/Translate_ttl_to_spec.md +++ b/doc/Translate_ttl_to_spec.md @@ -91,6 +91,29 @@ Maps to (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 ## RDF/S diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 9d2d0c1..d707134 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -4,54 +4,85 @@ [org.domaindrivenarchitecture.activity-pub-poc.owl :as owl] [org.domaindrivenarchitecture.activity-pub-poc.xsd :as xsd])) +; TODO gec: what is this needed for? (defn-spec is-functional-property? boolean? "Checks whether spec is a FunctionalProperty." [spec keyword?] (some #(clojure.string/includes? % "FunctionalProperty") (s/describe spec))) +(defn-spec map-class-spec s/spec? + "Spec which checks whether a value is a ::owl/Class + and if it is a map, if it validates the given map-spec." + [map-spec s/spec?] + (s/and + ::owl/Class + (s/or + :no-map #(not (map? %)) + :map map-spec))) + +;======================= + +;http://www.w3.org/ns/activitystreams#object +(s/def ::Object + (s/and + ::owl/Class + (s/keys :opt-un [::id ::type ::attachment]))) + +;http://www.w3.org/ns/activitystreams#Link +(s/def ::Link + (s/and + ::owl/Class + (s/keys :opt-un [::id ::type]))) + ;http://www.w3.org/ns/activitystreams#id -(s/def - ::id (s/and ::owl/DatatypeProperty - ::owl/FunctionalProperty - ::owl/DeprecatedProperty - ::xsd/anyURI)) +(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#Activity +;TODO: Define more properties necessary for Like +(s/def ::Activity + (s/and + ::owl/Class + ::Object + (s/keys :opt-un [::result ::object]))) + ;http://www.w3.org/ns/activitystreams#result (s/def ::result (s/and ::owl/ObjectProperty - ::Class - ::Object - ::Link)) - -;http://www.w3.org/ns/activitystreams#attachment -(s/def ::attachment - (s/and - ::owl/ObjectProperty - ::Class - ::Link - ::Object)) + (map-class-spec + (s/or :object ::Object + :link ::Link)))) ;http://www.w3.org/ns/activitystreams#Relationship -;TODO: definition in progress +;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 (s/keys :opt-un [::object]))) - -;http://www.w3.org/ns/activitystreams#Activity -;TODO: definition in progress -(s/def ::Activity - (s/and ::Object - (s/keys :opt-un [::result - ::object]))) + (s/and + ::owl/Class + ::Object + (s/keys :opt-un [::object]))) ;http://www.w3.org/ns/activitystreams#object (s/def ::object (s/and ::owl/ObjectProperty - ::Class - ::Object - ::Link)) + (map-class-spec + (s/or + :object ::Object + :link ::Link)))) ;http://www.w3.org/ns/activitystreams#object (defmulti object-type map?) @@ -72,12 +103,29 @@ (s/and ::Class)) (s/def ::Link link-type) +;http://www.w3.org/ns/activitystreams#attachment +; TODO: Why do we need to model this? Is this necessary for a Like-Activity? +(s/def ::attachment + (s/and + ::owl/ObjectProperty + (map-class-spec + (s/or + :object ::Object + :link ::Link)))) + +;http://www.w3.org/ns/activitystreams#Like +(s/def ::Like + (s/and + ::owl/Class + ::Activity)) + + + +;============= + ;TODO: There is no as:Class! Why do we need this? ;Answer jem: I do not want to enhance owl/Class inline from here. (s/def ::Class (s/and ::owl/Class)) - -;http://www.w3.org/ns/activitystreams#Like -(s/def ::Like ::Activity) \ No newline at end of file -- 2.45.2 From 5588bcd5b834ae53a39f2158e3f8b5e19099adf0 Mon Sep 17 00:00:00 2001 From: Clemens Date: Fri, 28 Jul 2023 16:08:32 +0200 Subject: [PATCH 10/24] adjustments --- .../activity_pub_poc/activitystreams2.cljc | 90 ++++++++++--------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index d707134..985d113 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -4,7 +4,6 @@ [org.domaindrivenarchitecture.activity-pub-poc.owl :as owl] [org.domaindrivenarchitecture.activity-pub-poc.xsd :as xsd])) -; TODO gec: what is this needed for? (defn-spec is-functional-property? boolean? "Checks whether spec is a FunctionalProperty." @@ -12,29 +11,70 @@ (some #(clojure.string/includes? % "FunctionalProperty") (s/describe spec))) (defn-spec map-class-spec s/spec? - "Spec which checks whether a value is a ::owl/Class + "Spec which checks whether a value is a ::Class and if it is a map, if it validates the given map-spec." [map-spec s/spec?] (s/and - ::owl/Class + ::Class (s/or :no-map #(not (map? %)) :map map-spec))) ;======================= +;TODO: There is no as:Class! Why do we need this? +;Answer jem: I do not want to enhance owl/Class inline from here. +(s/def + ::Class + (s/and ::owl/Class)) + +;======================= + ;http://www.w3.org/ns/activitystreams#object (s/def ::Object (s/and - ::owl/Class + ::Class (s/keys :opt-un [::id ::type ::attachment]))) ;http://www.w3.org/ns/activitystreams#Link (s/def ::Link (s/and - ::owl/Class + ::Class (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 + ::Class + ::Object + (s/keys :opt-un [::result ::object]))) + +;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 + ::Class + ::Object + (s/keys :opt-un [::object]))) + +;http://www.w3.org/ns/activitystreams#Like +(s/def ::Like + (s/and + ::Class + ::Activity)) + +;http://www.w3.org/ns/activitystreams#attachment +; TODO: Why do we need to model this? Is this necessary for a Like-Activity? +(s/def ::attachment + (s/and + ::owl/ObjectProperty + (map-class-spec + (s/or + :object ::Object + :link ::Link)))) + ;http://www.w3.org/ns/activitystreams#id (s/def ::id (s/and ::owl/DatatypeProperty @@ -49,15 +89,6 @@ ) -;http://www.w3.org/ns/activitystreams#Activity -;TODO: Define more properties necessary for Like -(s/def ::Activity - (s/and - ::owl/Class - ::Object - (s/keys :opt-un [::result ::object]))) - - ;http://www.w3.org/ns/activitystreams#result (s/def ::result (s/and @@ -66,15 +97,6 @@ (s/or :object ::Object :link ::Link)))) -;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 - (s/keys :opt-un [::object]))) - ;http://www.w3.org/ns/activitystreams#object (s/def ::object (s/and @@ -103,29 +125,9 @@ (s/and ::Class)) (s/def ::Link link-type) -;http://www.w3.org/ns/activitystreams#attachment -; TODO: Why do we need to model this? Is this necessary for a Like-Activity? -(s/def ::attachment - (s/and - ::owl/ObjectProperty - (map-class-spec - (s/or - :object ::Object - :link ::Link)))) - -;http://www.w3.org/ns/activitystreams#Like -(s/def ::Like - (s/and - ::owl/Class - ::Activity)) -;============= -;TODO: There is no as:Class! Why do we need this? -;Answer jem: I do not want to enhance owl/Class inline from here. -(s/def - ::Class - (s/and ::owl/Class)) + -- 2.45.2 From d572a8c05e90d1a7f0d91d0afdc72b6269bda702 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 16:55:41 +0200 Subject: [PATCH 11/24] catch up the idea of map-class-spec --- .../activity_pub_poc/activitystreams2.cljc | 69 +++++++------------ .../activity_pub_poc/owl.cljc | 3 +- .../activity_pub_poc/spec_helper.cljc | 14 ++++ .../activitystreams2_test.clj | 1 - 4 files changed, 40 insertions(+), 47 deletions(-) create mode 100644 src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 985d113..1ec80a9 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -1,6 +1,7 @@ (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])) @@ -10,16 +11,6 @@ [spec keyword?] (some #(clojure.string/includes? % "FunctionalProperty") (s/describe spec))) -(defn-spec map-class-spec s/spec? - "Spec which checks whether a value is a ::Class - and if it is a map, if it validates the given map-spec." - [map-spec s/spec?] - (s/and - ::Class - (s/or - :no-map #(not (map? %)) - :map map-spec))) - ;======================= ;TODO: There is no as:Class! Why do we need this? @@ -33,47 +24,46 @@ ;http://www.w3.org/ns/activitystreams#object (s/def ::Object (s/and - ::Class - (s/keys :opt-un [::id ::type ::attachment]))) + ::owl/Class + (sh/map-spec (s/keys :opt-un [::id ::type ::attachment])))) ;http://www.w3.org/ns/activitystreams#Link (s/def ::Link (s/and - ::Class - (s/keys :opt-un [::id ::type]))) + ::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 - ::Class + ::owl/Class ::Object - (s/keys :opt-un [::result ::object]))) + (sh/map-spec (s/keys :opt-un [::result ::object])))) ;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 - ::Class + ::owl/Class ::Object - (s/keys :opt-un [::object]))) + (sh/map-spec (s/keys :opt-un [::object])))) ;http://www.w3.org/ns/activitystreams#Like (s/def ::Like (s/and - ::Class + ::owl/Class ::Activity)) ;http://www.w3.org/ns/activitystreams#attachment ; TODO: Why do we need to model this? Is this necessary for a Like-Activity? (s/def ::attachment (s/and + ::owl/Class ::owl/ObjectProperty - (map-class-spec - (s/or - :object ::Object - :link ::Link)))) + ::Object + ::Link)) ;http://www.w3.org/ns/activitystreams#id (s/def ::id @@ -92,38 +82,29 @@ ;http://www.w3.org/ns/activitystreams#result (s/def ::result (s/and + ::owl/Class ::owl/ObjectProperty - (map-class-spec - (s/or :object ::Object - :link ::Link)))) + ::Object + ::Link)) ;http://www.w3.org/ns/activitystreams#object (s/def ::object (s/and + ::owl/Class ::owl/ObjectProperty - (map-class-spec - (s/or - :object ::Object - :link ::Link)))) + ::Object + ::Link)) ;http://www.w3.org/ns/activitystreams#object -(defmulti object-type map?) -(defmethod object-type true [_] - (s/and ::Class - (s/keys :opt-un [::id]))) -(defmethod object-type false [_] - (s/and ::Class)) -(s/def ::Object object-type) +(s/def ::Object + (s/and ::owl/Class + (sh/map-spec (s/keys :opt-un [::id])))) ;http://www.w3.org/ns/activitystreams#Link ;TODO: definition in progress -(defmulti link-type map?) -(defmethod link-type true [_] - (s/and ::Class - (s/keys :opt-un [::id]))) -(defmethod link-type false [_] - (s/and ::Class)) -(s/def ::Link link-type) +(s/def ::Link + (s/and ::owl/Class + (sh/map-spec (s/keys :opt-un [::id])))) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl.cljc index 0113755..86fce47 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl.cljc @@ -15,8 +15,7 @@ (defn-spec owl-class? boolean? [elem any?] (or (p/uri-string? elem) - (map? elem) - (vector? elem))) + (coll? elem))) (s/def ::Class owl-class?) ;http://www.w3.org/2002/07/owl#DatatypeProperty diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc new file mode 100644 index 0000000..cfebc7e --- /dev/null +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc @@ -0,0 +1,14 @@ +(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))) \ No newline at end of file diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj index 72a6d86..10f0dc3 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj @@ -16,7 +16,6 @@ (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"])))) -;TODO: where does the ability for a link reference come from ? (deftest object-test (is (s/valid? ::sut/object "http://example.org/posts/1")) (is (s/valid? ::sut/object {:type "Note", -- 2.45.2 From 077a50e733d0ba1ccd144f7243c733eec8f473c8 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 16:58:10 +0200 Subject: [PATCH 12/24] remove unused as:Class --- .../activity_pub_poc/activitystreams2.cljc | 8 -------- .../activity_pub_poc/activitystreams2_test.clj | 3 --- .../activity_pub_poc/owl_test.cljc | 4 ++++ 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 1ec80a9..71121f7 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -13,14 +13,6 @@ ;======================= -;TODO: There is no as:Class! Why do we need this? -;Answer jem: I do not want to enhance owl/Class inline from here. -(s/def - ::Class - (s/and ::owl/Class)) - -;======================= - ;http://www.w3.org/ns/activitystreams#object (s/def ::Object (s/and diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj index 10f0dc3..6d98ee3 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj @@ -25,9 +25,6 @@ :summary "A simple note", :content "That is a tree."}]))) -(deftest class-test - (is (s/valid? ::sut/Class "https://social.bla/alyssa/status/RANDOMHASH"))) - (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"})) diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl_test.cljc index ab12947..4bc968f 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl_test.cljc +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/owl_test.cljc @@ -19,3 +19,7 @@ (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 {}))) -- 2.45.2 From 21c5a0244e49c84963b2f59916c9fdef8044a294 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:06:13 +0200 Subject: [PATCH 13/24] refactore out more spec-herlper fcts --- .../activity_pub_poc/activitystreams2.cljc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 71121f7..296955f 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -5,11 +5,7 @@ [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))) + ;======================= -- 2.45.2 From 8aea2c5326bb94eb1ec3e9d301c63b0ac0a15769 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:06:24 +0200 Subject: [PATCH 14/24] refactore out more spec-herlper fcts --- .../activity_pub_poc/spec_helper.cljc | 8 +++++++- ...tystreams2_test.clj => activitystreams2_test.cljc} | 4 ---- .../activity_pub_poc/spec_helper_test.cljc | 11 +++++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) rename src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/{activitystreams2_test.clj => activitystreams2_test.cljc} (90%) create mode 100644 src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper_test.cljc diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc index cfebc7e..cada86f 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper.cljc @@ -11,4 +11,10 @@ (s/and (s/or :no-map #(not (map? %)) - :map spec))) \ No newline at end of file + :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))) \ No newline at end of file diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc similarity index 90% rename from src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj rename to src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc index 6d98ee3..136504f 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.clj +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc @@ -5,10 +5,6 @@ [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))) diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper_test.cljc new file mode 100644 index 0000000..cb7f08a --- /dev/null +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/spec_helper_test.cljc @@ -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)))) \ No newline at end of file -- 2.45.2 From fc539a28d9cdf9e3bf1b69cd030b5272133d0b5d Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:09:06 +0200 Subject: [PATCH 15/24] renamed --- .../{activitystreams_2.0_owl.ttl => activitystreams_2.0.ttl} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/{activitystreams_2.0_owl.ttl => activitystreams_2.0.ttl} (100%) diff --git a/src/main/resources/activitystreams_2.0_owl.ttl b/src/main/resources/activitystreams_2.0.ttl similarity index 100% rename from src/main/resources/activitystreams_2.0_owl.ttl rename to src/main/resources/activitystreams_2.0.ttl -- 2.45.2 From 614db2aa91673cf100ce3fed4be4b00d9fd94195 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:09:24 +0200 Subject: [PATCH 16/24] adjust translate receipt --- doc/Translate_ttl_to_spec.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/Translate_ttl_to_spec.md b/doc/Translate_ttl_to_spec.md index 8b09efe..8099c85 100644 --- a/doc/Translate_ttl_to_spec.md +++ b/doc/Translate_ttl_to_spec.md @@ -4,6 +4,7 @@ - [**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) @@ -85,10 +86,10 @@ 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** -- 2.45.2 From d7549638cf3d1465f1b8516c3e4940ae1e63fe8e Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:12:44 +0200 Subject: [PATCH 17/24] make transormation receipt more lean --- doc/Translate_ttl_to_spec.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/Translate_ttl_to_spec.md b/doc/Translate_ttl_to_spec.md index 8099c85..dc8dc54 100644 --- a/doc/Translate_ttl_to_spec.md +++ b/doc/Translate_ttl_to_spec.md @@ -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** @@ -75,6 +70,10 @@ Example in namespace activitypub2 as:id rdfs:domain [a owl:Class;] ``` +Maps to +```clojure +``` + ### owner is a **owl:unionOf** types 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. -- 2.45.2 From 5f94abcfdbb0de2f73dcd89dcb1f59473bcf95fe Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:26:53 +0200 Subject: [PATCH 18/24] fix as2.tl reference --- .../org/domaindrivenarchitecture/activity_pub_poc/common.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/common.clj b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/common.clj index baa9523..f0260c6 100644 --- a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/common.clj +++ b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/common.clj @@ -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")) \ No newline at end of file -- 2.45.2 From e4594d9391462a44cd96e65d35f5d0c90106a3a4 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:27:13 +0200 Subject: [PATCH 19/24] double-checked result --- .../activity_pub_poc/activitystreams2.cljc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 296955f..d7c025f 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -70,7 +70,6 @@ ;http://www.w3.org/ns/activitystreams#result (s/def ::result (s/and - ::owl/Class ::owl/ObjectProperty ::Object ::Link)) -- 2.45.2 From d8874ba147bc0eb890b5695546f6ffff2a553d0e Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:33:42 +0200 Subject: [PATCH 20/24] double-checked object --- .../activity_pub_poc/activitystreams2.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index d7c025f..c48b2ab 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -77,8 +77,8 @@ ;http://www.w3.org/ns/activitystreams#object (s/def ::object (s/and - ::owl/Class ::owl/ObjectProperty + ::owl/Class ::Object ::Link)) -- 2.45.2 From e04683d2538bb17ead71e80b9b141a07e6d6dc6a Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:36:15 +0200 Subject: [PATCH 21/24] remove douplicate spec defs --- .../activity_pub_poc/activitystreams2.cljc | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index c48b2ab..21807d1 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -9,13 +9,15 @@ ;======================= -;http://www.w3.org/ns/activitystreams#object +;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 @@ -81,21 +83,3 @@ ::owl/Class ::Object ::Link)) - -;http://www.w3.org/ns/activitystreams#object -(s/def ::Object - (s/and ::owl/Class - (sh/map-spec (s/keys :opt-un [::id])))) - -;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])))) - - - - - - - -- 2.45.2 From 72a51b3f2c4c954121e8a5cb8955a86338936e79 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:42:07 +0200 Subject: [PATCH 22/24] finished attachment --- .../activity_pub_poc/activitystreams2.cljc | 3 +-- .../activity_pub_poc/activitystreams2_test.cljc | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 21807d1..872d692 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -47,11 +47,10 @@ ::Activity)) ;http://www.w3.org/ns/activitystreams#attachment -; TODO: Why do we need to model this? Is this necessary for a Like-Activity? (s/def ::attachment (s/and - ::owl/Class ::owl/ObjectProperty + ::owl/Class ::Object ::Link)) diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc index 136504f..29fdd13 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc @@ -29,6 +29,8 @@ (is (not (s/valid? ::sut/result 47)))) -;(deftest attachment-test -; (is (s/valid? ::sut/attachment)) -; ) \ No newline at end of file +(deftest attachment-test + (is (s/valid? ::sut/attachment + [{:type "Image", + :content "This is what he looks like.", + :url "http://example.org/cat.jpeg"}]))) -- 2.45.2 From c5376319c5d4b135c45611537ecf4c58f1b38dcd Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:45:54 +0200 Subject: [PATCH 23/24] add Like-test --- .../activity_pub_poc/activitystreams2.cljc | 1 - .../activity_pub_poc/activitystreams2_test.cljc | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 872d692..69b1a66 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -67,7 +67,6 @@ any?;::xsd/anyURI ) - ;http://www.w3.org/ns/activitystreams#result (s/def ::result (s/and diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc index 29fdd13..efbc397 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc @@ -34,3 +34,12 @@ [{:type "Image", :content "This is what he looks like.", :url "http://example.org/cat.jpeg"}]))) + + +(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"}))) -- 2.45.2 From 4ee310596a9898bb226f9e52d796f32dda841df9 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Fri, 28 Jul 2023 17:57:30 +0200 Subject: [PATCH 24/24] add actor definition --- .../activity_pub_poc/activitystreams2.cljc | 10 +++++++++- .../activitystreams2_test.cljc | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc index 69b1a66..0be62e1 100644 --- a/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc +++ b/src/main/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2.cljc @@ -29,7 +29,7 @@ (s/and ::owl/Class ::Object - (sh/map-spec (s/keys :opt-un [::result ::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" @@ -81,3 +81,11 @@ ::owl/Class ::Object ::Link)) + +;http://www.w3.org/ns/activitystreams#actor +(s/def ::actor + (s/and + ::owl/ObjectProperty + ::owl/Class + ::Object + ::Link)) diff --git a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc index efbc397..9735f68 100644 --- a/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc +++ b/src/test/cljc/org/domaindrivenarchitecture/activity_pub_poc/activitystreams2_test.cljc @@ -35,6 +35,24 @@ :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 -- 2.45.2