use of edu.stanford.bmir.protege.web.server.renderer.RenderingManager in project webprotege by protegeproject.
the class ProjectChangesManager_IT method setUp.
@Before
public void setUp() throws Exception {
changeHistoryFile = temporaryFolder.newFile();
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLOntology rootOntology = manager.createOntology(IRI.create("http://stuff.com/ont"));
OWLDataFactory dataFactory = manager.getOWLDataFactory();
RevisionManager revisionManager = new RevisionManagerImpl(new RevisionStoreImpl(projectId, changeHistoryFile, dataFactory));
WebProtegeIRIShortFormProvider iriShortFormProvider = new WebProtegeIRIShortFormProvider(DefaultShortFormAnnotationPropertyIRIs.asImmutableList(), new HasAnnotationAssertionAxiomsImpl(rootOntology), () -> "", new LocalNameExtractor());
WebProtegeShortFormProvider webProtegeShortFormProvider = new WebProtegeShortFormProvider(iriShortFormProvider);
WebProtegeOntologyIRIShortFormProvider ontologyIRIShortFormProvider = new WebProtegeOntologyIRIShortFormProvider(rootOntology);
OWLEntityComparator entityComparator = new OWLEntityComparator(webProtegeShortFormProvider);
OWLClassExpressionSelector classExpressionSelector = new OWLClassExpressionSelector(entityComparator);
OWLObjectPropertyExpressionSelector objectPropertyExpressionSelector = new OWLObjectPropertyExpressionSelector(entityComparator);
OWLDataPropertyExpressionSelector dataPropertyExpressionSelector = new OWLDataPropertyExpressionSelector(entityComparator);
OWLIndividualSelector individualSelector = new OWLIndividualSelector(entityComparator);
SWRLAtomSelector atomSelector = new SWRLAtomSelector((o1, o2) -> 0);
EntitiesByRevisionCache entitiesByRevisionCache = new EntitiesByRevisionCache(new AxiomSubjectProvider(classExpressionSelector, objectPropertyExpressionSelector, dataPropertyExpressionSelector, individualSelector, atomSelector), rootOntology, dataFactory);
RenderingManager renderingManager = new RenderingManager(rootOntology, dataFactory, new EntityIRICheckerImpl(rootOntology), new DeprecatedEntityCheckerImpl(rootOntology), new WebProtegeBidirectionalShortFormProvider(projectId, rootOntology, webProtegeShortFormProvider), ontologyIRIShortFormProvider, new NullHighlightedEntityChecker());
AxiomComparatorImpl axiomComparator = new AxiomComparatorImpl(new AxiomBySubjectComparator(new AxiomSubjectProvider(classExpressionSelector, objectPropertyExpressionSelector, dataPropertyExpressionSelector, individualSelector, atomSelector), new OWLObjectComparatorImpl(renderingManager)), new AxiomByTypeComparator(DefaultAxiomTypeOrdering.get()), new AxiomByRenderingComparator(new OWLObjectRendererImpl(renderingManager)));
changesManager = new ProjectChangesManager(revisionManager, entitiesByRevisionCache, renderingManager, new ChangeRecordComparator(axiomComparator, (o1, o2) -> 0), ontologyIRIShortFormProvider);
createChanges(manager, rootOntology, dataFactory, revisionManager);
}
use of edu.stanford.bmir.protege.web.server.renderer.RenderingManager in project webprotege by protegeproject.
the class GetIndividualsActionHandler method execute.
@Nonnull
@Override
public GetIndividualsResult execute(@Nonnull GetIndividualsAction action, @Nonnull ExecutionContext executionContext) {
Stream<OWLNamedIndividual> stream;
if (action.getType().isOWLThing()) {
stream = rootOntology.getIndividualsInSignature(Imports.INCLUDED).stream();
} else {
stream = rootOntology.getImportsClosure().stream().flatMap(o -> o.getClassAssertionAxioms(action.getType()).stream()).map(OWLClassAssertionAxiom::getIndividual).filter(OWLIndividual::isNamed).map(OWLIndividual::asOWLNamedIndividual);
}
Counter counter = new Counter();
List<OWLNamedIndividualData> individualsData = stream.peek(i -> counter.increment()).map(renderingManager::getRendering).filter(i -> {
String searchString = action.getFilterString();
return searchString.isEmpty() || StringUtils.containsIgnoreCase(i.getBrowserText(), searchString);
}).distinct().sorted().collect(toList());
PageRequest pageRequest = action.getPageRequest();
Pager<OWLNamedIndividualData> pager = Pager.getPagerForPageSize(individualsData, pageRequest.getPageSize());
Page<OWLNamedIndividualData> page = pager.getPage(pageRequest.getPageNumber());
OWLClassData type = renderingManager.getRendering(action.getType());
logger.info(BROWSING, "{} {} retrieved instances of {} ({})", projectId, executionContext.getUserId(), action.getType(), renderingManager.getRendering(action.getType()).getBrowserText());
return new GetIndividualsResult(type, page, counter.getCount(), individualsData.size());
}
Aggregations