Search in sources :

Example 6 with Revision

use of edu.stanford.bmir.protege.web.server.revision.Revision in project webprotege by protegeproject.

the class RevisionManagerImpl_TestCase method should_addRevision.

@Test
public void should_addRevision() {
    UserId userId = mock(UserId.class);
    List<OWLOntologyChangeRecord> changes = Arrays.asList(new OWLOntologyChangeRecord(new OWLOntologyID(), new AddAxiomData(mock(OWLAxiom.class))));
    manager.addRevision(userId, changes, HIGHLEVEL_DESC);
    ArgumentCaptor<Revision> revisionCaptor = ArgumentCaptor.forClass(Revision.class);
    verify(revisionStore, times(1)).addRevision(revisionCaptor.capture());
    Revision addedRevision = revisionCaptor.getValue();
    assertThat(addedRevision.getUserId(), is(userId));
    assertThat(addedRevision.getHighLevelDescription(), is(HIGHLEVEL_DESC));
    assertThat(addedRevision.getRevisionNumber(), is(nextRevisionNumber));
}
Also used : OWLOntologyChangeRecord(org.semanticweb.owlapi.change.OWLOntologyChangeRecord) Revision(edu.stanford.bmir.protege.web.server.revision.Revision) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) OWLOntologyID(org.semanticweb.owlapi.model.OWLOntologyID) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) AddAxiomData(org.semanticweb.owlapi.change.AddAxiomData) Test(org.junit.Test)

Example 7 with Revision

use of edu.stanford.bmir.protege.web.server.revision.Revision in project webprotege by protegeproject.

the class RevisionReverterChangeListGenerator method generateChanges.

@Override
public OntologyChangeList<Boolean> generateChanges(ChangeGenerationContext context) {
    Optional<Revision> revision = revisionManager.getRevision(revisionNumber);
    if (!revision.isPresent()) {
        return OntologyChangeList.<Boolean>builder().build(false);
    }
    List<OWLOntologyChange> changes = new ArrayList<>();
    for (OWLOntologyChangeRecord record : revision.get()) {
        OWLOntologyChangeData revertingChangeData = changeDataReverter.getRevertingChange(record);
        OWLOntologyChangeRecord revertingRecord = new OWLOntologyChangeRecord(record.getOntologyID(), revertingChangeData);
        OWLOntologyManager manager = rootOntology.getOWLOntologyManager();
        OWLOntologyChange change = revertingRecord.createOntologyChange(manager);
        changes.add(0, change);
    }
    return OntologyChangeList.<Boolean>builder().addAll(changes).build(true);
}
Also used : OWLOntologyChangeRecord(org.semanticweb.owlapi.change.OWLOntologyChangeRecord) Revision(edu.stanford.bmir.protege.web.server.revision.Revision) OWLOntologyChange(org.semanticweb.owlapi.model.OWLOntologyChange) ArrayList(java.util.ArrayList) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) OWLOntologyChangeData(org.semanticweb.owlapi.change.OWLOntologyChangeData)

Aggregations

Revision (edu.stanford.bmir.protege.web.server.revision.Revision)7 OWLOntologyChangeRecord (org.semanticweb.owlapi.change.OWLOntologyChangeRecord)4 ImmutableList (com.google.common.collect.ImmutableList)1 ProjectResource (edu.stanford.bmir.protege.web.server.access.ProjectResource)1 Subject (edu.stanford.bmir.protege.web.server.access.Subject)1 ChangeApplicationResult (edu.stanford.bmir.protege.web.server.change.ChangeApplicationResult)1 HasGetRevisionSummary (edu.stanford.bmir.protege.web.server.change.HasGetRevisionSummary)1 EventTranslatorManager (edu.stanford.bmir.protege.web.server.events.EventTranslatorManager)1 RenameMap (edu.stanford.bmir.protege.web.server.owlapi.RenameMap)1 BrowserTextProvider (edu.stanford.bmir.protege.web.shared.BrowserTextProvider)1 DataFactory (edu.stanford.bmir.protege.web.shared.DataFactory)1 HasGetEntitiesWithIRI (edu.stanford.bmir.protege.web.shared.HasGetEntitiesWithIRI)1 ProjectChange (edu.stanford.bmir.protege.web.shared.change.ProjectChange)1 OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)1 edu.stanford.bmir.protege.web.shared.event (edu.stanford.bmir.protege.web.shared.event)1 ProjectEvent (edu.stanford.bmir.protege.web.shared.event.ProjectEvent)1 PermissionDeniedException (edu.stanford.bmir.protege.web.shared.permissions.PermissionDeniedException)1 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)1 RevisionSummary (edu.stanford.bmir.protege.web.shared.revision.RevisionSummary)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1