Skip to content

Commit

Permalink
Merge pull request #169 from EBISPOT/goci#809-Submission-history-issue
Browse files Browse the repository at this point in the history
Goci#809 submission history issue
  • Loading branch information
sajo-ebi authored Dec 6, 2022
2 parents 9e33605 + 70a85fd commit 92a6d5f
Show file tree
Hide file tree
Showing 19 changed files with 326 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
public interface AssociationRepository extends MongoRepository<Association, String> {

Stream<Association> readBySubmissionId(String submissionId);
Stream<Association> readByIdIn(List<String> ids);
Integer countByIsValidAndSubmissionId(Boolean isValid, String submissionId);
Integer countByIsApprovedAndSubmissionId(Boolean isApproved, String submissionId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ public interface SampleRepository extends MongoRepository<Sample, String> {

Page<Sample> findBySubmissionId(String submissionId, Pageable page);

List<Sample> findByIdIn(List<String> ids);

Stream<Sample> findByIdIn(List<String> ids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

@RestController
@RequestMapping(value = GeneralCommon.API_V1 + DepositionCurationConstants.API_SUBMISSIONS)
Expand Down Expand Up @@ -49,9 +50,14 @@ public List<VersionSummary> diffVersionSubmissions(@PathVariable String submissi
if(changeList != null && !changeList.isEmpty()) {
Optional<Map<Double, List<JaversChangeWrapper>>> convertedEntityOptional = conversionService.filterJaversResponse(changeList);
List<Double> versionMapTobeDeleted = conversionService.removeInvalidSumstatsEntries(changeList);
Optional<Set<Double>> versionMapMetaDataDuplicated = conversionService.removeDuplicateMetaDataVersions(convertedEntityOptional);
if(versionMapTobeDeleted != null && !versionMapTobeDeleted.isEmpty())
conversionService.removeVersionMap(convertedEntityOptional, versionMapTobeDeleted );
summaries = conversionService.filterStudiesFromJavers(convertedEntityOptional);
if(versionMapMetaDataDuplicated.isPresent()) {
conversionService.removeVersionMap(convertedEntityOptional,versionMapMetaDataDuplicated.get() );
}

summaries = conversionService.buiildVersionSummary(convertedEntityOptional);
Optional<List<FileUpload>> fileUploadsOptional = conversionService.filterJaversResponseForFiles(responseEntity.getBody());
summaries = fileUploadsOptional.isPresent()?conversionService.mapFilesToVersionSummary(summaries, fileUploadsOptional.get()):null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public interface AssociationJaversService {

public AddedRemoved getAssociationVersionStats(List<Association> prevAscns, List<Association> newAscns);

public Association processAssociationTag(ElementChange elementChange);
public String processAssociationTag(ElementChange elementChange);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import uk.ac.ebi.spot.gwas.deposition.dto.curation.SnpStatusReportDto;

import java.util.List;
import java.util.stream.Stream;

public interface AssociationsService {


Association getAssociation(String associationId);

Stream<Association> readBySeqIds(List<String> ids);

List<Association> getAssociations(String submissionId);

byte[] getSnpValidationReportTsv(String submissionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

public interface ConversionJaversService {

Expand All @@ -17,9 +18,14 @@ public interface ConversionJaversService {
public void removeVersionMap(Optional<Map<Double, List<JaversChangeWrapper>>> javersChangeWrapperMap,
List<Double> versionsTobeRemoved );

public void removeVersionMap(Optional<Map<Double, List<JaversChangeWrapper>>> javersChangeWrapperMap,
Set<Double> versionsTobeRemoved );

public Optional<Set<Double>> removeDuplicateMetaDataVersions(Optional<Map<Double, List<JaversChangeWrapper>>> javersChangeWrapperMap);

public Optional<List<FileUpload>> filterJaversResponseForFiles(List<JaversChangeWrapper> javersChangeWrapperList);

public List<VersionSummary> filterStudiesFromJavers(Optional<Map<Double, List<JaversChangeWrapper>>> javersChangeWrapperList);
public List<VersionSummary> buiildVersionSummary(Optional<Map<Double, List<JaversChangeWrapper>>> javersChangeWrapperList);

public List<VersionSummary> mapFilesToVersionSummary(List<VersionSummary> summaries, List<FileUpload> fileUploads);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public interface SampleJaversService {

public AddedRemoved getSampleVersionStats(List<Sample> prevSamples, List<Sample> newSamples);

public Sample processSampleTag(ElementChange elementChange);
public String processSampleTag(ElementChange elementChange);


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import uk.ac.ebi.spot.gwas.deposition.domain.Submission;

import java.util.List;
import java.util.stream.Stream;

public interface SamplesService {


Sample getSample(String sampleId);

Stream<Sample> findByIdIn(List<String> ids);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
import uk.ac.ebi.spot.gwas.deposition.dto.curation.*;

import java.util.List;
import java.util.stream.Stream;

public interface StudiesService {


Study getStudy(String studyId);

Stream<Study> getStudies(List<String> ids);

Study getStudyByAccession(String accessionId, String submissionId);

Study updateStudies(Study study);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public interface StudyJaversService {

public AddedRemoved getReportedEfoVersionStats(List<Study> prevStudies, List<Study> newStudies);

public Study processStudyTag(ElementChange elementChange);
public String processStudyTag(ElementChange elementChange);

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public VersionDiffStats findAssociationChanges(String tag, List<Association> pre
diffStats.setAssociations(new ArrayList<>());

prevAscns.forEach((asscn) -> {
log.info("VariantId*****"+asscn.getVariantId());
//log.info("VariantId*****"+asscn.getVariantId());
List<AssociationDto> newAsscnsDto = newAscns.stream()
.filter((ascn) -> ascn.getVariantId().equals(asscn.getVariantId()))
.map(AssociationDtoAssembler::assemble)
Expand Down Expand Up @@ -70,8 +70,8 @@ public VersionDiffStats findAssociationChanges(String tag, List<Association> pre
public List<ValueChangeWrapper> diffAssociations(AssociationDto dto1, AssociationDto dto2) {
Javers javers = JaversBuilder.javers().build();
Diff diff = javers.compare(dto1, dto2);
log.info("************");
log.info("Diff Asscn"+ diff);
//log.info("************");
//log.info("Diff Asscn"+ diff);
List<ValueChange> valChanges = diff.getChangesByType(ValueChange.class);
try {
ValueChangeWrapper[] changes = new ObjectMapper().readValue(
Expand All @@ -84,7 +84,7 @@ public List<ValueChangeWrapper> diffAssociations(AssociationDto dto1, Associatio
}

public AddedRemoved getAssociationVersionStats(List<Association> prevAscns, List<Association> newAscns) {
log.info("Inside getAssociationVersionStats() ");
//log.info("Inside getAssociationVersionStats() ");

List<String> newAscnsTags = newAscns.stream()
.map(asscn -> asscn.getStudyTag() + asscn.getVariantId())
Expand All @@ -102,10 +102,10 @@ public AddedRemoved getAssociationVersionStats(List<Association> prevAscns, List
.filter(asscn -> !prevAscnsTags.contains(asscn.getStudyTag() + asscn.getVariantId()))
.collect(Collectors.toList());

log.info("newAscnsTags****"+newAscnsTags);
log.info("prevAscnsTags****"+prevAscnsTags);
log.info("asscnsRemoved****"+asscnsRemoved);
log.info("asscnsAdded****"+asscnsAdded);
//log.info("newAscnsTags****"+newAscnsTags);
// log.info("prevAscnsTags****"+prevAscnsTags);
// log.info("asscnsRemoved****"+asscnsRemoved);
//log.info("asscnsAdded****"+asscnsAdded);

AddedRemoved addedRemoved = new AddedRemoved();
addedRemoved.setAdded(asscnsAdded.size());
Expand All @@ -114,9 +114,10 @@ public AddedRemoved getAssociationVersionStats(List<Association> prevAscns, List
return addedRemoved;
}

public Association processAssociationTag(ElementChange elementChange){
public String processAssociationTag(ElementChange elementChange){
if (elementChange.getElementChangeType().equals("ValueAdded")){
return associationsService.getAssociation(elementChange.getValue().toString() );
//return associationsService.getAssociation(elementChange.getValue().toString() );
return elementChange.getValue().toString();
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service
public class AssociationsServiceImpl implements AssociationsService {
Expand All @@ -39,10 +40,10 @@ public class AssociationsServiceImpl implements AssociationsService {

@Override
public Association getAssociation(String associationId) {
log.info("Retrieving association: {}", associationId);
//log.info("Retrieving association: {}", associationId);
Optional<Association> associationOptional = associationRepository.findById(associationId);
if (associationOptional.isPresent()) {
log.info("Found association: {}", associationOptional.get().getStudyTag());
//log.info("Found association: {}", associationOptional.get().getStudyTag());
return associationOptional.get();
}
log.error("Unable to find association: {}", associationId);
Expand Down Expand Up @@ -100,4 +101,9 @@ public SnpStatusReportDto getSnpStatus(String submissionId) {
snpStatusReportDto.setNoValidSnps(associationRepository.countByIsValidAndSubmissionId(true, submissionId));
return snpStatusReportDto;
}

@Override
public Stream<Association> readBySeqIds(List<String> ids) {
return associationRepository.readByIdIn(ids);
}
}
Loading

0 comments on commit 92a6d5f

Please sign in to comment.