Search in sources :

Example 1 with EntityLookupResult

use of edu.stanford.bmir.protege.web.shared.entity.EntityLookupResult in project webprotege by protegeproject.

the class LookupEntitiesActionResultCachingStrategy method getInvalidationKeys.

@Override
public Collection<OWLEntity> getInvalidationKeys(LookupEntitiesAction action, LookupEntitiesResult result) {
    List<OWLEntity> entities = new ArrayList<OWLEntity>();
    for (EntityLookupResult res : result.getEntityLookupResults()) {
        OWLEntity entity = res.getOWLEntityData().getEntity();
        entities.add(entity);
    }
    return entities;
}
Also used : OWLEntity(org.semanticweb.owlapi.model.OWLEntity) ArrayList(java.util.ArrayList) EntityLookupResult(edu.stanford.bmir.protege.web.shared.entity.EntityLookupResult)

Example 2 with EntityLookupResult

use of edu.stanford.bmir.protege.web.shared.entity.EntityLookupResult in project webprotege by protegeproject.

the class CommentAutoCompleter method handleAttemptAtEntityCompletions.

private void handleAttemptAtEntityCompletions(String queryUpToCaret, EditorPosition caretPos, AutoCompletionCallback callback) {
    // Last index of space or 0 if there are not spaces
    int wordStart = queryUpToCaret.lastIndexOf(" ") + 1;
    int wordFragmentLen = queryUpToCaret.length() - wordStart;
    String wordFragment = queryUpToCaret.substring(wordStart);
    if (wordFragment.isEmpty()) {
        callback.completionsReady(new AutoCompletionResult());
        return;
    }
    dispatchServiceManager.execute(new LookupEntitiesAction(projectId, lookUpEntities(wordFragment)), result -> {
        List<AutoCompletionChoice> choices = new ArrayList<>();
        EditorPosition pos = new EditorPosition(caretPos.getLineNumber(), caretPos.getColumnNumber() - wordFragmentLen);
        for (final EntityLookupResult entity : result.getEntityLookupResults()) {
            choices.add(new AutoCompletionChoice(formatReplacementTest(entity), entity.getOWLEntityData().getBrowserText(), "", pos, caretPos));
        }
        AutoCompletionResult autoCompletionResult = new AutoCompletionResult(choices, pos);
        callback.completionsReady(autoCompletionResult);
    });
}
Also used : EditorPosition(edu.stanford.bmir.gwtcodemirror.client.EditorPosition) LookupEntitiesAction(edu.stanford.bmir.protege.web.shared.entity.LookupEntitiesAction) ArrayList(java.util.ArrayList) AutoCompletionResult(edu.stanford.bmir.gwtcodemirror.client.AutoCompletionResult) EntityLookupResult(edu.stanford.bmir.protege.web.shared.entity.EntityLookupResult) AutoCompletionChoice(edu.stanford.bmir.gwtcodemirror.client.AutoCompletionChoice)

Aggregations

EntityLookupResult (edu.stanford.bmir.protege.web.shared.entity.EntityLookupResult)2 ArrayList (java.util.ArrayList)2 AutoCompletionChoice (edu.stanford.bmir.gwtcodemirror.client.AutoCompletionChoice)1 AutoCompletionResult (edu.stanford.bmir.gwtcodemirror.client.AutoCompletionResult)1 EditorPosition (edu.stanford.bmir.gwtcodemirror.client.EditorPosition)1 LookupEntitiesAction (edu.stanford.bmir.protege.web.shared.entity.LookupEntitiesAction)1 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)1