From: rkv Date: Tue, 5 Mar 2013 10:08:52 +0000 (+0000) Subject: Study search is fixed. Unit test for study search is fixed. X-Git-Tag: Root_Delivery2_2013_04_22~123 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d075e5fbad8622a7fb9bd03e77adaa056365b6b4;p=tools%2Fsiman.git Study search is fixed. Unit test for study search is fixed. --- diff --git a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java index f49c14e..7e62fd6 100644 --- a/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java +++ b/Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java @@ -275,7 +275,7 @@ public class SearchServiceImpl implements SearchService { Junction topJunction = initQuery(filter); String title = filter.getWords(); // Title - if (title != null) { + if (title != null && (!title.isEmpty())) { // Look for given words in study titles Junction critext; if (filter.isMatchAllCriteria()) { // AND @@ -360,16 +360,13 @@ public class SearchServiceImpl implements SearchService { addDatesCriteria(topJunction, filter); - int authorId = Integer.valueOf(filter.getAuthor()); + long authorId = Long.valueOf(filter.getAuthor()); if (authorId > 0) { // Author topJunction.add(Restrictions.eq("manager.rid", authorId)); } long actorId = filter.getConnectedUserId(); // Contributor, Reviewer or Approver if (actorId > 0) { - // User is not logged in - show only public studies - topJunction.add(Restrictions.eq("visibility", Visibility.PUBLIC)); - } else { // User is loggen in - show public studies and studies where he is participating Disjunction orCrit = Restrictions.disjunction(); topJunction @@ -399,6 +396,9 @@ public class SearchServiceImpl implements SearchService { /* If the study is public */ Restrictions.eq("study.visibility", Visibility.PUBLIC))); + } else { + // User is not logged in - show only public studies + topJunction.add(Restrictions.eq("visibility", Visibility.PUBLIC)); } return topJunction; } diff --git a/Workspace/Siman-Common/src/org/splat/service/dto/StudySearchFilterDTO.java b/Workspace/Siman-Common/src/org/splat/service/dto/StudySearchFilterDTO.java index 93d7ef4..f83c171 100644 --- a/Workspace/Siman-Common/src/org/splat/service/dto/StudySearchFilterDTO.java +++ b/Workspace/Siman-Common/src/org/splat/service/dto/StudySearchFilterDTO.java @@ -96,5 +96,4 @@ public class StudySearchFilterDTO extends SearchFilterDTO { public void setUpdatedBefore(final Date updatedBefore) { _updatedBefore = updatedBefore; } - } diff --git a/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java b/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java index 2af3b22..2c2f85a 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java @@ -34,6 +34,7 @@ import org.splat.service.SimulationContextService; import org.splat.service.StepService; import org.splat.service.StudyService; import org.splat.service.dto.Proxy; +import org.splat.service.dto.StudySearchFilterDTO; import org.splat.service.technical.ProjectSettingsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -232,17 +233,17 @@ public class TestSearchService extends BaseTest { ht.flush(); // Search by study author - Study.Properties sprop = new Study.Properties(); - sprop.setManager(goodUser); - List res = _searchService.selectStudiesWhere(true, true, sprop); + StudySearchFilterDTO filter = new StudySearchFilterDTO(); + filter.setAuthor(String.valueOf(goodUser.getIndex())); + List res = _searchService.selectStudiesWhere(filter); Assert.assertNotNull(res); Assert.assertEquals(res.size(), 1); Assert.assertEquals(res.get(0).getIndex(), titleStudyId); // Search for other logged in study contributor - sprop.clear(); - sprop.setActor(otherUser); - res = _searchService.selectStudiesWhere(true, true, sprop); + filter = new StudySearchFilterDTO(); + filter.setConnectedUserId(otherUser.getIndex()); + res = _searchService.selectStudiesWhere(filter); Assert.assertNotNull(res); Assert.assertEquals(res.size(), 3); Assert.assertEquals(res.get(0).getIndex(), refStudyId); // Public study @@ -250,9 +251,9 @@ public class TestSearchService extends BaseTest { Assert.assertEquals(res.get(2).getIndex(), reviewStudyId); // OtherUser is reviewer in this study // Search for logged in study contributor - sprop.clear(); - sprop.setActor(goodUser); - res = _searchService.selectStudiesWhere(true, true, sprop); + filter = new StudySearchFilterDTO(); + filter.setConnectedUserId(goodUser.getIndex()); + res = _searchService.selectStudiesWhere(filter); Assert.assertNotNull(res); Assert.assertEquals(res.size(), 3); Assert.assertEquals(res.get(0).getIndex(), privateStudyId); // goodUser is author @@ -260,29 +261,29 @@ public class TestSearchService extends BaseTest { Assert.assertEquals(res.get(1).getIndex(), refStudyId); // Public study // Search by study title contents - sprop.clear(); - sprop.setTitle("study public"); - res = _searchService.selectStudiesWhere(true, true, sprop); + filter = new StudySearchFilterDTO(); + filter.setWords("study public"); + res = _searchService.selectStudiesWhere(filter); Assert.assertNotNull(res); Assert.assertEquals(res.size(), 2); Assert.assertEquals(res.get(0).getIndex(), refStudyId); Assert.assertEquals(res.get(1).getIndex(), titleStudyId); // Search by study reference - sprop.clear(); - sprop.setReference("TEST_REF"); - res = _searchService.selectStudiesWhere(true, true, sprop); + filter = new StudySearchFilterDTO(); + filter.setReference("TEST_REF"); + res = _searchService.selectStudiesWhere(filter); Assert.assertNotNull(res); Assert.assertEquals(res.size(), 1); Assert.assertEquals(res.get(0).getIndex(), refStudyId); // Search a study by simulation context - sprop.clear(); - sprop.setActor(goodUser); + filter = new StudySearchFilterDTO(); + filter.setConnectedUserId(goodUser.getIndex()); List contexts = new ArrayList(); contexts.add(ctx); - sprop.setSimulationContexts(contexts); - res = _searchService.selectStudiesWhere(true, true, sprop); + filter.setSimContexts(contexts); + res = _searchService.selectStudiesWhere(filter); Assert.assertNotNull(res); Assert.assertEquals(res.size(), 1); Assert.assertEquals(res.get(0).getIndex(), privateStudyId);