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

updated NewRevisionsEventService #19

Merged
merged 1 commit into from
Dec 23, 2024
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
Expand Up @@ -3,12 +3,10 @@
import com.fasterxml.jackson.annotation.*;
import edu.stanford.protege.webprotege.common.*;

import java.sql.Timestamp;

@JsonTypeName(GetChangedEntitiesRequest.CHANNEL)
public record GetChangedEntitiesRequest(
@JsonProperty("projectId") ProjectId projectId,
@JsonProperty("timestamp") Timestamp timestamp
@JsonProperty("timestamp") long timestamp
) implements Request<GetChangedEntitiesResponse> {

public static final String CHANNEL = "webprotege.history.GetChangedEntities";
Expand All @@ -19,7 +17,7 @@ public String getChannel() {
}

public static GetChangedEntitiesRequest create(ProjectId projectId,
Timestamp timestamp) {
long timestamp) {
return new GetChangedEntitiesRequest(projectId, timestamp);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.NewRevisionsEvent;
import org.semanticweb.owlapi.model.OWLEntity;

import java.sql.Timestamp;
import java.util.Optional;

public interface NewRevisionsEventService {
Expand All @@ -15,7 +14,7 @@ public interface NewRevisionsEventService {

Page<ProjectChange> fetchPaginatedProjectChanges(ProjectId projectId, Optional<OWLEntity> subject, int pageNumber, int pageSize);

ChangedEntities getChangedEntitiesAfterTimestamp(ProjectId projectId, Timestamp timestamp);
ChangedEntities getChangedEntitiesAfterTimestamp(ProjectId projectId, long timestamp);

EntityHistorySummary getEntityHistorySummary(ProjectId projectId, String entityIri);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;
import java.time.*;
import java.util.*;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -81,8 +80,8 @@ public Page<ProjectChange> fetchPaginatedProjectChanges(ProjectId projectId, Opt
}

@Override
public ChangedEntities getChangedEntitiesAfterTimestamp(ProjectId projectId, Timestamp timestamp) {
List<RevisionsEvent> revisionsEvents = repository.findByProjectIdAndTimestampAfter(projectId.id(), timestamp.getTime());
public ChangedEntities getChangedEntitiesAfterTimestamp(ProjectId projectId, long timestamp) {
List<RevisionsEvent> revisionsEvents = repository.findByProjectIdAndTimestampAfter(projectId.id(), timestamp);

List<String> createdEntities = groupByChangeType(revisionsEvents, ChangeType.CREATE_ENTITY);

Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
server:
port: 7761

logging.level.root: DEBUG
logging:
level:
org.springframework.data.mongodb.core.MongoTemplate: DEBUG
org.mongodb.driver: DEBUG

spring:
application:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void GIVEN_eventsAfterTimestamp_WHEN_handleRequestCalled_THEN_returnChang
insertMockRevisionsEvent(projectId, "entity2", timestamp.getTime() + 5000, ChangeType.UPDATE_ENTITY);
insertMockRevisionsEvent(projectId, "entity3", timestamp.getTime() + 6000, ChangeType.DELETE_ENTITY);

GetChangedEntitiesRequest request = GetChangedEntitiesRequest.create(projectId, timestamp);
GetChangedEntitiesRequest request = GetChangedEntitiesRequest.create(projectId, timestamp.getTime());

Mono<GetChangedEntitiesResponse> responseMono = commandHandler.handleRequest(request, null);
GetChangedEntitiesResponse response = responseMono.block();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void GIVEN_noResults_WHEN_fetchPaginatedProjectChangesCalled_THEN_returnE
public void GIVEN_noEntitiesChangedAfterTimestamp_WHEN_getChangedEntitiesAfterTimestampCalled_THEN_emptyChangedEntitiesReturned() {
when(repository.findByProjectIdAndTimestampAfter(projectId.id(), timestamp.getTime())).thenReturn(List.of());

ChangedEntities result = service.getChangedEntitiesAfterTimestamp(projectId, timestamp);
ChangedEntities result = service.getChangedEntitiesAfterTimestamp(projectId, timestamp.getTime());

assertEquals(0, result.createdEntities().size());
assertEquals(0, result.updatedEntities().size());
Expand All @@ -151,7 +151,7 @@ public void GIVEN_entitiesChangedAfterTimestamp_WHEN_getChangedEntitiesAfterTime

when(repository.findByProjectIdAndTimestampAfter(projectId.id(), timestamp.getTime())).thenReturn(List.of(createdEntity, updatedEntity, deletedEntity));

ChangedEntities result = service.getChangedEntitiesAfterTimestamp(projectId, timestamp);
ChangedEntities result = service.getChangedEntitiesAfterTimestamp(projectId, timestamp.getTime());

assertEquals(1, result.createdEntities().size());
assertEquals("entityIRI1", result.createdEntities().get(0));
Expand All @@ -173,7 +173,7 @@ public void GIVEN_multipleEntitiesChangedAfterTimestamp_WHEN_getChangedEntitiesA

when(repository.findByProjectIdAndTimestampAfter(projectId.id(), timestamp.getTime())).thenReturn(List.of(createdEntity1, createdEntity2, updatedEntity));

ChangedEntities result = service.getChangedEntitiesAfterTimestamp(projectId, timestamp);
ChangedEntities result = service.getChangedEntitiesAfterTimestamp(projectId, timestamp.getTime());

assertEquals(1, result.createdEntities().size());
assertEquals("entityIRI1", result.createdEntities().get(0));
Expand Down
Loading