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);
}
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;
}
Aggregations