Search in sources :

Example 1 with PropertyValue

use of edu.stanford.bmir.protege.web.shared.frame.PropertyValue in project webprotege by protegeproject.

the class NamedIndividualFrameTranslator method translateToAxioms.

private Set<OWLAxiom> translateToAxioms(OWLNamedIndividual subject, NamedIndividualFrame frame, Mode mode) {
    Set<OWLAxiom> result = new HashSet<>();
    for (OWLClassData cls : frame.getClasses()) {
        result.add(DataFactory.get().getOWLClassAssertionAxiom(cls.getEntity(), subject));
    }
    for (PropertyValue propertyValue : frame.getPropertyValues()) {
        AxiomPropertyValueTranslator translator = new AxiomPropertyValueTranslator();
        result.addAll(translator.getAxioms(subject, propertyValue, mode));
    }
    for (OWLNamedIndividualData individual : frame.getSameIndividuals()) {
        result.add(DataFactory.get().getOWLSameIndividualAxiom(subject, individual.getEntity()));
    }
    return result;
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) PropertyValue(edu.stanford.bmir.protege.web.shared.frame.PropertyValue) OWLNamedIndividualData(edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData) HashSet(java.util.HashSet)

Example 2 with PropertyValue

use of edu.stanford.bmir.protege.web.shared.frame.PropertyValue in project webprotege by protegeproject.

the class PropertyValueListEditor method getValue.

@Override
public Optional<PropertyValueList> getValue() {
    Optional<List<PropertyValueDescriptor>> value = editor.getValue();
    if (!value.isPresent()) {
        return Optional.empty();
    }
    List<PropertyValue> propertyValues = Lists.newArrayList();
    for (PropertyValueDescriptor val : value.get()) {
        java.util.Optional<PropertyValue> propertyValue = val.toPropertyValue();
        if (propertyValue.isPresent()) {
            propertyValues.add(propertyValue.get());
        }
    }
    return Optional.of(new PropertyValueList(propertyValues));
}
Also used : PropertyValueDescriptor(edu.stanford.bmir.protege.web.shared.frame.PropertyValueDescriptor) PropertyValue(edu.stanford.bmir.protege.web.shared.frame.PropertyValue) List(java.util.List) PropertyValueList(edu.stanford.bmir.protege.web.shared.frame.PropertyValueList) PropertyValueList(edu.stanford.bmir.protege.web.shared.frame.PropertyValueList)

Example 3 with PropertyValue

use of edu.stanford.bmir.protege.web.shared.frame.PropertyValue in project webprotege by protegeproject.

the class ClassFrameTranslator method translateToAxioms.

private Set<OWLAxiom> translateToAxioms(OWLClassData subject, ClassFrame classFrame, Mode mode) {
    Set<OWLAxiom> result = new HashSet<>();
    for (OWLClassData cls : classFrame.getClassEntries()) {
        result.add(DataFactory.get().getOWLSubClassOfAxiom(subject.getEntity(), cls.getEntity()));
    }
    for (PropertyValue propertyValue : classFrame.getPropertyValues()) {
        AxiomPropertyValueTranslator translator = new AxiomPropertyValueTranslator();
        result.addAll(translator.getAxioms(subject.getEntity(), propertyValue, mode));
    }
    return result;
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) PropertyValue(edu.stanford.bmir.protege.web.shared.frame.PropertyValue) HashSet(java.util.HashSet)

Example 4 with PropertyValue

use of edu.stanford.bmir.protege.web.shared.frame.PropertyValue in project webprotege by protegeproject.

the class NamedIndividualFrameTranslator method translateToNamedIndividualFrame.

