 (defn index-controller
   [entity-key uri-parameters]
   (with-db-transaction'
-    (apply index-view entity-key (get-condition-matched-entities entity-key))))
+    (apply index-view entity-key (condition-matched-entities-and-page entity-key))))
 
 (defn select-controller
   [entity-key uri-parameters]
   (with-db-transaction'
-    (apply select-view entity-key (get-condition-matched-entities entity-key))))
+    (apply select-view entity-key (condition-matched-entities-and-page entity-key))))
 
 (defn new-controller
   [entity-key uri-parameters]

  [entity-key property-key]
  nil)

(defn get-condition-matched-entities
  [entity-key]
  (if (and (= (get-in *request* [:params :command]) "search") (empty? (:entity-param-errors *request*)))
    (let [pages      (->> (-> (->> (if-let [conditions (not-empty (keep (partial condition entity-key) (search-condition-property-keys entity-key)))]

(dog-mission/conj-resource-bundle-namespace "sweet-crossplane.message")

;; Utilities.

;; ring middlewares. You should add below middlewares in your application.

(defn wrap-http-header-cache-control
  [handler]
  (fn [request]
    (if-let [response (handler request)]
      (assoc-in response [:headers "Cache-Control"] "max-age=0, private, must-revalidate"))))

(defn wrap-time-zone
  [handler]
  (fn [{:keys [uri query-string] :as request}]
    (if-let [time-zone-id (get-in request [:cookies "time-zone-id" :value])]
      (binding [dog-mission/*time-zone* (TimeZone/getTimeZone time-zone-id)]
        (handler request))
      (compojure.response/render (html5 [:body
                                         (hidden-field   :go-back-uri (str uri (and (not-empty query-string) "?") query-string))
                                         (javascript-tag "var timeZoneOffset = new Date().getTimezoneOffset();
                                                          var timeZoneId = \"GMT\" + (timeZoneOffset < 0 ? \"+\" : \"-\") + (\"0\" + (Math.floor (Math.abs (timeZoneOffset / 60)))).slice(-2) + \":\" + (\"0\" + (timeZoneOffset % 60)).slice(-2);
                                                          document.cookie = \"time-zone-id=\" + encodeURIComponent(timeZoneId);
                                                          location.href = document.getElementById(\"go-back-uri\").value;")])
                                 request))))

(defn wrap-locale
  [handler {:keys [locales]}]
