branch develop updated (3a8ba65 -> b4ffcf9)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git from 3a8ba65 try webmotion 2.5-SNAPSHOT new 092d492 fixes #6429 review initial load off referential page new b4ffcf9 review way to update data in lucene index The 2 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 b4ffcf9a643ff308430079cb68ca4cf110b645fc Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 16 18:08:09 2015 +0100 review way to update data in lucene index commit 092d492afc495971dcc644c03fb61f5d605e8743 Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 16 18:07:24 2015 +0100 fixes #6429 review initial load off referential page Summary of changes: .../indexation/DocumentsIndexationService.java | 9 ++-- .../indexation/QuestionsIndexationService.java | 11 ++--- .../main/resources/coselmar-services.properties | 2 + .../indexation/QuestionsIndexationServiceTest.java | 12 +++++ .../src/main/webapp/js/coselmar-controllers.js | 54 +++++++++++++--------- 5 files changed, 55 insertions(+), 33 deletions(-) -- 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 develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit 092d492afc495971dcc644c03fb61f5d605e8743 Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 16 18:07:24 2015 +0100 fixes #6429 review initial load off referential page --- .../src/main/webapp/js/coselmar-controllers.js | 54 +++++++++++++--------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 75c9906..849873f 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -914,28 +914,8 @@ coselmarControllers.controller('ModalCreateDocumentsCtrl', function ($scope, $mo coselmarControllers.controller("ReferentialCtrl", ['$scope', '$routeParams', '$location', 'questionsService', 'documentService', function($scope, $routeParams, $location, questionsService, documentService){ - //manage keywords if given - $scope.search = { keywords : [], onDocuments: false, onQuestions: false }; $scope.result = { questions : [], documents : []}; - var keywords = $routeParams.keywords; - console.log(keywords); - if (Array.isArray(keywords)) { - $scope.search.keywords = keywords; - } else if (keywords) { - $scope.search.keywords.push(keywords); - } - - var onQuestions = $routeParams.onQuestions; - if (onQuestions) { - $scope.search.onQuestions = onQuestions; - } - - var onDocuments = $routeParams.onDocuments; - if (onDocuments) { - $scope.search.onDocuments = onDocuments; - } - var remoteSearchInReferential = function() { if ($scope.search.onQuestions && $scope.search.keywords.length > 0) { var questionSearchOptions = { 'privacy' : '', 'status' : '', 'keywords' : $scope.search.keywords}; @@ -952,11 +932,41 @@ coselmarControllers.controller("ReferentialCtrl", ['$scope', '$routeParams', '$l }; - remoteSearchInReferential(); + //init scope : if routeParams, use values + if ($routeParams && + ($routeParams.keywords + || $routeParams.onDocuments + || $routeParams.onQuestions)) { + + $scope.search = { keywords : [], onDocuments: false, onQuestions: false }; + + var keywords = $routeParams.keywords; + if (Array.isArray(keywords)) { + $scope.search.keywords = keywords; + } else if (keywords) { + $scope.search.keywords.push(keywords); + } + + var onQuestions = $routeParams.onQuestions; + if (onQuestions) { + $scope.search.onQuestions = onQuestions; + } + + var onDocuments = $routeParams.onDocuments; + if (onDocuments) { + $scope.search.onDocuments = onDocuments; + } + + // Launch search + remoteSearchInReferential(); + + } else { + // else, default values for screen init, no search is done + $scope.search = { keywords : [], onDocuments: true, onQuestions: true }; + } $scope.searchInReferential = function(){ - console.log($scope.search.keywords); if ($scope.search.keywords) { $location.search('keywords', $scope.search.keywords); } else { -- 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 develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit b4ffcf9a643ff308430079cb68ca4cf110b645fc Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 16 18:08:09 2015 +0100 review way to update data in lucene index --- .../services/indexation/DocumentsIndexationService.java | 9 ++++----- .../services/indexation/QuestionsIndexationService.java | 11 +++++------ .../src/main/resources/coselmar-services.properties | 2 ++ .../services/indexation/QuestionsIndexationServiceTest.java | 12 ++++++++++++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java index b7e7975..a6323df 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/indexation/DocumentsIndexationService.java @@ -197,21 +197,20 @@ public class DocumentsIndexationService extends CoselmarSimpleServiceSupport { ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs; if (hits.length > 0) { - Document doc = isearcher.doc(hits[0].doc); + Document doc = new Document(); + doc.add(new StringField(DOCUMENT_ID_INDEX_PROPERTY, document.getId(), Field.Store.YES)); - doc.removeField(DOCUMENT_NAME_INDEX_PROPERTY); doc.add(new TextField(DOCUMENT_NAME_INDEX_PROPERTY, document.getName(), Field.Store.YES)); - doc.removeField(DOCUMENT_AUTHORS_INDEX_PROPERTY); doc.add(new TextField(DOCUMENT_AUTHORS_INDEX_PROPERTY, document.getAuthors(), Field.Store.YES)); - doc.removeField(DOCUMENT_SUMMARY_INDEX_PROPERTY); doc.add(new TextField(DOCUMENT_SUMMARY_INDEX_PROPERTY, document.getSummary(), Field.Store.YES)); - doc.removeFields(DOCUMENT_KEYWORD_INDEX_PROPERTY); Set<String> keywords = document.getKeywords(); for (String keyword : keywords) { doc.add(new Field(DOCUMENT_KEYWORD_INDEX_PROPERTY, keyword, TextField.TYPE_STORED)); } + doc.add(new Field("type", DOCUMENT_TYPE, TextField.TYPE_STORED)); + getLuceneUtils().getIndexWriter().updateDocument(new Term(DOCUMENT_ID_INDEX_PROPERTY, document.getId()), doc); getLuceneUtils().getIndexWriter().commit(); } 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 d534f9e..0a8b864 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 @@ -84,25 +84,24 @@ public class QuestionsIndexationService extends CoselmarSimpleServiceSupport { ScoreDoc[] hits = isearcher.search(query, null, 1000).scoreDocs; if (hits.length > 0) { - Document doc = isearcher.doc(hits[0].doc); + Document doc = new Document(); + + doc.add(new StringField(QUESTION_ID_INDEX_PROPERTY, question.getId(), Field.Store.YES)); - doc.removeField(QUESTION_TITLE_INDEX_PROPERTY); doc.add(new TextField(QUESTION_TITLE_INDEX_PROPERTY, question.getTitle(), Field.Store.YES)); - doc.removeField(QUESTION_SUMMARY_INDEX_PROPERTY); doc.add(new TextField(QUESTION_SUMMARY_INDEX_PROPERTY, question.getSummary(), Field.Store.YES)); - doc.removeFields(QUESTION_THEME_INDEX_PROPERTY); Set<String> themes = question.getThemes(); for (String theme : themes) { doc.add(new Field(QUESTION_THEME_INDEX_PROPERTY, theme, TextField.TYPE_STORED)); } - doc.removeField(QUESTION_STATUS_INDEX_PROPERTY); doc.add(new TextField(QUESTION_STATUS_INDEX_PROPERTY, question.getStatus(), Field.Store.YES)); - doc.removeField(QUESTION_PRIVACY_INDEX_PROPERTY); doc.add(new TextField(QUESTION_PRIVACY_INDEX_PROPERTY, question.getPrivacy(), Field.Store.YES)); + doc.add(new Field("type", DOCUMENT_TYPE, TextField.TYPE_STORED)); + getLuceneUtils().getIndexWriter().updateDocument(new Term(QUESTION_ID_INDEX_PROPERTY, question.getId()), doc); } else { diff --git a/coselmar-rest/src/main/resources/coselmar-services.properties b/coselmar-rest/src/main/resources/coselmar-services.properties index 17a19aa..4c88a46 100644 --- a/coselmar-rest/src/main/resources/coselmar-services.properties +++ b/coselmar-rest/src/main/resources/coselmar-services.properties @@ -29,3 +29,5 @@ hibernate.connection.password=sa hibernate.connection.driver_class=org.h2.Driver hibernate.hbm2ddl.auto=update coselmar.version=${project.version} + +coselmar.index.directory=${coselmar.data.directory}/index \ No newline at end of file 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 3de962e..99755bb 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 @@ -264,6 +264,18 @@ public class QuestionsIndexationServiceTest extends AbstractCoselmarServiceTest Assert.assertEquals(1, questionMatchingTitleIds.size()); Assert.assertTrue(questionMatchingTitleIds.contains(questionOneId)); + // Edit an other time : + questionOne.setTitle("Just let me change"); + questionOne.setPrivacy(Privacy.PUBLIC.name()); + questionsIndexationService.indexQuestion(questionOne); + + // Ok, let's search now ! + searchBean.setKeywords(Arrays.asList("who")); + searchBean.setPrivacy(Privacy.PUBLIC.name()); + questionMatchingTitleIds = questionsIndexationService.searchQuestion(searchBean); + Assert.assertEquals(1, questionMatchingTitleIds.size()); + Assert.assertEquals(questionTwoId, questionMatchingTitleIds.get(0)); + } @Test -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm