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
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
/* 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;
}
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;
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
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
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);