use of edu.stanford.bmir.protege.web.shared.frame.PropertyAnnotationValue in project webprotege by protegeproject.
the class SetOntologyAnnotationsActionHandler method getChangeListGenerator.
@Override
protected ChangeListGenerator<Set<OWLAnnotation>> getChangeListGenerator(SetOntologyAnnotationsAction action, ExecutionContext executionContext) {
final Set<PropertyAnnotationValue> fromAnnotations = action.getFromAnnotations();
final Set<PropertyAnnotationValue> toAnnotations = action.getToAnnotations();
List<OWLOntologyChange> changeList = new ArrayList<>();
OWLDataFactory dataFactory = rootOntology.getOWLOntologyManager().getOWLDataFactory();
for (PropertyAnnotationValue annotation : fromAnnotations) {
if (!toAnnotations.contains(annotation)) {
annotation.getValue().asAnnotationValue().ifPresent(av -> {
changeList.add(new RemoveOntologyAnnotation(rootOntology, dataFactory.getOWLAnnotation(annotation.getProperty().getEntity().asOWLAnnotationProperty(), av)));
});
}
}
for (PropertyAnnotationValue annotation : toAnnotations) {
if (!fromAnnotations.contains(annotation)) {
annotation.getValue().asAnnotationValue().ifPresent(av -> {
changeList.add(new AddOntologyAnnotation(rootOntology, dataFactory.getOWLAnnotation(annotation.getProperty().getEntity().asOWLAnnotationProperty(), av)));
});
}
}
return new FixedChangeListGenerator<Set<OWLAnnotation>>(changeList, Collections.emptySet(), "Edited ontology annotations") {
@Override
public Set<OWLAnnotation> getRenamedResult(Set<OWLAnnotation> result, RenameMap renameMap) {
return super.getRenamedResult(result, renameMap);
}
};
}
Aggregations