Skip to content

Commit

Permalink
Merge pull request #272 from saidone75/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
saidone75 authored May 27, 2024
2 parents 02f2cb1 + 3c0464f commit cc3adcc
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
:dependencies [[org.clojure/clojure "1.11.3"]
[org.clojure/data.json "2.5.0"]
[org.clj-commons/clj-http-lite "1.0.13"]
[com.taoensso/telemere "1.0.0-beta12"]]
[com.taoensso/telemere "1.0.0-beta14"]]
:repl-options {:init-ns cral.alfresco})
46 changes: 46 additions & 0 deletions src/cral/api/core/queries.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
; CRAL
; Copyright (C) 2023-2024 Saidone
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.

(ns cral.api.core.queries
(:require [clj-http.lite.client :as client]
[cral.config :as config]
[cral.utils.utils :as utils])
(:import (clojure.lang PersistentHashMap)
(cral.model.auth Ticket)
(cral.model.core FindNodesQueryParams)))

(defn find-nodes
"Gets a list of nodes that match the given search criteria.
The search term is used to look for nodes that match against name, title, description, full text content or tags.
The search term:
- must contain a minimum of 3 alphanumeric characters
- allows \"quoted term\"
- can optionally use '*' for wildcard matching\n\n
By default, file and folder types will be searched unless a specific type is provided as a query parameter.
By default, the search will be across the repository unless a specific root node id is provided to start the search from.
You can sort the result list using the **order-by** parameter in `query-params`.
You can specify one or more of the following fields in the **order-by** parameter:
- name
- modifiedAt
- createdAt\n\n
More info [here](https://api-explorer.alfresco.com/api-explorer/?urls.primaryName=Core%20API#/queries/findNodes)."
([^Ticket ticket ^FindNodesQueryParams query-params & [^PersistentHashMap opts]]
(utils/call-rest
client/get
(format "%s/queries/nodes" (config/get-url 'core))
ticket
{:query-params query-params}
opts)))
11 changes: 11 additions & 0 deletions src/cral/model/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,17 @@
(defrecord GetPreferenceQueryParams
[^PersistentVector fields])

;; queries
(defrecord FindNodesQueryParams
[^String term
^String root-node-id
^Integer skip-count
^Integer max-items
^String node-type
^PersistentVector include
^PersistentVector order-by
^PersistentVector fields])

;; ratings
(defrecord ListRatingsQueryParams
[^Integer skip-count
Expand Down
2 changes: 1 addition & 1 deletion test/cral/audit_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(use-fixtures :once fixtures/setup)
(def alfresco-access "alfresco-access")

(deftest list-audit-test
(deftest list-audit-applications1-test
(let [ticket (get-in (auth/create-ticket c/user c/password) [:body :entry])]
;; list audit applications
(is (= (:status (audit/list-audit-applications ticket)) 200))))
Expand Down
30 changes: 30 additions & 0 deletions test/cral/queries_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
; CRAL
; Copyright (C) 2023-2024 Saidone
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.

(ns cral.queries-test
(:require [clojure.test :refer :all]
[cral.api.auth :as auth]
[cral.api.core.queries :as queries]
[cral.config :as c]
[cral.fixtures :as fixtures]
[cral.model.core :as model]))

(use-fixtures :once fixtures/setup)

(deftest find-nodes-test
(let [ticket (get-in (auth/create-ticket c/user c/password) [:body :entry])]
(println (->> (model/map->FindNodesQueryParams {:term "readme"})
(queries/find-nodes ticket)))))

0 comments on commit cc3adcc

Please sign in to comment.