private NamedIndividualFrame translateToNamedIndividualFrame(OWLNamedIndividualData subject) {
    Set<OWLAxiom> relevantAxioms = getRelevantAxioms(subject.getEntity());
    NamedIndividualFrame.Builder builder = new NamedIndividualFrame.Builder(subject);
    for (OWLAxiom axiom : relevantAxioms) {
        if (axiom instanceof OWLClassAssertionAxiom) {
            OWLClassAssertionAxiom ax = (OWLClassAssertionAxiom) axiom;
            if (ax.getIndividual().equals(subject.getEntity()) && !ax.getClassExpression().isAnonymous()) {
                builder.addClass(rm.getRendering(ax.getClassExpression().asOWLClass()));
            }
        }
    }
    List<PropertyValue> propertyValues = new ArrayList<>();
    for (OWLAxiom axiom : relevantAxioms) {
        AxiomPropertyValueTranslator translator = new AxiomPropertyValueTranslator();
        propertyValues.addAll(translator.getPropertyValues(subject.getEntity(), axiom, rootOntology, State.ASSERTED, rm));
    }
    for (OWLOntology ont : rootOntology.getImportsClosure()) {
        for (OWLClassAssertionAxiom ax : ont.getClassAssertionAxioms(subject.getEntity())) {
            if (!ax.getClassExpression().isAnonymous()) {
                OWLClass type = (OWLClass) ax.getClassExpression();
                ClassFrameTranslator classFrameTranslator = translatorProvider.get();
                ClassFrame classFrame = classFrameTranslator.getFrame(rm.getRendering(type));
                for (PropertyValue propertyValue : classFrame.getPropertyValues()) {
                    // Bit yucky
                    if (!propertyValue.isAnnotation()) {
                        propertyValues.add(propertyValue.setState(State.DERIVED));
                    }
                }
            }
        }
    }
    propertyValues = propertyValueMinimiser.minimisePropertyValues(propertyValues);
    propertyValues.sort(propertyValueComparator);
    builder.addPropertyValues(propertyValues);
    for (OWLOntology ont : rootOntology.getImportsClosure()) {
        for (OWLSameIndividualAxiom sameIndividualAxiom : ont.getSameIndividualAxioms(subject.getEntity())) {
            final Set<OWLIndividual> individuals = sameIndividualAxiom.getIndividuals();
            for (OWLIndividual ind : individuals) {
                if (!ind.isAnonymous() && !ind.equals(subject.getEntity())) {
                    builder.addSameIndividual(rm.getRendering(ind.asOWLNamedIndividual()));
                }
            }
        }
    }
    return builder.build();
}
Also used : ArrayList(java.util.ArrayList) PropertyValue(edu.stanford.bmir.protege.web.shared.frame.PropertyValue) NamedIndividualFrame(edu.stanford.bmir.protege.web.shared.frame.NamedIndividualFrame) ClassFrame(edu.stanford.bmir.protege.web.shared.frame.ClassFrame)

Example 5 with PropertyValue

use of edu.stanford.bmir.protege.web.shared.frame.PropertyValue in project webprotege by protegeproject.

the class PropertyValueListEditor method fillUp.

private void fillUp(PropertyValueList propertyValueList) {
    List<PropertyValueDescriptor> vals = Lists.newArrayList();
    for (PropertyValue propertyValue : propertyValueList.getPropertyValues()) {
        // if (propertyValue.getState() == State.ASSERTED) {
        Optional<PropertyValueDescriptor> val = addRelationship(propertyValue);
        if (val.isPresent()) {
            vals.add(val.get());
        }
    // }
    }
    editor.setValue(vals);
}
Also used : PropertyValueDescriptor(edu.stanford.bmir.protege.web.shared.frame.PropertyValueDescriptor) PropertyValue(edu.stanford.bmir.protege.web.shared.frame.PropertyValue)

Aggregations

PropertyValue (edu.stanford.bmir.protege.web.shared.frame.PropertyValue)6 OWLClassData (edu.stanford.bmir.protege.web.shared.entity.OWLClassData)2 PropertyValueDescriptor (edu.stanford.bmir.protege.web.shared.frame.PropertyValueDescriptor)2 HashSet (java.util.HashSet)2 OWLNamedIndividualData (edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData)1 ClassFrame (edu.stanford.bmir.protege.web.shared.frame.ClassFrame)1 NamedIndividualFrame (edu.stanford.bmir.protege.web.shared.frame.NamedIndividualFrame)1 PropertyValueList (edu.stanford.bmir.protege.web.shared.frame.PropertyValueList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1