                dc:title \"List of People\" ;
                dc:description \"A list of people contained within the application\" .
 
-ex:person-list data:haschild ex:person-name , ex:person-age , ex:pets-list .
+ex:person-list data:haschild ex:person-name , ex:person-age , ex:pets-list ,  ex:person-deleter .
+
+ex:person-deleter rdf:type data:deleter ;
+                  data:bindo rdf:type ;
+                  dc:title \"Remove\" ;
+                  dc:description \"Permanently delete a person from the database\" .
 
 ex:person-name rdf:type data:text-field ;
+               data:rank 5 ;
                data:bindo ont:name ;
                dc:title \"Name\" ;
                dc:description \"The name of a person\" .
 
 ex:person-age rdf:type data:text-field ;
+              data:rank 4 ;
               data:bindo ont:age ;
               dc:title \"Age\" ;
               dc:description \"The age of a person\".

(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))


(def functions
  {(db :list)
   {:bind (fn [uri binding predicate meta vals]
            (hic/html [:p (:title meta)]
                      [:ol {:data-uri uri
                            :data-predicate predicate
                            :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))}]]))
    :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)))))))
    ))

;;TODO projectors url should bind itself some stuff so it knows its unique values and its name

        (= (:type command) "create")
        (if reversed
          (simple-update "INSERT DATA { ?s ?p ?o }"
                         (res (:value command))
                         (prop (:predicate command))
                         (res (:uri command)))
          (simple-update "INSERT DATA { ?s ?p ?o }"
                         (res (:uri command))
                         (prop (:predicate command))
                         (res (:value command))))

        (= (:type command) "delete")
        (if reversed
          (simple-update "DELETE DATA { ?s ?p ?o }"
                         (res (:value command))
                         (prop (:predicate command))
                         (res (:uri command)))
          (simple-update "DELETE DATA { ?s ?p ?o }"
                         (res (:uri command))
                         (prop (:predicate command))
                         (res (:value command))))

       ))

(comment (if reversed
