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

fix for https://github.com/who-icatx/icatx-api-gateway/issues/19 #21

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
@@ -1,9 +1,15 @@
package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

public record EntityHistorySummary(List<EntityChange> changes) {
public static EntityHistorySummary create(List<EntityChange> changes) {
return new EntityHistorySummary(changes);
public record EntityHistorySummary(@JsonProperty("entityUri") String entityUri,
@JsonProperty("projectId") String projectId,
@JsonProperty("changes") List<EntityChange> changes) {
public static EntityHistorySummary create(String entityUri,
String projectId,
List<EntityChange> changes) {
return new EntityHistorySummary(entityUri, projectId, changes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@

import edu.stanford.protege.webprotege.change.ProjectChange;
import edu.stanford.protege.webprotege.common.Page;
import edu.stanford.protege.webprotege.common.*;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.dto.*;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.*;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.mappers.*;
import edu.stanford.protege.webprotege.common.ProjectId;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.dto.ChangeType;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.dto.ChangedEntities;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.dto.EntityChange;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.dto.EntityHistorySummary;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.NewRevisionsEvent;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.RevisionsEvent;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.mappers.ProjectChangeMapper;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.mappers.RevisionEventMapper;
import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.repositories.RevisionsEventRepository;
import org.semanticweb.owlapi.model.OWLEntity;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.*;
import java.util.*;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

import static edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.RevisionsEvent.*;
Expand Down Expand Up @@ -92,9 +100,9 @@ public ChangedEntities getChangedEntitiesAfterTimestamp(ProjectId projectId, lon
return new ChangedEntities(createdEntities, updatedEntities, deletedEntities);
}

private static List<String> groupByChangeType(List<RevisionsEvent> revisionsEvents, ChangeType createEntity) {
private static List<String> groupByChangeType(List<RevisionsEvent> revisionsEvents, ChangeType changeType) {
return revisionsEvents.stream()
.filter(event -> event.changeType() == createEntity)
.filter(event -> event.changeType() == changeType)
.map(RevisionsEvent::whoficEntityIri)
.filter(Objects::nonNull)
.distinct()
Expand All @@ -114,6 +122,6 @@ public EntityHistorySummary getEntityHistorySummary(ProjectId projectId, String
).toList();


return EntityHistorySummary.create(entityChanges);
return EntityHistorySummary.create(entityIri, projectId.value(), entityChanges);
}
}
Loading