Salome HOME
Reindex of studies is fixed.
authorrkv <rkv@opencascade.com>
Mon, 22 Oct 2012 07:53:24 +0000 (07:53 +0000)
committerrkv <rkv@opencascade.com>
Mon, 22 Oct 2012 07:53:24 +0000 (07:53 +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/technical/IndexServiceImpl.java
Workspace/Siman-Common/src/spring/businessServiceContext.xml
Workspace/Siman/WebContent/jsp/searchForm.jsp
Workspace/Siman/src/org/splat/simer/ApplicationSettings.java
Workspace/Siman/src/org/splat/simer/SearchStudyAction.java
Workspace/Siman/src/org/splat/simer/admin/DatabaseIndexingAction.java
Workspace/Siman/src/spring/applicationContext.xml

index 08a8ab8ad4b53493a819bddef84fba4d1a8cf520..b61b2f9fcf04ed80cec61f99471d8e3d143821a6 100644 (file)
@@ -7,7 +7,7 @@
  * @version        $Revision$
  *****************************************************************************/
 
-package org.splat.service; 
+package org.splat.service;
 
 import java.util.List;
 
@@ -16,12 +16,37 @@ import org.splat.dal.bo.som.Study;
 import org.splat.service.dto.Proxy;
 
 /**
- * @author rkv
- *
+ * Search service interface.
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public interface SearchService {
 
-       public List<Proxy> selectKnowledgeElementsWhere (KnowledgeElement.Properties... kprop);
-       public List<Proxy> selectStudiesWhere (Study.Properties... sprop);
-       public void indexStudy (Study study);
+       /**
+        * Refresh lucene index for studies.
+        * 
+        * @param ridlist
+        *            list of studies id's
+        */
+       public void reindexStudies(String[] ridlist);
+
+       /**
+        * Find knowledge elements with given properties.
+        * @param kprop search filter parameters
+        * @return the list of found knowledge elements as proxiy results of lucene search
+        */
+       public List<Proxy> selectKnowledgeElementsWhere(
+                       KnowledgeElement.Properties... kprop);
+
+       /**
+        * Find studies with given properties.
+        * @param sprop search filter parameters
+        * @return the list of found studies as proxiy results of lucene search
+        */
+       public List<Proxy> selectStudiesWhere(Study.Properties... sprop);
+
+       /**
+        * Refresh lucene index for a study.
+        * @param study the study to reindex
+        */
+       public void indexStudy(Study study);
 }
index 75f3d6a961f8ae6492fbb2fe01da66daa09ed484..ad113b60d7d84709f2981b7ff143889475fbd16c 100644 (file)
@@ -7,7 +7,7 @@
  * @version        $Revision$
  *****************************************************************************/
 
-package org.splat.service; 
+package org.splat.service;
 
 import java.io.File;
 import java.io.IOException;
@@ -38,263 +38,364 @@ 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.dao.som.Database;
 import org.splat.service.dto.Proxy;
 import org.splat.service.technical.IndexService;
 import org.splat.service.technical.IndexServiceImpl;
 import org.splat.service.technical.RepositoryService;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
