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;
/**
* The service logger.
*/
- public final static Logger logger = Logger
+ public final static Logger LOG = Logger
.getLogger(org.splat.service.SearchServiceImpl.class);
/**
* 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);
* @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 {
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])),
}
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
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;
}
searcher.close();
} catch (Exception error) {
- logger.error("Error during Lucene search, reason:", error);
+ LOG.error("Error during Lucene search, reason:", error);
}
return result;
}
*
* @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 {
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])),
}
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
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;
}
searcher.close();
} catch (Exception error) {
- logger.error("Error during Lucene search, reason:", error);
+ LOG.error("Error during Lucene search, reason:", error);
}
return result;
}
*
* @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();
.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);
}
}
*/
private IndexService getIndex() throws IOException {
IndexService lucin = getIndexService();
- if (!lucin.exists())
+ if (!lucin.exists()) {
lucin.create(); // Happens when re-indexing all studies
+ }
return lucin;
}
* @param repositoryService
* the repositoryService to set
*/
- public void setRepositoryService(RepositoryService repositoryService) {
+ public void setRepositoryService(final RepositoryService repositoryService) {
_repositoryService = repositoryService;
}
* @param indexService
* the indexService to set
*/
- public void setIndexService(IndexService indexService) {
+ public void setIndexService(final IndexService indexService) {
_indexService = indexService;
}
* @param studyService
* the studyService to set
*/
- public void setStudyService(StudyService studyService) {
+ public void setStudyService(final StudyService studyService) {
_studyService = studyService;
}
* @param studyDAO
* the studyDAO to set
*/
- public void setStudyDAO(StudyDAO studyDAO) {
+ public void setStudyDAO(final StudyDAO studyDAO) {
_studyDAO = studyDAO;
}
}