]> SALOME platform Git repositories - tools/siman.git/blobdiff - Workspace/Siman-Common/src/org/splat/service/SearchServiceImpl.java
Salome HOME
Modifications done to respect PMD rules. Versioning a document is fixed. Validation...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / service / SearchServiceImpl.java
index d58620a5368b5545a0375c534a8fd14fc84150f7..8fcb6693955ab7ea990f701b3157477ef43386cd 100644 (file)
@@ -39,11 +39,11 @@ 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.StudyDAO;
+import org.splat.service.dto.ImportedStudyDTO;
 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.splat.service.dto.ImportedStudyDTO;
 import org.splat.util.BeanHelper;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -57,7 +57,7 @@ public class SearchServiceImpl implements SearchService {
        /**
         * The service logger.
         */
-       public final static Logger logger = Logger
+       public final static Logger LOG = Logger
                        .getLogger(org.splat.service.SearchServiceImpl.class);
 
        /**
@@ -113,7 +113,7 @@ public class SearchServiceImpl implements SearchService {
         *            list of studies id's
         */
        @Transactional(readOnly = true)
-       public void reindexStudies(String[] ridlist) {
+       public void reindexStudies(final String[] ridlist) {
                for (int i = 0; i < ridlist.length; i++) {
                        long index = Long.valueOf(ridlist[i].trim());
                        Study study = getStudyService().selectStudy(index);
@@ -127,7 +127,7 @@ public class SearchServiceImpl implements SearchService {
         * @see org.splat.service.SearchService#selectKnowledgeElementsWhere(org.splat.dal.bo.som.KnowledgeElement.Properties[])
         */
        public List<Proxy> selectKnowledgeElementsWhere(
-                       KnowledgeElement.Properties... kprop) {
+                       final KnowledgeElement.Properties... kprop) {
                List<Proxy> result = new ArrayList<Proxy>();
                int hitsize = 20;
                try {
@@ -187,8 +187,9 @@ public class SearchServiceImpl implements SearchService {
                                        BooleanQuery critext = new BooleanQuery();
                                        String operator = "AND"; // Future user input
                                        BooleanClause.Occur clause = BooleanClause.Occur.MUST;
-                                       if (operator.equals("OR"))
+                                       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])),
@@ -212,8 +213,8 @@ public class SearchServiceImpl implements SearchService {
                                }
                                fulquery.add(query, BooleanClause.Occur.SHOULD);
                        }
-                       if (logger.isInfoEnabled()) {
-                               logger.info("Searching knowledges by Lucene query \""
+                       if (LOG.isInfoEnabled()) {
+                               LOG.info("Searching knowledges by Lucene query \""
                                                + fulquery.toString() + "\".");
                        }
                        // Creation of the knowledge filter
@@ -230,8 +231,9 @@ public class SearchServiceImpl implements SearchService {
                        TopFieldDocs found = searcher.search(fulquery, filter, hitsize,
                                        sort);
 
-                       if (found.totalHits < 1)
+                       if (found.totalHits < 1) {
                                return result; // No study found
+                       }
 
                        // Construction of the result list
                        ScoreDoc[] hits = found.scoreDocs;
@@ -241,7 +243,7 @@ public class SearchServiceImpl implements SearchService {
                        }
                        searcher.close();
                } catch (Exception error) {
-                       logger.error("Error during Lucene search, reason:", error);
+                       LOG.error("Error during Lucene search, reason:", error);
                }
                return result;
        }
@@ -251,7 +253,7 @@ public class SearchServiceImpl implements SearchService {
         * 
         * @see org.splat.service.SearchService#selectStudiesWhere(org.splat.dal.bo.som.Study.Properties[])
         */
-       public List<Proxy> selectStudiesWhere(Study.Properties... sprop) {
+       public List<Proxy> selectStudiesWhere(final Study.Properties... sprop) {
                List<Proxy> result = new ArrayList<Proxy>();
                int hitsize = 20;
                try {
@@ -317,8 +319,9 @@ public class SearchServiceImpl implements SearchService {
                                        BooleanQuery critext = new BooleanQuery();
                                        String operator = "AND"; // Future user input
                                        BooleanClause.Occur clause = BooleanClause.Occur.MUST;
-                                       if (operator.equals("OR"))
+                                       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])),
@@ -342,8 +345,8 @@ public class SearchServiceImpl implements SearchService {
                                }
                                fulquery.add(query, BooleanClause.Occur.SHOULD);
                        }
-                       if (logger.isInfoEnabled()) {
-                               logger.info("Searching studies by Lucene query \""
+                       if (LOG.isInfoEnabled()) {
+                               LOG.info("Searching studies by Lucene query \""
                                                + fulquery.toString() + "\".");
                        }
                        // Creation of the studies filter
@@ -360,8 +363,9 @@ public class SearchServiceImpl implements SearchService {
                        TopFieldDocs found = searcher.search(fulquery, filter, hitsize,
                                        sort);
 
-                       if (found.totalHits < 1)
+                       if (found.totalHits < 1) {
                                return result; // No study found
+                       }
 
                        // Construction of the result list
                        ScoreDoc[] hits = found.scoreDocs;
@@ -371,7 +375,7 @@ public class SearchServiceImpl implements SearchService {
                        }
                        searcher.close();
                } catch (Exception error) {
-                       logger.error("Error during Lucene search, reason:", error);
+                       LOG.error("Error during Lucene search, reason:", error);
                }
                return result;
        }
@@ -381,8 +385,8 @@ public class SearchServiceImpl implements SearchService {
         * 
         * @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="
+       public void indexStudy(final Study study) {
+               LOG.debug("Index study: id=" + study.getRid() + "; reference="
                                + study.getReference());
                try {
                        Study.Properties sprop = new Study.Properties();
@@ -390,29 +394,30 @@ public class SearchServiceImpl implements SearchService {
                                        .getReference()));
 
                        if (index.size() != 0) {
-                               logger.debug("The given study is already indexed.");
+                               LOG.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()
+                       LOG.debug("Number of study " + study.getReference()
                                        + " actors: " + study.getActor().size());
                        lucin.add(study);
-                       if (study.getProgressState() != ProgressState.inWORK)
+                       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="
+                                               LOG.debug("Knowlegge added: id="
                                                                + j.next().getIndex());
                                        }
                                }
+                       }
                } catch (Exception error) {
-                       logger.error("Unable to index the study '" + study.getIndex()
+                       LOG.error("Unable to index the study '" + study.getIndex()
                                        + "', reason:", error);
                }
        }
@@ -426,8 +431,9 @@ public class SearchServiceImpl implements SearchService {
         */
        private IndexService getIndex() throws IOException {
                IndexService lucin = getIndexService();
-               if (!lucin.exists())
+               if (!lucin.exists()) {
                        lucin.create(); // Happens when re-indexing all studies
+               }
                return lucin;
        }
 
@@ -446,7 +452,7 @@ public class SearchServiceImpl implements SearchService {
         * @param repositoryService
         *            the repositoryService to set
         */
-       public void setRepositoryService(RepositoryService repositoryService) {
+       public void setRepositoryService(final RepositoryService repositoryService) {
                _repositoryService = repositoryService;
        }
 
@@ -465,7 +471,7 @@ public class SearchServiceImpl implements SearchService {
         * @param indexService
         *            the indexService to set
         */
-       public void setIndexService(IndexService indexService) {
+       public void setIndexService(final IndexService indexService) {
                _indexService = indexService;
        }
 
@@ -484,7 +490,7 @@ public class SearchServiceImpl implements SearchService {
         * @param studyService
         *            the studyService to set
         */
-       public void setStudyService(StudyService studyService) {
+       public void setStudyService(final StudyService studyService) {
                _studyService = studyService;
        }
 
@@ -503,7 +509,7 @@ public class SearchServiceImpl implements SearchService {
         * @param studyDAO
         *            the studyDAO to set
         */
-       public void setStudyDAO(StudyDAO studyDAO) {
+       public void setStudyDAO(final StudyDAO studyDAO) {
                _studyDAO = studyDAO;
        }
 }