- * @author rkv
- *
+ * Search service implementation.
+ * 
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
  */
 public class SearchServiceImpl implements SearchService {
 
-    public final static Logger   logger = Logger.getLogger(org.splat.service.SearchServiceImpl.class);
-    
-       private RepositoryService _repositoryService;
+       /**
+        * The service logger.
+        */
+       public final static Logger logger = Logger
+                       .getLogger(org.splat.service.SearchServiceImpl.class);
 
+       /**
+        * Injected repository service.
+        */
+       private RepositoryService _repositoryService;
+       /**
+        * Injected index service.
+        */
        private IndexService _indexService;
-       
-       public List<Proxy> selectKnowledgeElementsWhere (KnowledgeElement.Properties... kprop) {
-       //  ---------------------------------------------------------------------------------------------
-             List<Proxy> result  = new ArrayList<Proxy>();
-             int         hitsize = 20;
-             try {
-       
-       //          Creation of the Lucene query
-               File          indir    = getRepositoryService().getRepositoryIndexDirectory();
-               Directory     index    = FSDirectory.open(indir);               
-               IndexSearcher searcher = new IndexSearcher(index, true);
-               BooleanQuery  fulquery = new BooleanQuery();
-               
-                   for (int i=0; i<kprop.length; i++) {
-                     BooleanQuery  query = new BooleanQuery();
-                     Term          input;                                 // Supposed initialized below at least by the visibility
-               
-                 Visibility area = kprop[i].getVisibility();          // Visibility
-                 if (area != null) {
-                   input = new Term("area");
-                   query.add(new TermQuery(input.createTerm(area.toString())), BooleanClause.Occur.MUST);
-                 }
-                 ProgressState state = kprop[i].getProgressState();   // State
-                 if (state != null) {
-                         input = new Term("state");
-                   query.add(new TermQuery(input.createTerm(state.toString())), BooleanClause.Occur.MUST);
-                 }
-                 String refid = kprop[i].getReference();              // Reference
-                 if (refid != null) {
-                   input = new Term("ref");
-                       query.add(new TermQuery(input.createTerm(refid)), BooleanClause.Occur.MUST);
-                 }
-                 KnowledgeElementType type = kprop[i].getType();      // Type
-                 if (type != null) {
-                   input = new Term("type");
-                       query.add(new TermQuery(input.createTerm(type.getName())), BooleanClause.Occur.MUST);
-                 }
-                 User manager = kprop[i].getAuthor();                 // Author
-                 if  (manager != null) {
-                   input = new Term("author");
-                       query.add(new TermQuery(input.createTerm(manager.toString())), BooleanClause.Occur.MUST);
-                 }
-                 User actor = kprop[i].getActor();                    // Contributor, Reviewer or Approver of the owner study
-                 if  (actor != null) {
-                       input = new Term("actor");
-                           query.add(new TermQuery(input.createTerm(actor.toString())), BooleanClause.Occur.MUST);
-                 }
-                 String title = kprop[i].getTitle();                  // Title
-                 if (title != null) {
-                   input = new Term("contents");
-                   BooleanQuery critext  = new BooleanQuery();
-                   String       operator = "AND";     // Future user input
-                   BooleanClause.Occur        clause = BooleanClause.Occur.MUST;
-                   if (operator.equals("OR")) clause = BooleanClause.Occur.SHOULD;
-                   String[] word = title.split(" ");
-                   for (int j=0; j<word.length; j++) {
-                     critext.add(new TermQuery(input.createTerm(word[j])), clause);
-                   }
-                   query.add(critext, BooleanClause.Occur.MUST);
-                 }
-                 List<SimulationContext> context = kprop[i].getSimulationContexts();
-                 if  (context != null && context.size() > 0) {
-                   BooleanQuery critext = new BooleanQuery();
-                   for (Iterator<SimulationContext> j=context.iterator(); j.hasNext();) {
-                     SimulationContext seltext = j.next();
-                     input =  new Term(String.valueOf(seltext.getType().getIndex()));
-                     critext.add(new TermQuery(input.createTerm(seltext.getValue())), BooleanClause.Occur.MUST);
-                   }
-                   query.add(critext, BooleanClause.Occur.MUST);
-                 }
-               fulquery.add(query, BooleanClause.Occur.SHOULD);
-                   }
+
+       /**
+        * Injected study service.
+        */
+       private StudyService _studyService;
+
+       /**
+        * Refresh lucene index for studies.
+        * 
+        * @param ridlist
+        *            list of studies id's
+        */
+       @Transactional(readOnly = true)
+       public void reindexStudies(String[] ridlist) {
+               for (int i = 0; i < ridlist.length; i++) {
+                       long index = Long.valueOf(ridlist[i].trim());
+                       Study study = getStudyService().selectStudy(index);
+                       indexStudy(study);
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SearchService#selectKnowledgeElementsWhere(org.splat.dal.bo.som.KnowledgeElement.Properties[])
+        */
+       public List<Proxy> selectKnowledgeElementsWhere(
+                       KnowledgeElement.Properties... kprop) {
+               List<Proxy> result = new ArrayList<Proxy>();
+               int hitsize = 20;
+               try {
+
+                       // Creation of the Lucene query
+                       File indir = getRepositoryService().getRepositoryIndexDirectory();
+                       Directory index = FSDirectory.open(indir);
+                       IndexSearcher searcher = new IndexSearcher(index, true);
+                       BooleanQuery fulquery = new BooleanQuery();
+
+                       for (int i = 0; i < kprop.length; i++) {
+                               BooleanQuery query = new BooleanQuery();
+                               Term input; // Supposed initialized below at least by the visibility
+
+                               Visibility area = kprop[i].getVisibility(); // Visibility
+                               if (area != null) {
+                                       input = new Term("area");
+                                       query.add(new TermQuery(input.createTerm(area.toString())),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               ProgressState state = kprop[i].getProgressState(); // State
+                               if (state != null) {
+                                       input = new Term("state");
+                                       query.add(
+                                                       new TermQuery(input.createTerm(state.toString())),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               String refid = kprop[i].getReference(); // Reference
+                               if (refid != null) {
+                                       input = new Term("ref");
+                                       query.add(new TermQuery(input.createTerm(refid)),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               KnowledgeElementType type = kprop[i].getType(); // Type
+                               if (type != null) {
+                                       input = new Term("type");
+                                       query.add(new TermQuery(input.createTerm(type.getName())),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               User manager = kprop[i].getAuthor(); // Author
+                               if (manager != null) {
+                                       input = new Term("author");
+                                       query.add(new TermQuery(input
+                                                       .createTerm(manager.toString())),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               User actor = kprop[i].getActor(); // Contributor, Reviewer or Approver of the owner study
+                               if (actor != null) {
+                                       input = new Term("actor");
+                                       query.add(
+                                                       new TermQuery(input.createTerm(actor.toString())),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               String title = kprop[i].getTitle(); // Title
+                               if (title != null) {
+                                       input = new Term("contents");
+                                       BooleanQuery critext = new BooleanQuery();
+                                       String operator = "AND"; // Future user input
+                                       BooleanClause.Occur clause = BooleanClause.Occur.MUST;
+                                       if (operator.equals("OR"))
+                                               clause = BooleanClause.Occur.SHOULD;
+                                       String[] word = title.split(" ");
+                                       for (int j = 0; j < word.length; j++) {
+                                               critext.add(new TermQuery(input.createTerm(word[j])),
+                                                               clause);
+                                       }
+                                       query.add(critext, BooleanClause.Occur.MUST);
+                               }
+                               List<SimulationContext> context = kprop[i]
+                                               .getSimulationContexts();
+                               if (context != null && context.size() > 0) {
+                                       BooleanQuery critext = new BooleanQuery();
+                                       for (Iterator<SimulationContext> j = context.iterator(); j
+                                                       .hasNext();) {
+                                               SimulationContext seltext = j.next();
+                                               input = new Term(String.valueOf(seltext.getType()
+                                                               .getIndex()));
+                                               critext.add(new TermQuery(input.createTerm(seltext
+                                                               .getValue())), BooleanClause.Occur.MUST);
+                                       }
+                                       query.add(critext, BooleanClause.Occur.MUST);
+                               }
+                               fulquery.add(query, BooleanClause.Occur.SHOULD);
+                       }
                        if (logger.isInfoEnabled()) {
-                   logger.info("Searching knowledges by Lucene query \"" + fulquery.toString() + "\".");
-               }
-       //    Creation of the knowledge filter
-                       BooleanFilter   filter = new BooleanFilter();
-                       TermsFilter     select = new TermsFilter();
-                       Term            mytype = new Term("class");
-                       select.addTerm( mytype.createTerm("KnowledgeElement") );
-                       filter.add(new FilterClause(select, BooleanClause.Occur.SHOULD));
-       
-       //    Creation of the sort criteria
-                       Sort  sort = new Sort(new SortField("title", SortField.STRING));
-       
-       //    Search
-               TopFieldDocs found = searcher.search(fulquery, filter, hitsize, sort);
-               
-               if (found.totalHits < 1) return result;   // No study found
-       
-       //    Construction of the result list
-               ScoreDoc[] hits = found.scoreDocs;
-                   for (int i=0; i<hits.length; i++) {
-                         result.add( new IndexServiceImpl.ObjectProxy(searcher.doc(hits[i].doc)) );
-                   }
-                   searcher.close();             
-             }
-             catch (Exception error) {
-               logger.error("Error during Lucene search, reason:", error);
-             }
-             return result;
+                               logger.info("Searching knowledges by Lucene query \""
+                                               + fulquery.toString() + "\".");
+                       }
+                       // Creation of the knowledge filter
+                       BooleanFilter filter = new BooleanFilter();
+                       TermsFilter select = new TermsFilter();
+                       Term mytype = new Term("class");
+                       select.addTerm(mytype.createTerm("KnowledgeElement"));
+                       filter.add(new FilterClause(select, BooleanClause.Occur.SHOULD));
+
+                       // Creation of the sort criteria
+                       Sort sort = new Sort(new SortField("title", SortField.STRING));
+
+                       // Search
+                       TopFieldDocs found = searcher.search(fulquery, filter, hitsize,
+                                       sort);
+
+                       if (found.totalHits < 1)
+                               return result; // No study found
+
+                       // Construction of the result list
+                       ScoreDoc[] hits = found.scoreDocs;
+                       for (int i = 0; i < hits.length; i++) {
+                               result.add(new IndexServiceImpl.ObjectProxy(searcher
+                                               .doc(hits[i].doc)));
+                       }
+                       searcher.close();
+               } catch (Exception error) {
+                       logger.error("Error during Lucene search, reason:", error);
                }
+               return result;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SearchService#selectStudiesWhere(org.splat.dal.bo.som.Study.Properties[])
+        */
+       public List<Proxy> selectStudiesWhere(Study.Properties... sprop) {
+               List<Proxy> result = new ArrayList<Proxy>();
+               int hitsize = 20;
+               try {
 
-       public List<Proxy> selectStudiesWhere (Study.Properties... sprop) {
-       //  ------------------------------------------------------------------------
-             List<Proxy> result  = new ArrayList<Proxy>();
-             int         hitsize = 20;
-             try {
-       
-       //    Creation of the Lucene query
-               File          indir    = getRepositoryService().getRepositoryIndexDirectory();
-               Directory     index    = FSDirectory.open(indir);               
-               IndexSearcher searcher = new IndexSearcher(index, true);
-               BooleanQuery  fulquery = new BooleanQuery();
-               
-                   for (int i=0; i<sprop.length; i++) {
-                     BooleanQuery  query = new BooleanQuery();
-                     Term          input;                                 // Supposed initialized below at least by the visibility
-       
-                 Visibility area = sprop[i].getVisibility();          // Visibility
-                 if (area != null) {
-                       input = new Term("area");
-                   query.add(new TermQuery(input.createTerm(area.toString())), BooleanClause.Occur.MUST);
-                 }
-                 ProgressState state = sprop[i].getProgressState();   // State
-                 if (state != null) {
-                       input = new Term("state");
-                   if (state == ProgressState.inPROGRESS) {
-                         BooleanQuery cristate = new BooleanQuery();
-                         cristate.add(new TermQuery(input.createTerm("inWORK")),  BooleanClause.Occur.SHOULD);
-                         cristate.add(new TermQuery(input.createTerm("inDRAFT")), BooleanClause.Occur.SHOULD);
-                         cristate.add(new TermQuery(input.createTerm("inCHECK")), BooleanClause.Occur.SHOULD);
-                     query.add(cristate, BooleanClause.Occur.MUST);
-                   } else {
-                     query.add(new TermQuery(input.createTerm(state.toString())), BooleanClause.Occur.MUST);
-                   }
-                 }
-                 String refid = sprop[i].getReference();              // Reference
-                 if (refid != null) {
-                   input = new Term("ref");
-                   query.add(new TermQuery(input.createTerm(refid)), BooleanClause.Occur.MUST);
-                 }
-                 User manager = sprop[i].getManager();                // Author
-                 if  (manager != null) {
-                       input = new Term("author");
-                           query.add(new TermQuery(input.createTerm(manager.toString())), BooleanClause.Occur.MUST);
-                 }
-                 User actor = sprop[i].getActor();                    // Contributor, Reviewer or Approver
-                 if  (actor != null) {
-                       input = new Term("actor");
-                           query.add(new TermQuery(input.createTerm(actor.toString())), BooleanClause.Occur.MUST);
-                 }
-                 String title = sprop[i].getTitle();                  // Title
-                 if (title != null) {
-                       input = new Term("contents");
-                       BooleanQuery critext  = new BooleanQuery();
-                       String       operator = "AND";     // Future user input
-                       BooleanClause.Occur        clause = BooleanClause.Occur.MUST;
-                       if (operator.equals("OR")) clause = BooleanClause.Occur.SHOULD;
-                       String[] word = title.split(" ");
-                       for (int j=0; j<word.length; j++) {
-                         critext.add(new TermQuery(input.createTerm(word[j])), clause);
-                       }
-                       query.add(critext, BooleanClause.Occur.MUST);
-                 }
-                 List<SimulationContext> context = sprop[i].getSimulationContexts();
-                 if  (context != null && context.size() > 0) {
-                   BooleanQuery critext = new BooleanQuery();
-                       for (Iterator<SimulationContext> j=context.iterator(); j.hasNext();) {
-                     SimulationContext seltext = j.next();
-                     input =  new Term(String.valueOf(seltext.getType().getIndex()));
-                     critext.add(new TermQuery(input.createTerm(seltext.getValue())), BooleanClause.Occur.MUST);
-                   }
-                   query.add(critext, BooleanClause.Occur.MUST);
-                 }          
-                 fulquery.add(query, BooleanClause.Occur.SHOULD);
-                   }
+                       // Creation of the Lucene query
+                       File indir = getRepositoryService().getRepositoryIndexDirectory();
+                       Directory index = FSDirectory.open(indir);
+                       IndexSearcher searcher = new IndexSearcher(index, true);
+                       BooleanQuery fulquery = new BooleanQuery();
+
+                       for (int i = 0; i < sprop.length; i++) {
+                               BooleanQuery query = new BooleanQuery();
+                               Term input; // Supposed initialized below at least by the visibility
+
+                               Visibility area = sprop[i].getVisibility(); // Visibility
+                               if (area != null) {
+                                       input = new Term("area");
+                                       query.add(new TermQuery(input.createTerm(area.toString())),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               ProgressState state = sprop[i].getProgressState(); // State
+                               if (state != null) {
+                                       input = new Term("state");
+                                       if (state == ProgressState.inPROGRESS) {
+                                               BooleanQuery cristate = new BooleanQuery();
+                                               cristate.add(new TermQuery(input.createTerm("inWORK")),
+                                                               BooleanClause.Occur.SHOULD);
+                                               cristate.add(
+                                                               new TermQuery(input.createTerm("inDRAFT")),
+                                                               BooleanClause.Occur.SHOULD);
+                                               cristate.add(
+                                                               new TermQuery(input.createTerm("inCHECK")),
+                                                               BooleanClause.Occur.SHOULD);
+                                               query.add(cristate, BooleanClause.Occur.MUST);
+                                       } else {
+                                               query.add(new TermQuery(input.createTerm(state
+                                                               .toString())), BooleanClause.Occur.MUST);
+                                       }
+                               }
+                               String refid = sprop[i].getReference(); // Reference
+                               if (refid != null) {
+                                       input = new Term("ref");
+                                       query.add(new TermQuery(input.createTerm(refid)),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               User manager = sprop[i].getManager(); // Author
+                               if (manager != null) {
+                                       input = new Term("author");
+                                       query.add(new TermQuery(input
+                                                       .createTerm(manager.toString())),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               User actor = sprop[i].getActor(); // Contributor, Reviewer or Approver
+                               if (actor != null) {
+                                       input = new Term("actor");
+                                       query.add(
+                                                       new TermQuery(input.createTerm(actor.toString())),
+                                                       BooleanClause.Occur.MUST);
+                               }
+                               String title = sprop[i].getTitle(); // Title
+                               if (title != null) {
+                                       input = new Term("contents");
+                                       BooleanQuery critext = new BooleanQuery();
+                                       String operator = "AND"; // Future user input
+                                       BooleanClause.Occur clause = BooleanClause.Occur.MUST;
+                                       if (operator.equals("OR"))
+                                               clause = BooleanClause.Occur.SHOULD;
+                                       String[] word = title.split(" ");
+                                       for (int j = 0; j < word.length; j++) {
+                                               critext.add(new TermQuery(input.createTerm(word[j])),
+                                                               clause);
+                                       }
+                                       query.add(critext, BooleanClause.Occur.MUST);
+                               }
+                               List<SimulationContext> context = sprop[i]
+                                               .getSimulationContexts();
+                               if (context != null && context.size() > 0) {
+                                       BooleanQuery critext = new BooleanQuery();
+                                       for (Iterator<SimulationContext> j = context.iterator(); j
+                                                       .hasNext();) {
+                                               SimulationContext seltext = j.next();
+                                               input = new Term(String.valueOf(seltext.getType()
+                                                               .getIndex()));
+                                               critext.add(new TermQuery(input.createTerm(seltext
+                                                               .getValue())), BooleanClause.Occur.MUST);
+                                       }
+                                       query.add(critext, BooleanClause.Occur.MUST);
+                               }
+                               fulquery.add(query, BooleanClause.Occur.SHOULD);
+                       }
                        if (logger.isInfoEnabled()) {
-                   logger.info("Searching studies by Lucene query \"" + fulquery.toString() + "\".");
-               }
-       //    Creation of the studies filter
-                       BooleanFilter   filter = new BooleanFilter();
-                       TermsFilter     select = new TermsFilter();
-                       Term            mytype = new Term("class");
-                       select.addTerm( mytype.createTerm("Study") );
-                       filter.add(new FilterClause(select, BooleanClause.Occur.SHOULD));
-       
-       //    Creation of the sort criteria
-                       Sort  sort = new Sort(new SortField("title", SortField.STRING));
-       
-       //    Search
-               TopFieldDocs found = searcher.search(fulquery, filter, hitsize, sort);
-               
-               if (found.totalHits < 1) return result;   // No study found
-       
-       //    Construction of the result list
-               ScoreDoc[] hits = found.scoreDocs;
-                   for (int i=0; i<hits.length; i++) {
-                         result.add( new IndexServiceImpl.ObjectProxy(searcher.doc(hits[i].doc)) );
-                   }
-                   searcher.close();             
-             }
-             catch (Exception error) {
-               logger.error("Error during Lucene search, reason:", error);
-             }
-             return result;
-           }
-
-       public void indexStudy (Study study) {
-       //  -------------------------------------------
-             try {
-               Study.Properties sprop = new Study.Properties();
-               List<Proxy>      index = selectStudiesWhere(sprop.setReference(study.getReference()));
-       
-               if (index.size() != 0) return;     // The given study is already indexed
-       
-               IndexService lucin = getIndex();
-               Scenario[] scenes = study.getScenarii();
-       
-               lucin.add(study);
-               if (study.getProgressState() != ProgressState.inWORK) for (int i=0; i<scenes.length; i++) {
-                 List<KnowledgeElement> list = scenes[i].getAllKnowledgeElements();
-                 for (Iterator<KnowledgeElement> j=list.iterator(); j.hasNext(); ) {
-                       lucin.add(j.next());
-                 }
-               }
-             }
-             catch (Exception error) {
-               Database.logger.error("Unable to index the study '" + study.getIndex() + "', reason:", error);
-             }
-           }
-
-    public IndexService getIndex () throws IOException {
+                               logger.info("Searching studies by Lucene query \""
+                                               + fulquery.toString() + "\".");
+                       }
+                       // Creation of the studies filter
+                       BooleanFilter filter = new BooleanFilter();
+                       TermsFilter select = new TermsFilter();
+                       Term mytype = new Term("class");
+                       select.addTerm(mytype.createTerm("Study"));
+                       filter.add(new FilterClause(select, BooleanClause.Occur.SHOULD));
+
+                       // Creation of the sort criteria
+                       Sort sort = new Sort(new SortField("title", SortField.STRING));
+
+                       // Search
+                       TopFieldDocs found = searcher.search(fulquery, filter, hitsize,
+                                       sort);
+
+                       if (found.totalHits < 1)
+                               return result; // No study found
+
+                       // Construction of the result list
+                       ScoreDoc[] hits = found.scoreDocs;
+                       for (int i = 0; i < hits.length; i++) {
+                               result.add(new IndexServiceImpl.ObjectProxy(searcher
+                                               .doc(hits[i].doc)));
+                       }
+                       searcher.close();
+               } catch (Exception error) {
+                       logger.error("Error during Lucene search, reason:", error);
+               }
+               return result;
+       }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.service.SearchService#indexStudy(org.splat.dal.bo.som.Study)
+        */
+       public void indexStudy(Study study) {
+               logger.debug("Index study: id=" + study.getRid() + "; reference=" + study.getReference());
+               try {
+                       Study.Properties sprop = new Study.Properties();
+                       List<Proxy> index = selectStudiesWhere(sprop.setReference(study
+                                       .getReference()));
+
+                       if (index.size() != 0) {
+                               logger.debug("The given study is already indexed.");
+                               return; // The given study is already indexed
+                       }
+
+                       IndexService lucin = getIndex();
+                       Scenario[] scenes = study.getScenarii();
+
+                       logger.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++) {
+                                       List<KnowledgeElement> list = scenes[i]
+                                                       .getAllKnowledgeElements();
+                                       for (Iterator<KnowledgeElement> j = list.iterator(); j
+                                                       .hasNext();) {
+                                               lucin.add(j.next());
+                                               logger.debug("Knowlegge added: id=" + j.next().getIndex());
+                                       }
+                               }
+               } catch (Exception error) {
+                       logger.error("Unable to index the study '"
+                                       + study.getIndex() + "', reason:", error);
+               }
+       }
+
+       /**
+        * Get lucene index handler. Create the index if it is not exist.
+        * 
+        * @return IndexService
+        * @throws IOException
+        *             if error when creating a new lucene index
+        */
+       private IndexService getIndex() throws IOException {
                IndexService lucin = getIndexService();
-               if ( !lucin.exists() ) lucin.create();     // Happens when re-indexing all studies
+               if (!lucin.exists())
+                       lucin.create(); // Happens when re-indexing all studies
                return lucin;
-    }
-    
+       }
+
        /**
         * Get the repositoryService.
+        * 
         * @return the repositoryService
         */
        public RepositoryService getRepositoryService() {
@@ -303,7 +404,9 @@ public class SearchServiceImpl implements SearchService {
 
        /**
         * Set the repositoryService.
-        * @param repositoryService the repositoryService to set
+        * 
+        * @param repositoryService
+        *            the repositoryService to set
         */
        public void setRepositoryService(RepositoryService repositoryService) {
                _repositoryService = repositoryService;
@@ -311,6 +414,7 @@ public class SearchServiceImpl implements SearchService {
 
        /**
         * Get the indexService.
+        * 
         * @return the indexService
         */
        public IndexService getIndexService() {
@@ -319,9 +423,27 @@ public class SearchServiceImpl implements SearchService {
 
        /**
         * Set the indexService.
-        * @param indexService the indexService to set
+        * 
+        * @param indexService
+        *            the indexService to set
         */
        public void setIndexService(IndexService indexService) {
                _indexService = indexService;
        }
+
+       /**
+        * Get the studyService.
+        * @return the studyService
+        */
+       public StudyService getStudyService() {
+               return _studyService;
+       }
+
+       /**
+        * Set the studyService.
+        * @param studyService the studyService to set
+        */
+       public void setStudyService(StudyService studyService) {
+               _studyService = studyService;
+       }
 }
index 6f96dc9401d755e873d3b71d465f63c310d49c72..498026d2ed26001cebab91af52490462322d5ec8 100644 (file)
@@ -1,4 +1,5 @@
 package org.splat.service.technical;
+
 /**
  * 
  * @author    Daniel Brunier-Coulin
@@ -30,261 +31,297 @@ import org.splat.dal.bo.som.ProgressState;
 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.dao.som.Database;
 import org.splat.service.ProjectElementService;
 import org.splat.service.dto.Proxy;
 import org.splat.som.Step;
 
-
 public class IndexServiceImpl implements IndexService {
 
-    private Directory                            index;
-    private org.apache.lucene.document.Document  body;
+       private Directory index;
+       private org.apache.lucene.document.Document body;
        private ProjectElementService _projectElementService;
-       private RepositoryService     _repositoryService;
-    
-       protected static       StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_29);
-    private   static final Logger           logger   = Logger.getLogger(IndexServiceImpl.class);
-
-    private class Entry extends IndexWriter {
-//  ---------------------------------------
-      private org.apache.lucene.document.Document entry;
-
-      private Entry (Study study) throws CorruptIndexException, LockObtainFailedException, IOException
-      {
-        super(index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
-
-//      Addition of mandatory fields
-        entry = new org.apache.lucene.document.Document();        
-       Field  field;
-       field = body.getField("index");
-       field.setValue(String.valueOf(study.getIndex()));
-       entry.add(field);
-       field = body.getField("class");
-       field.setValue("Study");
-       entry.add(field);
-       field = body.getField("type");
-       field.setValue("");     // Reserved for configurable Study type
-       entry.add(field);
-       field = body.getField("ref");
-       field.setValue(study.getReference());
-       entry.add(field);
-       field = body.getField("area");
-       field.setValue(study.getVisibility().toString());
-       entry.add(field);
-       field = body.getField("state");
-       field.setValue(study.getProgressState().toString());
-       entry.add(field);
-       field = body.getField("author");
-       field.setValue(study.getAuthor().toString());
-       entry.add(field);
-       field = body.getField("title");
-       field.setValue(study.getTitle());
-       entry.add(field);
-       field = body.getField("contents");
-       field.setValue(study.getTitle());
-       entry.add(field);
-
-//      Addition of optional fields
-       setActorsOf(study);
-       setContextAt(getProjectElementService().getSteps(study));
-      }
-      private Entry (KnowledgeElement kelm) throws CorruptIndexException, LockObtainFailedException, IOException
-      {
-        super(index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
-
-//      Addition of mandatory fields
-        entry = new org.apache.lucene.document.Document();        
-       Field field;
-        field = body.getField("index");
-        field.setValue(String.valueOf(kelm.getIndex()));
-       entry.add(field);
-        field = body.getField("class");
-        field.setValue("KnowledgeElement");
-       entry.add(field);
-        field = body.getField("type");
-        field.setValue(kelm.getType().getName());
-       entry.add(field);
-        field = body.getField("ref");
-        field.setValue(kelm.getReference());
-       entry.add(field);
-       field = body.getField("area");
-       field.setValue(kelm.getVisibility().toString());
-       entry.add(field);
-       field = body.getField("state");
-       field.setValue(kelm.getProgressState().toString());
-       entry.add(field);
-        field = body.getField("author");
-        field.setValue(kelm.getAuthor().toString());
-       entry.add(field);
-        field = body.getField("title");
-        field.setValue(kelm.getTitle());
-       entry.add(field);
-        field = body.getField("contents");
-        field.setValue(kelm.getTitle());
-       entry.add(field);
-
-//TODO: Addition of optional fields
-       Scenario scene = kelm.getOwnerScenario();
-       Study    study = scene.getOwnerStudy();
-       setActorsOf(study);  // For restricting the visibility of knowledges attached to private studies
-       setContextAt(getProjectElementService().getSteps(study));
-       setContextAt(getProjectElementService().getSteps(scene));
-      }
-      private void add () throws CorruptIndexException, IOException
-      {
-        addDocument(entry);
-//      Save the new entry
-        optimize();          // Should be called before committing the index
-        close();             // Commits the index
-      }
-      private void update () throws CorruptIndexException, IOException
-      {
-       String value = entry.getField("ref").stringValue();   // Only field with unique value
-       Term   term  = new Term("ref").createTerm(value);
-        updateDocument(term, entry);
-//      Save the updated entry
-        optimize();          // Should be called before committing the index
-        close();             // Commits the index
-      }
-      private void setContextAt (Step[] step)
-      {
-               for (int i=0; i<step.length; i++) {
-          List<SimulationContext> contexts = step[i].getAllSimulationContexts();
-          for (Iterator<SimulationContext> j=contexts.iterator(); j.hasNext();) {
-            SimulationContext  context = j.next();
-            String             type    = String.valueOf(context.getType().getIndex());
-            String             value   = context.getValue();
-            entry.add( new Field(type, value, Field.Store.NO, Field.Index.NOT_ANALYZED) );
-          }
-       }
-      }
-      private void setActorsOf (Study study)
-      {
-//RKV: This set is always not null. Let's assume that it must be initialized before reindexing:        Set<User> actors = study.getActors();
-       Set<User> actors = study.getActor(); //RKV
-       for (Iterator<User> i=actors.iterator(); i.hasNext(); ) {
-         String value = i.next().toString();
-          entry.add( new Field("actor", value, Field.Store.NO, Field.Index.NOT_ANALYZED) );
-       }
-      }
-    }      
-    public static class ObjectProxy implements Proxy, Serializable {
-//  --------------------------------------------------------------
-      private Long           rid;
-      private String        sid;
-      private ProgressState state;
-      private String        title;
-      private String        type;
-      private String        name;
-      private static final long serialVersionUID = -4386494192709562221L;
-          
-      public ObjectProxy (org.apache.lucene.document.Document ludoc) {
-        rid   = Long.valueOf(ludoc.get("index"));
-        sid   = ludoc.get("ref");
-        state = ProgressState.valueOf(ludoc.get("state"));
-        title = ludoc.get("title");
-        name  = ludoc.get("author");
-      }
-      public String getAuthorName () {
-        return name;
-      }
-      public Long getIndex () {
-        return rid;
-      }
-      public ProgressState getProgressState () {
-        return state;
-      }
-      public String getReference () {
-        return sid;
-      }
-      public String getTitle () {
-       return title;
-      }
-      public String getType () {
-        return type;
-      }
-    }
-
-//  ==============================================================================================================================
-//  Construction
-//  ==============================================================================================================================
-    
-    public void configure () throws IOException {
-        File indir = getRepositoryService().getRepositoryIndexDirectory();
-        index = FSDirectory.open(indir);
-        body  = new org.apache.lucene.document.Document();
-        body.add( new Field("index",   "", Field.Store.YES, Field.Index.NOT_ANALYZED) );
-        body.add( new Field("class",   "", Field.Store.NO,  Field.Index.NOT_ANALYZED) );
-        body.add( new Field("type",    "", Field.Store.YES, Field.Index.NOT_ANALYZED) );
-        body.add( new Field("ref",     "", Field.Store.YES, Field.Index.NOT_ANALYZED) );
-        body.add( new Field("area",    "", Field.Store.NO,  Field.Index.NOT_ANALYZED) );
-        body.add( new Field("state",   "", Field.Store.YES, Field.Index.NOT_ANALYZED) );
-        body.add( new Field("author",  "", Field.Store.YES, Field.Index.NOT_ANALYZED) );
-        body.add( new Field("title",   "", Field.Store.YES, Field.Index.NOT_ANALYZED) );
-        body.add( new Field("contents","", Field.Store.NO,  Field.Index.ANALYZED) );
-        if ( !this.exists() ) this.create();     // Happens when re-indexing all studies
-    }
-    
-    public void create () throws IOException {
-//  -------------------------------
-      Directory   index  = FSDirectory.open(getRepositoryService().getRepositoryIndexDirectory());
-         IndexWriter writer = new IndexWriter(index, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
-         writer.close();                                    // ====  Creates an empty index
-    }
-
-//  ==============================================================================================================================
-//  Member functions
-//  ==============================================================================================================================
-
-    public void add (Study study) throws IOException {
-//  --------------------------------
-      IndexServiceImpl.Entry entry = new Entry(study);
-      entry.add();
-      if (logger.isInfoEnabled()) {
-          logger.info("Study \"" + study.getIndex() + "\" indexed.");
-      }
-    }
-
-    public void add (KnowledgeElement kelm) throws IOException {
-//  ------------------------------------------
-         IndexServiceImpl.Entry entry = new Entry(kelm);
-      entry.add();
-         if (logger.isInfoEnabled()) {
-          logger.info("Knowledge \"" + kelm.getIndex() + "\" indexed.");
-         }
-    }
-
-    public boolean exists () {
-//  ---------------------------
-      try {
-               return IndexReader.indexExists(index);
-      }
-      catch (IOException error) {
-        error.printStackTrace();
-        return false;
+       private RepositoryService _repositoryService;
+
+       protected static StandardAnalyzer analyzer = new StandardAnalyzer(
+                       Version.LUCENE_29);
+       private static final Logger logger = Logger
+                       .getLogger(IndexServiceImpl.class);
+
+       private class Entry extends IndexWriter {
+               private org.apache.lucene.document.Document entry;
+
+               private Entry(Study study) throws CorruptIndexException,
+                               LockObtainFailedException, IOException {
+                       super(index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
+
+                       // Addition of mandatory fields
+                       entry = new org.apache.lucene.document.Document();
+                       Field field;
+                       field = body.getField("index");
+                       field.setValue(String.valueOf(study.getIndex()));
+                       entry.add(field);
+                       field = body.getField("class");
+                       field.setValue("Study");
+                       entry.add(field);
+                       field = body.getField("type");
+                       field.setValue(""); // Reserved for configurable Study type
+                       entry.add(field);
+                       field = body.getField("ref");
+                       field.setValue(study.getReference());
+                       entry.add(field);
+                       field = body.getField("area");
+                       field.setValue(study.getVisibility().toString());
+                       entry.add(field);
+                       field = body.getField("state");
+                       field.setValue(study.getProgressState().toString());
+                       entry.add(field);
+                       field = body.getField("author");
+                       field.setValue(study.getAuthor().toString());
+                       entry.add(field);
+                       field = body.getField("title");
+                       field.setValue(study.getTitle());
+                       entry.add(field);
+                       field = body.getField("contents");
+                       field.setValue(study.getTitle());
+                       entry.add(field);
+
+                       // Addition of optional fields
+                       setActorsOf(study);
+                       setContextAt(getProjectElementService().getSteps(study));
+               }
+
+               private Entry(KnowledgeElement kelm) throws CorruptIndexException,
+                               LockObtainFailedException, IOException {
+                       super(index, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED);
+
+                       // Addition of mandatory fields
+                       entry = new org.apache.lucene.document.Document();
+                       Field field;
+                       field = body.getField("index");
+                       field.setValue(String.valueOf(kelm.getIndex()));
+                       entry.add(field);
+                       field = body.getField("class");
+                       field.setValue("KnowledgeElement");
+                       entry.add(field);
+                       field = body.getField("type");
+                       field.setValue(kelm.getType().getName());
+                       entry.add(field);
+                       field = body.getField("ref");
+                       field.setValue(kelm.getReference());
+                       entry.add(field);
+                       field = body.getField("area");
+                       field.setValue(kelm.getVisibility().toString());
+                       entry.add(field);
+                       field = body.getField("state");
+                       field.setValue(kelm.getProgressState().toString());
+                       entry.add(field);
+                       field = body.getField("author");
+                       field.setValue(kelm.getAuthor().toString());
+                       entry.add(field);
+                       field = body.getField("title");
+                       field.setValue(kelm.getTitle());
+                       entry.add(field);
+                       field = body.getField("contents");
+                       field.setValue(kelm.getTitle());
+                       entry.add(field);
+
+                       // TODO: Addition of optional fields
+                       Scenario scene = kelm.getOwnerScenario();
+                       Study study = scene.getOwnerStudy();
+                       setActorsOf(study); // For restricting the visibility of knowledges attached to private studies
+                       setContextAt(getProjectElementService().getSteps(study));
+                       setContextAt(getProjectElementService().getSteps(scene));
+               }
+
+               private void add() throws CorruptIndexException, IOException {
+                       addDocument(entry);
+                       // Save the new entry
+                       optimize(); // Should be called before committing the index
+                       close(); // Commits the index
+               }
+
+               private void update() throws CorruptIndexException, IOException {
+                       String value = entry.getField("ref").stringValue(); // Only field with unique value
+                       Term term = new Term("ref").createTerm(value);
+                       updateDocument(term, entry);
+                       // Save the updated entry
+                       optimize(); // Should be called before committing the index
+                       close(); // Commits the index
+               }
+
+               private void setContextAt(Step[] step) {
+                       for (int i = 0; i < step.length; i++) {
+                               List<SimulationContext> contexts = step[i]
+                                               .getAllSimulationContexts();
+                               for (Iterator<SimulationContext> j = contexts.iterator(); j
+                                               .hasNext();) {
+                                       SimulationContext context = j.next();
+                                       String type = String.valueOf(context.getType().getIndex());
+                                       String value = context.getValue();
+                                       entry.add(new Field(type, value, Field.Store.NO,
+                                                       Field.Index.NOT_ANALYZED));
+                               }
+                       }
+               }
+
+               private void setActorsOf(Study study) {
+                       // RKV: This set is always not null. Let's assume that it must be initialized before reindexing: Set<User> actors =
+                       // study.getActors();
+                       Set<User> actors = study.getActor(); // RKV
+                       if (logger.isDebugEnabled()) {
+                               logger.debug("Study " + study.getReference()
+                                               + " actors number to be added to the lucen index: "
+                                               + actors.size());
+                       }
+                       for (Iterator<User> i = actors.iterator(); i.hasNext();) {
+                               String value = i.next().toString();
+                               entry.add(new Field("actor", value, Field.Store.NO,
+                                               Field.Index.NOT_ANALYZED));
+                               if (logger.isDebugEnabled()) {
+                                       logger.debug("    actor added to the lucen index: " + value);
+                               }
+                       }
+               }
+       }
+
+       public static class ObjectProxy implements Proxy, Serializable {
+               // --------------------------------------------------------------
+               private Long rid;
+               private String sid;
+               private ProgressState state;
+               private String title;
+               private String type;
+               private String name;
+               private static final long serialVersionUID = -4386494192709562221L;
+
+               public ObjectProxy(org.apache.lucene.document.Document ludoc) {
+                       rid = Long.valueOf(ludoc.get("index"));
+                       sid = ludoc.get("ref");
+                       state = ProgressState.valueOf(ludoc.get("state"));
+                       title = ludoc.get("title");
+                       name = ludoc.get("author");
+               }
+
+               public String getAuthorName() {
+                       return name;
+               }
+
+               public Long getIndex() {
+                       return rid;
+               }
+
+               public ProgressState getProgressState() {
+                       return state;
+               }
+
+               public String getReference() {
+                       return sid;
+               }
+
+               public String getTitle() {
+                       return title;
+               }
+
+               public String getType() {
+                       return type;
+               }
+       }
+
+       // ==============================================================================================================================
+       // Construction
+       // ==============================================================================================================================
+
+       public void configure() throws IOException {
+               File indir = getRepositoryService().getRepositoryIndexDirectory();
+               index = FSDirectory.open(indir);
+               body = new org.apache.lucene.document.Document();
+               body.add(new Field("index", "", Field.Store.YES,
+                               Field.Index.NOT_ANALYZED));
+               body.add(new Field("class", "", Field.Store.NO,
+                               Field.Index.NOT_ANALYZED));
+               body.add(new Field("type", "", Field.Store.YES,
+                               Field.Index.NOT_ANALYZED));
+               body
+                               .add(new Field("ref", "", Field.Store.YES,
+                                               Field.Index.NOT_ANALYZED));
+               body
+                               .add(new Field("area", "", Field.Store.NO,
+                                               Field.Index.NOT_ANALYZED));
+               body.add(new Field("state", "", Field.Store.YES,
+                               Field.Index.NOT_ANALYZED));
+               body.add(new Field("author", "", Field.Store.YES,
+                               Field.Index.NOT_ANALYZED));
+               body.add(new Field("title", "", Field.Store.YES,
+                               Field.Index.NOT_ANALYZED));
+               body
+                               .add(new Field("contents", "", Field.Store.NO,
+                                               Field.Index.ANALYZED));
+               if (!this.exists())
+                       this.create(); // Happens when re-indexing all studies
+       }
+
+       public void create() throws IOException {
+               // -------------------------------
+               Directory index = FSDirectory.open(getRepositoryService()
+                               .getRepositoryIndexDirectory());
+               IndexWriter writer = new IndexWriter(index, analyzer, true,
+                               IndexWriter.MaxFieldLength.UNLIMITED);
+               writer.close(); // ==== Creates an empty index
+       }
+
+       // ==============================================================================================================================
+       // Member functions
+       // ==============================================================================================================================
+
+       public void add(Study study) throws IOException {
+               // --------------------------------
+               IndexServiceImpl.Entry entry = new Entry(study);
+               entry.add();
+               if (logger.isInfoEnabled()) {
+                       logger.info("Study \"" + study.getIndex() + "\" indexed.");
+               }
+       }
+
+       public void add(KnowledgeElement kelm) throws IOException {
+               // ------------------------------------------
+               IndexServiceImpl.Entry entry = new Entry(kelm);
+               entry.add();
+               if (logger.isInfoEnabled()) {
+                       logger.info("Knowledge \"" + kelm.getIndex() + "\" indexed.");
+               }
+       }
+
+       public boolean exists() {
+               // ---------------------------
+               try {
+                       return IndexReader.indexExists(index);
+               } catch (IOException error) {
+                       error.printStackTrace();
+                       return false;
+               }
        }
-    }
-
-    public void update (Study study) throws IOException {
-//  -----------------------------------
-         IndexServiceImpl.Entry entry = new Entry(study);
-         entry.update();
-      if (logger.isInfoEnabled()) {
-          logger.info("Study \"" + study.getIndex() + "\" re-indexed.");
-      }
-    }
-
-    public void update (KnowledgeElement kelm) throws IOException {
-//  ---------------------------------------------
-         IndexServiceImpl.Entry entry = new Entry(kelm);
-         entry.update();
-      if (logger.isInfoEnabled()) {
-          logger.info("Knowledge \"" + kelm.getIndex() + "\" re-indexed.");
-      }
-    }
+
+       public void update(Study study) throws IOException {
+               // -----------------------------------
+               IndexServiceImpl.Entry entry = new Entry(study);
+               entry.update();
+               if (logger.isInfoEnabled()) {
+                       logger.info("Study \"" + study.getIndex() + "\" re-indexed.");
+               }
+       }
+
+       public void update(KnowledgeElement kelm) throws IOException {
+               // ---------------------------------------------
+               IndexServiceImpl.Entry entry = new Entry(kelm);
+               entry.update();
+               if (logger.isInfoEnabled()) {
+                       logger.info("Knowledge \"" + kelm.getIndex() + "\" re-indexed.");
+               }
+       }
+
        /**
         * Get the projectElementService.
+        * 
         * @return the projectElementService
         */
        public ProjectElementService getProjectElementService() {
@@ -293,14 +330,18 @@ public class IndexServiceImpl implements IndexService {
 
        /**
         * Set the projectElementService.
-        * @param projectElementService the projectElementService to set
+        * 
+        * @param projectElementService
+        *            the projectElementService to set
         */
-       public void setProjectElementService(ProjectElementService projectElementService) {
+       public void setProjectElementService(
+                       ProjectElementService projectElementService) {
                _projectElementService = projectElementService;
        }
 
        /**
         * Get the repositoryService.
+        * 
         * @return the repositoryService
         */
        public RepositoryService getRepositoryService() {
@@ -309,7 +350,9 @@ public class IndexServiceImpl implements IndexService {
 
        /**
         * Set the repositoryService.
-        * @param repositoryService the repositoryService to set
+        * 
+        * @param repositoryService
+        *            the repositoryService to set
         */
        public void setRepositoryService(RepositoryService repositoryService) {
                _repositoryService = repositoryService;
index 6ad603fda2585f1c32c5f9faed5a4e20f4227651..d4abfbc97b28ba28b7dc6bed0fee1c7acee8a8dd 100644 (file)
@@ -85,7 +85,8 @@ http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
        <bean id="searchService"
                class="org.splat.service.SearchServiceImpl">
                <property name="indexService" ref="indexService" />
-               <property name="repositoryService" ref="repositoryService" />
+        <property name="repositoryService" ref="repositoryService" />
+        <property name="studyService" ref="studyService" />
        </bean>
 
        <bean id="stepService" class="org.splat.service.StepServiceImpl">
index c75c17a825b0a2abe905504c1d07c579c3ecb5be..4e8e668f73916a23078c812f004d59ea2a4b611d 100644 (file)
                 </s:if><s:else>
                   <input type=radio name="state" value="inCHECK" onClick="changeFilter()"><s:text name="criterion.incheck"/><br/>
                 </s:else>
-                <s:if test="state == 'END'">
-                  <input type=radio name="state" value="END" checked onClick="changeFilter()"><s:text name="criterion.end"/>
+                <s:if test="state == 'APPROVED'">
+                  <input type=radio name="state" value="APPROVED" checked onClick="changeFilter()"><s:text name="criterion.end"/>
                 </s:if><s:else>
-                  <input type=radio name="state" value="END" onClick="changeFilter()"><s:text name="criterion.end"/>
+                  <input type=radio name="state" value="APPROVED" onClick="changeFilter()"><s:text name="criterion.end"/>
                 </s:else>
                 </div>
               </td>
index ed1df7ae9690ee92c19b607b2a6ec925d6e5ba21..af7bd67f257cb220085756fdaf6f45bfa1880270 100644 (file)
@@ -606,7 +606,7 @@ public class ApplicationSettings {
                fprop.put("visibility", "PRIVATE");
                fprop.put("matchamong", "all");
                fprop.put("matcontext", "all");
-               fprop.put("state", "END");
+               fprop.put("state", "APPROVED");
                fprop.put("author", "0");
                fprop.put("reference", "");
                fprop.put("title", "");
index 188e5f07f6e3d79eef7de7228222477d720af81b..e6e8c06ff0a9dfcb1f2492b5916c2c041da83efd 100644 (file)
@@ -3,11 +3,8 @@ package org.splat.simer;
 import java.util.List;
 import java.util.Map;
 
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.kernel.InvalidPropertyException;
 import org.splat.dal.bo.kernel.User;
-import org.splat.dal.dao.som.Database;
 import org.splat.dal.bo.som.ProgressState;
 import org.splat.service.SearchService;
 import org.splat.service.SimulationContextService;
@@ -18,17 +15,27 @@ import org.splat.dal.bo.som.SimulationContextType;
 import org.splat.dal.bo.som.Study;
 import org.splat.dal.bo.som.Visibility;
 
-
+/**
+ * Search studies form action.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
 public class SearchStudyAction extends SearchBaseAction {
 
-    private String            visibility = null;   // "Private", "Public", "All"
-    private String            state      = null;   // "In-Work", "In-Draft", "In-Check"...
-    private String            matchamong = null;   // "all" or "any"
-    private String            matcontext = null;   // "all" or "any"
-    private String            refid      = null;   // Study reference
-    private String            words      = null;   // Full text search words
-       private SearchService _searchService;
+       private String visibility = null; // "Private", "Public", "All"
+       private String state = null; // "In-Work", "In-Draft", "In-Check"...
+       private String matchamong = null; // "all" or "any"
+       private String matcontext = null; // "all" or "any"
+       private String refid = null; // Study reference
+       private String words = null; // Full text search words
+       /**
+        * Injected project settings service.
+        */
        private ProjectSettingsService _projectSettingsService;
+       /**
+        * Injected search service.
+        */
+       private SearchService _searchService;
        /**
         * Injected simulation context service.
         */
@@ -43,184 +50,207 @@ public class SearchStudyAction extends SearchBaseAction {
         */
        private static final long serialVersionUID = -1910481357051393077L;
 
-    enum UserAction { refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext }
-
-//  ==============================================================================================================================
-//  Action methods
-//  ==============================================================================================================================
-
-    public String doInitialize () {
-//  -----------------------------
-      Session      connex  = Database.getCurSession();
-      Transaction  transax = connex.beginTransaction();
-      try {
-        loadFilter();
-        doSearch();
-
-//      Final initialization of the form
-        setCandidates();
-        setContextTypeOptions(getInvolvedContexts());
-
-        transax.commit();
-        return SUCCESS;
-      }
-      catch (Exception error) {
-//      No need to roll back the transaction as it is read only
-       logger.error("Reason: ", error);
-        return ERROR;
-      }
-    }
-
-    protected String doSearch () throws InvalidPropertyException {
-//  ----------------------------
-      Map<String, Object> session = getSession();
-      User                user    = getConnectedUser();
-
-      Study.Properties  sprop = new Study.Properties();
-
-//    Search matching all criteria
-        if (!this.state.equals("ANY"))     sprop.setState( ProgressState.valueOf(this.state) );
-        if (words.length() > 0)            sprop.setTitle(words);
-        if (refid.length() > 0)            sprop.setReference(refid);
-        if (context.size() > 0)            sprop.setSimulationContexts(context);
-        int index = Integer.valueOf(author);
-        if (index > 0) {
-          User him = getUserService().selectUser(index);
-          sprop.setManager(him);
-        }
-//    Set of the visibility
-        if (visibility.equals("all")) {
-          Study.Properties  other = sprop.copy();
-
-          other.setVisibility(Visibility.PUBLIC);
-          sprop.setVisibility(Visibility.PRIVATE);
-          sprop.setActor(user);
-
-          result = getSearchService().selectStudiesWhere(sprop, other);
-        }
-        else {
-          Visibility reparea = null;
-          if (visibility.equals("onlypublic")) reparea = Visibility.PUBLIC;
-          else                                 reparea = Visibility.valueOf(visibility);
-          sprop.setVisibility(reparea);
-          if (reparea == Visibility.PRIVATE) sprop.setActor(user);
-
-          result = getSearchService().selectStudiesWhere(sprop);
-      }
-      session.put("search.result", result);                          // For redisplaying the page without re-executing the search
-      return "refresh";
-    }
-
-//  ==============================================================================================================================
-//  Getters
-//  ==============================================================================================================================
-
-    public String getContextMatch () {
-//  --------------------------------
-      return matcontext;
-    }
-    public String getCriteriaMatch () {
-//  ---------------------------------
-      return matchamong;
-    }
-    public String getReference () {
-//  -----------------------------
-      return refid;
-    }
-    public String getState () {
-//  -------------------------
-      return state;
-    }
-    public String getVisibility () {
-//  ------------------------------
-      return visibility;
-    }
-    public String getWords () {
-//  -------------------------
-      return words;
-    }
-
-//  ==============================================================================================================================
-//  Setters
-//  ==============================================================================================================================
-
-    public void setContextMatch (String value) {
-//  ------------------------------------------
-      this.matcontext = value;
-    }
-    public void setCriteriaMatch (String value) {
-//  -------------------------------------------
-      this.matchamong = value;
-    }
-    public void setReference (String value) {
-//  ---------------------------------------
-      this.refid = value;
-    }
-    public void setState (String value) {
-//  -----------------------------------
-      this.state = value;
-    }
-    public void setVisibility (String value) {
-//  ----------------------------------------
-      this.visibility = value;
-    }
-    public void setWords (String value) {
-//  -----------------------------------
-      this.words = value;
-    }
-
-//  ==============================================================================================================================
-//  Implementation of abstract services
-//  ==============================================================================================================================
-
-       protected List<SimulationContextType> getInvolvedContexts () {
-//  ------------------------------------------------------------
-      List<ProjectSettingsService.Step>  steps  = getProjectSettings().getStepsOf(Study.class);
-      ProjectSettingsService.Step[]      number = steps.toArray(new ProjectSettingsService.Step[steps.size()]);
-      
-      return getSimulationContextService().selectTypesOf(number);
+       enum UserAction {
+               refreshResult, selectContextType, selectContextValue, cancelSelect, removeContext
+       }
+
+       // ==============================================================================================================================
+       // Action methods
+       // ==============================================================================================================================
+
+       /**
+        * Initialize study search form.
+        * @return SUCCESS if no exception, otherwise return ERROR
+        */
+       public String doInitialize() {
+               try {
+                       loadFilter();
+                       doSearch();
+
+                       // Final initialization of the form
+                       setCandidates();
+                       setContextTypeOptions(getInvolvedContexts());
+
+                       return SUCCESS;
+               } catch (Exception error) {
+                       // No need to roll back the transaction as it is read only
+                       logger.error("Reason: ", error);
+                       return ERROR;
+               }
+       }
+
+       protected String doSearch() throws InvalidPropertyException {
+               // ----------------------------
+               Map<String, Object> session = getSession();
+               User user = getConnectedUser();
+
+               Study.Properties sprop = new Study.Properties();
+
+               // Search matching all criteria
+               if (!this.state.equals("ANY"))
+                       sprop.setState(ProgressState.valueOf(this.state));
+               if (words.length() > 0)
+                       sprop.setTitle(words);
+               if (refid.length() > 0)
+                       sprop.setReference(refid);
+               if (context.size() > 0)
+                       sprop.setSimulationContexts(context);
+               int index = Integer.valueOf(author);
+               if (index > 0) {
+                       User him = getUserService().selectUser(index);
+                       sprop.setManager(him);
+               }
+               // Set of the visibility
+               if (visibility.equals("all")) {
+                       Study.Properties other = sprop.copy();
+
+                       other.setVisibility(Visibility.PUBLIC);
+                       sprop.setVisibility(Visibility.PRIVATE);
+                       sprop.setActor(user);
+
+                       result = getSearchService().selectStudiesWhere(sprop, other);
+               } else {
+                       Visibility reparea = null;
+                       if (visibility.equals("onlypublic"))
+                               reparea = Visibility.PUBLIC;
+                       else
+                               reparea = Visibility.valueOf(visibility);
+                       sprop.setVisibility(reparea);
+                       if (reparea == Visibility.PRIVATE)
+                               sprop.setActor(user);
+
+                       result = getSearchService().selectStudiesWhere(sprop);
+               }
+               session.put("search.result", result); // For redisplaying the page without re-executing the search
+               return "refresh";
+       }
+
+       // ==============================================================================================================================
+       // Getters
+       // ==============================================================================================================================
+
+       public String getContextMatch() {
+               // --------------------------------
+               return matcontext;
+       }
+
+       public String getCriteriaMatch() {
+               // ---------------------------------
+               return matchamong;
+       }
+
+       public String getReference() {
+               // -----------------------------
+               return refid;
+       }
+
+       public String getState() {
+               // -------------------------
+               return state;
+       }
+
+       public String getVisibility() {
+               // ------------------------------
+               return visibility;
+       }
+
+       public String getWords() {
+               // -------------------------
+               return words;
+       }
+
+       // ==============================================================================================================================
+       // Setters
+       // ==============================================================================================================================
+
+       public void setContextMatch(String value) {
+               // ------------------------------------------
+               this.matcontext = value;
        }
 
-    @SuppressWarnings("unchecked")
-       protected void loadFilter () {
-//  ----------------------------
-      Map<String,Object> session = getSession();
-      User                user    = getConnectedUser();
-      Map<String,Object> filter  = (Map<String, Object>)session.get("study.filter");   // A default filter is supposed being set at start
-
-      visibility = (String)filter.get("visibility");
-      matchamong = (String)filter.get("matchamong");
-      matcontext = (String)filter.get("matcontext");
-      state      = (String)filter.get("state");
-      author     = (String)filter.get("author");
-      refid      = (String)filter.get("reference");
-      words      = (String)filter.get("title");
-      context    = (List<SimulationContext>)filter.get("context");
-
-      if (user == null) {
-       visibility = "onlypublic";
-      }
-    }
-    
-    @SuppressWarnings("unchecked")
-       protected void saveFilter () {
-//  ----------------------------
-      Map<String, Object> session = getSession();
-      Map<String, Object> filter  = (Map<String, Object>)session.get("study.filter");   // A default filter is supposed being set at start
-
-      filter.put("visibility", this.visibility);
-      filter.put("matchamong", this.matchamong);
-      filter.put("matcontext", this.matcontext);
-      filter.put("state",      this.state);
-      filter.put("author",     this.author);
-      filter.put("reference",  this.refid);
-      filter.put("title",      this.words);
-
-      context = (List<SimulationContext>)filter.get("context");  // Only criteria not part of the form
-
-    }
-    /**
+       public void setCriteriaMatch(String value) {
+               // -------------------------------------------
+               this.matchamong = value;
+       }
+
+       public void setReference(String value) {
+               // ---------------------------------------
+               this.refid = value;
+       }
+
+       public void setState(String value) {
+               // -----------------------------------
+               this.state = value;
+       }
+
+       public void setVisibility(String value) {
+               // ----------------------------------------
+               this.visibility = value;
+       }
+
+       public void setWords(String value) {
+               // -----------------------------------
+               this.words = value;
+       }
+
+       // ==============================================================================================================================
+       // Implementation of abstract services
+       // ==============================================================================================================================
+
+       protected List<SimulationContextType> getInvolvedContexts() {
+               // ------------------------------------------------------------
+               List<ProjectSettingsService.Step> steps = getProjectSettings()
+                               .getStepsOf(Study.class);
+               ProjectSettingsService.Step[] number = steps
+                               .toArray(new ProjectSettingsService.Step[steps.size()]);
+
+               return getSimulationContextService().selectTypesOf(number);
+       }
+
+       @SuppressWarnings("unchecked")
+       protected void loadFilter() {
+               // ----------------------------
+               Map<String, Object> session = getSession();
+               User user = getConnectedUser();
+               Map<String, Object> filter = (Map<String, Object>) session
+                               .get("study.filter"); // A default filter is supposed being set at start
+
+               visibility = (String) filter.get("visibility");
+               matchamong = (String) filter.get("matchamong");
+               matcontext = (String) filter.get("matcontext");
+               state = (String) filter.get("state");
+               author = (String) filter.get("author");
+               refid = (String) filter.get("reference");
+               words = (String) filter.get("title");
+               context = (List<SimulationContext>) filter.get("context");
+
+               if (user == null) {
+                       visibility = "onlypublic";
+               }
+       }
+
+       @SuppressWarnings("unchecked")
+       protected void saveFilter() {
+               // ----------------------------
+               Map<String, Object> session = getSession();
+               Map<String, Object> filter = (Map<String, Object>) session
+                               .get("study.filter"); // A default filter is supposed being set at start
+
+               filter.put("visibility", this.visibility);
+               filter.put("matchamong", this.matchamong);
+               filter.put("matcontext", this.matcontext);
+               filter.put("state", this.state);
+               filter.put("author", this.author);
+               filter.put("reference", this.refid);
+               filter.put("title", this.words);
+
+               context = (List<SimulationContext>) filter.get("context"); // Only criteria not part of the form
+
+       }
+
+       /**
         * Get the searchService.
+        * 
         * @return the searchService
         */
        public SearchService getSearchService() {
@@ -229,13 +259,17 @@ public class SearchStudyAction extends SearchBaseAction {
 
        /**
         * Set the searchService.
-        * @param searchService the searchService to set
+        * 
+        * @param searchService
+        *            the searchService to set
         */
        public void setSearchService(SearchService searchService) {
                _searchService = searchService;
        }
-    /**
-     * Get project settings.
+
+       /**
+        * Get project settings.
+        * 
         * @return Project settings service
         */
        private ProjectSettingsService getProjectSettings() {
@@ -244,10 +278,11 @@ public class SearchStudyAction extends SearchBaseAction {
 
        /**
         * Set project settings service.
-        * @param projectSettingsService project settings service
+        * 
+        * @param projectSettingsService
+        *            project settings service
         */
-       public void setProjectSettings(
-                       ProjectSettingsService projectSettingsService) {
+       public void setProjectSettings(ProjectSettingsService projectSettingsService) {
                _projectSettingsService = projectSettingsService;
        }
 
@@ -273,6 +308,7 @@ public class SearchStudyAction extends SearchBaseAction {
 
        /**
         * Get the userService.
+        * 
         * @return the userService
         */
        public UserService getUserService() {
@@ -281,7 +317,9 @@ public class SearchStudyAction extends SearchBaseAction {
 
        /**
         * Set the userService.
-        * @param userService the userService to set
+        * 
+        * @param userService
+        *            the userService to set
         */
        public void setUserService(UserService userService) {
                _userService = userService;
index e0cb6c917dd90156c7b106edf7db4360f1146523..f862a1406f80b3a941d55fd15db26e88c1ee6c37 100644 (file)
@@ -3,100 +3,75 @@ package org.splat.simer.admin;
 import java.util.List;
 import java.util.Map;
 
-import org.hibernate.Session;
-import org.hibernate.Transaction;
 import org.splat.service.SearchService;
-import org.splat.service.SearchServiceImpl;
-import org.splat.service.StudyService;
 import org.splat.simer.Action;
-import org.splat.dal.dao.som.Database;
-import org.splat.dal.bo.som.Study;
-
 
+/**
+ * Action for updating lucene index.
+ *
+ * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
+ */
 public class DatabaseIndexingAction extends Action {
 
        /**
         * Serial version ID.
         */
-    private static final long serialVersionUID = 4194268823457749655L;
+       private static final long serialVersionUID = 4194268823457749655L;
 
-    private List<ImportedStudy> newstudies;
-    private String              indices;
-       private SearchService _searchService;
+       private List<ImportedStudy> newstudies;
+       private String indices;
        private ImportedStudy _importedStudy;
-       private StudyService _studyService;
-
-//  ==============================================================================================================================
-//  Action methods
-//  ==============================================================================================================================
-
-    public String doInitialize () {
-//  -----------------------------
-      Session      connex  = Database.getCurSession();
-      Transaction  transax = connex.beginTransaction();
-
-      newstudies = getImportedStudy().selectAll();
-      indices    = "";
-
-      transax.commit();
-      return SUCCESS;
-    }
-
-    public String doIndexing () {
-//  ---------------------------
-      Session             connex  = Database.getCurSession();
-      Transaction         transax = connex.beginTransaction();
-      String[]            ridlist = indices.split(",");
-      @SuppressWarnings("unchecked")
-      Map<String, Object> filter  = (Map<String, Object>)getSession().get("study.filter");
-
-      for (int i=0; i<ridlist.length; i++) {
-       int                 index = Integer.valueOf(ridlist[i].trim());
-       Study               study = getStudyService().selectStudy(index);
-        getSearchService().indexStudy(study);
-      }
-      filter.put("owner", "all");   // Just in case of 1st study search
-
-      transax.commit();
-      return SUCCESS;
-    }
-
-//  ==============================================================================================================================
-//  Getters and setters
-//  ==============================================================================================================================
-
-    public List<ImportedStudy> getNewStudies () {
-//  -------------------------------------------
-      return newstudies;
-    }
-    public String getIndices () {
-//  ---------------------------
-      return indices;
-    }
-
-    public void setIndices (String indices) {
-//  ---------------------------------------
-      this.indices = indices;
-    }
+       /**
+        * Injected search service.
+        */
+       private SearchService _searchService;
+
+       // ==============================================================================================================================
+       // Action methods
+       // ==============================================================================================================================
 
        /**
-        * Get the searchService.
-        * @return the searchService
+        * Initialize the action.
+        * @return SUCCESS
         */
-       public SearchService getSearchService() {
-               return _searchService;
+       public String doInitialize() {
+               newstudies = getImportedStudy().selectAll();
+               indices = "";
+               return SUCCESS;
        }
 
        /**
-        * Set the searchService.
-        * @param searchService the searchService to set
+        * Reindex studies.
+        * @return SUCCESS
         */
-       public void setSearchService(SearchService searchService) {
-               _searchService = searchService;
+       public String doIndexing() {
+               String[] ridlist = indices.split(",");
+               @SuppressWarnings("unchecked")
+               Map<String, Object> filter = (Map<String, Object>) getSession().get(
+                               "study.filter");
+               getSearchService().reindexStudies(ridlist);
+               filter.put("owner", "all"); // Just in case of 1st study search
+
+               return SUCCESS;
+       }
+
+       // ==============================================================================================================================
+       // Getters and setters
+       // ==============================================================================================================================
+
+       /**
+        * Get the new studies.
+        * 
+        * @return the new studies
+        */
+       public List<ImportedStudy> getNewStudies() {
+               // -------------------------------------------
+               return newstudies;
        }
 
        /**
         * Get the importedStudy.
+        * 
         * @return the importedStudy
         */
        public ImportedStudy getImportedStudy() {
@@ -105,28 +80,46 @@ public class DatabaseIndexingAction extends Action {
 
        /**
         * Set the importedStudy.
-        * @param importedStudy the importedStudy to set
+        * 
+        * @param importedStudy
+        *            the importedStudy to set
         */
        public void setImportedStudy(ImportedStudy importedStudy) {
                _importedStudy = importedStudy;
        }
 
        /**
-        * Get the studyService.
+        * Get the indices.
+        * @return the indices
+        */
+       public String getIndices() {
+               return indices;
+       }
+
+       /**
+        * Set the indices.
+        * @param indices the indices to set
+        */
+       public void setIndices(String indices) {
+               this.indices = indices;
+       }
+
+       /**
+        * Get the searchService.
         * 
-        * @return the studyService
+        * @return the searchService
         */
-       public StudyService getStudyService() {
-               return _studyService;
+       public SearchService getSearchService() {
+               return _searchService;
        }
 
        /**
-        * Set the studyService.
+        * Set the searchService.
         * 
-        * @param studyService
-        *            the studyService to set
+        * @param searchService
+        *            the searchService to set
         */
-       public void setStudyService(StudyService studyService) {
-               _studyService = studyService;
+       public void setSearchService(SearchService searchService) {
+               _searchService = searchService;
        }
 }
\ No newline at end of file
index 71782db2122dde67ee387b715c0ac43e9fcf154b..33a9369a91003067b8cea740cbf356586c2d12d6 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans  
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
@@ -16,7 +17,8 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <!-- configuration i18n -->
        <bean id="i18nUtils" class="org.splat.i18n.I18nUtils">
-               <property name="resourceBundleMessageSource" ref="messageSource" />
+               <property name="resourceBundleMessageSource"
+                       ref="messageSource" />
        </bean>
 
        <bean id="messageSource"
@@ -31,51 +33,57 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <!-- ref 'baseMessageSource' into Siman-common\src\spring\globalContext.xml -->
        <!-- property name="parentMessageSource" ref="baseMessageSource"/ -->
 
-       <bean id="applicationSettings" class="org.splat.simer.ApplicationSettings"
-               factory-method="getMe">
+       <bean id="applicationSettings"
+               class="org.splat.simer.ApplicationSettings" factory-method="getMe">
                <property name="projectSettings" ref="projectSettings" />
                <property name="documentTypeService" ref="documentTypeService" />
        </bean>
 
        <bean id="importedStudy" class="org.splat.simer.admin.ImportedStudy"
-               scope="prototype" />
+               scope="prototype">
+               <property name="searchService" ref="searchService" />
+       </bean>
 
        <bean id="slidMenu" scope="session" abstract="true">
-               <property name="projectElementService" ref="projectElementService" />
+               <property name="projectElementService"
+                       ref="projectElementService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
-       <bean id="studyMenu" class="org.splat.simer.StudyMenu" scope="session"
-               parent="slidMenu" />
+       <bean id="studyMenu" class="org.splat.simer.StudyMenu"
+               scope="session" parent="slidMenu" />
 
        <bean id="newScenarioMenu" class="org.splat.simer.NewScenarioMenu"
                scope="session" parent="slidMenu" />
 
-       <bean id="openObject" abstract="true" class="org.splat.simer.OpenObject"
-               scope="session">
-               <property name="projectElementService" ref="projectElementService" />
+       <bean id="openObject" abstract="true"
+               class="org.splat.simer.OpenObject" scope="session">
+               <property name="projectElementService"
+                       ref="projectElementService" />
                <property name="projectSettings" ref="projectSettings" />
-               <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
+               <property name="knowledgeElementTypeService"
+                       ref="knowledgeElementTypeService" />
        </bean>
 
-       <bean id="openStudy" class="org.splat.simer.OpenStudy" parent="openObject"
-               scope="session">
-               <property name="projectElementService" ref="projectElementService" />
+       <bean id="openStudy" class="org.splat.simer.OpenStudy"
+               parent="openObject" scope="session">
+               <property name="projectElementService"
+                       ref="projectElementService" />
                <property name="publicationService" ref="publicationService" />
                <property name="studyService" ref="studyService" />
                <property name="stepService" ref="stepService" />
                <property name="repositoryService" ref="repositoryService" />
                <property name="menu" ref="studyMenu" />
                <property name="documentTypeService" ref="documentTypeService" />
-        <property name="documentService" ref="documentService" />
+               <property name="documentService" ref="documentService" />
        </bean>
 
        <bean id="openKnowledge" class="org.splat.simer.OpenKnowledge"
                parent="openObject" scope="session">
        </bean>
 
-       <bean id="baseAction" class="org.splat.simer.Action" scope="prototype"
-               abstract="true">
+       <bean id="baseAction" class="org.splat.simer.Action"
+               scope="prototype" abstract="true">
                <property name="openStudy" ref="openStudy" />
                <property name="openKnowledge" ref="openKnowledge" />
        </bean>
@@ -84,20 +92,24 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
        <bean id="newStudyAction" class="org.splat.simer.NewStudyAction"
                parent="baseAction" scope="prototype">
-               <property name="simulationContextService" ref="simulationContextService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
                <property name="scenarioService" ref="scenarioService" />
                <property name="studyService" ref="studyService" />
        </bean>
 
-       <bean id="newScenarioAction" class="org.splat.simer.NewScenarioAction"
-               parent="baseAction" scope="prototype">
-               <property name="projectElementService" ref="projectElementService" />
+       <bean id="newScenarioAction"
+               class="org.splat.simer.NewScenarioAction" parent="baseAction"
+               scope="prototype">
+               <property name="projectElementService"
+                       ref="projectElementService" />
                <property name="scenarioService" ref="scenarioService" />
                <property name="menu" ref="newScenarioMenu" />
        </bean>
 
-       <bean id="importDocumentAction" class="org.splat.simer.ImportDocumentAction"
-               scope="prototype" parent="baseAction">
+       <bean id="importDocumentAction"
+               class="org.splat.simer.ImportDocumentAction" scope="prototype"
+               parent="baseAction">
                <property name="stepService" ref="stepService" />
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
@@ -105,52 +117,63 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="documentTypeService" ref="documentTypeService" />
        </bean>
 
-       <bean id="displayStudyStepAction" class="org.splat.simer.DisplayStudyStepAction"
-               parent="baseAction" scope="prototype">
+       <bean id="displayStudyStepAction"
+               class="org.splat.simer.DisplayStudyStepAction" parent="baseAction"
+               scope="prototype">
                <property name="studyService" ref="studyService" />
        </bean>
 
        <!--========= Inherited from displayStudyStepAction ========= -->
 
-       <bean id="studyPropertiesAction" class="org.splat.simer.StudyPropertiesAction"
-               scope="prototype" parent="displayStudyStepAction">
+       <bean id="studyPropertiesAction"
+               class="org.splat.simer.StudyPropertiesAction" scope="prototype"
+               parent="displayStudyStepAction">
                <property name="documentTypeService" ref="documentTypeService" />
-        <property name="userService" ref="userService" />
+               <property name="userService" ref="userService" />
        </bean>
 
        <bean id="editStudyAction" class="org.splat.simer.EditStudyAction"
                scope="prototype" parent="displayStudyStepAction">
        </bean>
 
-       <bean id="editScenarioPropertiesAction" class="org.splat.simer.EditScenarioPropertiesAction"
-               scope="prototype" parent="displayStudyStepAction">
-               <property name="projectElementService" ref="projectElementService" />
+       <bean id="editScenarioPropertiesAction"
+               class="org.splat.simer.EditScenarioPropertiesAction" scope="prototype"
+               parent="displayStudyStepAction">
+               <property name="projectElementService"
+                       ref="projectElementService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
-       <bean id="editSimulationContextAction" class="org.splat.simer.EditSimulationContextAction"
-               scope="prototype" parent="displayStudyStepAction">
+       <bean id="editSimulationContextAction"
+               class="org.splat.simer.EditSimulationContextAction" scope="prototype"
+               parent="displayStudyStepAction">
                <property name="stepService" ref="stepService" />
-               <property name="simulationContextService" ref="simulationContextService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
        </bean>
 
-       <bean id="editDocumentAction" class="org.splat.simer.EditDocumentAction"
-               scope="prototype" parent="displayStudyStepAction">
+       <bean id="editDocumentAction"
+               class="org.splat.simer.EditDocumentAction" scope="prototype"
+               parent="displayStudyStepAction">
                <property name="stepService" ref="stepService" />
                <property name="publicationService" ref="publicationService" />
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-       <bean id="editKnowledgeElementAction" class="org.splat.simer.EditKnowledgeElementAction"
-               scope="prototype" parent="displayStudyStepAction">
-               <property name="knowledgeElementService" ref="knowledgeElementService" />
-               <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
+       <bean id="editKnowledgeElementAction"
+               class="org.splat.simer.EditKnowledgeElementAction" scope="prototype"
+               parent="displayStudyStepAction">
+               <property name="knowledgeElementService"
+                       ref="knowledgeElementService" />
+               <property name="knowledgeElementTypeService"
+                       ref="knowledgeElementTypeService" />
                <property name="scenarioService" ref="scenarioService" />
        </bean>
 
        <!-- End of Inherited from displayStudyStepAction -->
 
-       <bean id="startAction" class="org.splat.simer.StartAction" scope="prototype">
+       <bean id="startAction" class="org.splat.simer.StartAction"
+               scope="prototype">
                <property name="applicationSettings" ref="applicationSettings" />
                <property name="projectSettings" ref="projectSettings" />
        </bean>
@@ -158,36 +181,41 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                scope="prototype">
        </bean>
 
-       <bean id="menuAction" class="org.splat.simer.MenuAction" scope="prototype">
+       <bean id="menuAction" class="org.splat.simer.MenuAction"
+               scope="prototype">
        </bean>
 
-       <bean id="notYetImplementedAction" class="org.splat.simer.NotYetImplementedAction"
-               scope="prototype">
+       <bean id="notYetImplementedAction"
+               class="org.splat.simer.NotYetImplementedAction" scope="prototype">
        </bean>
 
-       <bean id="searchStudyAction" class="org.splat.simer.SearchStudyAction"
-               scope="prototype">
+       <bean id="searchStudyAction"
+               class="org.splat.simer.SearchStudyAction" scope="prototype">
                <property name="projectSettings" ref="projectSettings" />
                <property name="searchService" ref="searchService" />
-               <property name="simulationContextService" ref="simulationContextService" />
-        <property name="userService" ref="userService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
+               <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="searchKnowledgeAction" class="org.splat.simer.SearchKnowledgeAction"
-               scope="prototype">
+       <bean id="searchKnowledgeAction"
+               class="org.splat.simer.SearchKnowledgeAction" scope="prototype">
                <property name="searchService" ref="searchService" />
-               <property name="simulationContextService" ref="simulationContextService" />
-               <property name="knowledgeElementTypeService" ref="knowledgeElementTypeService" />
-        <property name="userService" ref="userService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
+               <property name="knowledgeElementTypeService"
+                       ref="knowledgeElementTypeService" />
+               <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="searchDocumentAction" class="org.splat.simer.SearchDocumentAction"
-               scope="prototype">
+       <bean id="searchDocumentAction"
+               class="org.splat.simer.SearchDocumentAction" scope="prototype">
        </bean>
 
-       <bean id="displayKnowledgeAction" class="org.splat.simer.DisplayKnowledgeAction"
-               scope="prototype">
-               <property name="knowledgeElementService" ref="knowledgeElementService" />
+       <bean id="displayKnowledgeAction"
+               class="org.splat.simer.DisplayKnowledgeAction" scope="prototype">
+               <property name="knowledgeElementService"
+                       ref="knowledgeElementService" />
        </bean>
 
        <bean id="uploadAction" class="org.splat.simer.UploadAction"
@@ -195,47 +223,52 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd">
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-       <bean id="versionDocumentAction" class="org.splat.simer.VersionDocumentAction"
-               scope="prototype">
+       <bean id="versionDocumentAction"
+               class="org.splat.simer.VersionDocumentAction" scope="prototype">
                <property name="projectSettings" ref="projectSettings" />
                <property name="publicationService" ref="publicationService" />
                <property name="stepService" ref="stepService" />
                <property name="repositoryService" ref="repositoryService" />
        </bean>
 
-       <bean id="databaseIndexingAction" class="org.splat.simer.admin.DatabaseIndexingAction"
+       <bean id="databaseIndexingAction"
+               class="org.splat.simer.admin.DatabaseIndexingAction"
                scope="prototype">
-               <property name="studyService" ref="studyService" />
                <property name="importedStudy" ref="importedStudy" />
                <property name="searchService" ref="searchService" />
        </bean>
 
-       <bean id="importUserAction" class="org.splat.simer.admin.ImportUserAction"
-               scope="prototype">
+       <bean id="importUserAction"
+               class="org.splat.simer.admin.ImportUserAction" scope="prototype">
                <property name="repositoryService" ref="repositoryService" />
-        <property name="userService" ref="userService" />
+               <property name="userService" ref="userService" />
        </bean>
 
-       <bean id="simulationContextAction" class="org.splat.simer.admin.SimulationContextAction"
+       <bean id="simulationContextAction"
+               class="org.splat.simer.admin.SimulationContextAction"
                scope="prototype">
-               <property name="knowledgeElementService" ref="knowledgeElementService" />
+               <property name="knowledgeElementService"
+                       ref="knowledgeElementService" />
                <property name="searchService" ref="searchService" />
                <property name="projectSettings" ref="projectSettings" />
-               <property name="simulationContextService" ref="simulationContextService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
        </bean>
 
-       <bean id="knowledgeElementAction" class="org.splat.simer.admin.KnowledgeElementAction"
+       <bean id="knowledgeElementAction"
+               class="org.splat.simer.admin.KnowledgeElementAction"
                scope="prototype">
        </bean>
 
-       <bean id="saveDocumentAction" class="org.splat.module.SaveDocumentAction"
-               scope="prototype">
+       <bean id="saveDocumentAction"
+               class="org.splat.module.SaveDocumentAction" scope="prototype">
                <property name="documentTypeService" ref="documentTypeService" />
                <property name="publicationService" ref="publicationService" />
                <property name="repositoryService" ref="repositoryService" />
                <property name="scenarioService" ref="scenarioService" />
                <property name="stepService" ref="stepService" />
-               <property name="simulationContextService" ref="simulationContextService" />
+               <property name="simulationContextService"
+                       ref="simulationContextService" />
        </bean>
 
 </beans>