diff --git a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/CreateLinearizationFromParentCommandHandler.java b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/CreateLinearizationFromParentCommandHandler.java index 94cfd72..3fa88f3 100644 --- a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/CreateLinearizationFromParentCommandHandler.java +++ b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/CreateLinearizationFromParentCommandHandler.java @@ -1,15 +1,11 @@ package edu.stanford.protege.webprotege.linearizationservice.handlers; -import edu.stanford.protege.webprotege.common.EventId; import edu.stanford.protege.webprotege.ipc.*; import edu.stanford.protege.webprotege.linearizationservice.mappers.WhoficEntityLinearizationSpecificationMapper; import edu.stanford.protege.webprotege.linearizationservice.services.*; -import edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.changes.ProjectLinearizationChangedEvent; import org.jetbrains.annotations.NotNull; import reactor.core.publisher.Mono; -import java.util.List; - import static edu.stanford.protege.webprotege.linearizationservice.handlers.CreateLinearizationFromParentRequest.CHANNEL; @WebProtegeHandler @@ -19,16 +15,13 @@ public class CreateLinearizationFromParentCommandHandler implements CommandHandl private final LinearizationEventsProcessorService linearizationEventsProcessor; private final WhoficEntityLinearizationSpecificationMapper whoficSpecMapper; - private final LinearizationChangeEmitterService linChangeEmitter; public CreateLinearizationFromParentCommandHandler(LinearizationHistoryService linearizationHistoryService, LinearizationEventsProcessorService linearizationEventsProcessor, - WhoficEntityLinearizationSpecificationMapper whoficSpecMapper, - LinearizationChangeEmitterService linChangeEmitter) { + WhoficEntityLinearizationSpecificationMapper whoficSpecMapper) { this.linearizationHistoryService = linearizationHistoryService; this.linearizationEventsProcessor = linearizationEventsProcessor; this.whoficSpecMapper = whoficSpecMapper; - this.linChangeEmitter = linChangeEmitter; } @NotNull @@ -53,7 +46,6 @@ public Mono handleRequest(CreateLineariza linearizationHistoryService.addRevision(newEntityWhoficSpec, request.projectId(), executionContext.userId()); - linChangeEmitter.emitLinearizationChangeEvent(request.projectId(), List.of(ProjectLinearizationChangedEvent.create(EventId.generate(), request.projectId()))); return Mono.just(CreateLinearizationFromParentResponse.create()); } diff --git a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/MergeWithParentEntitiesCommandHandler.java b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/MergeWithParentEntitiesCommandHandler.java index 4e0bf14..acde30d 100644 --- a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/MergeWithParentEntitiesCommandHandler.java +++ b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/MergeWithParentEntitiesCommandHandler.java @@ -1,14 +1,12 @@ package edu.stanford.protege.webprotege.linearizationservice.handlers; -import edu.stanford.protege.webprotege.common.EventId; import edu.stanford.protege.webprotege.ipc.*; import edu.stanford.protege.webprotege.linearizationservice.model.WhoficEntityLinearizationSpecification; import edu.stanford.protege.webprotege.linearizationservice.services.*; -import edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.changes.ProjectLinearizationChangedEvent; import org.jetbrains.annotations.NotNull; import reactor.core.publisher.Mono; -import java.util.*; +import java.util.Optional; import static edu.stanford.protege.webprotege.linearizationservice.handlers.MergeWithParentEntitiesRequest.CHANNEL; @@ -19,15 +17,13 @@ public class MergeWithParentEntitiesCommandHandler implements CommandHandler handleRequest(MergeWithParentEntiti readWriteLock.executeWriteLock(() -> { Optional newWhoficSpec = historyProcessorService.mergeLinearizationViewsFromParentsAndGetDefaultSpec(request.currentEntityIri(), request.parentEntityIris(), request.projectId()); - newWhoficSpec.ifPresent(newSpec -> { - linearizationHistoryService.addRevision(newSpec, request.projectId(), executionContext.userId()); - linChangeEmitter.emitLinearizationChangeEvent(request.projectId(), List.of(ProjectLinearizationChangedEvent.create(EventId.generate(), request.projectId()))); - }); + newWhoficSpec.ifPresent(newSpec -> linearizationHistoryService.addRevision(newSpec, request.projectId(), executionContext.userId())); }); return Mono.just(MergeWithParentEntitiesResponse.create()); } diff --git a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/RevertLinearitationToRevisionCommandHandler.java b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/RevertLinearitationToRevisionCommandHandler.java index d1e8e47..fe3803f 100644 --- a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/RevertLinearitationToRevisionCommandHandler.java +++ b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/RevertLinearitationToRevisionCommandHandler.java @@ -1,13 +1,10 @@ package edu.stanford.protege.webprotege.linearizationservice.handlers; -import edu.stanford.protege.webprotege.common.EventId; import edu.stanford.protege.webprotege.ipc.*; import edu.stanford.protege.webprotege.linearizationservice.services.*; -import edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.changes.ProjectLinearizationChangedEvent; import org.jetbrains.annotations.NotNull; import reactor.core.publisher.Mono; -import java.util.List; import java.util.stream.Collectors; import static edu.stanford.protege.webprotege.linearizationservice.handlers.RevertLinearitationToRevisionRequest.CHANNEL; @@ -18,14 +15,11 @@ public class RevertLinearitationToRevisionCommandHandler implements CommandHandl private final LinearizationHistoryService historyService; private final LinearizationEventsProcessorService eventsProcessorService; - private final LinearizationChangeEmitterService linChangeEmitter; public RevertLinearitationToRevisionCommandHandler(LinearizationHistoryService historyService, - LinearizationEventsProcessorService eventsProcessorService, - LinearizationChangeEmitterService linChangeEmitter) { + LinearizationEventsProcessorService eventsProcessorService) { this.historyService = historyService; this.eventsProcessorService = eventsProcessorService; - this.linChangeEmitter = linChangeEmitter; } @NotNull @@ -53,7 +47,6 @@ public Mono handleRequest(RevertLinearita historyService.addRevision(newRevisionUntilTimestamp, request.projectId(), executionContext.userId()); - linChangeEmitter.emitLinearizationChangeEvent(request.projectId(), List.of(ProjectLinearizationChangedEvent.create(EventId.generate(), request.projectId()))); }); return Mono.just(RevertLinearitationToRevisionResponse.create()); diff --git a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/SaveEntityLinearizationCommandHandler.java b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/SaveEntityLinearizationCommandHandler.java index 2fd23e6..0dcadfe 100644 --- a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/SaveEntityLinearizationCommandHandler.java +++ b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/SaveEntityLinearizationCommandHandler.java @@ -1,27 +1,19 @@ package edu.stanford.protege.webprotege.linearizationservice.handlers; -import edu.stanford.protege.webprotege.common.EventId; import edu.stanford.protege.webprotege.ipc.*; -import edu.stanford.protege.webprotege.linearizationservice.services.*; -import edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.changes.ProjectLinearizationChangedEvent; +import edu.stanford.protege.webprotege.linearizationservice.services.LinearizationHistoryService; import org.jetbrains.annotations.NotNull; import reactor.core.publisher.Mono; -import java.util.List; - @WebProtegeHandler public class SaveEntityLinearizationCommandHandler implements CommandHandler { private final LinearizationHistoryService linearizationHistoryService; - private final LinearizationChangeEmitterService linChangeEmitter; - - public SaveEntityLinearizationCommandHandler(LinearizationHistoryService linearizationHistoryService, - LinearizationChangeEmitterService linChangeEmitter) { + public SaveEntityLinearizationCommandHandler(LinearizationHistoryService linearizationHistoryService) { this.linearizationHistoryService = linearizationHistoryService; - this.linChangeEmitter = linChangeEmitter; } @@ -41,7 +33,6 @@ public Mono handleRequest(SaveEntityLinearizati linearizationHistoryService.addRevision(request.entityLinearization(), request.projectId(), executionContext.userId()); - linChangeEmitter.emitLinearizationChangeEvent(request.projectId(), List.of(ProjectLinearizationChangedEvent.create(EventId.generate(), request.projectId()))); return Mono.just(SaveEntityLinearizationResponse.create()); } diff --git a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/UploadLinearizationCommandHandler.java b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/UploadLinearizationCommandHandler.java index 0c1083d..9c5f944 100644 --- a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/UploadLinearizationCommandHandler.java +++ b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/handlers/UploadLinearizationCommandHandler.java @@ -1,12 +1,10 @@ package edu.stanford.protege.webprotege.linearizationservice.handlers; -import edu.stanford.protege.webprotege.common.EventId; import edu.stanford.protege.webprotege.ipc.*; import edu.stanford.protege.webprotege.linearizationservice.StreamUtils; import edu.stanford.protege.webprotege.linearizationservice.model.WhoficEntityLinearizationSpecification; import edu.stanford.protege.webprotege.linearizationservice.repositories.document.LinearizationDocumentRepository; import edu.stanford.protege.webprotege.linearizationservice.services.*; -import edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.changes.ProjectLinearizationChangedEvent; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Value; import reactor.core.publisher.Mono; @@ -31,17 +29,13 @@ public class UploadLinearizationCommandHandler implements CommandHandler handleRequest(UploadLinearizationReques stream.collect(StreamUtils.batchCollector(batchSize, batchProcessor)); }); - linChangeEmitter.emitLinearizationChangeEvent(request.projectId(), List.of(ProjectLinearizationChangedEvent.create(EventId.generate(), request.projectId()))); return Mono.just(UploadLinearizationResponse.create()); } diff --git a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/services/LinearizationChangeEmitterService.java b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/services/LinearizationChangeEmitterService.java deleted file mode 100644 index eaedeb7..0000000 --- a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/services/LinearizationChangeEmitterService.java +++ /dev/null @@ -1,9 +0,0 @@ -package edu.stanford.protege.webprotege.linearizationservice.services; - -import edu.stanford.protege.webprotege.common.*; - -import java.util.List; - -public interface LinearizationChangeEmitterService { - void emitLinearizationChangeEvent(ProjectId projectId, List eventList); -} diff --git a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/services/LinearizationChangeEmitterServiceImpl.java b/src/main/java/edu/stanford/protege/webprotege/linearizationservice/services/LinearizationChangeEmitterServiceImpl.java deleted file mode 100644 index 1bca385..0000000 --- a/src/main/java/edu/stanford/protege/webprotege/linearizationservice/services/LinearizationChangeEmitterServiceImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -package edu.stanford.protege.webprotege.linearizationservice.services; - -import edu.stanford.protege.webprotege.common.*; -import edu.stanford.protege.webprotege.ipc.EventDispatcher; -import edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.changes.*; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -public class LinearizationChangeEmitterServiceImpl implements LinearizationChangeEmitterService { - - private final EventDispatcher eventDispatcher; - - public LinearizationChangeEmitterServiceImpl(EventDispatcher eventDispatcher) { - this.eventDispatcher = eventDispatcher; - } - - @Override - public void emitLinearizationChangeEvent(ProjectId projectId, List eventList) { - if(!eventList.isEmpty()) { - var packagedProjectChange = new PackagedProjectChangeEvent(projectId, EventId.generate(), eventList); - eventDispatcher.dispatchEvent(packagedProjectChange); - } - } -} diff --git a/src/test/java/edu/stanford/protege/webprotege/linearizationservice/handlers/RevertLinearitationToRevisionCommandHandlerTest.java b/src/test/java/edu/stanford/protege/webprotege/linearizationservice/handlers/RevertLinearitationToRevisionCommandHandlerTest.java index 6dde017..a8f3839 100644 --- a/src/test/java/edu/stanford/protege/webprotege/linearizationservice/handlers/RevertLinearitationToRevisionCommandHandlerTest.java +++ b/src/test/java/edu/stanford/protege/webprotege/linearizationservice/handlers/RevertLinearitationToRevisionCommandHandlerTest.java @@ -27,9 +27,6 @@ public class RevertLinearitationToRevisionCommandHandlerTest { @Mock private LinearizationEventsProcessorService eventsProcessorService; - @Mock - private LinearizationChangeEmitterService linChangeEmitter; - @InjectMocks private RevertLinearitationToRevisionCommandHandler commandHandler;