|
22 | 22 | [k (into {} (map #(apply vector (rest %)) vs))])) |
23 | 23 | (into {})) |
24 | 24 | node-list (loop [nl [] n node] |
25 | | - (if (= :naga/nil n) |
| 25 | + (if-not n |
26 | 26 | nl |
27 | 27 | (let [{f :naga/first r :naga/rest} (listmap n)] |
28 | 28 | (recur (conj nl f) r))))] |
|
44 | 44 | (let [id (store/new-node *current-storage*) |
45 | 45 | [value-id triples] (value-triples v) |
46 | 46 | [next-id next-triples] (list-triples vs)] |
47 | | - [id (concat [[id (store/data-property *current-storage* value-id) value-id] |
48 | | - [id :naga/rest next-id]] |
| 47 | + [id (concat [[id (store/data-property *current-storage* value-id) value-id]] |
| 48 | + (when next-id [[id :naga/rest next-id]]) |
49 | 49 | triples |
50 | | - next-triples)]) |
51 | | - [:naga/nil nil])) |
| 50 | + next-triples)]))) |
52 | 51 |
|
53 | 52 | (defmethod value-triples List |
54 | 53 | [vlist] |
|
59 | 58 |
|
60 | 59 | (defmethod value-triples Map [v] (map->triples v)) |
61 | 60 |
|
62 | | -(defmethod value-triples nil [v] [:naga/nil nil]) |
| 61 | +(defmethod value-triples nil [v] nil) |
63 | 62 |
|
64 | 63 | (defmethod value-triples :default [v] [v nil]) |
65 | 64 |
|
|
69 | 68 | and builds triples around it" |
70 | 69 | [entity-id :- s/Any |
71 | 70 | [property value] :- [s/Keyword s/Any]] |
72 | | - (let [[value-id value-data] (value-triples value)] |
| 71 | + (if-let [[value-id value-data] (value-triples value)] |
73 | 72 | (cons [entity-id property value-id] value-data))) |
74 | 73 |
|
75 | 74 |
|
|
128 | 127 | "Return all the property/value pairs for a given entity in the store." |
129 | 128 | [store :- Storage |
130 | 129 | entity :- s/Any] |
131 | | - (if-not (= entity :naga/nil) |
132 | | - (store/resolve-pattern store [entity '?p '?o]))) |
| 130 | + (store/resolve-pattern store [entity '?p '?o])) |
133 | 131 |
|
134 | 132 |
|
135 | 133 | (s/defn check-structure :- (s/maybe [[s/Keyword s/Any]]) |
|
161 | 159 | ;; convert the data to a map |
162 | 160 | (let [st (into {} pairs)] |
163 | 161 | ;; if the properties indicate a list, then process it |
164 | | - (if-let [remaining (:naga/rest st)] |
165 | | - (let [first-prop-elt (get-data st) |
| 162 | + (when (:naga/first st) |
| 163 | + (let [remaining (:naga/rest st) |
| 164 | + first-prop-elt (get-data st) |
166 | 165 | [_ first-elt] (recurse-node store first-prop-elt)] |
167 | 166 | (assert first-elt) |
168 | 167 | ;; recursively build the list |
|
0 commit comments