use of gov.nih.nci.ctd2.dashboard.impl.SubmissionImpl in project nci-ctd2-dashboard by CBIIT.
the class DashboardDaoImpl method searchSingleTerm.
private void searchSingleTerm(final String singleTerm, final Map<Subject, Integer> subjects, final Map<Submission, Integer> submissions) {
FullTextSession fullTextSession = Search.getFullTextSession(getSession());
MultiFieldQueryParser multiFieldQueryParser = new MultiFieldQueryParser(defaultSearchFields, new KeywordAnalyzer());
Query luceneQuery = null;
try {
luceneQuery = multiFieldQueryParser.parse(singleTerm);
log.debug(luceneQuery);
} catch (ParseException e) {
e.printStackTrace();
return;
}
FullTextQuery fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery, searchableClasses);
fullTextQuery.setReadOnly(true);
List<?> list = fullTextQuery.list();
fullTextSession.close();
Integer numberOfSearchResults = getMaxNumberOfSearchResults();
if (numberOfSearchResults > 0 && list.size() > numberOfSearchResults) {
// if lte 0, the maximum number is ignored
log.warn("search result number " + list.size() + " is larger than the maximum expected, " + numberOfSearchResults);
}
for (Object o : list) {
if (o instanceof ObservationTemplate) {
List<Submission> submissionList = queryWithClass("select o from SubmissionImpl as o where o.observationTemplate = :ot", "ot", (ObservationTemplate) o);
for (Submission submission : submissionList) {
if (submissions.containsKey(submission)) {
submissions.put(submission, submissions.get(submission) + 1);
} else {
submissions.put(submission, 1);
}
}
} else if (o instanceof Subject) {
Subject s = (Subject) o;
if (subjects.containsKey(s)) {
subjects.put(s, subjects.get(s) + 1);
} else {
subjects.put(s, 1);
}
} else {
log.warn("unexpected type returned by searching: " + o.getClass().getName());
}
}
}
Aggregations