-
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.
Set entity from api adding transactionality (#52)
add commit/rollback mechanism. Add ChangeRequestId to Revision Events for rollback there as well.
- Loading branch information
1 parent
fe81e02
commit 121edf6
Showing
29 changed files
with
423 additions
and
79 deletions.
There are no files selected for viewing
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
36 changes: 36 additions & 0 deletions
36
...u/stanford/protege/webprotege/postcoordinationservice/events/EntityUpdateFailedEvent.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,36 @@ | ||
package edu.stanford.protege.webprotege.postcoordinationservice.events; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import edu.stanford.protege.webprotege.common.ChangeRequestId; | ||
import edu.stanford.protege.webprotege.common.EventId; | ||
import edu.stanford.protege.webprotege.common.ProjectEvent; | ||
import edu.stanford.protege.webprotege.common.ProjectId; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public record EntityUpdateFailedEvent(@JsonProperty("projectId") ProjectId projectId, | ||
@JsonProperty("eventId") EventId eventId, | ||
|
||
@JsonProperty("entityIri") String entityIri, | ||
@JsonProperty("changeRequestId")ChangeRequestId changeRequestId) implements ProjectEvent { | ||
|
||
public static String CHANNEL = "webprotege.api.EntityUpdateFailed"; | ||
|
||
|
||
@Nonnull | ||
@Override | ||
public ProjectId projectId() { | ||
return projectId; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public EventId eventId() { | ||
return eventId; | ||
} | ||
|
||
@Override | ||
public String getChannel() { | ||
return CHANNEL; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...ord/protege/webprotege/postcoordinationservice/events/EntityUpdatedSuccessfullyEvent.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,36 @@ | ||
package edu.stanford.protege.webprotege.postcoordinationservice.events; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import edu.stanford.protege.webprotege.common.ChangeRequestId; | ||
import edu.stanford.protege.webprotege.common.EventId; | ||
import edu.stanford.protege.webprotege.common.ProjectEvent; | ||
import edu.stanford.protege.webprotege.common.ProjectId; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public record EntityUpdatedSuccessfullyEvent(@JsonProperty("projectId") ProjectId projectId, | ||
@JsonProperty("eventId") EventId eventId, | ||
|
||
@JsonProperty("entityIri") String entityIri, | ||
@JsonProperty("changeRequestId") ChangeRequestId changeRequestId) implements ProjectEvent { | ||
|
||
public static String CHANNEL = "webprotege.api.EntityUpdatedSuccessfully"; | ||
|
||
|
||
@Nonnull | ||
@Override | ||
public ProjectId projectId() { | ||
return projectId; | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public EventId eventId() { | ||
return eventId; | ||
} | ||
|
||
@Override | ||
public String getChannel() { | ||
return CHANNEL; | ||
} | ||
} |
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
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
41 changes: 41 additions & 0 deletions
41
...protege/webprotege/postcoordinationservice/handlers/EntityUpdatedSuccessfullyHandler.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,41 @@ | ||
package edu.stanford.protege.webprotege.postcoordinationservice.handlers; | ||
|
||
|
||
import edu.stanford.protege.webprotege.ipc.EventHandler; | ||
import edu.stanford.protege.webprotege.postcoordinationservice.events.EntityUpdatedSuccessfullyEvent; | ||
import edu.stanford.protege.webprotege.postcoordinationservice.services.RevisionCommitService; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class EntityUpdatedSuccessfullyHandler implements EventHandler<EntityUpdatedSuccessfullyEvent> { | ||
|
||
|
||
private final RevisionCommitService revisionCommitService; | ||
|
||
public EntityUpdatedSuccessfullyHandler(RevisionCommitService revisionCommitService) { | ||
this.revisionCommitService = revisionCommitService; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getChannelName() { | ||
return EntityUpdatedSuccessfullyEvent.CHANNEL; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getHandlerName() { | ||
return this.getClass().getName(); | ||
} | ||
|
||
@Override | ||
public Class<EntityUpdatedSuccessfullyEvent> getEventClass() { | ||
return EntityUpdatedSuccessfullyEvent.class; | ||
} | ||
|
||
@Override | ||
public void handleEvent(EntityUpdatedSuccessfullyEvent event) { | ||
revisionCommitService.commitRevision(event.changeRequestId(), event.projectId(), event.entityIri()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...tanford/protege/webprotege/postcoordinationservice/handlers/EventUpdateFailedHandler.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,40 @@ | ||
package edu.stanford.protege.webprotege.postcoordinationservice.handlers; | ||
|
||
|
||
import edu.stanford.protege.webprotege.ipc.EventHandler; | ||
import edu.stanford.protege.webprotege.postcoordinationservice.events.EntityUpdateFailedEvent; | ||
import edu.stanford.protege.webprotege.postcoordinationservice.services.RevisionCommitService; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class EventUpdateFailedHandler implements EventHandler<EntityUpdateFailedEvent> { | ||
|
||
private final RevisionCommitService revisionCommitService; | ||
|
||
public EventUpdateFailedHandler(RevisionCommitService revisionCommitService) { | ||
this.revisionCommitService = revisionCommitService; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getChannelName() { | ||
return EntityUpdateFailedEvent.CHANNEL; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getHandlerName() { | ||
return EventUpdateFailedHandler.class.getName(); | ||
} | ||
|
||
@Override | ||
public Class<EntityUpdateFailedEvent> getEventClass() { | ||
return EntityUpdateFailedEvent.class; | ||
} | ||
|
||
@Override | ||
public void handleEvent(EntityUpdateFailedEvent event) { | ||
revisionCommitService.rollbackRevision(event.changeRequestId(), event.projectId(), event.entityIri()); | ||
} | ||
} |
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
6 changes: 6 additions & 0 deletions
6
...main/java/edu/stanford/protege/webprotege/postcoordinationservice/model/CommitStatus.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,6 @@ | ||
package edu.stanford.protege.webprotege.postcoordinationservice.model; | ||
|
||
public enum CommitStatus { | ||
COMMITTED, | ||
UNCOMMITTED; | ||
} |
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
Oops, something went wrong.