Search in sources :

Example 6 with EntityType

use of org.semanticweb.owlapi.model.EntityType in project webprotege by protegeproject.

the class PrimitiveDataParserImpl method parsePrimitiveDataFromTrimmedContent.

private void parsePrimitiveDataFromTrimmedContent(final String trimmedContent, final java.util.Optional<String> lang, Set<PrimitiveType> allowedTypes, final PrimitiveDataParserCallback callback) {
    if (trimmedContent.isEmpty()) {
        callback.onSuccess(java.util.Optional.empty());
        return;
    }
    if (lang.isPresent()) {
        if (allowedTypes.contains(PrimitiveType.LITERAL)) {
            OWLLiteralData literalData = parseLiteralData(trimmedContent, lang);
            callback.onSuccess(java.util.Optional.of(literalData));
        } else {
            // TODO: Literal not expected
            callback.parsingFailure();
        }
        return;
    }
    Set<EntityType<?>> allowedEntityTypes = Sets.newHashSet();
    for (PrimitiveType primitiveType : allowedTypes) {
        if (primitiveType.isEntityType()) {
            allowedEntityTypes.add(primitiveType.getEntityType());
        }
    }
    parseEntityDataIRIOrLiteral(trimmedContent, lang, allowedEntityTypes, allowedTypes, callback);
}
Also used : EntityType(org.semanticweb.owlapi.model.EntityType) OWLLiteralData(edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData) PrimitiveType(edu.stanford.bmir.protege.web.shared.PrimitiveType)

Example 7 with EntityType

use of org.semanticweb.owlapi.model.EntityType in project webprotege by protegeproject.

the class GetManchesterSyntaxFrameCompletionsActionHandler method getEntityAutocompletionChoices.

private List<AutoCompletionChoice> getEntityAutocompletionChoices(GetManchesterSyntaxFrameCompletionsAction action, ParserException e, EditorPosition fromPos, EditorPosition toPos, String lastWordPrefix) {
    List<AutoCompletionMatch> matches = Lists.newArrayList();
    Set<EntityType<?>> expectedEntityTypes = Sets.newHashSet(ManchesterSyntaxFrameParser.getExpectedEntityTypes(e));
    if (!expectedEntityTypes.isEmpty()) {
        BidirectionalShortFormProvider shortFormProvider = renderingManager.getShortFormProvider();
        for (String shortForm : shortFormProvider.getShortForms()) {
            EntityNameMatcher entityNameMatcher = new EntityNameMatcher(lastWordPrefix);
            Optional<EntityNameMatchResult> match = entityNameMatcher.findIn(shortForm);
            if (match.isPresent()) {
                Set<OWLEntity> entities = shortFormProvider.getEntities(shortForm);
                for (OWLEntity entity : entities) {
                    if (expectedEntityTypes.contains(entity.getEntityType())) {
                        EscapingShortFormProvider escapingShortFormProvider = new EscapingShortFormProvider(shortFormProvider);
                        AutoCompletionChoice choice = new AutoCompletionChoice(escapingShortFormProvider.getShortForm(entity), shortForm, "", fromPos, toPos);
                        AutoCompletionMatch autoCompletionMatch = new AutoCompletionMatch(match.get(), choice);
                        matches.add(autoCompletionMatch);
                    }
                }
            }
        }
    }
    Collections.sort(matches);
    List<AutoCompletionChoice> result = Lists.newArrayList();
    for (AutoCompletionMatch match : matches) {
        result.add(match.getAutoCompletionChoice());
        if (result.size() == action.getEntityTypeSuggestLimit()) {
            break;
        }
    }
    return result;
}
Also used : EscapingShortFormProvider(edu.stanford.bmir.protege.web.server.shortform.EscapingShortFormProvider) EntityNameMatcher(edu.stanford.bmir.protege.web.shared.search.EntityNameMatcher) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) AutoCompletionChoice(edu.stanford.bmir.gwtcodemirror.client.AutoCompletionChoice) EntityType(org.semanticweb.owlapi.model.EntityType) BidirectionalShortFormProvider(org.semanticweb.owlapi.util.BidirectionalShortFormProvider) EntityNameMatchResult(edu.stanford.bmir.protege.web.shared.search.EntityNameMatchResult)

Aggregations

EntityType (org.semanticweb.owlapi.model.EntityType)7 HashSet (java.util.HashSet)3 EntityLookupRequest (edu.stanford.bmir.protege.web.shared.entity.EntityLookupRequest)2 Test (org.junit.Test)2 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)2 UiHandler (com.google.gwt.uibinder.client.UiHandler)1 AutoCompletionChoice (edu.stanford.bmir.gwtcodemirror.client.AutoCompletionChoice)1 EscapingShortFormProvider (edu.stanford.bmir.protege.web.server.shortform.EscapingShortFormProvider)1 PrimitiveType (edu.stanford.bmir.protege.web.shared.PrimitiveType)1 AxiomTypeGroup (edu.stanford.bmir.protege.web.shared.axiom.AxiomTypeGroup)1 ColumnType (edu.stanford.bmir.protege.web.shared.csv.ColumnType)1 OWLLiteralData (edu.stanford.bmir.protege.web.shared.entity.OWLLiteralData)1 OWLPrimitiveData (edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)1 FilterId (edu.stanford.bmir.protege.web.shared.filter.FilterId)1 Page (edu.stanford.bmir.protege.web.shared.pagination.Page)1 PageRequest (edu.stanford.bmir.protege.web.shared.pagination.PageRequest)1 EntityNameMatchResult (edu.stanford.bmir.protege.web.shared.search.EntityNameMatchResult)1 EntityNameMatcher (edu.stanford.bmir.protege.web.shared.search.EntityNameMatcher)1 EntitySearchResult (edu.stanford.bmir.protege.web.shared.search.EntitySearchResult)1 PerformEntitySearchResult (edu.stanford.bmir.protege.web.shared.search.PerformEntitySearchResult)1