Search in sources :

Example 6 with PropertyAnnotationValue

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);
        }
    };
}
Also used : Set(java.util.Set) FixedChangeListGenerator(edu.stanford.bmir.protege.web.server.change.FixedChangeListGenerator) ArrayList(java.util.ArrayList) RenameMap(edu.stanford.bmir.protege.web.server.owlapi.RenameMap) PropertyAnnotationValue(edu.stanford.bmir.protege.web.shared.frame.PropertyAnnotationValue)

Aggregations

PropertyAnnotationValue (edu.stanford.bmir.protege.web.shared.frame.PropertyAnnotationValue)6 PropertyValueList (edu.stanford.bmir.protege.web.shared.frame.PropertyValueList)2 ArrayList (java.util.ArrayList)2 ImmutableList (com.google.common.collect.ImmutableList)1 FixedChangeListGenerator (edu.stanford.bmir.protege.web.server.change.FixedChangeListGenerator)1 RenameMap (edu.stanford.bmir.protege.web.server.owlapi.RenameMap)1 GetOntologyAnnotationsAction (edu.stanford.bmir.protege.web.shared.dispatch.actions.GetOntologyAnnotationsAction)1 GetOntologyAnnotationsResult (edu.stanford.bmir.protege.web.shared.dispatch.actions.GetOntologyAnnotationsResult)1 OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)1 AnnotationPropertyFrame (edu.stanford.bmir.protege.web.shared.frame.AnnotationPropertyFrame)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Nonnull (javax.annotation.Nonnull)1 OWLAnnotation (org.semanticweb.owlapi.model.OWLAnnotation)1