use of edu.stanford.bmir.protege.web.shared.entity.OWLPropertyData in project webprotege by protegeproject.
the class PropertyValueComparator method compare.
@Override
public int compare(PropertyValue o1, PropertyValue o2) {
// if(o1.getState() == State.DERIVED) {
// if(o2.getState() != State.DERIVED) {
// return -1;
// }
// }
// else if(o2.getState() == State.DERIVED) {
// return 1;
// }
// Sort property values by language, property rendering and then value rendering.
// rdfs:label and then rdfs:comment get priority over other properties.
OWLPrimitiveData val1 = o1.getValue();
OWLPrimitiveData val2 = o2.getValue();
if (val1 instanceof OWLLiteralData && val2 instanceof OWLLiteralData) {
OWLLiteralData lit1 = (OWLLiteralData) val1;
OWLLiteralData lit2 = (OWLLiteralData) val2;
if (lit1.hasLang() && lit2.hasLang()) {
if (isDefaultLanguage(lit1)) {
if (!isDefaultLanguage(lit2)) {
return BEFORE;
}
} else {
if (isDefaultLanguage(lit2)) {
return AFTER;
}
}
int langDelta = lit1.getLang().compareToIgnoreCase(lit2.getLang());
if (langDelta != 0) {
return langDelta;
}
}
}
OWLPropertyData property1 = o1.getProperty();
OWLPropertyData property2 = o2.getProperty();
if (property1.isOWLAnnotationProperty()) {
if (property2.isOWLAnnotationProperty()) {
OWLAnnotationPropertyData annoProp1 = (OWLAnnotationPropertyData) property1;
OWLAnnotationPropertyData annoProp2 = (OWLAnnotationPropertyData) property2;
return annotationPropertyComparator.compare(annoProp1.getEntity(), annoProp2.getEntity());
} else {
return BEFORE;
}
} else if (property2.isOWLAnnotationProperty()) {
return AFTER;
}
String prop1BrowserText = property1.getBrowserText();
String prop2BrowserText = property2.getBrowserText();
int delta = prop1BrowserText.compareToIgnoreCase(prop2BrowserText);
if (delta != 0) {
return delta;
}
String val1Rendering = val1.getBrowserText();
String val2Rendering = val2.getBrowserText();
return val1Rendering.compareToIgnoreCase(val2Rendering);
}
use of edu.stanford.bmir.protege.web.shared.entity.OWLPropertyData in project webprotege by protegeproject.
the class PropertyValueDescriptorEditorImpl method getValue.
@Override
public Optional<PropertyValueDescriptor> getValue() {
if (state == State.DERIVED) {
return currentValue;
} else {
if (propertyField.getValue().isPresent() && valueField.getValue().isPresent()) {
Set<OWLAxiom> augmentingAxioms = Sets.newHashSet();
java.util.Optional<EntitySuggestion> selectedSuggestion = valueField.getSelectedSuggestion();
if (selectedSuggestion.isPresent()) {
if (selectedSuggestion.get() instanceof FreshEntitySuggestion) {
augmentingAxioms.addAll(((FreshEntitySuggestion) selectedSuggestion.get()).getAugmentingAxioms());
}
}
return Optional.of(new PropertyValueDescriptor((OWLPropertyData) propertyField.getValue().get(), valueField.getValue().get(), state, false, augmentingAxioms));
} else {
return Optional.empty();
}
}
}
Aggregations