All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.stanford.protege.webprotege.merge.AnnotationDiffCalculator Maven / Gradle / Ivy

The newest version!
package edu.stanford.protege.webprotege.merge;

import com.google.common.collect.ImmutableSet;
import edu.stanford.protege.webprotege.project.Ontology;
import org.semanticweb.owlapi.model.OWLAnnotation;

import javax.inject.Inject;

/**
 * Matthew Horridge
 * Stanford Center for Biomedical Informatics Research
 * 26/01/15
 */
public class AnnotationDiffCalculator {

    @Inject
    public AnnotationDiffCalculator() {
    }

    public Diff computeDiff(Ontology from, Ontology to) {
        ImmutableSet.Builder addedAnnotations = ImmutableSet.builder();
        ImmutableSet.Builder removedAnnotations = ImmutableSet.builder();
        for(OWLAnnotation anno : to.getAnnotations()) {
            if(!from.getAnnotations().contains(anno)) {
                addedAnnotations.add(anno);
            }
        }
        for(OWLAnnotation anno : from.getAnnotations()) {
            if(!to.getAnnotations().contains(anno)) {
                removedAnnotations.add(anno);
            }
        }
        return new Diff<>(addedAnnotations.build(), removedAnnotations.build());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy