Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

133 be add backend service project changes to the combined history in event history service #27

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.changes;

public enum ChangeType {
CREATE_ENTITY,
DELETE_ENTITY,
UPDATE_ENTITY
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
package edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.changes;

import edu.stanford.protege.webprotege.change.ProjectChange;
import org.jetbrains.annotations.NotNull;

public record ProjectChangeForEntity(String whoficEntityIri,
ProjectChange projectChange) {
ChangeType changeType,
ProjectChange projectChange) implements Comparable<ProjectChangeForEntity> {

public static ProjectChangeForEntity create(String whoficEntityIri,
ChangeType changeType,
ProjectChange projectChange) {
return new ProjectChangeForEntity(whoficEntityIri, projectChange);
return new ProjectChangeForEntity(whoficEntityIri, changeType, projectChange);
}

//All linearization/postcoordination changes are updates made on the whoficEntityIri.
// From this microservice we don't create or delete entities. that is the responsibility of the backend-service.
public static ProjectChangeForEntity create(String whoficEntityIri,
ProjectChange projectChange) {
return new ProjectChangeForEntity(whoficEntityIri, ChangeType.UPDATE_ENTITY, projectChange);
}

@Override
public int compareTo(@NotNull ProjectChangeForEntity other) {
int timestampComparison = Long.compare(this.projectChange.getTimestamp(), other.projectChange.getTimestamp());
if (timestampComparison != 0) {
return timestampComparison;
}
return this.whoficEntityIri.compareTo(other.whoficEntityIri);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import edu.stanford.protege.webprotege.linearizationservice.repositories.definitions.LinearizationDefinitionRepository;
import edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.diff.Revision2DiffElementsTranslator;
import edu.stanford.protege.webprotege.linearizationservice.uiHistoryConcern.nodeRendering.EntityRendererManager;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.*;
import org.mockito.junit.jupiter.MockitoExtension;
Expand Down Expand Up @@ -64,7 +64,11 @@ public void GIVEN_validHistories_WHEN_getProjectChangesForHistoriesCalled_THEN_r
assertEquals(1, result.size());
Iterator<ProjectChangeForEntity> iterator = result.iterator();

ProjectChange projectChange = iterator.next().projectChange();
ProjectChangeForEntity projectChangeForEntity = iterator.next();
ChangeType projectChangeType = projectChangeForEntity.changeType();
assertEquals(ChangeType.UPDATE_ENTITY, projectChangeType);

ProjectChange projectChange = projectChangeForEntity.projectChange();
assertNotNull(projectChange);
assertEquals(12345L, projectChange.getTimestamp());
assertEquals("user1", projectChange.getAuthor().id());
Expand Down Expand Up @@ -117,6 +121,7 @@ public void GIVEN_validProjectIdAndRevision_WHEN_getProjectChangesForRevisionCal

assertNotNull(result);
assertEquals(entityIri, result.whoficEntityIri());
assertEquals(ChangeType.UPDATE_ENTITY, result.changeType());

ProjectChange projectChange = result.projectChange();
assertNotNull(projectChange);
Expand Down
Loading