Beginnings of a combined property hierarchy
Esse commit está contido em:
+176
@@ -0,0 +1,176 @@
|
||||
package org.protege.editor.owl.model.hierarchy;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import org.semanticweb.owlapi.model.*;
|
||||
import org.semanticweb.owlapi.util.OWLObjectVisitorExAdapter;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Matthew Horridge
|
||||
* Stanford Center for Biomedical Informatics Research
|
||||
* 10/03/15
|
||||
*/
|
||||
public class OWLPropertyHierarchyProvider extends AbstractOWLObjectHierarchyProvider<OWLEntity> {
|
||||
|
||||
private OWLObjectHierarchyProvider<OWLObjectProperty> objectPropertyHierarchyProvider;
|
||||
|
||||
private OWLObjectHierarchyProvider<OWLDataProperty> dataPropertyHierarchyProvider;
|
||||
|
||||
private OWLObjectHierarchyProvider<OWLAnnotationProperty> annotationPropertyHierarchyProvider;
|
||||
|
||||
public OWLPropertyHierarchyProvider(
|
||||
OWLOntologyManager owlOntologyManager,
|
||||
OWLObjectHierarchyProvider<OWLObjectProperty> objectPropertyHierarchyProvider,
|
||||
OWLObjectHierarchyProvider<OWLDataProperty> dataPropertyHierarchyProvider,
|
||||
OWLObjectHierarchyProvider<OWLAnnotationProperty> annotationPropertyHierarchyProvider
|
||||
) {
|
||||
super(owlOntologyManager);
|
||||
this.annotationPropertyHierarchyProvider = annotationPropertyHierarchyProvider;
|
||||
this.dataPropertyHierarchyProvider = dataPropertyHierarchyProvider;
|
||||
this.objectPropertyHierarchyProvider = objectPropertyHierarchyProvider;
|
||||
|
||||
annotationPropertyHierarchyProvider.addListener(new OWLObjectHierarchyProviderListener<OWLAnnotationProperty>() {
|
||||
@Override
|
||||
public void nodeChanged(OWLAnnotationProperty node) {
|
||||
OWLPropertyHierarchyProvider.this.fireNodeChanged(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hierarchyChanged() {
|
||||
OWLPropertyHierarchyProvider.this.fireHierarchyChanged();
|
||||
}
|
||||
});
|
||||
dataPropertyHierarchyProvider.addListener(new OWLObjectHierarchyProviderListener<OWLDataProperty>() {
|
||||
@Override
|
||||
public void nodeChanged(OWLDataProperty node) {
|
||||
OWLPropertyHierarchyProvider.this.fireNodeChanged(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hierarchyChanged() {
|
||||
OWLPropertyHierarchyProvider.this.fireHierarchyChanged();
|
||||
}
|
||||
});
|
||||
objectPropertyHierarchyProvider.addListener(new OWLObjectHierarchyProviderListener<OWLObjectProperty>() {
|
||||
@Override
|
||||
public void nodeChanged(OWLObjectProperty node) {
|
||||
OWLPropertyHierarchyProvider.this.fireNodeChanged(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hierarchyChanged() {
|
||||
OWLPropertyHierarchyProvider.this.fireHierarchyChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsReference(OWLEntity object) {
|
||||
return object.accept(new OWLObjectVisitorExAdapter<Boolean>() {
|
||||
@Override
|
||||
public Boolean visit(OWLAnnotationProperty property) {
|
||||
return annotationPropertyHierarchyProvider.containsReference(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visit(OWLDataProperty property) {
|
||||
return dataPropertyHierarchyProvider.containsReference(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visit(OWLObjectProperty property) {
|
||||
return objectPropertyHierarchyProvider.containsReference(property);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ontologies that this hierarchy provider should use
|
||||
* in order to determine the hierarchy.
|
||||
*
|
||||
* @param ontologies
|
||||
*/
|
||||
@Override
|
||||
public void setOntologies(Set<OWLOntology> ontologies) {
|
||||
annotationPropertyHierarchyProvider.setOntologies(ontologies);
|
||||
dataPropertyHierarchyProvider.setOntologies(ontologies);
|
||||
objectPropertyHierarchyProvider.setOntologies(ontologies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the objects that represent the roots of the hierarchy.
|
||||
*/
|
||||
@Override
|
||||
public Set<OWLEntity> getRoots() {
|
||||
LinkedHashSet<OWLEntity> roots = new LinkedHashSet<>();
|
||||
roots.addAll(objectPropertyHierarchyProvider.getRoots());
|
||||
roots.addAll(dataPropertyHierarchyProvider.getRoots());
|
||||
roots.addAll(annotationPropertyHierarchyProvider.getRoots());
|
||||
return roots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<OWLEntity> getChildren(OWLEntity object) {
|
||||
Set<? extends OWLObject> result = object.accept(new OWLObjectVisitorExAdapter<Set<? extends OWLEntity>>() {
|
||||
@Override
|
||||
public Set<? extends OWLEntity> visit(OWLAnnotationProperty property) {
|
||||
return annotationPropertyHierarchyProvider.getChildren(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends OWLEntity> visit(OWLDataProperty property) {
|
||||
return dataPropertyHierarchyProvider.getChildren(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends OWLEntity> visit(OWLObjectProperty property) {
|
||||
return objectPropertyHierarchyProvider.getChildren(property);
|
||||
}
|
||||
});
|
||||
return (Set<OWLEntity>)result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<OWLEntity> getParents(OWLEntity object) {
|
||||
Set<? extends OWLEntity> result = object.accept(new OWLObjectVisitorExAdapter<Set<? extends OWLEntity>>() {
|
||||
@Override
|
||||
public Set<? extends OWLEntity> visit(OWLAnnotationProperty property) {
|
||||
return annotationPropertyHierarchyProvider.getParents(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends OWLEntity> visit(OWLDataProperty property) {
|
||||
return dataPropertyHierarchyProvider.getParents(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends OWLEntity> visit(OWLObjectProperty property) {
|
||||
return objectPropertyHierarchyProvider.getParents(property);
|
||||
}
|
||||
});
|
||||
return (Set<OWLEntity>)result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<OWLEntity> getEquivalents(OWLEntity object) {
|
||||
Set<? extends OWLEntity> result = object.accept(new OWLObjectVisitorExAdapter<Set<? extends OWLEntity>>() {
|
||||
@Override
|
||||
public Set<? extends OWLEntity> visit(OWLAnnotationProperty property) {
|
||||
return annotationPropertyHierarchyProvider.getEquivalents(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends OWLEntity> visit(OWLDataProperty property) {
|
||||
return dataPropertyHierarchyProvider.getEquivalents(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<? extends OWLEntity> visit(OWLObjectProperty property) {
|
||||
return objectPropertyHierarchyProvider.getEquivalents(property);
|
||||
}
|
||||
});
|
||||
return (Set<OWLEntity>)result;
|
||||
}
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package org.protege.editor.owl.ui.hierarchy;
|
||||
|
||||
import org.protege.editor.owl.model.OWLModelManager;
|
||||
import org.protege.editor.owl.model.hierarchy.OWLHierarchyManager;
|
||||
import org.protege.editor.owl.model.hierarchy.OWLObjectHierarchyProvider;
|
||||
import org.protege.editor.owl.model.hierarchy.OWLPropertyHierarchyProvider;
|
||||
import org.protege.editor.owl.ui.view.AbstractOWLEntityHierarchyViewComponent;
|
||||
import org.semanticweb.owlapi.model.OWLDataProperty;
|
||||
import org.semanticweb.owlapi.model.OWLEntity;
|
||||
import org.semanticweb.owlapi.model.OWLObject;
|
||||
import org.semanticweb.owlapi.model.OWLObjectProperty;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Matthew Horridge
|
||||
* Stanford Center for Biomedical Informatics Research
|
||||
* 10/03/15
|
||||
*/
|
||||
public class OWLPropertyHierarchyViewComponent extends AbstractOWLEntityHierarchyViewComponent<OWLEntity> {
|
||||
|
||||
private OWLPropertyHierarchyProvider hierarchyProvider;
|
||||
|
||||
@Override
|
||||
protected OWLObjectHierarchyProvider<OWLEntity> getHierarchyProvider() {
|
||||
if(hierarchyProvider == null) {
|
||||
OWLModelManager modelManager = getOWLModelManager();
|
||||
OWLHierarchyManager hierarchyManager = modelManager.getOWLHierarchyManager();
|
||||
hierarchyProvider = new OWLPropertyHierarchyProvider(
|
||||
modelManager.getOWLOntologyManager(),
|
||||
hierarchyManager.getOWLObjectPropertyHierarchyProvider(),
|
||||
hierarchyManager.getOWLDataPropertyHierarchyProvider(),
|
||||
hierarchyManager.getOWLAnnotationPropertyHierarchyProvider());
|
||||
}
|
||||
return hierarchyProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performExtraInitialisation() throws Exception {
|
||||
getTree().setOWLObjectComparator(new Comparator<OWLObject>() {
|
||||
@Override
|
||||
public int compare(OWLObject o1, OWLObject o2) {
|
||||
if(o1 instanceof OWLObjectProperty) {
|
||||
if(!(o2 instanceof OWLObjectProperty)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if(o1 instanceof OWLDataProperty) {
|
||||
if(o2 instanceof OWLObjectProperty) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(o2 instanceof OWLObjectProperty) {
|
||||
return 1;
|
||||
}
|
||||
else if(o2 instanceof OWLDataProperty) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
String s1 = getOWLModelManager().getRendering(o1);
|
||||
String s2 = getOWLModelManager().getRendering(o2);
|
||||
return s1.compareToIgnoreCase(s2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Request that the view is updated to display the current selection.
|
||||
*
|
||||
* @return The OWLEntity that the view is displaying. This
|
||||
* list is typically used to generate the view header text to give the
|
||||
* user an indication of what the view is displaying.
|
||||
*/
|
||||
@Override
|
||||
protected OWLObject updateView() {
|
||||
return getTree().getSelectedOWLObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OWLEntity> find(String match) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
Referência em uma Nova Issue
Bloquear um usuário