-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from protegeproject/39-create-uihistoryconcern…
…-package-for-postcoordination-similar-to-the-one-in-linearization-service work for ui history
- Loading branch information
Showing
10 changed files
with
376 additions
and
246 deletions.
There are no files selected for viewing
414 changes: 207 additions & 207 deletions
414
...n/java/edu/stanford/protege/webprotegeeventshistory/config/ObjectMapperConfiguration.java
Large diffs are not rendered by default.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
...nford/protege/webprotegeeventshistory/config/events/ProjectLinearizationChangedEvent.java
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
...java/edu/stanford/protege/webprotegeeventshistory/config/events/UpdateUiHistoryEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package edu.stanford.protege.webprotegeeventshistory.config.events; | ||
|
||
import com.fasterxml.jackson.annotation.*; | ||
import com.google.common.base.Objects; | ||
import edu.stanford.protege.webprotege.common.*; | ||
|
||
import java.util.Set; | ||
|
||
@JsonTypeName(UpdateUiHistoryEvent.CHANNEL) | ||
public record UpdateUiHistoryEvent(EventId eventId, | ||
ProjectId projectId, | ||
Set<String> affectedEntityIris) implements ProjectEvent { | ||
|
||
@JsonCreator | ||
public static UpdateUiHistoryEvent create(@JsonProperty("eventId") EventId eventId, | ||
@JsonProperty("projectId") ProjectId projectId, | ||
@JsonProperty("afectedEntityIris") Set<String> afectedEntityIris | ||
) { | ||
return new UpdateUiHistoryEvent(eventId, projectId, afectedEntityIris); | ||
} | ||
|
||
public static final String CHANNEL = "webprotege.events.projects.uiHistory.UpdateUiHistoryEvent"; | ||
|
||
@JsonProperty("projectId") | ||
public ProjectId projectId() { | ||
return this.projectId; | ||
} | ||
|
||
@Override | ||
@JsonProperty("eventId") | ||
public EventId eventId() { | ||
return eventId; | ||
} | ||
|
||
@Override | ||
@JsonProperty("afectedEntityIris") | ||
public Set<String> affectedEntityIris() { | ||
return affectedEntityIris; | ||
} | ||
|
||
@Override | ||
public String getChannel() { | ||
return CHANNEL; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
UpdateUiHistoryEvent that = (UpdateUiHistoryEvent) o; | ||
return Objects.equal(eventId, that.eventId) && Objects.equal(projectId, that.projectId) && Objects.equal(affectedEntityIris, that.affectedEntityIris); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(eventId, projectId, affectedEntityIris); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "UpdateUiHistoryEvent{" + | ||
"eventId=" + eventId + | ||
", projectId=" + projectId + | ||
", subjects=" + affectedEntityIris + | ||
'}'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...rd/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeDispatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.services; | ||
|
||
import edu.stanford.protege.webprotege.common.*; | ||
|
||
public interface ProjectChangeDispatcher { | ||
void dispatchEvent(ProjectId projectId, ProjectEvent event); | ||
} |
24 changes: 24 additions & 0 deletions
24
...rotege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeDispatcherImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.services; | ||
|
||
import edu.stanford.protege.webprotege.common.*; | ||
import edu.stanford.protege.webprotege.ipc.EventDispatcher; | ||
import edu.stanford.protege.webprotegeeventshistory.dto.PackagedProjectChangeEvent; | ||
import org.springframework.stereotype.*; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class ProjectChangeDispatcherImpl implements ProjectChangeDispatcher { | ||
|
||
private final EventDispatcher eventDispatcher; | ||
|
||
public ProjectChangeDispatcherImpl(EventDispatcher eventDispatcher) { | ||
this.eventDispatcher = eventDispatcher; | ||
} | ||
|
||
@Override | ||
public void dispatchEvent(ProjectId projectId, ProjectEvent event) { | ||
var packagedProjectChange = new PackagedProjectChangeEvent(projectId, EventId.generate(), List.of(event)); | ||
eventDispatcher.dispatchEvent(packagedProjectChange); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...nford/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.services; | ||
|
||
import edu.stanford.protege.webprotege.common.*; | ||
|
||
public interface ProjectChangeService { | ||
void emitProjectChange(ProjectId projectId, ProjectEvent event); | ||
} |
29 changes: 29 additions & 0 deletions
29
...d/protege/webprotegeeventshistory/uiHistoryConcern/services/ProjectChangeServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.services; | ||
|
||
import edu.stanford.protege.webprotege.common.*; | ||
import edu.stanford.protege.webprotegeeventshistory.config.events.UpdateUiHistoryEvent; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.scheduling.annotation.Async; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ProjectChangeServiceImpl implements ProjectChangeService { | ||
|
||
private final ProjectChangeDispatcher changeDispatcher; | ||
|
||
public ProjectChangeServiceImpl(ProjectChangeDispatcher changeDispatcher) { | ||
this.changeDispatcher = changeDispatcher; | ||
} | ||
|
||
@Async | ||
@EventListener | ||
public void handleUiHistoryEvent(UpdateUiHistoryEvent event) { | ||
// Emit the project change when the event is handled | ||
emitProjectChange(event.projectId(), UpdateUiHistoryEvent.create(EventId.generate(), event.projectId(), event.affectedEntityIris())); | ||
} | ||
|
||
@Override | ||
public void emitProjectChange(ProjectId projectId, ProjectEvent event) { | ||
this.changeDispatcher.dispatchEvent(projectId, event); | ||
} | ||
} |