Search in sources :

Example 11 with OWLClassData

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

the class TermRelationshipsManager method getRelationships.

public OBOTermRelationships getRelationships(OWLClass term) {
    OWLClass cls = dataFactory.getOWLClass(term.getIRI());
    Set<OWLSubClassOfAxiom> subClassOfAxioms = rootOntology.getSubClassAxiomsForSubClass(cls);
    Set<OBORelationship> rels = new HashSet<>();
    for (OWLSubClassOfAxiom ax : subClassOfAxioms) {
        Set<OWLObjectSomeValuesFrom> relationships = new HashSet<>();
        Set<OWLClassExpression> conjuncts = ax.getSuperClass().asConjunctSet();
        for (OWLClassExpression conjunct : conjuncts) {
            if (conjunct instanceof OWLObjectSomeValuesFrom) {
                OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom) conjunct;
                if (!svf.getProperty().isAnonymous() && !svf.getFiller().isAnonymous()) {
                    relationships.add((OWLObjectSomeValuesFrom) conjunct);
                }
            }
        }
        if (relationships.size() == conjuncts.size()) {
            for (OWLObjectSomeValuesFrom rel : relationships) {
                OWLObjectPropertyData property = renderingManager.getRendering(rel.getProperty().asOWLObjectProperty());
                OWLClassData filler = renderingManager.getRendering(rel.getFiller().asOWLClass());
                OBORelationship oboRel = new OBORelationship(property, filler);
                rels.add(oboRel);
            }
        }
    }
    return new OBOTermRelationships(rels);
}
Also used : OWLObjectPropertyData(edu.stanford.bmir.protege.web.shared.entity.OWLObjectPropertyData) OBOTermRelationships(edu.stanford.bmir.protege.web.shared.obo.OBOTermRelationships) OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OBORelationship(edu.stanford.bmir.protege.web.shared.obo.OBORelationship) HashSet(java.util.HashSet)

Example 12 with OWLClassData

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

the class DataPropertyFrameTranslator method getFrame.

@Override
public DataPropertyFrame getFrame(OWLDataPropertyData subject) {
    Set<OWLAxiom> propertyValueAxioms = new HashSet<>();
    Set<OWLClassData> domains = new HashSet<>();
    Set<OWLDatatypeData> ranges = new HashSet<>();
    boolean functional = false;
    for (OWLOntology ontology : rootOntology.getImportsClosure()) {
        propertyValueAxioms.addAll(ontology.getAnnotationAssertionAxioms(subject.getEntity().getIRI()));
        for (OWLDataPropertyDomainAxiom ax : ontology.getDataPropertyDomainAxioms(subject.getEntity())) {
            if (!ax.getDomain().isAnonymous()) {
                domains.add(renderingManager.getRendering(ax.getDomain().asOWLClass()));
            }
        }
        for (OWLDataPropertyRangeAxiom ax : ontology.getDataPropertyRangeAxioms(subject.getEntity())) {
            if (ax.getRange().isDatatype()) {
                ranges.add(renderingManager.getRendering(ax.getRange().asOWLDatatype()));
            }
        }
        if (EntitySearcher.isFunctional(subject.getEntity(), ontology)) {
            functional = true;
        }
    }
    Set<PropertyValue> propertyValues = new HashSet<>();
    AxiomPropertyValueTranslator translator = new AxiomPropertyValueTranslator();
    for (OWLAxiom ax : propertyValueAxioms) {
        propertyValues.addAll(translator.getPropertyValues(subject.getEntity(), ax, rootOntology, State.ASSERTED, renderingManager));
    }
    PropertyValueList pvl = new PropertyValueList(propertyValues);
    return new DataPropertyFrame(subject, pvl, domains, ranges, functional);
}
Also used : OWLDatatypeData(edu.stanford.bmir.protege.web.shared.entity.OWLDatatypeData) OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OWLDataPropertyDomainAxiom(org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) OWLDataPropertyRangeAxiom(org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) HashSet(java.util.HashSet)

Example 13 with OWLClassData

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

the class DataPropertyFrameTranslator method getAxioms.

@Override
public Set<OWLAxiom> getAxioms(DataPropertyFrame 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().getOWLDataPropertyDomainAxiom(frame.getSubject().getEntity(), domain.getEntity());
        result.add(ax);
    }
    for (OWLDatatypeData range : frame.getRanges()) {
        OWLAxiom ax = DataFactory.get().getOWLDataPropertyRangeAxiom(frame.getSubject().getEntity(), range.getEntity());
        result.add(ax);
    }
    if (frame.isFunctional()) {
        result.add(DataFactory.get().getOWLFunctionalDataPropertyAxiom(frame.getSubject().getEntity()));
    }
    return result;
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OWLDatatypeData(edu.stanford.bmir.protege.web.shared.entity.OWLDatatypeData) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) HashSet(java.util.HashSet)

Example 14 with OWLClassData

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

the class ObjectPropertyFrameEditor method getValue.

@Override
public Optional<LabelledFrame<ObjectPropertyFrame>> getValue() {
    if (!previouslySetValue.isPresent()) {
        return previouslySetValue;
    }
    Set<PropertyAnnotationValue> annotationValueSet = new HashSet<PropertyAnnotationValue>();
    annotationValueSet.addAll(annotations.getValue().get().getAnnotationPropertyValues());
    final ObjectPropertyFrame previousFrame = previouslySetValue.get().getFrame();
    OWLObjectPropertyData subject = previousFrame.getSubject();
    List<OWLClassData> editedDomains = Lists.newArrayList();
    for (OWLPrimitiveData data : domains.getValue().get()) {
        editedDomains.add((OWLClassData) data);
    }
    List<OWLClassData> editedRanges = Lists.newArrayList();
    for (OWLPrimitiveData data : ranges.getValue().get()) {
        editedRanges.add((OWLClassData) data);
    }
    ObjectPropertyFrame frame = new ObjectPropertyFrame(subject, annotationValueSet, new HashSet<>(editedDomains), new HashSet<>(editedRanges), Collections.emptySet(), characteristics);
    return Optional.of(new LabelledFrame<>(previouslySetValue.get().getDisplayName(), frame));
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OWLObjectPropertyData(edu.stanford.bmir.protege.web.shared.entity.OWLObjectPropertyData) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)

Example 15 with OWLClassData

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

the class ClassFrameEditor method getValue.

@Override
public Optional<LabelledFrame<ClassFrame>> getValue() {
    if (currentSubject == null) {
        return Optional.empty();
    } else {
        Set<OWLClassData> classesData = new HashSet<>();
        for (OWLPrimitiveData cls : classes.getValue().get()) {
            classesData.add((OWLClassData) cls);
        }
        Set<PropertyValue> propertyValues = new TreeSet<>();
        propertyValues.addAll(annotations.getValue().get().getPropertyValues());
        propertyValues.addAll(properties.getValue().get().getPropertyValues());
        ClassFrame cf = new ClassFrame(currentSubject, classesData, propertyValues);
        LabelledFrame<ClassFrame> labelledClassFrame = new LabelledFrame<>(lastClassFrame.getDisplayName(), cf);
        return Optional.of(labelledClassFrame);
    }
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) OWLPrimitiveData(edu.stanford.bmir.protege.web.shared.entity.OWLPrimitiveData)

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