Search in sources :

Example 1 with RenderingManager

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);
}
Also used : EntityIRICheckerImpl(edu.stanford.bmir.protege.web.server.mansyntax.render.EntityIRICheckerImpl) OWLObjectRendererImpl(edu.stanford.bmir.protege.web.server.renderer.OWLObjectRendererImpl) ChangeRecordComparator(edu.stanford.bmir.protege.web.server.change.ChangeRecordComparator) OWLObjectComparatorImpl(edu.stanford.bmir.protege.web.server.object.OWLObjectComparatorImpl) OWLEntityComparator(org.semanticweb.owlapi.util.OWLEntityComparator) DeprecatedEntityCheckerImpl(edu.stanford.bmir.protege.web.server.mansyntax.render.DeprecatedEntityCheckerImpl) HasAnnotationAssertionAxiomsImpl(edu.stanford.bmir.protege.web.server.owlapi.HasAnnotationAssertionAxiomsImpl) RenderingManager(edu.stanford.bmir.protege.web.server.renderer.RenderingManager) NullHighlightedEntityChecker(edu.stanford.bmir.protege.web.server.mansyntax.render.NullHighlightedEntityChecker) Before(org.junit.Before)

Example 2 with RenderingManager

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());
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) RootOntology(edu.stanford.bmir.protege.web.server.inject.project.RootOntology) LoggerFactory(org.slf4j.LoggerFactory) OWLNamedIndividualData(edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData) Inject(javax.inject.Inject) PageRequest(edu.stanford.bmir.protege.web.shared.pagination.PageRequest) RenderingManager(edu.stanford.bmir.protege.web.server.renderer.RenderingManager) OWLIndividual(org.semanticweb.owlapi.model.OWLIndividual) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) AccessManager(edu.stanford.bmir.protege.web.server.access.AccessManager) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Page(edu.stanford.bmir.protege.web.shared.pagination.Page) Imports(org.semanticweb.owlapi.model.parameters.Imports) Logger(org.slf4j.Logger) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) OWLClassAssertionAxiom(org.semanticweb.owlapi.model.OWLClassAssertionAxiom) VIEW_PROJECT(edu.stanford.bmir.protege.web.shared.access.BuiltInAction.VIEW_PROJECT) BuiltInAction(edu.stanford.bmir.protege.web.shared.access.BuiltInAction) Pager(edu.stanford.bmir.protege.web.server.pagination.Pager) GetIndividualsResult(edu.stanford.bmir.protege.web.shared.individualslist.GetIndividualsResult) AbstractProjectActionHandler(edu.stanford.bmir.protege.web.server.dispatch.AbstractProjectActionHandler) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) ExecutionContext(edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext) OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) GetIndividualsAction(edu.stanford.bmir.protege.web.shared.individualslist.GetIndividualsAction) ProjectId(edu.stanford.bmir.protege.web.shared.project.ProjectId) BROWSING(edu.stanford.bmir.protege.web.server.logging.Markers.BROWSING) OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) PageRequest(edu.stanford.bmir.protege.web.shared.pagination.PageRequest) GetIndividualsResult(edu.stanford.bmir.protege.web.shared.individualslist.GetIndividualsResult) OWLNamedIndividual(org.semanticweb.owlapi.model.OWLNamedIndividual) OWLNamedIndividualData(edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData) OWLIndividual(org.semanticweb.owlapi.model.OWLIndividual) Nonnull(javax.annotation.Nonnull)

Aggregations

RenderingManager (edu.stanford.bmir.protege.web.server.renderer.RenderingManager)2 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)1 ChangeRecordComparator (edu.stanford.bmir.protege.web.server.change.ChangeRecordComparator)1 AbstractProjectActionHandler (edu.stanford.bmir.protege.web.server.dispatch.AbstractProjectActionHandler)1 ExecutionContext (edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext)1 RootOntology (edu.stanford.bmir.protege.web.server.inject.project.RootOntology)1 BROWSING (edu.stanford.bmir.protege.web.server.logging.Markers.BROWSING)1 DeprecatedEntityCheckerImpl (edu.stanford.bmir.protege.web.server.mansyntax.render.DeprecatedEntityCheckerImpl)1 EntityIRICheckerImpl (edu.stanford.bmir.protege.web.server.mansyntax.render.EntityIRICheckerImpl)1 NullHighlightedEntityChecker (edu.stanford.bmir.protege.web.server.mansyntax.render.NullHighlightedEntityChecker)1 OWLObjectComparatorImpl (edu.stanford.bmir.protege.web.server.object.OWLObjectComparatorImpl)1 HasAnnotationAssertionAxiomsImpl (edu.stanford.bmir.protege.web.server.owlapi.HasAnnotationAssertionAxiomsImpl)1 Pager (edu.stanford.bmir.protege.web.server.pagination.Pager)1 OWLObjectRendererImpl (edu.stanford.bmir.protege.web.server.renderer.OWLObjectRendererImpl)1 BuiltInAction (edu.stanford.bmir.protege.web.shared.access.BuiltInAction)1 VIEW_PROJECT (edu.stanford.bmir.protege.web.shared.access.BuiltInAction.VIEW_PROJECT)1 OWLClassData (edu.stanford.bmir.protege.web.shared.entity.OWLClassData)1 OWLNamedIndividualData (edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData)1 GetIndividualsAction (edu.stanford.bmir.protege.web.shared.individualslist.GetIndividualsAction)1 GetIndividualsResult (edu.stanford.bmir.protege.web.shared.individualslist.GetIndividualsResult)1