From a699adbe2fd5bae449198d68ceb2b6af53238a43 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Tue, 6 Sep 2016 22:08:57 +0000 Subject: [PATCH] Merged 5.2.N (5.2.1) to HEAD (5.2) 130287 gjames: Merged searchapi (5.2.1) to 5.2.N (5.2.1) 130026 gjames: SEARCH-119: Implementing filter queries (without tags) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@130359 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../rest/api/search/impl/SearchMapper.java | 19 ++++++ .../rest/api/search/model/FilterQuery.java | 60 +++++++++++++++++++ .../rest/api/search/model/SearchQuery.java | 20 +++++-- .../rest/api/search/SearchMapperTests.java | 18 +++++- .../search/SearchQuerySerializerTests.java | 4 ++ .../rest/api/search/SerializerTestHelper.java | 1 + 6 files changed, 115 insertions(+), 7 deletions(-) create mode 100644 source/java/org/alfresco/rest/api/search/model/FilterQuery.java diff --git a/source/java/org/alfresco/rest/api/search/impl/SearchMapper.java b/source/java/org/alfresco/rest/api/search/impl/SearchMapper.java index 8a3186c9b2..6aa30d109b 100644 --- a/source/java/org/alfresco/rest/api/search/impl/SearchMapper.java +++ b/source/java/org/alfresco/rest/api/search/impl/SearchMapper.java @@ -27,6 +27,7 @@ package org.alfresco.rest.api.search.impl; import org.alfresco.rest.api.search.model.Default; +import org.alfresco.rest.api.search.model.FilterQuery; import org.alfresco.rest.api.search.model.Query; import org.alfresco.rest.api.search.model.SearchQuery; import org.alfresco.rest.api.search.model.SortDef; @@ -90,6 +91,7 @@ public class SearchMapper fromTemplate(sp, searchQuery.getTemplates()); validateInclude(searchQuery.getInclude()); fromDefault(sp, searchQuery.getDefaults()); + fromFilterQuery(sp, searchQuery.getFilterQueries()); return sp; } @@ -238,4 +240,21 @@ public class SearchMapper } } + + /** + ** SearchParameters from List + * @param sp + * @param filterQueries + */ + public void fromFilterQuery(SearchParameters sp, List filterQueries) + { + if (filterQueries != null && !filterQueries.isEmpty()) + { + for (FilterQuery fq:filterQueries) + { + sp.addFilterQuery(fq.getQuery()); + } + } + } + } diff --git a/source/java/org/alfresco/rest/api/search/model/FilterQuery.java b/source/java/org/alfresco/rest/api/search/model/FilterQuery.java new file mode 100644 index 0000000000..ea9966844f --- /dev/null +++ b/source/java/org/alfresco/rest/api/search/model/FilterQuery.java @@ -0,0 +1,60 @@ +/*- + * #%L + * Alfresco Remote API + * %% + * Copyright (C) 2005 - 2016 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.api.search.model; + +import org.codehaus.jackson.annotate.JsonCreator; +import org.codehaus.jackson.annotate.JsonProperty; + +import java.util.List; + + +/** + * POJO class representing a FilterQuery + * + * @author Gethin James + */ +public class FilterQuery +{ + private final String query; + private final List tags; + + @JsonCreator + public FilterQuery(@JsonProperty("query") String query, @JsonProperty("tags") List tags) + { + this.query = query; + this.tags = tags; + } + + public String getQuery() + { + return query; + } + + public List getTags() + { + return tags; + } +} diff --git a/source/java/org/alfresco/rest/api/search/model/SearchQuery.java b/source/java/org/alfresco/rest/api/search/model/SearchQuery.java index 377bbd2134..42744821b4 100644 --- a/source/java/org/alfresco/rest/api/search/model/SearchQuery.java +++ b/source/java/org/alfresco/rest/api/search/model/SearchQuery.java @@ -45,16 +45,18 @@ public class SearchQuery private final List sort; private final List