use of edu.stanford.bmir.protege.web.shared.frame.ClassFrame in project webprotege by protegeproject.
the class GetClassFrameActionHandler method execute.
@Nonnull
@Override
public GetClassFrameResult execute(@Nonnull GetClassFrameAction action, @Nonnull ExecutionContext executionContext) {
OWLClass subject = action.getSubject();
FrameActionResultTranslator<ClassFrame, OWLClassData> translator = new FrameActionResultTranslator<>(renderingManager, translatorProvider.get(), renderingManager.getRendering(subject));
LabelledFrame<ClassFrame> f = translator.doIT();
ProjectId projectId = action.getProjectId();
logger.info(BROWSING, "{} {} retrieved Class frame for {} ({})", projectId, executionContext.getUserId(), subject, f.getDisplayName());
return new GetClassFrameResult(f);
}
use of edu.stanford.bmir.protege.web.shared.frame.ClassFrame 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();
}
Aggregations