Search in sources :

Example 16 with OWLClassData

use of edu.stanford.bmir.protege.web.shared.entity.OWLClassData in project webprotege by protegeproject.

the class ClassFrame method toString.

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("ClassFrame");
    sb.append("(");
    sb.append(subject);
    sb.append(" Classes(");
    for (Iterator<OWLClassData> it = classEntries.iterator(); it.hasNext(); ) {
        OWLClassData entry = it.next();
        sb.append(entry);
        if (it.hasNext()) {
            sb.append(" ");
        }
    }
    sb.append(") ");
    sb.append("PropertyValues(");
    for (Iterator<PropertyValue> it = propertyValues.iterator(); it.hasNext(); ) {
        PropertyValue pv = it.next();
        sb.append(pv);
        if (it.hasNext()) {
            sb.append(" ");
        }
    }
    sb.append(")");
    sb.append(")");
    return sb.toString();
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData)

Example 17 with OWLClassData

use of edu.stanford.bmir.protege.web.shared.entity.OWLClassData in project webprotege by protegeproject.

the class ObjectPropertyFrameTranslator method getAxioms.

@Override
public Set<OWLAxiom> getAxioms(ObjectPropertyFrame frame, Mode mode) {
    Set<OWLAxiom> result = new HashSet<>();
    for (PropertyAnnotationValue pv : frame.getAnnotationPropertyValues()) {
        AxiomPropertyValueTranslator translator = new AxiomPropertyValueTranslator();
        result.addAll(translator.getAxioms(frame.getSubject().getEntity(), pv, mode));
    }
    for (OWLClassData domain : frame.getDomains()) {
        OWLAxiom ax = DataFactory.get().getOWLObjectPropertyDomainAxiom(frame.getSubject().getEntity(), domain.getEntity());
        result.add(ax);
    }
    for (OWLClassData range : frame.getRanges()) {
        OWLAxiom ax = DataFactory.get().getOWLObjectPropertyRangeAxiom(frame.getSubject().getEntity(), range.getEntity());
        result.add(ax);
    }
    for (ObjectPropertyCharacteristic characteristic : frame.getCharacteristics()) {
        OWLAxiom ax = characteristic.createAxiom(frame.getSubject().getEntity(), DataFactory.get());
        result.add(ax);
    }
    return result;
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) HashSet(java.util.HashSet)

Example 18 with OWLClassData

use of edu.stanford.bmir.protege.web.shared.entity.OWLClassData 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)

Example 19 with OWLClassData

use of edu.stanford.bmir.protege.web.shared.entity.OWLClassData in project webprotege by protegeproject.

the class TermCrossProductsManager method setCrossProduct.

public void setCrossProduct(@Nonnull UserId userId, @Nonnull OWLClass term, @Nonnull OBOTermCrossProduct crossProduct) {
    Set<OWLClassExpression> intersectionOperands = new HashSet<>();
    Optional<OWLClassData> genus = crossProduct.getGenus();
    if (genus.isPresent()) {
        OWLClass cls = genus.get().getEntity();
        intersectionOperands.add(cls);
    }
    for (OBORelationship relationship : crossProduct.getRelationships().getRelationships()) {
        OWLObjectSomeValuesFrom someValuesFrom = relationshipConverter.toSomeValuesFrom(relationship);
        intersectionOperands.add(someValuesFrom);
    }
    OWLObjectIntersectionOf intersectionOf = df.getOWLObjectIntersectionOf(intersectionOperands);
    OWLEquivalentClassesAxiom newXPAxiom = df.getOWLEquivalentClassesAxiom(term, intersectionOf);
    Optional<OWLEquivalentClassesAxiom> existingXPAxiom = getCrossProductEquivalentClassesAxiom(term);
    List<OWLOntologyChange> changes = new ArrayList<>();
    changes.add(new AddAxiom(rootOntology, newXPAxiom));
    existingXPAxiom.ifPresent(ax -> changes.add(new RemoveAxiom(rootOntology, ax)));
    changeManager.applyChanges(userId, new FixedChangeListGenerator<>(changes, term, "Set cross product values"));
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OBORelationship(edu.stanford.bmir.protege.web.shared.obo.OBORelationship)

Example 20 with OWLClassData

use of edu.stanford.bmir.protege.web.shared.entity.OWLClassData in project webprotege by protegeproject.

the class RelationshipConverter method toOboRelationship.

@Nonnull
public OBORelationship toOboRelationship(@Nonnull OWLObjectSomeValuesFrom someValuesFrom) {
    OWLObjectPropertyData property = renderingManager.getRendering(someValuesFrom.getProperty().asOWLObjectProperty());
    OWLClassData filler = renderingManager.getRendering(someValuesFrom.getFiller().asOWLClass());
    return new OBORelationship(property, filler);
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OBORelationship(edu.stanford.bmir.protege.web.shared.obo.OBORelationship) OWLObjectPropertyData(edu.stanford.bmir.protege.web.shared.entity.OWLObjectPropertyData) Nonnull(javax.annotation.Nonnull)

Aggregations

OWLClassData (edu.stanford.bmir.protege.web.shared.entity.OWLClassData)20 HashSet (java.util.HashSet)6 OWLPrimitiveData (edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)5 OBORelationship (edu.stanford.bmir.protege.web.shared.obo.OBORelationship)5 Nonnull (javax.annotation.Nonnull)4 OWLDatatypeData (edu.stanford.bmir.protege.web.shared.entity.OWLDatatypeData)3 OWLNamedIndividualData (edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData)3 OWLObjectPropertyData (edu.stanford.bmir.protege.web.shared.entity.OWLObjectPropertyData)3 OBOTermRelationships (edu.stanford.bmir.protege.web.shared.obo.OBOTermRelationships)3 PropertyValue (edu.stanford.bmir.protege.web.shared.frame.PropertyValue)2 PropertyValueList (edu.stanford.bmir.protege.web.shared.frame.PropertyValueList)2 OBOTermCrossProduct (edu.stanford.bmir.protege.web.shared.obo.OBOTermCrossProduct)2 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)2 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)2 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)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