Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse RDF lists outside as part of SHACL processing #4

Open
bartkl opened this issue Jun 5, 2022 · 2 comments
Open

Parse RDF lists outside as part of SHACL processing #4

bartkl opened this issue Jun 5, 2022 · 2 comments
Assignees
Labels
quality Improving the quality of code and documentation

Comments

@bartkl
Copy link
Owner

bartkl commented Jun 5, 2022

Now, RDF lists in the Asami results are converted to seqs (using rdf-list->seq) during the Avro processing. That's bad separation of concerns.

Spec'ing made me catch this! Because I now had to deal with RDF lists in my SHACL specs.

@bartkl bartkl changed the title Parse rdf lists outside as part of SHACL processing Parse RDF lists outside as part of SHACL processing Jun 5, 2022
@bartkl bartkl added the quality Improving the quality of code and documentation label Jul 13, 2022
@bartkl bartkl added this to Metamorph Jul 14, 2022
@bartkl bartkl moved this to Todo in Metamorph Jul 14, 2022
@bartkl bartkl moved this from Todo to In Progress in Metamorph Nov 9, 2022
@bartkl bartkl self-assigned this Nov 9, 2022
@bartkl
Copy link
Owner Author

bartkl commented Nov 9, 2022

Making matters more pressing: the SQL schema generation code also does this list parsing itself, and now that we're implementing OpenAPI as a new schema target, we would yet again have to repeat ourselves.

This is the time to fix this.

@bartkl bartkl moved this from In Progress to Todo in Metamorph Jan 30, 2023
@bartkl bartkl moved this from Todo to In Progress in Metamorph Jan 30, 2023
@bartkl
Copy link
Owner Author

bartkl commented Feb 1, 2023

(ns metamorph.graph.db
  (:require [clojure.walk :as walk]
            [asami.core :as d]
            [metamorph.rdf.datatype :refer [rdf-list->seq]]))

;; ...

(defn parse-rdf-lists [n]
  (letfn [(rdf-list? [f] (and (:rdf/first f) (:rdf/rest f)))
          (single-property? [f] (and
                                 (vector? f)
                                 (= (first f) :sh/property)
                                 (not (set? (second f)))))]
    (println (:id n))
    (->> n
         (walk/prewalk #(cond
                          (rdf-list? %) (into [] (rdf-list->seq %))
                          (single-property? %) [(first %) (hash-set (second %))]
                          :else %)))))

;; ...

(defn get-resource [conn iri]
  (parse-rdf-lists (d/entity conn iri true)))

;; And of course remove the existing calls to `rdf-list->seq`.

@bartkl bartkl moved this from In Progress to Todo in Metamorph Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quality Improving the quality of code and documentation
Projects
None yet
Development

No branches or pull requests

1 participant