]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Study search is fixed. Unit test for study search is fixed.
authorrkv <rkv@opencascade.com>
Tue, 5 Mar 2013 10:08:52 +0000 (10:08 +0000)
committerrkv <rkv@opencascade.com>
Tue, 5 Mar 2013 10:08:52 +0000 (10:08 +0000)
Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/dto/StudySearchFilterDTO.java
Workspace/Siman-Common/src/test/splat/service/TestSearchService.java

index f49c14ed72cdcb1b24f3c7e4c2eecb283a7799ec..7e62fd613ac69429ad80e180a0ca10fc9e6b26e6 100644 (file)
@@ -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;
        }
index 93d7ef434759be98822c3969122f83faf0f2d795..f83c171823a00ce5179deb5e76d290aa9db6b71b 100644 (file)
@@ -96,5 +96,4 @@ public class StudySearchFilterDTO extends SearchFilterDTO {
        public void setUpdatedBefore(final Date updatedBefore) {
                _updatedBefore = updatedBefore;
        }
-       
 }
index 2af3b222034d62a40ecbb53f2185150af36c97c3..2c2f85af1c521408ec8a76b972245d95b9ae9555 100644 (file)
@@ -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<Proxy> res = _searchService.selectStudiesWhere(true, true, sprop);
+               StudySearchFilterDTO filter = new StudySearchFilterDTO();
+               filter.setAuthor(String.valueOf(goodUser.getIndex()));
+               List<Proxy> 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<SimulationContext> contexts = new ArrayList<SimulationContext>();
                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);