This is an automated email from the git hooks/post-receive script. New commit to branch feature/7644-recherche-avancée-documents in repository coselmar. See http://git.codelutin.com/coselmar.git commit a6df97b2448a0b14bcef22f58cca2daa652f0bcd Author: Yannick Martel <martel@©odelutin.com> Date: Wed Dec 9 17:56:41 2015 +0100 refs-20 #7778 Premier jet pour l'ecran de recherche avancée sur les documents et preparation côté service --- .../ifremer/coselmar/beans/DocumentSearchBean.java | 76 ++++++++++++++++++++++ .../services/CoselmarRestApplicationListener.java | 4 +- .../coselmar/services/v1/DocumentsWebService.java | 19 +++--- .../coselmar/services/v1/UsersWebService.java | 2 +- .../src/main/webapp/js/coselmar-controllers.js | 9 ++- .../src/main/webapp/js/coselmar-services.js | 9 ++- .../main/webapp/views/documents/editDocument.html | 2 +- .../main/webapp/views/documents/newdocument.html | 2 +- .../src/main/webapp/views/documents/toolsPart.html | 68 +++++++++++++++++++ 9 files changed, 175 insertions(+), 16 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentSearchBean.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentSearchBean.java new file mode 100644 index 0000000..107aea3 --- /dev/null +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/beans/DocumentSearchBean.java @@ -0,0 +1,76 @@ +package fr.ifremer.coselmar.beans; + +/* + * #%L + * Coselmar :: Rest Services + * $Id:$ + * $HeadURL:$ + * %% + * Copyright (C) 2014 Ifremer, Code Lutin + * %% + * 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/gpl-3.0.html>. + * #L% + */ + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/** + * @author ymartel <martel@codelutin.com> + */ +public class DocumentSearchBean extends DocumentBean { + + private static final long serialVersionUID = -2665085000774964576L; + + protected Integer limit; + protected Integer page; + protected List<String> fullTextSearch; + + + public DocumentSearchBean(String id, String name, String ownerName, String ownerId, String privacy, + Date depositDate, Collection<String> keywords, + String type, String summary, String language, Date publicationDate, + String authors, String license, String copyright, + boolean withFile, String mimeType, String externalUrl, + String comment, String fileName) { + super(id, name, ownerName, ownerId, privacy, depositDate, keywords, type, summary, language, publicationDate, authors, license, copyright, withFile, mimeType, externalUrl, comment, fileName); + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + this.limit = limit; + } + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public List<String> getFullTextSearch() { + return fullTextSearch; + } + + public void setFullTextSearch(List<String> fullTextSearch) { + this.fullTextSearch = fullTextSearch; + } + +} diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/CoselmarRestApplicationListener.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/CoselmarRestApplicationListener.java index 5715dd0..58b4b23 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/CoselmarRestApplicationListener.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/CoselmarRestApplicationListener.java @@ -29,6 +29,7 @@ import java.util.Set; import com.google.common.collect.Sets; import fr.ifremer.coselmar.beans.DocumentBean; +import fr.ifremer.coselmar.beans.DocumentSearchBean; import fr.ifremer.coselmar.beans.QuestionBean; import fr.ifremer.coselmar.beans.QuestionSearchBean; import fr.ifremer.coselmar.beans.UserBean; @@ -52,7 +53,8 @@ public class CoselmarRestApplicationListener implements WebMotionServerListener UserBean.class, QuestionBean.class, UserSearchBean.class, - QuestionSearchBean.class + QuestionSearchBean.class, + DocumentSearchBean.class ); @Override diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java index 6c058a9..482ae7c 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java @@ -41,11 +41,15 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import fr.ifremer.coselmar.beans.DocumentBean; +import fr.ifremer.coselmar.beans.DocumentSearchBean; import fr.ifremer.coselmar.beans.QuestionBean; +import fr.ifremer.coselmar.beans.QuestionSearchBean; import fr.ifremer.coselmar.beans.UserBean; +import fr.ifremer.coselmar.beans.UserSearchBean; import fr.ifremer.coselmar.beans.UserWebToken; import fr.ifremer.coselmar.converter.BeanEntityConverter; import fr.ifremer.coselmar.exceptions.CoselmarTechnicalException; +import fr.ifremer.coselmar.persistence.SearchRequestBean; import fr.ifremer.coselmar.persistence.entity.CoselmarUser; import fr.ifremer.coselmar.persistence.entity.CoselmarUserGroup; import fr.ifremer.coselmar.persistence.entity.CoselmarUserRole; @@ -142,22 +146,19 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { return documentBean; } - public List<DocumentBean> getDocuments(List<String> searchKeywords) throws InvalidCredentialException { + public List<DocumentBean> getDocuments(DocumentSearchBean searchBean) throws InvalidCredentialException { // Check authentication String authorization = getContext().getHeader("Authorization"); - UserWebToken userWebToken = checkAuthentication(authorization); - - // Retrieve current user - String fullCurrentUserId = getFullUserIdFromShort(userWebToken.getUserId()); - CoselmarUser currentUser = getCoselmarUserDao().forTopiaIdEquals(fullCurrentUserId).findAnyOrNull(); + CoselmarUser currentUser = checkUserAuthentication(authorization); - String currentUserRole = userWebToken.getRole().toUpperCase(); + CoselmarUserRole currentUserRole = currentUser.getRole(); List<Document> documentList; // Admin and Supervisor can see all documents (public, private and restricted) - if (Lists.newArrayList(CoselmarUserRole.ADMIN.name(), CoselmarUserRole.SUPERVISOR.name()).contains(currentUserRole)) { + if (Lists.newArrayList(CoselmarUserRole.ADMIN, CoselmarUserRole.SUPERVISOR).contains(currentUserRole)) { + List<String> searchKeywords = searchBean.getFullTextSearch(); if (searchKeywords != null && !searchKeywords.isEmpty()) { DocumentsIndexationService documentsIndexationService = getServicesContext().newService(DocumentsIndexationService.class); @@ -180,7 +181,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { } else { //Other can only see public, his own private and restricted for which he is allowed - documentList = getDocumentDao().findAllFilterByUser(currentUser, searchKeywords); + documentList = getDocumentDao().findAllFilterByUser(currentUser, searchBean.getFullTextSearch()); } List<DocumentBean> result = new ArrayList<>(documentList.size()); diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/UsersWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/UsersWebService.java index d3fb0d6..63746ea 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/UsersWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/UsersWebService.java @@ -160,7 +160,7 @@ public class UsersWebService extends CoselmarWebServiceSupport { String authorization = getContext().getHeader("Authorization"); CoselmarUser currentUser = checkUserAuthentication(authorization); - // Who is allowed here ? Admin and user himself + // Who is allowed here ? Admin, Supervisor, Expert if (currentUser.getRole() != CoselmarUserRole.ADMIN && currentUser.getRole() != CoselmarUserRole.SUPERVISOR && currentUser.getRole() != CoselmarUserRole.EXPERT) { diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 2426648..cd2e0ad 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -157,7 +157,7 @@ coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routePara //manage keywords if given $scope.search = { searchKeywords : []}; - $scope.example = { active : "true", role : 'ALL'}; + $scope.example = { keywords: []}; var keywords = $routeParams.keywords; if (Array.isArray(keywords)) { @@ -189,6 +189,13 @@ coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routePara $scope.searchDocuments = function(){ $location.search('keywords', $scope.search.searchKeywords); }; + + $scope.advancedSearchDocuments = function() { + + documentService.getAdvancedUsers($scope.example, function(documents){ + $scope.documents = documents; + }); + }; }]); // Controller for new document View diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index 0dc895b..b145c11 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -115,8 +115,7 @@ function Document(resource, config){ this.getDocuments = function(searchKeywords, successFunction, failFunction){ // Load all documents - - var docResource = resource(baseURL, {searchKeywords : searchKeywords}); + var docResource = resource(baseURL, {'searchBean' : {'fullTextSearch' : searchKeywords}}); docResource.query(successFunction, failFunction); }; @@ -136,4 +135,10 @@ function Document(resource, config){ }; + this.getAdvancedDocuments = function(searchExample, successFunction){ + // Load documents with search example + var docResource = resource(baseURL, {'searchBean' : searchExample}); + userResource.query(successFunction); + }; + }; \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/views/documents/editDocument.html b/coselmar-ui/src/main/webapp/views/documents/editDocument.html index 4b73fa5..b6588ec 100644 --- a/coselmar-ui/src/main/webapp/views/documents/editDocument.html +++ b/coselmar-ui/src/main/webapp/views/documents/editDocument.html @@ -118,7 +118,7 @@ </ui-select-match> <ui-select-choices - repeat="user in users track by user.id | propsFilter: {name: $select.search, firstName: $select.search, organization: $select.search}" + repeat="user in (users | propsFilter: {name: $select.search, firstName: $select.search, organization: $select.search}) track by user.id" refresh="refreshUsers($select.search)" refresh-delay="500"> {{user.firstName}} {{user.name}} ({{user.organization}}) diff --git a/coselmar-ui/src/main/webapp/views/documents/newdocument.html b/coselmar-ui/src/main/webapp/views/documents/newdocument.html index 7e29535..7209af4 100644 --- a/coselmar-ui/src/main/webapp/views/documents/newdocument.html +++ b/coselmar-ui/src/main/webapp/views/documents/newdocument.html @@ -127,7 +127,7 @@ </ui-select-match> <ui-select-choices - repeat="user in users track by user.id | propsFilter: {name: $select.search, firstName: $select.search, organization: $select.search}" + repeat="user in (users | propsFilter: {name: $select.search, firstName: $select.search, organization: $select.search}) track by user.id" refresh="refreshUsers($select.search)" refresh-delay="500"> {{user.firstName}} {{user.name}} ({{user.organization}}) diff --git a/coselmar-ui/src/main/webapp/views/documents/toolsPart.html b/coselmar-ui/src/main/webapp/views/documents/toolsPart.html index aba3898..410533b 100644 --- a/coselmar-ui/src/main/webapp/views/documents/toolsPart.html +++ b/coselmar-ui/src/main/webapp/views/documents/toolsPart.html @@ -61,5 +61,73 @@ </div> <form class="form-horizontal" name="userFullOption" role="userFullOptions" ng-submit="advancedSearchDocuments()"> + <div class="form-group row"> + + <label class="col-md-1 control-label">{{ 'document.metadata.name' | translate }}</label> + <div class="col-md-2"> + <input class="form-control" type="search" class="form-control" placeholder="Titre" ng-model="example.title" /> + </div> + + <label class="col-md-1 control-label">{{ 'document.metadata.authors' | translate }}</label> + <div class="col-md-2"> + <input class="form-control" type="search" class="form-control" placeholder="Nom et/ou Prénom" ng-model="example.authors" /> + </div> + + <label class="col-md-1 control-label">{{ 'document.metadata.type' | translate }}</label> + <div class="col-md-2"> + <select class="form-control" name="type" ng-model="example.type" required> + <option value="PERIODICAL_PUBLICATION">{{ 'document.metadata.type.periodicalPublication' | translate }}</option> + <option value="MEETING_PUBLICATION">{{ 'document.metadata.type.meetingPublication' | translate }}</option> + <option value="THESIS">{{ 'document.metadata.type.thesis' | translate }}</option> + <option value="REPORT">{{ 'document.metadata.type.report' | translate }}</option> + <option value="SCIENTIFIC_REPORT">{{ 'document.metadata.type.scientificReport' | translate }}</option> + <option value="SCIENTIFIC_WORK">{{ 'document.metadata.type.scientificWork' | translate }}</option> + <option value="CHAPTER_WORK">{{ 'document.metadata.type.chapterWork' | translate }}</option> + <option value="CONTRACT_REPORT">{{ 'document.metadata.type.contractReport' | translate }}</option> + <option value="EXPERTISE">{{ 'document.metadata.type.expertise' | translate }}</option> + <option value="POSTER">{{ 'document.metadata.type.poster' | translate }}</option> + <option value="CONFERENCE_ARTICLE">{{ 'document.metadata.type.conferenceArticle' | translate }}</option> + <option value="CONFERENCE_SUMMARY">{{ 'document.metadata.type.conferenceSummary' | translate }}</option> + <option value="DATA">{{ 'document.metadata.type.data' | translate }}</option> + <option value="OTHER">{{ 'document.metadata.type.other' | translate }}</option> + </select> + </div> + + <label class="col-md-1 control-label">{{ 'document.metadata.privacy' | translate }}</label> + <div class="col-md-2"> + <select class="form-control" name="privacy" + ng-model="example.privacy"> + <option value="PRIVATE">{{ 'common.privacy.private' | translate }}</option> + <option value="PUBLIC">{{ 'common.privacy.public' | translate }}</option> + <option value="RESTRICTED">{{ 'common.privacy.restricted' | translate }}</option> + </select> + </div> + + </div> + + <div class="form-group row"> + + <label class="col-md-1 control-label">{{ 'document.metadata.depositor' | translate }}</label> + <div class="col-md-2"> + <input type="search" class="form-control" placeholder="Prénom Nom" ng-model="example.depositor" ng-list /> + + </div> + + <label class="col-md-1 control-label">{{ 'document.metadata.keywords' | translate }}</label> + <div class="col-md-2"> + <input type="search" class="form-control" placeholder="keyword1,keyword2,..." ng-model="example.keywords" ng-list /> + </div> + + <label class="col-md-1 control-label">{{ 'document.metadata.licence' | translate }}</label> + <div class="col-md-2"> + <input type="text" class="form-control" name="licence" + placeholder="Licence" ng-model="example.licence"/> + </div> + + <div class="col-md-3 text-right"> + <button type="submit" class="btn btn-primary fa fa-search" ng-click="advancedSearchDocuments()"><span class="paddingLeft10">Search</span></button> + </div> + + </div> </form> </div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm