Skip to content

Commit

Permalink
removed notification to ui if a new revision has been created. this i…
Browse files Browse the repository at this point in the history
…s the responsability of event-history-service (#22)

Co-authored-by: Gheorghe Soimu <[email protected]>
  • Loading branch information
soimugeoWB and soimugeo authored Oct 14, 2024
1 parent a1d8243 commit 8af525b
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 84 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -53,7 +46,6 @@ public Mono<CreateLinearizationFromParentResponse> 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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -19,15 +17,13 @@ public class MergeWithParentEntitiesCommandHandler implements CommandHandler<Mer
private final LinearizationHistoryProcessorService historyProcessorService;
private final ReadWriteLockService readWriteLock;

private final LinearizationChangeEmitterService linChangeEmitter;

public MergeWithParentEntitiesCommandHandler(LinearizationHistoryService linearizationHistoryService,
LinearizationHistoryProcessorService historyProcessorService,
ReadWriteLockService readWriteLock, LinearizationChangeEmitterService linChangeEmitter) {
ReadWriteLockService readWriteLock) {
this.linearizationHistoryService = linearizationHistoryService;
this.historyProcessorService = historyProcessorService;
this.readWriteLock = readWriteLock;
this.linChangeEmitter = linChangeEmitter;
}


Expand All @@ -48,10 +44,7 @@ public Mono<MergeWithParentEntitiesResponse> handleRequest(MergeWithParentEntiti
readWriteLock.executeWriteLock(() -> {
Optional<WhoficEntityLinearizationSpecification> 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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -53,7 +47,6 @@ public Mono<RevertLinearitationToRevisionResponse> 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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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<SaveEntityLinearizationRequest, SaveEntityLinearizationResponse> {


private final LinearizationHistoryService linearizationHistoryService;

private final LinearizationChangeEmitterService linChangeEmitter;


public SaveEntityLinearizationCommandHandler(LinearizationHistoryService linearizationHistoryService,
LinearizationChangeEmitterService linChangeEmitter) {
public SaveEntityLinearizationCommandHandler(LinearizationHistoryService linearizationHistoryService) {
this.linearizationHistoryService = linearizationHistoryService;
this.linChangeEmitter = linChangeEmitter;
}


Expand All @@ -41,7 +33,6 @@ public Mono<SaveEntityLinearizationResponse> 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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -31,17 +29,13 @@ public class UploadLinearizationCommandHandler implements CommandHandler<UploadL

private final ReadWriteLockService readWriteLock;

private final LinearizationChangeEmitterService linChangeEmitter;


public UploadLinearizationCommandHandler(LinearizationDocumentRepository linearizationRepository,
LinearizationHistoryService linearizationHistoryService,
ReadWriteLockService readWriteLock,
LinearizationChangeEmitterService linChangeEmitter) {
ReadWriteLockService readWriteLock) {
this.linearizationRepository = linearizationRepository;
this.linearizationHistoryService = linearizationHistoryService;
this.readWriteLock = readWriteLock;
this.linChangeEmitter = linChangeEmitter;
}

@NotNull
Expand All @@ -66,7 +60,6 @@ public Mono<UploadLinearizationResponse> 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());
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public class RevertLinearitationToRevisionCommandHandlerTest {
@Mock
private LinearizationEventsProcessorService eventsProcessorService;

@Mock
private LinearizationChangeEmitterService linChangeEmitter;

@InjectMocks
private RevertLinearitationToRevisionCommandHandler commandHandler;

Expand Down

0 comments on commit 8af525b

Please sign in to comment.