Salome HOME
Simulation context type selection is fixed in study search. Lucene is no more used...
authorrkv <rkv@opencascade.com>
Tue, 26 Feb 2013 08:04:25 +0000 (08:04 +0000)
committerrkv <rkv@opencascade.com>
Tue, 26 Feb 2013 08:04:25 +0000 (08:04 +0000)
Workspace/Siman-Common/src/org/splat/service/SearchService.java
Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java
Workspace/Siman-Common/src/org/splat/service/dto/StudyDTO.java [new file with mode: 0644]
Workspace/Siman-Common/src/test/splat/service/TestSearchService.java [new file with mode: 0644]
Workspace/Siman-Common/src/test/splat/util/TestEntitiesGenerator.java
Workspace/Siman/WebContent/js/search.js
Workspace/Siman/WebContent/study/searchStudy.jsp
Workspace/Siman/src/org/splat/simer/AbstractSearchBaseAction.java
Workspace/Siman/src/org/splat/simer/SearchStudyAction.java
Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java

index 18a024d4b7101832881c6d0bd49d011f57e21973..95e72d6dfc5d7de1405861ec210c94bbffc47bc6 100644 (file)
@@ -51,11 +51,16 @@ public interface SearchService {
        /**
         * Find studies with given properties.
         * 
+        * @param allCriteria
+        *            if true then search for all criteria (AND), otherwise search for any criteria
+        * @param allContexts
+        *            if true then search for all simulation contexts (AND), otherwise search for any simulation contexts
         * @param sprop
         *            search filter parameters
-        * @return the list of found studies as proxiy results of lucene search
+        * @return the list of found studies as proxy results
         */
-       List<Proxy> selectStudiesWhere(Study.Properties... sprop);
+       List<Proxy> selectStudiesWhere(boolean allCriteria, boolean allContexts,
+                       Study.Properties sprop);
 
        /**
         * Refresh lucene index for a study.
index 8fcb6693955ab7ea990f701b3157477ef43386cd..beaf1afde47f128c7c9ab20a3bb4668da3772833 100644 (file)
@@ -30,6 +30,14 @@ import org.apache.lucene.search.TermsFilter;
 import org.apache.lucene.search.TopFieldDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
+import org.hibernate.Criteria;
+import org.hibernate.Hibernate;
+import org.hibernate.criterion.DetachedCriteria;
+import org.hibernate.criterion.Disjunction;
+import org.hibernate.criterion.Junction;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.type.Type;
 import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.KnowledgeElement;
 import org.splat.dal.bo.som.KnowledgeElementType;
@@ -38,9 +46,11 @@ import org.splat.dal.bo.som.Scenario;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.Visibility;
+import org.splat.dal.bo.som.Study.Properties;
 import org.splat.dal.dao.som.StudyDAO;
 import org.splat.service.dto.ImportedStudyDTO;
 import org.splat.service.dto.Proxy;
+import org.splat.service.dto.StudyDTO;
 import org.splat.service.technical.IndexService;
 import org.splat.service.technical.IndexServiceImpl;
 import org.splat.service.technical.RepositoryService;
@@ -79,9 +89,10 @@ public class SearchServiceImpl implements SearchService {
 
        /**
         * Get a list of studies which are currently not presented in the lucene index.
+        * 
         * @return list of ImportedStudy DTO
         */
-       @Transactional(readOnly=true)
+       @Transactional(readOnly = true)
        public List<ImportedStudyDTO> selectStudies() {
                List<ImportedStudyDTO> table = new ArrayList<ImportedStudyDTO>();
                Study.Properties sprop = new Study.Properties();
@@ -99,7 +110,7 @@ public class SearchServiceImpl implements SearchService {
                        } catch (Exception error) {
                                continue;
                        }
-                       // Add the study to the list of studies which are 
+                       // Add the study to the list of studies which are
                        // currently not presented in the lucene index.
                        table.add(BeanHelper.copyBean(aStudy, ImportedStudyDTO.class));
                }
@@ -113,6 +124,7 @@ public class SearchServiceImpl implements SearchService {
         *            list of studies id's
         */
        @Transactional(readOnly = true)
+       @Deprecated
        public void reindexStudies(final String[] ridlist) {
                for (int i = 0; i < ridlist.length; i++) {
                        long index = Long.valueOf(ridlist[i].trim());
@@ -253,6 +265,140 @@ public class SearchServiceImpl implements SearchService {
         * 
         * @see org.splat.service.SearchService#selectStudiesWhere(org.splat.dal.bo.som.Study.Properties[])
         */
+       public List<Proxy> selectStudiesWhere(final boolean allCriteria,
+                       final boolean allContexts, final Study.Properties sprop) {
+               List<Proxy> result = new ArrayList<Proxy>();
+
+               DetachedCriteria query = DetachedCriteria
+                               .forClass(Study.class, "study");
+               // Creation of the query
+               initQuery(query, sprop);
+
+               String title = sprop.getTitle(); // Title
+               if (title != null) {
+                       // Look for given words in study titles
+                       Junction critext;
+                       if (allCriteria) { // AND
+                               critext = Restrictions.conjunction();
+                       } else { // OR
+                               critext = Restrictions.disjunction();
+                       }
+
+                       String[] word = title.split(" ");
+                       for (int j = 0; j < word.length; j++) {
+                               critext.add(Restrictions.like("title", "%" + word[j] + "%"));
+                       }
+                       query.add(critext);
+               }
+
+               List<SimulationContext> context = sprop.getSimulationContexts();
+               if (context != null && (!context.isEmpty())) {
+                       // Get only studies which have given contexts
+                       query.createAlias("contex", "ctx", Criteria.INNER_JOIN);
+                       Junction critctx;
+                       if (allContexts) { // AND
+                               critctx = Restrictions.conjunction();
+                       } else { // OR
+                               critctx = Restrictions.disjunction();
+                       }
+                       for (SimulationContext seltext : context) {
+                               // (simctxType = seltext.getType() AND simctxValue = seltext.getValue())
+                               critctx.add(Restrictions.and(Restrictions.eq("ctx.value",
+                                               seltext.getValue()), Restrictions.eq("ctx.type",
+                                               seltext.getType())));
+
+                       }
+                       query.add(critctx);
+               }
+
+               // Group by study
+               query.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
+               // Creation of the sort criteria
+               query.addOrder(Order.asc("title"));
+
+               if (LOG.isInfoEnabled()) {
+                       LOG.info("Searching studies: \"" + query.toString() + "\".");
+               }
+
+               // Search
+               List<Study> found = getStudyDAO().getFilteredList(query);
+
+               // Construction of the result list
+               for (Study std : found) {
+                       result.add(new StudyDTO(std.getIndex(), std.getReference(), std
+                                       .getProgressState(), std.getTitle(), std.getAuthor()
+                                       .getDisplayName()));
+               }
+               return result;
+       }
+
+       /**
+        * Initialize query with base criteria.
+        * 
+        * @param query
+        *            the query
+        * @param sprop
+        *            the criteria
+        */
+       private void initQuery(final DetachedCriteria query, final Properties sprop) {
+               ProgressState state = sprop.getProgressState(); // State
+               if (state != null) {
+                       query.add(Restrictions.eq("state", state));
+               }
+               String refid = sprop.getReference(); // Reference
+               if (refid != null) {
+                       query.add(Restrictions.eq("sid", refid));
+               }
+               User manager = sprop.getManager(); // Author
+               if (manager != null) {
+                       query.add(Restrictions.eq("manager", manager));
+               }
+
+               User actor = sprop.getActor(); // Contributor, Reviewer or Approver
+               if (actor == null) {
+                       // User is not logged in - show only public studies
+                       query.add(Restrictions.eq("visibility", Visibility.PUBLIC));
+               } else {
+                       // User is loggen in - show public studies and studies where he is participating
+                       Disjunction orCrit = Restrictions.disjunction();
+                       query
+                                       .add(orCrit
+                                                       .add(
+                                                                       /* If the user is a validation cycle participant */
+                                                                       Restrictions
+                                                                                       .sqlRestriction(
+                                                                                                       "{alias}.rid in (select vcrel.owner from cycle_rel vcrel inner join cycle vc on vcrel.refer = vc.rid where {alias}.rid = vcrel.owner AND (vc.publisher = ? OR vc.reviewer = ? OR vc.approver = ? OR vc.signatory = ?) group by vcrel.owner)",
+                                                                                                       new Object[] {
+                                                                                                                       actor.getIndex(),
+                                                                                                                       actor.getIndex(),
+                                                                                                                       actor.getIndex(),
+                                                                                                                       actor.getIndex() },
+                                                                                                       new Type[] {
+                                                                                                                       Hibernate.LONG,
+                                                                                                                       Hibernate.LONG,
+                                                                                                                       Hibernate.LONG,
+                                                                                                                       Hibernate.LONG }))
+                                                       .add(
+                                                                       /* If the user is contributor */
+                                                                       Restrictions
+                                                                                       .sqlRestriction(
+                                                                                                       "{alias}.rid in (select rel.owner from contributor_rel rel where {alias}.rid = rel.owner AND rel.refer = ?)",
+                                                                                                       actor.getIndex(),
+                                                                                                       Hibernate.LONG)).add(
+                                                       /* If the user is author */
+                                                       Restrictions.eq("study.manager", actor)).add(
+                                                                       /* If the study is public */
+                                                                       Restrictions.eq("study.visibility",
+                                                                                       Visibility.PUBLIC)));
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SearchService#selectStudiesWhere(org.splat.dal.bo.som.Study.Properties[])
+        */
+       @Deprecated
        public List<Proxy> selectStudiesWhere(final Study.Properties... sprop) {
                List<Proxy> result = new ArrayList<Proxy>();
                int hitsize = 20;
@@ -385,6 +531,7 @@ public class SearchServiceImpl implements SearchService {
         * 
         * @see org.splat.service.SearchService#indexStudy(org.splat.dal.bo.som.Study)
         */
+       @Deprecated
        public void indexStudy(final Study study) {
                LOG.debug("Index study: id=" + study.getRid() + "; reference="
                                + study.getReference());
@@ -401,8 +548,8 @@ public class SearchServiceImpl implements SearchService {
                        IndexService lucin = getIndex();
                        Scenario[] scenes = study.getScenarii();
 
-                       LOG.debug("Number of study " + study.getReference()
-                                       + " actors: " + study.getActor().size());
+                       LOG.debug("Number of study " + study.getReference() + " actors: "
+                                       + study.getActor().size());
                        lucin.add(study);
                        if (study.getProgressState() != ProgressState.inWORK) {
                                for (int i = 0; i < scenes.length; i++) {
@@ -411,8 +558,7 @@ public class SearchServiceImpl implements SearchService {
                                        for (Iterator<KnowledgeElement> j = list.iterator(); j
                                                        .hasNext();) {
                                                lucin.add(j.next());
-                                               LOG.debug("Knowlegge added: id="
-                                                               + j.next().getIndex());
+                                               LOG.debug("Knowlegge added: id=" + j.next().getIndex());
                                        }
                                }
                        }
diff --git a/Workspace/Siman-Common/src/org/splat/service/dto/StudyDTO.java b/Workspace/Siman-Common/src/org/splat/service/dto/StudyDTO.java
new file mode 100644 (file)
index 0000000..6221a38
--- /dev/null
@@ -0,0 +1,128 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   20.02.2013
+ * @author         $Author$
+ * @version        $Revision$
+ * @copyright      OPEN CASCADE 2012
+ *****************************************************************************/
+
+package org.splat.service.dto;
+
+import java.io.Serializable;
+
+import org.splat.dal.bo.som.ProgressState;
+
+/**
+ * Study DTO class. Used in study search results.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
+public class StudyDTO implements Proxy, Serializable {
+       /**
+        * Study persistent id.
+        */
+       private transient final Long _rid;
+       /**
+        * Study reference.
+        */
+       private transient final String _sid;
+       /**
+        * Study progress state.
+        */
+       private transient final ProgressState _state;
+       /**
+        * Study title.
+        */
+       private transient final String _title;
+       /**
+        * Study name.
+        */
+       private transient final String _name;
+       /**
+        * Type.
+        */
+       private transient String _type;
+       /**
+        * Serialization version id.
+        */
+       private static final long serialVersionUID = -4386494192709562221L;
+
+       /**
+        * Costructor from properties.
+        * 
+        * @param id
+        *            study persistent id
+        * @param reference
+        *            study reference
+        * @param state
+        *            study progress state
+        * @param title
+        *            study title
+        * @param author
+        *            study author display name
+        */
+       public StudyDTO(final Long id, final String reference,
+                       final ProgressState state, final String title, final String author) {
+               _rid = id;
+               _sid = reference;
+               _state = state;
+               _title = title;
+               _name = author;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.dto.Proxy#getAuthorName()
+        */
+       public String getAuthorName() {
+               return _name;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.dto.Proxy#getIndex()
+        */
+       public Long getIndex() {
+               return _rid;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.dto.Proxy#getProgressState()
+        */
+       public ProgressState getProgressState() {
+               return _state;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.dto.Proxy#getReference()
+        */
+       public String getReference() {
+               return _sid;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.dto.Proxy#getTitle()
+        */
+       public String getTitle() {
+               return _title;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.dto.Proxy#getType()
+        */
+       public String getType() {
+               return _type;
+       }
+}
diff --git a/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java b/Workspace/Siman-Common/src/test/splat/service/TestSearchService.java
new file mode 100644 (file)
index 0000000..2af3b22
--- /dev/null
@@ -0,0 +1,302 @@
+/*****************************************************************************
+ * Company         OPEN CASCADE
+ * Application     SIMAN
+ * File            $Id$ 
+ * Creation date   12 Oct 2012
+ * @author         $Author$
+ * @version        $Revision$
+ *****************************************************************************/
+package test.splat.service;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.splat.dal.bo.kernel.User;
+import org.splat.dal.bo.som.ContributorRelation;
+import org.splat.dal.bo.som.DocumentType;
+import org.splat.dal.bo.som.SimulationContext;
+import org.splat.dal.bo.som.Study;
+import org.splat.dal.bo.som.ValidationCycle;
+import org.splat.dal.bo.som.ValidationCycleRelation;
+import org.splat.dal.bo.som.ValidationStep;
+import org.splat.dal.bo.som.Visibility;
+import org.splat.dal.dao.kernel.UserDAO;
+import org.splat.dal.dao.som.Database;
+import org.splat.dal.dao.som.StudyDAO;
+import org.splat.dal.dao.som.ValidationCycleDAO;
+import org.splat.exception.BusinessException;
+import org.splat.log.AppLogger;
+import org.splat.service.DocumentTypeService;
+import org.splat.service.PublicationService;
+import org.splat.service.SearchService;
+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.technical.ProjectSettingsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.orm.hibernate3.HibernateTemplate;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import test.splat.common.BaseTest;
+import test.splat.util.TestEntitiesGenerator;
+
+/**
+ * Test class for StudyService.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ * 
+ */
+public class TestSearchService extends BaseTest {
+
+       /**
+        * Logger for the class.
+        */
+       private static final AppLogger LOG = AppLogger
+                       .getLogger(TestSearchService.class);
+
+       /**
+        * The StudyDAO. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("studyDAO")
+       private transient StudyDAO _studyDAO;
+
+       /**
+        * The PublicationService. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("publicationService")
+       private transient PublicationService _publicationService;
+
+       /**
+        * The StepService. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("stepService")
+       private transient StepService _stepService;
+
+       /**
+        * The ProjectSettingsService. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("projectSettings")
+       private transient ProjectSettingsService _projectSettings;
+
+       /**
+        * The DocumentTypeService. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("documentTypeService")
+       private transient DocumentTypeService _documentTypeService;
+
+       /**
+        * The StudyService. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("studyService")
+       private transient StudyService _studyService;
+
+       /**
+        * The SearchService. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("searchService")
+       private transient SearchService _searchService;
+
+       /**
+        * The UserDAO. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("userDAO")
+       private transient UserDAO _userDAO;
+
+       /**
+        * The ValidationCycleDAO. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("validationCycleDAO")
+       private transient ValidationCycleDAO _validationCycleDAO;
+
+       /**
+        * The SimulationContextService. Later injected by Spring.
+        */
+       @Autowired
+       @Qualifier("simulationContextService")
+       private transient SimulationContextService _simulationContextService;
+
+       /**
+        * Test of searching a study.<BR>
+        * <B>Description :</B> <BR>
+        * <i>Create studies and try to find them according next document index.</i><BR>
+        * <B>Action : </B><BR>
+        * <i>
+        * <ol>
+        * <li>Search study by state</li>
+        * <li>Search study by reference</li>
+        * <li>Search study by author</li>
+        * <li>Search study by actor</li>
+        * <li>Search study by title</li>
+        * <li>Search study by simulation contexts</li>
+        * <li>Search study by all criteria</li>
+        * <li>Search study by any criteria</li>
+        * </ol>
+        * </i> <B>Test data : </B><BR>
+        * <i>no input parameters</i><BR>
+        * 
+        * <B>Outcome results:</B><BR>
+        * <i>
+        * <ul>
+        * <li>A study must be found according to the given criteria<BR>
+        * </li>
+        * </ul>
+        * </i>
+        * 
+        * @throws BusinessException
+        *             if can't create test user or study
+        */
+       @Test
+       public void testSelectStudiesWhere() throws BusinessException {
+               LOG.debug(">>>>> BEGIN testGenerateLocalIndex()");
+               startNestedTransaction();
+
+               HibernateTemplate ht = getHibernateTemplate();
+
+               Database.getInstance().reset();
+               _projectSettings.getAllSteps().clear(); // Clear config to be able to load it again
+               // Load workflow customization
+               try {
+                       _projectSettings.configure(ClassLoader.getSystemResource(
+                                       "test/som.xml").getPath());
+               } catch (Exception e) {
+                       Assert.fail("Can't load som.xml: ", e);
+               }
+
+               User goodUser = TestEntitiesGenerator.getTestUser("goodUser");
+               _userDAO.create(goodUser);
+               User otherUser = TestEntitiesGenerator.getTestUser("otherUser");
+               _userDAO.create(otherUser);
+               User thirdUser = TestEntitiesGenerator.getTestUser("thirdUser");
+               _userDAO.create(thirdUser);
+
+               // Create private study
+               Study aStudy = TestEntitiesGenerator.getTestStudy(goodUser);
+               aStudy.setTitle("0.This is private study");
+               Long privateStudyId = _studyDAO.create(aStudy);
+
+               // Add simulation context to the study 0
+               SimulationContext.Properties cprop = new SimulationContext.Properties();
+               cprop.setType(_simulationContextService.selectType("product"))
+                               .setValue("Test Simulation Context: Product");
+               SimulationContext ctx = _studyService.addProjectContext(aStudy, cprop);
+               ht.flush();
+
+               // Create public study with predefined title
+               aStudy = TestEntitiesGenerator.getTestStudy(goodUser);
+               aStudy.setVisibility(Visibility.PUBLIC);
+               aStudy.setTitle("2.This is a public study");
+               aStudy.addRelation(new ContributorRelation(aStudy, otherUser));
+               Long titleStudyId = _studyDAO.create(aStudy);
+
+               // Add simulation context to the study 2
+               SimulationContext.Properties cprop1 = new SimulationContext.Properties();
+               cprop.setType(_simulationContextService.selectType("product"))
+                               .setValue("Test Simulation Context: Product1");
+               SimulationContext ctx1 = _studyService.addProjectContext(aStudy, cprop);
+               ht.flush();
+
+               // Create public study with predefined reference
+               aStudy = TestEntitiesGenerator.getTestStudy(otherUser);
+               aStudy.setVisibility(Visibility.PUBLIC);
+               aStudy.setTitle("1.This is another public study");
+               aStudy.setReference("TEST_REF");
+               Long refStudyId = _studyDAO.create(aStudy);
+
+               // Create private study of third user with otherUser as a reviewer
+               aStudy = TestEntitiesGenerator.getTestStudy(thirdUser);
+               aStudy.setTitle("3.This is a private study of third user");
+               Long reviewStudyId = _studyDAO.create(aStudy);
+
+               // Create validation cycle for the last study
+               ValidationCycle.Properties vprop = new ValidationCycle.Properties();
+               DocumentType type = _documentTypeService.selectType("specification");
+               vprop.setDocumentType(type);
+               vprop.setActor(ValidationStep.REVIEW, otherUser);
+               ValidationCycle cycle = new ValidationCycle(aStudy, vprop);
+               _validationCycleDAO.create(cycle);
+               ValidationCycleRelation link = cycle.getContext();
+               aStudy.addRelation(link);
+               ht.flush();
+
+               // Search by study author
+               Study.Properties sprop = new Study.Properties();
+               sprop.setManager(goodUser);
+               List<Proxy> res = _searchService.selectStudiesWhere(true, true, sprop);
+               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);
+               Assert.assertNotNull(res);
+               Assert.assertEquals(res.size(), 3);
+               Assert.assertEquals(res.get(0).getIndex(), refStudyId); // Public study
+               Assert.assertEquals(res.get(1).getIndex(), titleStudyId); // 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);
+               Assert.assertNotNull(res);
+               Assert.assertEquals(res.size(), 3);
+               Assert.assertEquals(res.get(0).getIndex(), privateStudyId); // goodUser is author
+               Assert.assertEquals(res.get(2).getIndex(), titleStudyId); // Public study
+               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);
+               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);
+               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);
+               List<SimulationContext> contexts = new ArrayList<SimulationContext>();
+               contexts.add(ctx);
+               sprop.setSimulationContexts(contexts);
+               res = _searchService.selectStudiesWhere(true, true, sprop);
+               Assert.assertNotNull(res);
+               Assert.assertEquals(res.size(), 1);
+               Assert.assertEquals(res.get(0).getIndex(), privateStudyId);
+               // Check simualtion contexts of the found study
+               aStudy = _studyService.selectStudy(res.get(0).getIndex());
+               Iterator<SimulationContext> ctxIter = aStudy.SimulationContextIterator();
+               contexts.clear();
+               while (ctxIter.hasNext()) {
+                       contexts.add(ctxIter.next());
+               }
+               Assert.assertEquals(contexts.size(), 1);
+               Assert.assertEquals(contexts.get(0), ctx);
+
+               rollbackNestedTransaction();
+               LOG.debug(">>>>> END testGenerateLocalIndex()");
+       }
+}
index d43b93223c98604ef1e35c8def87a942d3bef3e6..95783bd4915d95889457d0f86fab51a0e3a1ddcd 100644 (file)
@@ -16,7 +16,6 @@ import org.splat.dal.bo.kernel.User;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.Study;
-import org.splat.dal.bo.som.Visibility;
 import org.splat.exception.BusinessException;
 
 /**
@@ -61,8 +60,7 @@ public class TestEntitiesGenerator {
                                .setDate(new Date())
                                .setReference("test reference")
                                .setSimulationContexts(new ArrayList<SimulationContext>())
-                               .setState(ProgressState.inWORK)
-                               .setVisibility(Visibility.PUBLIC);
+                               .setState(ProgressState.inWORK);
                Study study = new Study(studyProps);
                return study;
        }
index 69c905bb7c934442828774545f15cd0d59ac1ad9..a2a28bfce76d06ab2faf463ea83df5317c1e1405 100644 (file)
@@ -1,28 +1,7 @@
     function initialize (result) {
-      var state = search.state.value;
-
-      if (state == "inWORK" || state == "inDRAFT" || state == "inCHECK") {
-        search.visibility[0].checked  = true;        
-        search.visibility[1].disabled = true;
-        search.visibility[2].disabled = true;
-      }
       if (result == "obsolete") changeFilter();   // Hides the result section and enables the Search button
     }
 
-    function setState () {
-      var state = search.state.value;
-
-      if (state == "inWORK" || state == "inDRAFT" || state == "inCHECK") {
-        search.visibility[0].checked  = true;        
-        search.visibility[1].disabled = true;
-        search.visibility[2].disabled = true;
-      } else if (search.visibility[1].value != "onlypublic") {
-        search.visibility[1].disabled = false;
-        search.visibility[2].disabled = false;
-      }
-      changeFilter();
-    }
-
     function changeFilter () {
       var result = document.getElementById("resulist");
 
index b2280e124dc1766bf0b92fd8bcd72c9c3be4a2ad..17248fc5d3c5f9299523a4d5f8d024636928619d 100644 (file)
@@ -63,7 +63,7 @@ $(document).ready(function () {
                 <tr>
                   <td colspan="2"><s:text name="criterion.study"/>&nbsp;</td>
                   <td colspan="3" align="center">
-                  <select name="state" style="width: <s:text name="size.search.select"/>" onChange="setState()">
+                  <select name="state" style="width: <s:text name="size.search.select"/>" onChange="changeFilter()">
                     <s:if test="state == 'ANY'">       <option value="ANY"        selected><s:text name="criterion.any" /></option></s:if>
                     <s:else>                           <option value="ANY"                ><s:text name="criterion.any" /></option></s:else>
                     <s:if test="connectedUser != null">
index 276ca13387f43b0d8268f37304f6298cc869dd0f..477a447674f4f49b87c30fe37ef50956528bf46f 100644 (file)
@@ -154,6 +154,7 @@ public abstract class AbstractSearchBaseAction extends Action {
                        // We keep the previous result search, if valid
                        _result = (List<Proxy>) getSession().get(RESULT_KEY);
                }
+               setActionType("setContext");
                return "selectype";
        }
 
index 423e39c374d2f9f9c7def02e8e134f1a9807eb68..b331929ba5a7540eeccd5a38af463feec97f18ea 100644 (file)
@@ -8,7 +8,6 @@ import org.splat.dal.bo.som.ProgressState;
 import org.splat.dal.bo.som.SimulationContext;
 import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Study;
-import org.splat.dal.bo.som.Visibility;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.service.SearchService;
 import org.splat.service.technical.ProjectSettingsService;
@@ -117,14 +116,11 @@ public class SearchStudyAction extends AbstractSearchBaseAction {
                        User him = getUserService().selectUser(index);
                        sprop.setManager(him);
                }
-               // Set of the visibility
-               Study.Properties other = sprop.copy();
-
-               other.setVisibility(Visibility.PUBLIC);
-               sprop.setVisibility(Visibility.PRIVATE);
                sprop.setActor(getConnectedUser());
 
-               _result = getSearchService().selectStudiesWhere(sprop, other);
+               _result = getSearchService().selectStudiesWhere(
+                               "all".equals(_criteriaMatch), "all".equals(_contextMatch),
+                               sprop);
                session.put(RESULT_KEY, _result); // For redisplaying the page without re-executing the search
                return "refresh";
        }
index 05b593179906b3accdf29a642dee55c6e8415835..7d8671d10bae7872ff627bd1aa154ddc44112012 100644 (file)
@@ -12,6 +12,7 @@ import org.splat.simer.Action;
  *
  * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
+@Deprecated
 public class DatabaseIndexingAction extends Action {
 
        /**