 (defn plit [val]
   (. ResourceFactory createPlainLiteral val))
 
-(defn uuid [] (res (str "urn:uuid:" (java.util.UUID/randomUUID))))
-
-(def db (uris "http://logangilmour.com/data-binder#" :root :binds :bindo :haschild :projects :list :paragraph :text-field))
+(defn uuid [] (str "urn:uuid:" (java.util.UUID/randomUUID)))
+
+(def db (uris "http://logangilmour.com/data-binder#" :rank :root :binds :bindo :deleter :haschild :projects :list :paragraph :text-field))
 
 
 (def functions
   {(db :list)
-   {:bind (fn [uri binding predicate meta vals]
-            (hic/html [:p (:title meta)]
-                      [:ol {:data-uri uri
-                            :data-predicate predicate
+   {:resource (fn [uri binding meta vals]
+                (hic/html [:p (:title meta)]
+                          [:ol.list-binding {:data-uri uri
+                                :data-binding binding
+                                :data-description (:description meta)}
+                           vals]
+                          [:a.list-add-binding
+                           {:href "#"
+                            :data-uri uri
+                            :data-binding binding} "Create"]))
+    :value (fn [parent uri binding meta val]
+             (hic/html [:li {:data-uri uri} val]))
+
+    :update (fn [uri pred data]
+              {:type "create" :uri uri :predicate pred :value (uuid)})}
+
+   (db :deleter)
+   {:resource (fn [uri binding meta vals]
+                (hic/html [:a.remove-binding
+                                 {:href "#"
+                                  :data-uri uri
+                                  :data-binding binding
+                                  :data-value (apply str vals)} (:title meta)]))
+    :value (fn [parent uri binding meta val]
+             val)
+
+    :update (fn [uri pred data]
+              {:type "delete" :uri uri :predicate pred :value data})}
+
+   (db :paragraph)
+   {:resource (fn [uri binding meta vals]
+                (hic/html [:p {:data-uri uri
+                       :data-binding binding
+                       :data-description (:description meta)}
+                   (:title meta) ": " vals]))
+    :value (fn [parent uri binding meta val]
+             (hic/html val))
+    :update nil}
+
+   (db :text-field)
+   {:resource (fn [uri binding meta vals]
+                (hic/html [:label (str (:title meta) " ")
+                   [:input {:type "text"
+                            :class "text-field-binding"
+                            :data-uri uri
                             :data-binding binding
-                            :data-description (:description meta)}
-                       (map (fn [val] [:li (:html val) [:a.list-remove-binding
-                                               {:href "#"
-                                                :data-uri uri
-                                                :data-binding binding
-                                                :data-predicate predicate
-                                                :data-value (:uri val)} "X"]]) vals)
-                       [:a.list-add-binding
-                        {:href "#"
-                         :data-uri uri
-                         :data-binding binding
-                         :data-predicate predicate} "Create"]]))
-
-    :update (fn [uri pred data]
-              (cond (= (:type data) "add")
-                    {:type "create" :uri uri :predicate pred :value (uuid)}
-                    (= data "remove")
-                    {:type "remove" :uri uri :predicate pred :value (:value data)}))}
-
-   (db :paragraph)
-   {:bind (fn [uri binding predicate meta vals]
-            (hic/html [:p {:data-uri uri
-                           :data-binding binding
-                           :data-predicate predicate
-                           :data-description (:description meta)}
-                       (:title meta) ": " (map :html vals)]))
-    :update nil}
-
-   (db :text-field)
-   {:bind (fn [uri binding predicate meta vals]
-            (hic/html [:label (str (:title meta) " ")
-                       [:input {:type "text"
-                                :class "text-field-binding"
-                                :data-uri uri
-                                :data-predicate predicate
-                                :data-binding binding
-                                :data-description (:description meta)
-                                :value (apply str (map :html vals))}]]))
+                            :data-description (:description meta)
+                            :value (apply str vals)}]]))
+    :value (fn [parent uri binding meta val]
+             (hic/html val))
     :update (fn [uri pred data]
               {:type "update" :uri uri :predicate pred :value data})}})
 
 
 (defn relator [statement model resource]
+
   (let [binder (.getURI (.getPredicate statement))]
     (if (= binder (db :binds))
       (iterator-seq (.listResourcesWithProperty model (prop (.getURI (.asResource (.getObject statement)))) resource ))
-      (iterator-seq (.listObjectsOfProperty model resource (prop (.getURI (.asResource (.getObject statement)))))))
+      (iterator-seq
+       (.listObjectsOfProperty model resource
+                               (prop
+                                (.getURI
+                                 (.asResource
+                                  (.getObject statement)))))))
     ))
 
 ;;TODO projectors url should bind itself some stuff so it knows its unique values and its name


(def data-model (to-model data))

(def broadcast-channel (channel))
(def edit (editor (to-model example-view)))

(defn store [message]

                          (map literalize related)
                          (map seq (apply map vector (map (fn [sub-call]
                                                            (map
                                                             (partial sub-call data nil)
                                                             related))
                                                          sub-calls)))))))))))

