Search in sources :

Example 1 with TimelineEventSearchEntry

use of com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry in project step by STEPBible.

the class SearchServiceImpl method buildTimelineSearchResults.

/**
 * Construct the relevant entity structure to represent timeline search results
 *
 * @param sq     the search query
 * @param events the list of events retrieved
 * @return the search results
 */
private SearchResult buildTimelineSearchResults(final SearchQuery sq, final EntityDoc[] events) {
    final List<SearchEntry> results = new ArrayList<SearchEntry>();
    final SearchResult r = new SearchResult();
    r.setResults(results);
    for (final EntityDoc e : events) {
        final String refs = e.get("storedReferences");
        final String[] references = StringUtils.split(refs);
        final List<VerseSearchEntry> verses = new ArrayList<VerseSearchEntry>();
        // TODO FIXME: REFACTOR to only make 1 jsword call?
        for (final String ref : references) {
            // TODO: REFACTOR only supports one version lookup
            final VerseSearchEntry verseEntry = new VerseSearchEntry();
            verses.add(verseEntry);
        }
        final TimelineEventSearchEntry entry = new TimelineEventSearchEntry();
        entry.setId(e.get("id"));
        entry.setDescription(e.get("name"));
        entry.setVerses(verses);
        results.add(entry);
    }
    return r;
}
Also used : TimelineEventSearchEntry(com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry) ArrayList(java.util.ArrayList) EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchResult(com.tyndalehouse.step.core.models.search.SearchResult) KeyedSearchResultSearchEntry(com.tyndalehouse.step.core.models.search.KeyedSearchResultSearchEntry) TimelineEventSearchEntry(com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry) VerseSearchEntry(com.tyndalehouse.step.core.models.search.VerseSearchEntry) SearchEntry(com.tyndalehouse.step.core.models.search.SearchEntry) LexicalSearchEntry(com.tyndalehouse.step.core.models.search.LexicalSearchEntry)

Aggregations

EntityDoc (com.tyndalehouse.step.core.data.EntityDoc)1 KeyedSearchResultSearchEntry (com.tyndalehouse.step.core.models.search.KeyedSearchResultSearchEntry)1 LexicalSearchEntry (com.tyndalehouse.step.core.models.search.LexicalSearchEntry)1 SearchEntry (com.tyndalehouse.step.core.models.search.SearchEntry)1 SearchResult (com.tyndalehouse.step.core.models.search.SearchResult)1 TimelineEventSearchEntry (com.tyndalehouse.step.core.models.search.TimelineEventSearchEntry)1 VerseSearchEntry (com.tyndalehouse.step.core.models.search.VerseSearchEntry)1 ArrayList (java.util.ArrayList)1