Skip to content

Commit

Permalink
add change request id to new Revision Event
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsilaghi committed Dec 11, 2024
1 parent 376cc34 commit 14fdde6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package edu.stanford.protege.webprotege.postcoordinationservice.services;

import edu.stanford.protege.webprotege.common.ChangeRequestId;
import edu.stanford.protege.webprotege.common.ProjectId;
import edu.stanford.protege.webprotege.postcoordinationservice.model.*;

import java.util.List;

public interface NewRevisionsEventEmitterService {
void emitNewRevisionsEventForScaleHistory(ProjectId projectId, List<EntityCustomScalesValuesHistory> entityCustomScaleHistories);
void emitNewRevisionsEventForScaleHistory(ProjectId projectId, List<EntityCustomScalesValuesHistory> entityCustomScaleHistories, ChangeRequestId changeRequestId);

void emitNewRevisionsEventForSpecHistory(ProjectId projectId, List<EntityPostCoordinationHistory> entitySpecHistories);
void emitNewRevisionsEventForSpecHistory(ProjectId projectId, List<EntityPostCoordinationHistory> entitySpecHistories, ChangeRequestId changeRequestId);

void emitNewRevisionsEvent(ProjectId projectId, String whoficEntityIri, PostCoordinationCustomScalesRevision entityCustomScaleRevision);
void emitNewRevisionsEvent(ProjectId projectId, String whoficEntityIri, PostCoordinationCustomScalesRevision entityCustomScaleRevision, ChangeRequestId changeRequestId);

void emitNewRevisionsEvent(ProjectId projectId, String whoficEntityIri, PostCoordinationSpecificationRevision entitySpecRevision);
void emitNewRevisionsEvent(ProjectId projectId, String whoficEntityIri, PostCoordinationSpecificationRevision entitySpecRevision, ChangeRequestId changeRequestId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ public NewRevisionsEventEmitterServiceImpl(EventDispatcher eventDispatcher,
}

@Override
public void emitNewRevisionsEventForScaleHistory(ProjectId projectId, List<EntityCustomScalesValuesHistory> entityCustomScaleHistories) {
public void emitNewRevisionsEventForScaleHistory(ProjectId projectId, List<EntityCustomScalesValuesHistory> entityCustomScaleHistories, ChangeRequestId changeRequestId) {
Set<ProjectChangeForEntity> changeList = projectChangesManager.getProjectChangesForCustomScaleHistories(projectId, entityCustomScaleHistories);
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, changeList);
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, changeList, changeRequestId);
eventDispatcher.dispatchEvent(revisionsEvent);
}

@Override
public void emitNewRevisionsEventForSpecHistory(ProjectId projectId, List<EntityPostCoordinationHistory> entitySpecHistories) {
public void emitNewRevisionsEventForSpecHistory(ProjectId projectId, List<EntityPostCoordinationHistory> entitySpecHistories, ChangeRequestId changeRequestId) {
Set<ProjectChangeForEntity> changeList = projectChangesManager.getProjectChangesForSpecHistories(projectId, entitySpecHistories);
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, changeList);
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, changeList, changeRequestId);
eventDispatcher.dispatchEvent(revisionsEvent);
}

@Override
public void emitNewRevisionsEvent(ProjectId projectId, String whoficEntityIri, PostCoordinationCustomScalesRevision entityCustomScaleRevision) {
public void emitNewRevisionsEvent(ProjectId projectId, String whoficEntityIri, PostCoordinationCustomScalesRevision entityCustomScaleRevision, ChangeRequestId changeRequestId) {
ProjectChangeForEntity projectChange = projectChangesManager.getProjectChangesForCustomScaleRevision(projectId, whoficEntityIri, entityCustomScaleRevision);
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, Set.of(projectChange));
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, Set.of(projectChange), changeRequestId);
eventDispatcher.dispatchEvent(revisionsEvent);
}

