Search in sources :

Example 1 with NamedIndividualFrame

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

the class GetNamedIndividualFrameActionHandler method execute.

@Nonnull
@Override
public GetNamedIndividualFrameResult execute(@Nonnull GetNamedIndividualFrameAction action, @Nonnull ExecutionContext executionContext) {
    NamedIndividualFrame frame = translator.getFrame(renderingManager.getRendering(action.getSubject()));
    String rendering = renderingManager.getShortForm(action.getSubject());
    LabelledFrame<NamedIndividualFrame> labelledFrame = new LabelledFrame<>(rendering, frame);
    logger.info(BROWSING, "{} {} retrieved NamedIndividual frame for {} ({})", action.getProjectId(), executionContext.getUserId(), action.getSubject(), labelledFrame.getDisplayName());
    return new GetNamedIndividualFrameResult(labelledFrame);
}
Also used : NamedIndividualFrame(edu.stanford.bmir.protege.web.shared.frame.NamedIndividualFrame) LabelledFrame(edu.stanford.bmir.protege.web.shared.frame.LabelledFrame) GetNamedIndividualFrameResult(edu.stanford.bmir.protege.web.shared.dispatch.actions.GetNamedIndividualFrameResult) Nonnull(javax.annotation.Nonnull)

Example 2 with NamedIndividualFrame

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

the class NamedIndividualFrameEditor method getValue.

@Override
public Optional<LabelledFrame<NamedIndividualFrame>> getValue() {
    GWT.log("[NamedIndividualFrameEditor] Get value: Dirty: " + isDirty() + " Edited frame: " + editedFrame);
    if (!editedFrame.isPresent()) {
        return Optional.empty();
    }
    PropertyValueList propertyValueList = assertions.getValue().get();
    Set<OWLClassData> rawTypes = getRawTypes();
    Set<OWLNamedIndividualData> sameAs = getRawSameAs();
    NamedIndividualFrame reference = new NamedIndividualFrame(editedFrame.get().getFrame().getSubject(), rawTypes, propertyValueList, sameAs);
    return Optional.of(new LabelledFrame<>(editedFrame.get().getDisplayName(), reference));
}
Also used : OWLClassData(edu.stanford.bmir.protege.web.shared.entity.OWLClassData) NamedIndividualFrame(edu.stanford.bmir.protege.web.shared.frame.NamedIndividualFrame) OWLNamedIndividualData(edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData) PropertyValueList(edu.stanford.bmir.protege.web.shared.frame.PropertyValueList)

Example 3 with NamedIndividualFrame

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

Aggregations

NamedIndividualFrame (edu.stanford.bmir.protege.web.shared.frame.NamedIndividualFrame)3 GetNamedIndividualFrameResult (edu.stanford.bmir.protege.web.shared.dispatch.actions.GetNamedIndividualFrameResult)1 OWLClassData (edu.stanford.bmir.protege.web.shared.entity.OWLClassData)1 OWLNamedIndividualData (edu.stanford.bmir.protege.web.shared.entity.OWLNamedIndividualData)1 ClassFrame (edu.stanford.bmir.protege.web.shared.frame.ClassFrame)1 LabelledFrame (edu.stanford.bmir.protege.web.shared.frame.LabelledFrame)1 PropertyValue (edu.stanford.bmir.protege.web.shared.frame.PropertyValue)1 PropertyValueList (edu.stanford.bmir.protege.web.shared.frame.PropertyValueList)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1