Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP 369 subAnnotations for all types of axioms #370

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.edmcouncil.spec.ontoviewer.core.model.property;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.edmcouncil.spec.ontoviewer.core.model.OwlType;
import org.edmcouncil.spec.ontoviewer.core.model.PropertyValue;

/**
* @author Michał Daniel ([email protected])
Expand All @@ -14,6 +17,7 @@ public class OwlAxiomPropertyValue extends PropertyValueAbstract<String> {
private Map<String, OwlAxiomPropertyEntity> entityMaping = new HashMap<>();
private boolean inferable = false;
private RestrictionType restrictionType = RestrictionType.OTHER;
private List <PropertyValue> annotationPropertyValues = new LinkedList();

public OwlAxiomPropertyValue() {
super();
Expand Down Expand Up @@ -53,6 +57,10 @@ public String getFullRenderedString() {
return fullRenderedString;
}

public void setAnnotationPropertyValues(List <PropertyValue> annotationPropertyValues) { this.annotationPropertyValues = annotationPropertyValues;}

public List <PropertyValue> getAnnotationPropertyValues() { return annotationPropertyValues;}

public boolean isInferable() {
return inferable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class DetailsManager {
private final DeprecatedHandler deprecatedHandler;
private final VersionIriHandler versionIriHandler;


public DetailsManager(ApplicationConfigurationService applicationConfigurationService,
OntologyManager ontologyManager,
ClassHandler particularClassHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
import static org.semanticweb.owlapi.model.parameters.Imports.INCLUDED;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.Set;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import org.edmcouncil.spec.ontoviewer.core.model.PropertyValue;
import org.edmcouncil.spec.ontoviewer.core.model.property.OwlAnnotationPropertyValue;
import org.edmcouncil.spec.ontoviewer.core.model.property.OwlAnnotationPropertyValueWithSubAnnotations;
import org.edmcouncil.spec.ontoviewer.core.model.property.OwlAxiomPropertyValue;
import org.edmcouncil.spec.ontoviewer.core.model.property.OwlDetailsProperties;
import org.edmcouncil.spec.ontoviewer.core.ontology.data.extractor.OwlDataExtractor;
import org.edmcouncil.spec.ontoviewer.core.ontology.data.handler.StringIdentifier;
import org.edmcouncil.spec.ontoviewer.core.ontology.data.handler.data.AnnotationsDataHandler;
import org.edmcouncil.spec.ontoviewer.core.ontology.data.visitor.ContainsVisitors;
import org.edmcouncil.spec.ontoviewer.core.ontology.factory.ViewerIdentifierFactory;
import org.edmcouncil.spec.ontoviewer.core.utils.StringUtils;
import org.edmcouncil.spec.ontoviewer.core.model.OwlType;
import org.semanticweb.owlapi.model.AxiomType;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLAnnotation;
import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
import org.semanticweb.owlapi.model.OWLAnnotationAxiom;
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
import org.semanticweb.owlapi.model.OWLAnonymousIndividual;
Expand All @@ -29,13 +39,18 @@
import org.semanticweb.owlapi.model.OWLObjectPropertyAxiom;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLSubClassOfAxiom;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class AxiomsHandler {

private static final Logger LOG = LoggerFactory.getLogger(AxiomsHandler.class);
private final AxiomsHelper axiomsHelper;
private final ContainsVisitors containsVisitors;
private OwlDataExtractor dataExtractor = new OwlDataExtractor();
private AnnotationsDataHandler annotationsDataHandler;


public AxiomsHandler(AxiomsHelper axiomsHelper, ContainsVisitors containsVisitors) {
this.axiomsHelper = axiomsHelper;
Expand Down Expand Up @@ -109,25 +124,49 @@ private <T extends OWLAxiom> OwlDetailsProperties<PropertyValue> handle(
T axiom = axiomsIterator.next();

String key = axiom.getAxiomType().getName();
key = ViewerIdentifierFactory.createId(ViewerIdentifierFactory.Type.axiom, key);
if (axiom instanceof OWLSubClassOfAxiom) {
OWLSubClassOfAxiom clazzAxiom = (OWLSubClassOfAxiom) axiom;
if (clazzAxiom.isGCI()) {
key = "gci";
}
}
key = ViewerIdentifierFactory.createId(ViewerIdentifierFactory.Type.axiom, key);

OwlAxiomPropertyValue axiomPropertyValue = axiomsHelper.prepareAxiomPropertyValue(
axiom, iriFragment, splitFragment, fixRenderedIri, true);
var axiomAnnotations = axiom.annotations().collect(Collectors.toList());
OwlAxiomPropertyValue axiomPropertyValue;
if (axiomAnnotations.size() > 0) {
LinkedList annotationPropertyValues = new LinkedList();
for (OWLAnnotation owlAnnotation : axiomAnnotations) {
String value = owlAnnotation.annotationValue().toString();
PropertyValue annotationValue = new OwlAnnotationPropertyValue();
annotationValue.setType(dataExtractor.extractAnnotationType(owlAnnotation));
annotationValue.setValue(value);
Map<String, PropertyValue> annotationMap = new LinkedHashMap<>();
annotationMap.put(owlAnnotation.getProperty().getIRI().getIRIString(), annotationValue);
OwlAnnotationPropertyValueWithSubAnnotations annotationPropertyValue = new OwlAnnotationPropertyValueWithSubAnnotations();
annotationPropertyValue.setType(OwlType.AXIOM);
annotationPropertyValue.setValue(annotationValue.toString());
annotationPropertyValue.setSubAnnotations(annotationMap);
annotationPropertyValues.add(annotationPropertyValue);

}
LOG.info("anotated: {}", axiom.annotations().collect(Collectors.toList()));

axiomPropertyValue = axiomsHelper.prepareAxiomPropertyValue(
axiom, iriFragment, splitFragment, fixRenderedIri, true, annotationPropertyValues);
} else {
axiomPropertyValue = axiomsHelper.prepareAxiomPropertyValue(
axiom, iriFragment, splitFragment, fixRenderedIri, true);
}
if (axiomPropertyValue == null) {
continue;
}

if (!key.equals(StringIdentifier.subClassOfIriString) || !axiomPropertyValue.getType().equals(TAXONOMY)) {
result.addProperty(key, axiomPropertyValue);
}
result.sortPropertiesInAlphabeticalOrder();
}
result.sortPropertiesInAlphabeticalOrder();
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.edmcouncil.spec.ontoviewer.core.ontology.data.handler.axiom;

import com.github.jsonldjava.shaded.com.google.common.collect.ImmutableSet;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import java.util.*;

import org.edmcouncil.spec.ontoviewer.core.model.OwlType;
import org.edmcouncil.spec.ontoviewer.core.model.PropertyValue;
import org.edmcouncil.spec.ontoviewer.core.model.property.OwlAxiomPropertyValue;
import org.edmcouncil.spec.ontoviewer.core.model.property.RestrictionType;
import org.edmcouncil.spec.ontoviewer.core.utils.OwlUtils;
Expand Down Expand Up @@ -54,11 +54,25 @@ public AxiomsHelper(OwlUtils owlUtils, Parser parser) {
}
//todo
public <T extends OWLAxiom> OwlAxiomPropertyValue prepareAxiomPropertyValue(
T axiom,
String iriFragment,
String splitFragment,
Boolean fixRenderedIri,
boolean bypassClass
T axiom,
String iriFragment,
String splitFragment,
Boolean fixRenderedIri,
boolean bypassClass,
List<PropertyValue> annotationPropertyValues
)
{
OwlAxiomPropertyValue axiomPropertyValue = prepareAxiomPropertyValue(axiom, iriFragment, splitFragment, fixRenderedIri, bypassClass);
axiomPropertyValue.setAnnotationPropertyValues(annotationPropertyValues);
return axiomPropertyValue;
}

public <T extends OWLAxiom> OwlAxiomPropertyValue prepareAxiomPropertyValue(
T axiom,
String iriFragment,
String splitFragment,
Boolean fixRenderedIri,
boolean bypassClass
) {
String value = rendering.render(axiom);
for (String unwantedType : unwantedTypes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private PropertyValue extractSubAnnotation(OWLAnnotation owlAnnotation) {
return annotationValue;
}

private <T extends HasAnnotationValue> PropertyValue getAnnotationPropertyValue(
public <T extends HasAnnotationValue> PropertyValue getAnnotationPropertyValue(
T annotationAssertion,
String value, PropertyValue annotationPropertyValue) {
if (annotationAssertion.annotationValue().isIRI()) {
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion onto-viewer-web-app/ontologies
Submodule ontologies updated from 487882 to 0676e5