use of edu.stanford.bmir.protege.web.server.shortform.EscapingShortFormProvider in project webprotege by protegeproject.
the class GetManchesterSyntaxFrameActionHandler method execute.
@Nonnull
@Override
public GetManchesterSyntaxFrameResult execute(@Nonnull GetManchesterSyntaxFrameAction action, @Nonnull ExecutionContext executionContext) {
StringWriter writer = new StringWriter();
EscapingShortFormProvider entityShortFormProvider = new EscapingShortFormProvider(shortFormProvider);
final ManchesterOWLSyntaxFrameRenderer frameRenderer = new ManchesterOWLSyntaxFrameRenderer(importsClosure.getImportsClosure(), writer, entityShortFormProvider);
frameRenderer.setOntologyIRIShortFormProvider(ontologyIRIShortFormProvider);
frameRenderer.setRenderExtensions(true);
// frameRenderer.setRenderOntologyLists(true);
// frameRenderer.setUseTabbing(true);
// frameRenderer.setUseWrapping(true);
frameRenderer.writeFrame(action.getSubject());
// frameRenderer.writeRulesContainingPredicate(action.getSubject());
return new GetManchesterSyntaxFrameResult(writer.getBuffer().toString());
}
use of edu.stanford.bmir.protege.web.server.shortform.EscapingShortFormProvider 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