This is an automated email from the git hooks/post-receive script. New change to branch feature/7644-recherche-avancée-documents in repository coselmar. See http://git.codelutin.com/coselmar.git from 9424a8a refs-30 #7778 Revue de la couche DAO pour la recherche de documents new 0ec2d8b refs-90 #7778 Revue avancée de documents The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 0ec2d8b36d187cc228c7b3dfe16b49d17535865a Author: Yannick Martel <martel@©odelutin.com> Date: Thu Dec 10 18:28:17 2015 +0100 refs-90 #7778 Revue avancée de documents Summary of changes: .../coselmar/beans/DocumentSearchExample.java | 69 ++++++++++++++++++++++ .../ifremer/coselmar/beans/QuestionSearchBean.java | 30 +--------- .../fr/ifremer/coselmar/beans/SearchExample.java | 65 ++++++++++++++++++++ .../persistence/entity/DocumentTopiaDao.java | 30 ++++++++-- .../persistence/entity/QuestionTopiaDao.java | 2 +- .../coselmar/converter/BeanEntityConverter.java | 60 +++++++++++++++++++ .../indexation/QuestionsIndexationService.java | 2 +- .../coselmar/services/v1/DocumentsWebService.java | 20 +++++-- .../coselmar/services/QuestionsWebServiceTest.java | 14 ++--- .../indexation/QuestionsIndexationServiceTest.java | 54 ++++++++--------- .../src/main/webapp/js/coselmar-controllers.js | 10 ++-- .../src/main/webapp/js/coselmar-services.js | 2 +- .../src/main/webapp/views/documents/toolsPart.html | 8 +-- .../src/main/webapp/views/questions/questions.html | 2 +- 14 files changed, 284 insertions(+), 84 deletions(-) create mode 100644 coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/DocumentSearchExample.java create mode 100644 coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/SearchExample.java -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 0ec2d8b36d187cc228c7b3dfe16b49d17535865a Author: Yannick Martel <martel@©odelutin.com> Date: Thu Dec 10 18:28:17 2015 +0100 refs-90 #7778 Revue avancée de documents --- .../coselmar/beans/DocumentSearchExample.java | 69 ++++++++++++++++++++++ .../ifremer/coselmar/beans/QuestionSearchBean.java | 30 +--------- .../fr/ifremer/coselmar/beans/SearchExample.java | 65 ++++++++++++++++++++ .../persistence/entity/DocumentTopiaDao.java | 30 ++++++++-- .../persistence/entity/QuestionTopiaDao.java | 2 +- .../coselmar/converter/BeanEntityConverter.java | 60 +++++++++++++++++++ .../indexation/QuestionsIndexationService.java | 2 +- .../coselmar/services/v1/DocumentsWebService.java | 20 +++++-- .../coselmar/services/QuestionsWebServiceTest.java | 14 ++--- .../indexation/QuestionsIndexationServiceTest.java | 54 ++++++++--------- .../src/main/webapp/js/coselmar-controllers.js | 10 ++-- .../src/main/webapp/js/coselmar-services.js | 2 +- .../src/main/webapp/views/documents/toolsPart.html | 8 +-- .../src/main/webapp/views/questions/questions.html | 2 +- 14 files changed, 284 insertions(+), 84 deletions(-) diff --git a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/DocumentSearchExample.java b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/DocumentSearchExample.java new file mode 100644 index 0000000..7c72c61 --- /dev/null +++ b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/DocumentSearchExample.java @@ -0,0 +1,69 @@ +package fr.ifremer.coselmar.beans; + +import fr.ifremer.coselmar.persistence.SearchRequestBean; +import fr.ifremer.coselmar.persistence.entity.Document; + +import java.util.Date; + +/** + * @author ymartel (martel@codelutin.com) + */ +public class DocumentSearchExample extends SearchExample<Document> { + + public static final DocumentSearchExample newDefaultSearchExample() { + DocumentSearchExample searchExample = new DocumentSearchExample(); + searchExample.setPage(DEFAULT_PAGE); + searchExample.setLimit(DEFAULT_PAGE_SIZE); + return searchExample; + } + + protected Date publicationAfterDate; + + protected Date publicationBeforeDate; + + protected Date depositAfterDate; + + protected Date depositBeforeDate; + + protected String ownerName; + + public Date getPublicationAfterDate() { + return publicationAfterDate; + } + + public void setPublicationAfterDate(Date publicationAfterDate) { + this.publicationAfterDate = publicationAfterDate; + } + + public Date getPublicationBeforeDate() { + return publicationBeforeDate; + } + + public void setPublicationBeforeDate(Date publicationBeforeDate) { + this.publicationBeforeDate = publicationBeforeDate; + } + + public Date getDepositAfterDate() { + return depositAfterDate; + } + + public void setDepositAfterDate(Date depositAfterDate) { + this.depositAfterDate = depositAfterDate; + } + + public Date getDepositBeforeDate() { + return depositBeforeDate; + } + + public void setDepositBeforeDate(Date depositBeforeDate) { + this.depositBeforeDate = depositBeforeDate; + } + + public String getOwnerName() { + return ownerName; + } + + public void setOwnerName(String ownerName) { + this.ownerName = ownerName; + } +} diff --git a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/QuestionSearchBean.java b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/QuestionSearchBean.java index 12d9a82..656fb3e 100644 --- a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/QuestionSearchBean.java +++ b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/QuestionSearchBean.java @@ -24,30 +24,21 @@ package fr.ifremer.coselmar.beans; * #L% */ +import fr.ifremer.coselmar.persistence.entity.Question; + import java.io.Serializable; import java.util.List; /** * @author ymartel <martel@codelutin.com> */ -public class QuestionSearchBean implements Serializable { +public class QuestionSearchBean extends SearchExample<Question> { private static final long serialVersionUID = -3318003570685481073L; - protected List<String> keywords; protected String status; protected String privacy; - protected Integer limit; - protected Integer page; - - public List<String> getKeywords() { - return keywords; - } - - public void setKeywords(List<String> keywords) { - this.keywords = keywords; - } public String getStatus() { return status; @@ -65,19 +56,4 @@ public class QuestionSearchBean implements Serializable { this.privacy = privacy; } - 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; - } } diff --git a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/SearchExample.java b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/SearchExample.java new file mode 100644 index 0000000..c8548d3 --- /dev/null +++ b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/beans/SearchExample.java @@ -0,0 +1,65 @@ +package fr.ifremer.coselmar.beans; + +import org.nuiton.topia.persistence.TopiaEntity; + +import java.io.Serializable; +import java.util.List; + +/** + * @author ymartel (martel@codelutin.com) + */ +public class SearchExample<E extends TopiaEntity> implements Serializable { + + private static final long serialVersionUID = 4024861043438299258L; + + public static final int DEFAULT_PAGE_SIZE = -1; + public static final int DEFAULT_PAGE = 0; + + protected E example; + + protected List<String> fullTextSearch; + + // Pagination Parameters + protected Integer limit; + protected Integer page; + + public E getExample() { + return example; + } + + public void setExample(E example) { + this.example = example; + } + + public List<String> getFullTextSearch() { + return fullTextSearch; + } + + public void setFullTextSearch(List<String> fullTextSearch) { + this.fullTextSearch = fullTextSearch; + } + + public Integer getLimit() { + return limit; + } + + public void setLimit(Integer limit) { + if (limit == null) { + this.limit = DEFAULT_PAGE_SIZE; + } else { + this.limit = limit; + } + } + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + if (page == null) { + this.page = DEFAULT_PAGE; + } else { + this.page = page; + } + } +} diff --git a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/DocumentTopiaDao.java b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/DocumentTopiaDao.java index c5b691d..aec17d4 100644 --- a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/DocumentTopiaDao.java +++ b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/DocumentTopiaDao.java @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import fr.ifremer.coselmar.beans.DocumentSearchExample; import fr.ifremer.coselmar.persistence.DaoUtils; import fr.ifremer.coselmar.persistence.SearchRequestBean; import org.apache.commons.lang3.StringUtils; @@ -102,10 +103,11 @@ public class DocumentTopiaDao extends AbstractDocumentTopiaDao<Document> { return documents; } - public List<Document> findAllByExample(CoselmarUser userFilter, Document example, SearchRequestBean requestBean) { + public List<Document> findAllByExample(CoselmarUser userFilter, DocumentSearchExample searchExample) { StringBuilder hqlBuilder = new StringBuilder("SELECT DISTINCT(D) FROM " + Document.class.getName() + " D" - + " LEFT OUTER JOIN D." + Document.PROPERTY_RESTRICTED_LIST + " CUG "); + + " LEFT OUTER JOIN D." + Document.PROPERTY_RESTRICTED_LIST + " CUG " + + " LEFT OUTER JOIN D." + Document.PROPERTY_OWNER + " DO "); hqlBuilder.append(" WHERE 1=1 "); // Just because next clause will begin with operator Map<String, Object> args = new HashMap<>(); @@ -127,6 +129,7 @@ public class DocumentTopiaDao extends AbstractDocumentTopiaDao<Document> { // Manage example + Document example = searchExample.getExample(); if (example != null) { hqlBuilder.append(" AND ( 1 = 1 "); @@ -167,14 +170,33 @@ public class DocumentTopiaDao extends AbstractDocumentTopiaDao<Document> { hqlBuilder.append(ownerCondition); } + + // Now lets start keywords on each text fields on User ! + if (StringUtils.isNotBlank(searchExample.getOwnerName())) { + + String activeCondition = DaoUtils.andAttributeEquals("DO", CoselmarUser.PROPERTY_ACTIVE, args, true); + hqlBuilder.append(activeCondition); + + // try to find name in user#firstName or user#name! + hqlBuilder.append(" AND ( 1=0 "); // Same as previously : need to have an insignificant clause to add all OR after + String orFirstname = DaoUtils.orAttributeLike("DO", CoselmarUser.PROPERTY_FIRSTNAME, args, searchExample.getOwnerName()); + hqlBuilder.append(orFirstname); + + // Name + String orName = DaoUtils.orAttributeLike("DO", CoselmarUser.PROPERTY_NAME, args, searchExample.getOwnerName()); + hqlBuilder.append(orName); + + hqlBuilder.append(" ) "); // Close this keywords clause + } + hqlBuilder.append(" ) "); } // Manage keywords search in : title, summary, authors and keywords - if (requestBean.getFullTextSearch() != null && !requestBean.getFullTextSearch().isEmpty()) { + if (searchExample.getFullTextSearch() != null && !searchExample.getFullTextSearch().isEmpty()) { hqlBuilder.append(" AND ( 1 = 0 "); - for (String keyword : requestBean.getFullTextSearch()) { + for (String keyword : searchExample.getFullTextSearch()) { String nameClause = DaoUtils.orAttributeLike("D", Document.PROPERTY_NAME, args, keyword); String summaryClause = DaoUtils.orAttributeLike("D", Document.PROPERTY_SUMMARY, args, keyword); String authorsClause = DaoUtils.orAttributeLike("D", Document.PROPERTY_AUTHORS, args, keyword); diff --git a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/QuestionTopiaDao.java b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/QuestionTopiaDao.java index bc02716..9983f18 100644 --- a/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/QuestionTopiaDao.java +++ b/coselmar-persistence/src/main/java/fr/ifremer/coselmar/persistence/entity/QuestionTopiaDao.java @@ -237,7 +237,7 @@ public class QuestionTopiaDao extends AbstractQuestionTopiaDao<Question> { finerHqlBuilder.append(statusHql); } - List<String> keywords = searchBean.getKeywords(); + List<String> keywords = searchBean.getFullTextSearch(); if (keywords != null && !keywords.isEmpty()) { // should be like : """ ( (1=1) // AND ( 1=0 OR title like keyword1 OR summary like keyword1 OR theme contains keyword1 ) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java index 5e2bc97..25914fe 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/converter/BeanEntityConverter.java @@ -27,6 +27,7 @@ package fr.ifremer.coselmar.converter; import java.util.Collection; import java.util.Date; import java.util.HashSet; +import java.util.LinkedList; import java.util.Set; import com.google.common.collect.Sets; @@ -38,6 +39,8 @@ import fr.ifremer.coselmar.persistence.entity.CoselmarUserGroup; import fr.ifremer.coselmar.persistence.entity.CoselmarUserImpl; import fr.ifremer.coselmar.persistence.entity.CoselmarUserRole; import fr.ifremer.coselmar.persistence.entity.Document; +import fr.ifremer.coselmar.persistence.entity.DocumentImpl; +import fr.ifremer.coselmar.persistence.entity.Privacy; import fr.ifremer.coselmar.persistence.entity.Question; import org.apache.commons.lang3.StringUtils; import org.nuiton.topia.persistence.TopiaIdFactory; @@ -263,4 +266,61 @@ public class BeanEntityConverter { return result; } + /** + * Convert simple fields from {@link DocumentBean} into a {@link Document}. + * So, this does not convert : + * <ul> + * <li>Document#owner</li> + * <li>Document#restrictedList</li> + * </ul> + * If documentBean is null, simply return null Document. + */ + public static Document fromBean(DocumentBean documentBean) { + if (documentBean == null) { + return null; + } + + Document document = new DocumentImpl(); + + document.setName(documentBean.getName()); + + Date depositDate = documentBean.getDepositDate(); + if (depositDate != null) { + document.setDepositDate(new Date(depositDate.getTime())); + } + + Set<String> keywords = documentBean.getKeywords(); + if (keywords != null) { + document.setKeywords(new LinkedList(keywords)); + } + + document.setMimeType(documentBean.getMimeType()); + document.setCopyright(documentBean.getCopyright()); + document.setAuthors(documentBean.getAuthors()); + document.setLicense(documentBean.getLicense()); + document.setLanguage(documentBean.getLanguage()); + document.setType(documentBean.getType()); + String privacy = documentBean.getPrivacy(); + + if (StringUtils.isNotBlank(privacy)) { + document.setPrivacy(Privacy.valueOf(privacy)); + } + + Date publicationDate = documentBean.getPublicationDate(); + if (publicationDate != null) { + document.setPublicationDate(new Date(publicationDate.getTime())); + } else { + document.setPublicationDate(null); + } + + document.setSummary(documentBean.getSummary()); + document.setWithFile(documentBean.isWithFile()); + document.setExternalUrl(documentBean.getExternalUrl()); + document.setComment(documentBean.getComment()); + document.setFileName(documentBean.getFileName()); + + return document; + } + + } diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationService.java index 36bffef..70d2469 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationService.java @@ -156,7 +156,7 @@ public class QuestionsIndexationService extends CoselmarSimpleServiceSupport { } // Keywords part - List<String> keywords = searchBean.getKeywords(); + List<String> keywords = searchBean.getFullTextSearch(); if (keywords != null && !keywords.isEmpty()) { BooleanQuery keywordsQuery = new BooleanQuery(); 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 6dd657f..3eba6e1 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 @@ -42,6 +42,7 @@ 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.DocumentSearchExample; import fr.ifremer.coselmar.beans.QuestionBean; import fr.ifremer.coselmar.beans.QuestionSearchBean; import fr.ifremer.coselmar.beans.UserBean; @@ -154,17 +155,24 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { CoselmarUserRole currentUserRole = currentUser.getRole(); - SearchRequestBean requestBean = SearchRequestBean.newDefaultSearchRequestBean(); + DocumentSearchExample searchExample = DocumentSearchExample.newDefaultSearchExample(); if (searchBean != null) { if (searchBean.getPage() != null) { - requestBean.setPage(searchBean.getPage()); + searchExample.setPage(searchBean.getPage()); } if (searchBean.getLimit() != null) { - requestBean.setLimit(searchBean.getLimit()); + searchExample.setLimit(searchBean.getLimit()); } - requestBean.setFullTextSearch(searchBean.getFullTextSearch()); + searchExample.setFullTextSearch(searchBean.getFullTextSearch()); + + Document example = BeanEntityConverter.fromBean(searchBean); + searchExample.setExample(example); + + searchExample.setOwnerName(searchBean.getOwnerName()); + } + List<Document> documentList; // Admin and Supervisor can see all documents (public, private and restricted) @@ -187,12 +195,12 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { } } else { - documentList = getDocumentDao().findAll(); + documentList = getDocumentDao().findAllByExample(null, searchExample); } } else { //Other can only see public, his own private and restricted for which he is allowed - documentList = getDocumentDao().findAllByExample(currentUser, null, requestBean); + documentList = getDocumentDao().findAllByExample(currentUser, searchExample); } List<DocumentBean> result = new ArrayList<>(documentList.size()); diff --git a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/QuestionsWebServiceTest.java b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/QuestionsWebServiceTest.java index d579413..1d8903f 100644 --- a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/QuestionsWebServiceTest.java +++ b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/QuestionsWebServiceTest.java @@ -155,7 +155,7 @@ public class QuestionsWebServiceTest extends AbstractCoselmarWebServiceTest { // Third search : as supervisor, searchBean with public privacy and test keywords : retrieve documentOne searchRequest = createRequest("/v1/questions") - .addParameter("searchOption", "{privacy : 'public', keywords : ['test']}") + .addParameter("searchOption", "{privacy : 'public', fullTextSearch : ['test']}") .Get() .addHeader("Authorization", "Bearer " + supervisorToken); @@ -169,7 +169,7 @@ public class QuestionsWebServiceTest extends AbstractCoselmarWebServiceTest { // Fourth search : as supervisor, searchBean with test and pandorica keywords : retrieve nothing searchRequest = createRequest("/v1/questions") - .addParameter("searchOption", "{privacy : 'public', keywords : ['test', 'pandorica']}") + .addParameter("searchOption", "{privacy : 'public', fullTextSearch : ['test', 'pandorica']}") .Get() .addHeader("Authorization", "Bearer " + supervisorToken); @@ -182,7 +182,7 @@ public class QuestionsWebServiceTest extends AbstractCoselmarWebServiceTest { // Fifth search : as supervisor, searchBean with test keyword : retrieve documentOne and documentThree searchRequest = createRequest("/v1/questions") - .addParameter("searchOption", "{keywords : ['test']}") + .addParameter("searchOption", "{fullTextSearch : ['test']}") .Get() .addHeader("Authorization", "Bearer " + supervisorToken); @@ -198,7 +198,7 @@ public class QuestionsWebServiceTest extends AbstractCoselmarWebServiceTest { // Sixth search : as supervisor, searchBean with test and universe keywords : retrieve documentThree searchRequest = createRequest("/v1/questions") - .addParameter("searchOption", "{keywords : ['test', 'Universe']}") + .addParameter("searchOption", "{fullTextSearch : ['test', 'Universe']}") .Get() .addHeader("Authorization", "Bearer " + supervisorToken); @@ -259,7 +259,7 @@ public class QuestionsWebServiceTest extends AbstractCoselmarWebServiceTest { // Ninth search : as expert, searchBean with public privacy and test keywords : retrieve documentOne searchRequest = createRequest("/v1/questions") - .addParameter("searchOption", "{privacy : 'public', keywords : ['test']}") + .addParameter("searchOption", "{privacy : 'public', fullTextSearch : ['test']}") .Get() .addHeader("Authorization", "Bearer " + expertToken); @@ -273,7 +273,7 @@ public class QuestionsWebServiceTest extends AbstractCoselmarWebServiceTest { // Tenth search : as supervisor, searchBean with test and pandorica keywords : retrieve nothing searchRequest = createRequest("/v1/questions") - .addParameter("searchOption", "{privacy : 'public', keywords : ['test', 'pandorica']}") + .addParameter("searchOption", "{privacy : 'public', fullTextSearch : ['test', 'pandorica']}") .Get() .addHeader("Authorization", "Bearer " + expertToken); @@ -286,7 +286,7 @@ public class QuestionsWebServiceTest extends AbstractCoselmarWebServiceTest { // Eleventh search : as expert, searchBean with pandorica keyword : retrieve nothing (documentThree is private) searchRequest = createRequest("/v1/questions") - .addParameter("searchOption", "{keywords : ['zero']}") + .addParameter("searchOption", "{fullTextSearch : ['zero']}") .Get() .addHeader("Authorization", "Bearer " + expertToken); diff --git a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationServiceTest.java b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationServiceTest.java index 99755bb..b71bb04 100644 --- a/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationServiceTest.java +++ b/coselmar-rest/src/test/java/fr/ifremer/coselmar/services/indexation/QuestionsIndexationServiceTest.java @@ -127,76 +127,76 @@ public class QuestionsIndexationServiceTest extends AbstractCoselmarServiceTest // Ok, let's search now ! QuestionSearchBean searchBean = new QuestionSearchBean(); - searchBean.setKeywords(Arrays.asList("ultimate")); + searchBean.setFullTextSearch(Arrays.asList("ultimate")); List<String> questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingTitleIds.size()); Assert.assertEquals(questionTwoId, questionMatchingTitleIds.get(0)); - searchBean.setKeywords(Arrays.asList("amy")); + searchBean.setFullTextSearch(Arrays.asList("amy")); List<String> questionMatchingAmyIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertTrue(questionMatchingAmyIds.isEmpty()); - searchBean.setKeywords(Arrays.asList("Pandorica")); + searchBean.setFullTextSearch(Arrays.asList("Pandorica")); List<String> questionMatchingPandoricaIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingPandoricaIds.size()); Assert.assertEquals(questionThreeId, questionMatchingPandoricaIds.get(0)); - searchBean.setKeywords(Arrays.asList("universe")); + searchBean.setFullTextSearch(Arrays.asList("universe")); List<String> questionMatchingUniverseIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(2, questionMatchingUniverseIds.size()); Assert.assertTrue(questionMatchingUniverseIds.contains(questionThreeId)); Assert.assertTrue(questionMatchingUniverseIds.contains(questionOneId)); - searchBean.setKeywords(Arrays.asList("universe", "someone")); + searchBean.setFullTextSearch(Arrays.asList("universe", "someone")); List<String> questionMatchingUniverseAndSomeoneIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingUniverseAndSomeoneIds.size()); Assert.assertEquals(questionThreeId, questionMatchingUniverseAndSomeoneIds.get(0)); - searchBean.setKeywords(Arrays.asList("Unknown")); + searchBean.setFullTextSearch(Arrays.asList("Unknown")); List<String> documentMatchingUnknownIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertTrue(documentMatchingUnknownIds.isEmpty()); - searchBean.setKeywords(Arrays.asList("Something blue")); + searchBean.setFullTextSearch(Arrays.asList("Something blue")); List<String> documentMatchingPartOfSummaryIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, documentMatchingPartOfSummaryIds.size()); Assert.assertEquals(questionThreeId, documentMatchingPartOfSummaryIds.get(0)); - searchBean.setKeywords(Arrays.asList("Something borrowed,")); + searchBean.setFullTextSearch(Arrays.asList("Something borrowed,")); documentMatchingPartOfSummaryIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, documentMatchingPartOfSummaryIds.size()); Assert.assertEquals(questionThreeId, documentMatchingPartOfSummaryIds.get(0)); - searchBean.setKeywords(Arrays.asList("can we")); + searchBean.setFullTextSearch(Arrays.asList("can we")); documentMatchingPartOfSummaryIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, documentMatchingPartOfSummaryIds.size()); Assert.assertEquals(questionOneId, documentMatchingPartOfSummaryIds.get(0)); - searchBean.setKeywords(null); + searchBean.setFullTextSearch(null); searchBean.setPrivacy(Privacy.PUBLIC.name()); List<String> documentMatchingPrivacyIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(2, documentMatchingPrivacyIds.size()); Assert.assertTrue(documentMatchingPrivacyIds.contains(questionOneId)); Assert.assertTrue(documentMatchingPrivacyIds.contains(questionTwoId)); - searchBean.setKeywords(null); + searchBean.setFullTextSearch(null); searchBean.setPrivacy(Privacy.PRIVATE.name()); documentMatchingPrivacyIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, documentMatchingPrivacyIds.size()); Assert.assertEquals(questionThreeId, documentMatchingPrivacyIds.get(0)); - searchBean.setKeywords(Arrays.asList("Universe")); + searchBean.setFullTextSearch(Arrays.asList("Universe")); searchBean.setPrivacy(Privacy.PUBLIC.name()); List<String> documentMatchingPrivacyAndUniverseKeywordIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, documentMatchingPrivacyAndUniverseKeywordIds.size()); Assert.assertEquals(questionOneId, documentMatchingPrivacyAndUniverseKeywordIds.get(0)); - searchBean.setKeywords(Arrays.asList("Something blue")); + searchBean.setFullTextSearch(Arrays.asList("Something blue")); searchBean.setPrivacy(Privacy.PRIVATE.name()); List<String> documentMatchingPrivacyAndPartOfSummaryIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, documentMatchingPrivacyAndPartOfSummaryIds.size()); Assert.assertEquals(questionThreeId, documentMatchingPrivacyAndPartOfSummaryIds.get(0)); - searchBean.setKeywords(Arrays.asList("Something blue")); + searchBean.setFullTextSearch(Arrays.asList("Something blue")); searchBean.setPrivacy(Privacy.PUBLIC.name()); documentMatchingPrivacyAndPartOfSummaryIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertTrue(documentMatchingPrivacyAndPartOfSummaryIds.isEmpty()); @@ -243,22 +243,22 @@ public class QuestionsIndexationServiceTest extends AbstractCoselmarServiceTest // Ok, let's search now ! QuestionSearchBean searchBean = new QuestionSearchBean(); - searchBean.setKeywords(Arrays.asList("awesome")); + searchBean.setFullTextSearch(Arrays.asList("awesome")); List<String> questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertTrue(questionMatchingTitleIds.isEmpty()); - searchBean.setKeywords(Arrays.asList("who")); + searchBean.setFullTextSearch(Arrays.asList("who")); questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(2, questionMatchingTitleIds.size()); Assert.assertTrue(questionMatchingTitleIds.contains(questionOneId)); Assert.assertTrue(questionMatchingTitleIds.contains(questionTwoId)); - searchBean.setKeywords(Arrays.asList("doctor")); + searchBean.setFullTextSearch(Arrays.asList("doctor")); questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingTitleIds.size()); Assert.assertTrue(questionMatchingTitleIds.contains(questionOneId)); - searchBean.setKeywords(null); + searchBean.setFullTextSearch(null); searchBean.setPrivacy(Privacy.PRIVATE.name()); questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingTitleIds.size()); @@ -270,7 +270,7 @@ public class QuestionsIndexationServiceTest extends AbstractCoselmarServiceTest questionsIndexationService.indexQuestion(questionOne); // Ok, let's search now ! - searchBean.setKeywords(Arrays.asList("who")); + searchBean.setFullTextSearch(Arrays.asList("who")); searchBean.setPrivacy(Privacy.PUBLIC.name()); questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingTitleIds.size()); @@ -314,17 +314,17 @@ public class QuestionsIndexationServiceTest extends AbstractCoselmarServiceTest // Ok, let's search now ! QuestionSearchBean searchBean = new QuestionSearchBean(); - searchBean.setKeywords(Arrays.asList("awesome")); + searchBean.setFullTextSearch(Arrays.asList("awesome")); List<String> questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingTitleIds.size()); Assert.assertEquals(questionOneId, questionMatchingTitleIds.get(0)); - searchBean.setKeywords(Arrays.asList("missing")); + searchBean.setFullTextSearch(Arrays.asList("missing")); questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingTitleIds.size()); Assert.assertEquals(questionTwoId, questionMatchingTitleIds.get(0)); - searchBean.setKeywords(Arrays.asList("universe")); + searchBean.setFullTextSearch(Arrays.asList("universe")); List<String> questionMatchingUniverseIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(2, questionMatchingUniverseIds.size()); Assert.assertTrue(questionMatchingUniverseIds.contains(questionOneId)); @@ -334,26 +334,26 @@ public class QuestionsIndexationServiceTest extends AbstractCoselmarServiceTest questionsIndexationService.deleteQuestion(questionOneId); // and let's search same now ! - searchBean.setKeywords(Arrays.asList("awesome")); + searchBean.setFullTextSearch(Arrays.asList("awesome")); questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertTrue(questionMatchingTitleIds.isEmpty()); - searchBean.setKeywords(Arrays.asList("missing")); + searchBean.setFullTextSearch(Arrays.asList("missing")); questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingTitleIds.size()); Assert.assertTrue(questionMatchingTitleIds.contains(questionTwoId)); - searchBean.setKeywords(Arrays.asList("universe")); + searchBean.setFullTextSearch(Arrays.asList("universe")); questionMatchingUniverseIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, questionMatchingUniverseIds.size()); Assert.assertTrue(questionMatchingUniverseIds.contains(questionTwoId)); - searchBean.setKeywords(Arrays.asList("can we")); + searchBean.setFullTextSearch(Arrays.asList("can we")); List<String> documentMatchingPartOfSummaryIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertTrue(documentMatchingPartOfSummaryIds.isEmpty()); - searchBean.setKeywords(Arrays.asList("Something blue")); + searchBean.setFullTextSearch(Arrays.asList("Something blue")); documentMatchingPartOfSummaryIds = questionsIndexationService.searchQuestion(searchBean); Assert.assertEquals(1, documentMatchingPartOfSummaryIds.size()); Assert.assertEquals(questionTwoId, documentMatchingPartOfSummaryIds.get(0)); diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index cd2e0ad..5a47ca4 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -192,7 +192,7 @@ coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routePara $scope.advancedSearchDocuments = function() { - documentService.getAdvancedUsers($scope.example, function(documents){ + documentService.getAdvancedDocuments($scope.example, function(documents){ $scope.documents = documents; }); }; @@ -844,7 +844,7 @@ coselmarControllers.directive('identicalCheck', [function () { coselmarControllers.controller("QuestionsCtrl", ['$scope', '$route', '$routeParams', '$location', 'questionsService', 'notify', 'errorService', function($scope, $route, $routeParams, $location, questionsService, notify, errorService){ - $scope.searchOptions = { 'privacy' : '', 'status' : '', 'keywords' : []}; + $scope.searchOptions = { 'privacy' : '', 'status' : '', 'fullTextSearch' : []}; questionsService.getQuestions($scope.searchOptions, function(questions) { // success : just get the questions @@ -1340,7 +1340,7 @@ coselmarControllers.controller('ModalSearchDocumentsCtrl', function ($scope, $mo coselmarControllers.controller('ModalSearchQuestionsCtrl', function ($scope, $modalInstance, currentQuestionId, questionsService, errorService) { $scope.searchKeywords = []; - $scope.searchOptions = { 'type' : 'PERIODICAL_PUBLICATION', 'privacy' : '', 'status' : '', 'keywords' : []}; + $scope.searchOptions = { 'type' : 'PERIODICAL_PUBLICATION', 'privacy' : '', 'status' : '', 'fullTextSearch' : []}; $scope.currentQuestionId = currentQuestionId; questionsService.getQuestions($scope.searchOptions, function(questions) { @@ -1348,7 +1348,7 @@ coselmarControllers.controller('ModalSearchQuestionsCtrl', function ($scope, $mo }, errorService.defaultFailOnCall); $scope.searchQuestions = function(searchKeywords) { - $scope.searchOptions = { 'privacy' : '', 'status' : '', 'keywords' : searchKeywords}; + $scope.searchOptions = { 'privacy' : '', 'status' : '', 'fullTextSearch' : searchKeywords}; questionsService.getQuestions($scope.searchOptions, function(questions) { $scope.questions = questions; }, errorService.defaultFailOnCall); @@ -1446,7 +1446,7 @@ coselmarControllers.controller("ReferentialCtrl", ['$scope', '$routeParams', '$l var remoteSearchInReferential = function() { if ($scope.search.onQuestions && $scope.search.keywords.length > 0) { - var questionSearchOptions = { 'privacy' : '', 'status' : '', 'keywords' : $scope.search.keywords}; + var questionSearchOptions = { 'privacy' : '', 'status' : '', 'fullTextSearch' : $scope.search.keywords}; questionsService.getQuestions(questionSearchOptions, function(questions) { $scope.result.questions = questions; }); diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index b145c11..cd741f5 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -138,7 +138,7 @@ function Document(resource, config){ this.getAdvancedDocuments = function(searchExample, successFunction){ // Load documents with search example var docResource = resource(baseURL, {'searchBean' : searchExample}); - userResource.query(successFunction); + docResource.query(successFunction); }; }; \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/views/documents/toolsPart.html b/coselmar-ui/src/main/webapp/views/documents/toolsPart.html index 410533b..6378b84 100644 --- a/coselmar-ui/src/main/webapp/views/documents/toolsPart.html +++ b/coselmar-ui/src/main/webapp/views/documents/toolsPart.html @@ -65,7 +65,7 @@ <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" /> + <input class="form-control" type="search" class="form-control" placeholder="Titre" ng-model="example.name" /> </div> <label class="col-md-1 control-label">{{ 'document.metadata.authors' | translate }}</label> @@ -109,7 +109,7 @@ <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 /> + <input type="search" class="form-control" placeholder="Prénom Nom" ng-model="example.ownerName" /> </div> @@ -120,8 +120,8 @@ <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"/> + <input type="text" class="form-control" name="license" + placeholder="Licence" ng-model="example.license"/> </div> <div class="col-md-3 text-right"> diff --git a/coselmar-ui/src/main/webapp/views/questions/questions.html b/coselmar-ui/src/main/webapp/views/questions/questions.html index cf1fdea..3f580d9 100644 --- a/coselmar-ui/src/main/webapp/views/questions/questions.html +++ b/coselmar-ui/src/main/webapp/views/questions/questions.html @@ -38,7 +38,7 @@ <form class="form-inline pull-right search-zone" role="questionOptions" ng-submit="searchQuestions()"> <div class="form-group"> <span class="fa fa-info-circle" tooltip-placement="bottom" tooltip-html-unsafe="{{ 'common.message.info.searchKeywords' | translate }}"></span> - <input type="search" class="form-control" placeholder="keyword1,keyword2,..." ng-model="searchOptions.keywords" ng-list /> + <input type="search" class="form-control" placeholder="keyword1,keyword2,..." ng-model="searchOptions.fullTextSearch" ng-list /> </div> <div class="form-group"> <button type="submit" class="btn btn-primary glyphicon glyphicon-search"></button> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm