Search in sources :

Example 1 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc in project step by STEPBible.

the class TimelineServiceImpl method getTimelineEvent.

@Override
public EnhancedTimelineEvent getTimelineEvent(final String id, final String version) {
    final EntityDoc[] results = this.timelineEvents.searchExactTermBySingleField("id", 1, id);
    if (results.length == 0) {
        return null;
    }
    final EnhancedTimelineEvent ete = new EnhancedTimelineEvent(results[0]);
    final String references = ete.getEvent().get("storedReferences");
    final String[] refs = StringUtils.split(references);
    for (final String r : refs) {
    // final OsisWrapper osisText = this.jsword.peakOsisText(version, KEYED_REFERENCE_VERSION, r);
    // ete.add(osisText);
    }
    return ete;
}
Also used : EnhancedTimelineEvent(com.tyndalehouse.step.core.models.EnhancedTimelineEvent) EntityDoc(com.tyndalehouse.step.core.data.EntityDoc)

Example 2 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc in project step by STEPBible.

the class TimelineServiceImpl method getEventsFromScripture.

@Override
public TimelineEventsAndDate getEventsFromScripture(final String reference) {
    final TimelineEventsAndDate timelineEventsAndDate = new TimelineEventsAndDate();
    final EntityDoc[] matchingTimelineEvents = lookupEventsMatchingReference(reference);
    timelineEventsAndDate.setEvents(matchingTimelineEvents);
    timelineEventsAndDate.setDateTime(getDateForEvents(matchingTimelineEvents));
    return timelineEventsAndDate;
}
Also used : EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) TimelineEventsAndDate(com.tyndalehouse.step.core.data.entities.aggregations.TimelineEventsAndDate)

Example 3 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc in project step by STEPBible.

the class VocabularyServiceImpl method getDataFromLexiconDefinition.

/**
 * gets data from the matched lexicon definitions
 *
 * @param reference        the reference that anchors the strong number
 * @param vocabIdentifiers the identifiers
 * @param provider         the provider used to get data from it
 * @return the data in String form
 */
private String getDataFromLexiconDefinition(final String version, final String reference, final String vocabIdentifiers, final LexiconDataProvider provider) {
    // else we lookup and concatenate
    EntityDoc[] lds = getLexiconDefinitions(vocabIdentifiers, version, reference);
    if (lds.length == 0) {
        return vocabIdentifiers;
    } else if (lds.length == 1) {
        return provider.getData(lds[0]);
    }
    // otherwise, we need to resort to concatenating the fields
    final StringBuilder sb = new StringBuilder(lds.length * 32);
    sb.append('[');
    for (int ii = 0; ii < lds.length; ii++) {
        final EntityDoc l = lds[ii];
        sb.append(provider.getData(l));
        if (ii + 1 < lds.length) {
            sb.append(MULTI_WORD_SEPARATOR);
        }
    }
    sb.append(']');
    return sb.toString();
}
Also used : EntityDoc(com.tyndalehouse.step.core.data.EntityDoc)

Example 4 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc in project step by STEPBible.

the class LexiconDefinitionServiceImpl method lookup.

@Override
public Map<String, LexiconSuggestion> lookup(final Set<String> strongNumbers, final String userLanguage) {
    final Map<String, LexiconSuggestion> results = new HashMap<String, LexiconSuggestion>(strongNumbers.size() * 2);
    // exit early if no strong numbers
    if (strongNumbers.size() == 0) {
        return results;
    }
    final StringBuilder query = new StringBuilder(strongNumbers.size() * 7);
    for (final String strong : strongNumbers) {
        query.append(strong);
        query.append(' ');
    }
    final EntityDoc[] lexiconDefitions = this.definitions.searchSingleColumn("strongNumber", query.toString());
    for (final EntityDoc lexiconDefinition : lexiconDefitions) {
        final String strongNumber = lexiconDefinition.get("strongNumber");
        final LexiconSuggestion suggestion = getLexiconSuggestion(lexiconDefinition, strongNumber, userLanguage);
        results.put(strongNumber, suggestion);
    }
    return results;
}
Also used : LexiconSuggestion(com.tyndalehouse.step.core.models.LexiconSuggestion) HashMap(java.util.HashMap) EntityDoc(com.tyndalehouse.step.core.data.EntityDoc)

Example 5 with EntityDoc

use of com.tyndalehouse.step.core.data.EntityDoc in project step by STEPBible.

the class MorphologyServiceImpl method getMorphology.

@Override
public List<EntityDoc> getMorphology(final String code) {
    // split code into keys
    final String[] codes = split(code, SPACE_SEPARATOR);
    final List<EntityDoc> morphs = new ArrayList<EntityDoc>(codes.length);
    for (final String c : codes) {
        // check cache for key, otherwise obtain from database
        final EntityDoc item = retrieveMorphologyByLongName(c);
        if (item != null) {
            morphs.add(item);
        }
    }
    return morphs;
}
Also used : EntityDoc(com.tyndalehouse.step.core.data.EntityDoc) ArrayList(java.util.ArrayList)

Aggregations

EntityDoc (com.tyndalehouse.step.core.data.EntityDoc)39 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 StepInternalException (com.tyndalehouse.step.core.exceptions.StepInternalException)5 TranslatedException (com.tyndalehouse.step.core.exceptions.TranslatedException)5 LexiconSuggestion (com.tyndalehouse.step.core.models.LexiconSuggestion)5 ParseException (org.apache.lucene.queryParser.ParseException)5 SearchQuery (com.tyndalehouse.step.core.service.impl.SearchQuery)4 IOException (java.io.IOException)4 MultiFieldQueryParser (org.apache.lucene.queryParser.MultiFieldQueryParser)4 Query (org.apache.lucene.search.Query)4 BookAndBibleCount (com.tyndalehouse.step.core.models.search.BookAndBibleCount)3 SearchEntry (com.tyndalehouse.step.core.models.search.SearchEntry)3 SearchResult (com.tyndalehouse.step.core.models.search.SearchResult)3 QueryParser (org.apache.lucene.queryParser.QueryParser)3 Key (org.crosswire.jsword.passage.Key)3 ExpandableSubjectHeadingEntry (com.tyndalehouse.step.core.models.search.ExpandableSubjectHeadingEntry)2 LexicalSearchEntry (com.tyndalehouse.step.core.models.search.LexicalSearchEntry)2 SubjectHeadingSearchEntry (com.tyndalehouse.step.core.models.search.SubjectHeadingSearchEntry)2