@Override
public void emitNewRevisionsEvent(ProjectId projectId, String whoficEntityIri, PostCoordinationSpecificationRevision entitySpecRevision) {
public void emitNewRevisionsEvent(ProjectId projectId, String whoficEntityIri, PostCoordinationSpecificationRevision entitySpecRevision, ChangeRequestId changeRequestId) {
ProjectChangeForEntity projectChange = projectChangesManager.getProjectChangesForSpecRevision(projectId, whoficEntityIri, entitySpecRevision);
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, Set.of(projectChange));
NewRevisionsEvent revisionsEvent = NewRevisionsEvent.create(EventId.generate(), projectId, Set.of(projectChange), changeRequestId);
eventDispatcher.dispatchEvent(revisionsEvent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private Consumer<List<WhoficCustomScalesValues>> createBatchProcessorForSavingPa

repository.bulkWriteDocuments(documents, POSTCOORDINATION_CUSTOM_SCALES_COLLECTION);

newRevisionsEventEmitter.emitNewRevisionsEventForScaleHistory(projectId, new ArrayList<>(histories));
newRevisionsEventEmitter.emitNewRevisionsEventForScaleHistory(projectId, new ArrayList<>(histories), null);
}
};
}
Expand Down Expand Up @@ -126,7 +126,7 @@ private Consumer<List<WhoficEntityPostCoordinationSpecification>> createBatchPro

saveMultipleEntityPostCoordinationHistories(histories);

newRevisionsEventEmitter.emitNewRevisionsEventForSpecHistory(projectId, histories.stream().toList());
newRevisionsEventEmitter.emitNewRevisionsEventForSpecHistory(projectId, histories.stream().toList(), null);
}
};
}
Expand Down Expand Up @@ -185,15 +185,15 @@ public void addSpecificationRevision(WhoficEntityPostCoordinationSpecification n
if (!specEvents.isEmpty()) {
var newRevision = PostCoordinationSpecificationRevision.create(userId, specEvents, changeRequestId);
repository.addSpecificationRevision(newSpecification.whoficEntityIri(), projectId, newRevision);
newRevisionsEventEmitter.emitNewRevisionsEvent(projectId, newSpecification.whoficEntityIri(), newRevision);
newRevisionsEventEmitter.emitNewRevisionsEvent(projectId, newSpecification.whoficEntityIri(), newRevision, changeRequestId);
}
}, () -> {
EntityPostCoordinationHistory history = createNewSpecificationHistory(newSpecification, projectId, userId, changeRequestId);
var savedHistory = repository.saveNewSpecificationHistory(history);
savedHistory.getPostCoordinationRevisions()
.stream()
.findFirst()
.ifPresent(revision -> newRevisionsEventEmitter.emitNewRevisionsEvent(projectId, savedHistory.getWhoficEntityIri(), revision));
.ifPresent(revision -> newRevisionsEventEmitter.emitNewRevisionsEvent(projectId, savedHistory.getWhoficEntityIri(), revision, changeRequestId));
}
);
}
Expand Down Expand Up @@ -221,15 +221,15 @@ public void addCustomScaleRevision(WhoficCustomScalesValues newScales,
if (!events.isEmpty()) {
var newRevision = PostCoordinationCustomScalesRevision.create(userId, events, changeRequestId);
repository.addCustomScalesRevision(newScales.whoficEntityIri(), projectId, newRevision);
newRevisionsEventEmitter.emitNewRevisionsEvent(projectId, newScales.whoficEntityIri(), newRevision);
newRevisionsEventEmitter.emitNewRevisionsEvent(projectId, newScales.whoficEntityIri(), newRevision, changeRequestId);
}
}, () -> {
var newHistory = createNewEntityCustomScalesHistory(newScales, projectId, userId, changeRequestId);
var savedHistory = repository.saveNewCustomScalesHistory(newHistory);
savedHistory.getPostCoordinationCustomScalesRevisions()
.stream()
.findFirst()
.ifPresent(revision -> newRevisionsEventEmitter.emitNewRevisionsEvent(projectId, newScales.whoficEntityIri(), revision));
.ifPresent(revision -> newRevisionsEventEmitter.emitNewRevisionsEvent(projectId, newScales.whoficEntityIri(), revision, changeRequestId));
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
public record NewRevisionsEvent(
EventId eventId,
ProjectId projectId,
Set<ProjectChangeForEntity> changes
Set<ProjectChangeForEntity> changes,
ChangeRequestId changeRequestId
) implements ProjectEvent {
public final static String CHANNEL = "webprotege.events.projects.uiHistory.NewRevisionsEvent";

public static NewRevisionsEvent create(EventId eventId,
ProjectId projectId,
Set<ProjectChangeForEntity> changes) {
return new NewRevisionsEvent(eventId, projectId, changes);
Set<ProjectChangeForEntity> changes,
ChangeRequestId changeRequestId) {
return new NewRevisionsEvent(eventId, projectId, changes,changeRequestId);
}

@NotNull
Expand Down

0 comments on commit 14fdde6

Please sign in to comment.