Skip to content

Commit b799468

Browse files
authored
Merge pull request #659 from overture-stack/rc/4.2.4
Rc/4.2.4
2 parents 07ece40 + 5adab7e commit b799468

File tree

17 files changed

+437
-105
lines changed

17 files changed

+437
-105
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<groupId>bio.overture</groupId>
2222
<artifactId>song</artifactId>
2323
<packaging>pom</packaging>
24-
<version>4.2.3</version>
24+
<version>4.2.4</version>
2525
<modules>
2626
<module>song-core</module>
2727
<module>song-java-sdk</module>

song-client/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<parent>
1919
<artifactId>song</artifactId>
2020
<groupId>bio.overture</groupId>
21-
<version>4.2.3</version>
21+
<version>4.2.4</version>
2222
</parent>
2323
<modelVersion>4.0.0</modelVersion>
2424

@@ -35,12 +35,12 @@
3535
<dependency>
3636
<groupId>bio.overture</groupId>
3737
<artifactId>song-java-sdk</artifactId>
38-
<version>4.2.3</version>
38+
<version>4.2.4</version>
3939
</dependency>
4040
<dependency>
4141
<groupId>bio.overture</groupId>
4242
<artifactId>song-core</artifactId>
43-
<version>4.2.3</version>
43+
<version>4.2.4</version>
4444
</dependency>
4545

4646
<!-- CLI -->

song-core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>song</artifactId>
2121
<groupId>bio.overture</groupId>
22-
<version>4.2.3</version>
22+
<version>4.2.4</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

song-core/src/main/java/bio/overture/song/core/exceptions/ServerErrors.java

+3
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ public enum ServerErrors implements ServerError {
9191
DONOR_ALREADY_EXISTS(CONFLICT),
9292
SPECIMEN_ALREADY_EXISTS(CONFLICT),
9393
SAMPLE_TO_SPECIMEN_ID_MISMATCH(CONFLICT),
94+
MISMATCHING_SAMPLE_DATA(CONFLICT),
95+
MISMATCHING_SPECIMEN_DATA(CONFLICT),
96+
MISMATCHING_DONOR_DATA(CONFLICT),
9497
SPECIMEN_TO_DONOR_ID_MISMATCH(CONFLICT),
9598
VARIANT_CALL_CORRUPTED_DUPLICATE(INTERNAL_SERVER_ERROR),
9699
SEQUENCING_READ_CORRUPTED_DUPLICATE(INTERNAL_SERVER_ERROR),

song-core/src/main/java/bio/overture/song/core/utils/RandomGenerator.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.fasterxml.uuid.impl.RandomBasedGenerator;
2929
import com.google.common.collect.ImmutableList;
3030
import com.google.common.hash.Hashing;
31+
import java.util.Collection;
3132
import java.util.EnumSet;
3233
import java.util.List;
3334
import java.util.Random;
@@ -249,15 +250,15 @@ public <T> T randomElement(List<T> list) {
249250
}
250251

251252
/**
252-
* Select a random element from a list, ignoring a set of values. This is useful for selecting
253-
* random and different enum values
253+
* Select a random element from a collection, ignoring a set of values. This is useful for
254+
* selecting random and different enum values
254255
*
255-
* @param list input list to select from
256+
* @param collection input collection to select from
256257
* @param ignoreSet set of values to exclude from randomization
257258
*/
258-
public <T> T randomElementIgnoring(List<T> list, Set<T> ignoreSet) {
259+
public <T> T randomElementIgnoring(Collection<T> collection, Set<T> ignoreSet) {
259260
val filteredList =
260-
list.stream().filter(x -> !ignoreSet.contains(x)).collect(toUnmodifiableList());
261+
collection.stream().filter(x -> !ignoreSet.contains(x)).collect(toUnmodifiableList());
261262
log.debug(
262263
"Selecting RandomElementIgnoring for RandomGenerator[{}] with seed '{}' and callCount '{}'",
263264
id,

song-java-sdk/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<parent>
1919
<artifactId>song</artifactId>
2020
<groupId>bio.overture</groupId>
21-
<version>4.2.3</version>
21+
<version>4.2.4</version>
2222
</parent>
2323
<modelVersion>4.0.0</modelVersion>
2424

song-server/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>song</artifactId>
2121
<groupId>bio.overture</groupId>
22-
<version>4.2.3</version>
22+
<version>4.2.4</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>bio.overture</groupId>
3939
<artifactId>song-core</artifactId>
40-
<version>4.2.3</version>
40+
<version>4.2.4</version>
4141
</dependency>
4242

4343
<!-- Spring -->

song-server/src/main/java/bio/overture/song/server/service/CompositeEntityService.java

+37-13
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
package bio.overture.song.server.service;
1919

20+
import static bio.overture.song.core.exceptions.ServerErrors.MISMATCHING_SAMPLE_DATA;
21+
import static bio.overture.song.core.exceptions.ServerErrors.MISMATCHING_SPECIMEN_DATA;
2022
import static bio.overture.song.core.exceptions.ServerErrors.SAMPLE_TO_SPECIMEN_ID_MISMATCH;
2123
import static bio.overture.song.core.exceptions.ServerErrors.SPECIMEN_TO_DONOR_ID_MISMATCH;
2224
import static bio.overture.song.core.exceptions.ServerException.checkServer;
2325
import static java.util.Objects.isNull;
2426

2527
import bio.overture.song.server.model.entity.Sample;
28+
import bio.overture.song.server.model.entity.Specimen;
2629
import bio.overture.song.server.model.entity.composites.CompositeEntity;
2730
import lombok.AllArgsConstructor;
2831
import lombok.extern.slf4j.Slf4j;
@@ -74,26 +77,38 @@ public String save(String studyId, CompositeEntity s) {
7477
specimen.getSubmitterSpecimenId().equals(submitterSpecimenId),
7578
getClass(),
7679
SAMPLE_TO_SPECIMEN_ID_MISMATCH,
77-
"Existing sample (sampleId='%s') has specimenId='%s', but this submission says it has "
78-
+ "specimenId='%s' instead. Please re-submit with the correct specimenId.",
80+
"Existing sample (submitterSampleId='%s') has submitterSpecimenId='%s', but this submission says it has "
81+
+ "submitterSpecimenId='%s' instead. Please re-submit with the correct submitterSpecimenId.",
7982
submitterSampleId,
8083
specimen.getSubmitterSpecimenId(),
8184
submitterSpecimenId);
8285
s.setSampleId(id);
83-
sampleService.update(s);
86+
checkSameSample(sample, s);
8487
}
8588
return id;
8689
}
8790

91+
private void checkSameSample(Sample existing, CompositeEntity input) {
92+
val newSample = new Sample();
93+
newSample.setWithSample(input);
94+
checkServer(
95+
existing.equals(newSample),
96+
getClass(),
97+
MISMATCHING_SAMPLE_DATA,
98+
"Input Sample data does not match the existing Sample data for submitterSampleId '%s'. Ensure the data matches.",
99+
existing.getSubmitterSampleId());
100+
}
101+
88102
private String getSampleParent(String studyId, CompositeEntity s) {
89-
val specimen = s.getSpecimen();
90-
String id = specimenService.findByBusinessKey(studyId, specimen.getSubmitterSpecimenId());
103+
val inputSpecimen = s.getSpecimen();
104+
String specimenId =
105+
specimenService.findByBusinessKey(studyId, inputSpecimen.getSubmitterSpecimenId());
91106

92-
if (isNull(id)) {
93-
specimen.setDonorId(getSpecimenParent(studyId, s));
94-
id = specimenService.create(studyId, specimen);
107+
if (isNull(specimenId)) {
108+
inputSpecimen.setDonorId(getSpecimenParent(studyId, s));
109+
specimenId = specimenService.create(studyId, inputSpecimen);
95110
} else {
96-
val existingSpecimen = specimenService.securedRead(studyId, id);
111+
val existingSpecimen = specimenService.securedRead(studyId, specimenId);
97112
val existingDonor = donorService.securedRead(studyId, existingSpecimen.getDonorId());
98113
checkServer(
99114
s.getDonor().getSubmitterDonorId().equals(existingDonor.getSubmitterDonorId()),
@@ -104,11 +119,20 @@ private String getSampleParent(String studyId, CompositeEntity s) {
104119
existingSpecimen.getSubmitterSpecimenId(),
105120
existingDonor.getSubmitterDonorId(),
106121
s.getDonor().getSubmitterDonorId());
107-
specimen.setSpecimenId(id);
108-
specimen.setDonorId(getSpecimenParent(studyId, s));
109-
specimenService.update(specimen);
122+
inputSpecimen.setSpecimenId(specimenId);
123+
inputSpecimen.setDonorId(getSpecimenParent(studyId, s));
124+
checkSameSpecimen(existingSpecimen, inputSpecimen);
110125
}
111-
return id;
126+
return specimenId;
127+
}
128+
129+
private void checkSameSpecimen(Specimen existing, Specimen input) {
130+
checkServer(
131+
existing.equals(input),
132+
getClass(),
133+
MISMATCHING_SPECIMEN_DATA,
134+
"Input Specimen data does not match the existing Specimen data for submitterSpecimenId '%s'. Ensure the data matches.",
135+
existing.getSubmitterSpecimenId());
112136
}
113137

114138
private String getSpecimenParent(String studyId, CompositeEntity s) {

song-server/src/main/java/bio/overture/song/server/service/DonorService.java

+14-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static bio.overture.song.core.exceptions.ServerErrors.DONOR_ID_IS_CORRUPTED;
2222
import static bio.overture.song.core.exceptions.ServerErrors.ENTITY_NOT_RELATED_TO_STUDY;
2323
import static bio.overture.song.core.exceptions.ServerErrors.ID_NOT_FOUND;
24+
import static bio.overture.song.core.exceptions.ServerErrors.MISMATCHING_DONOR_DATA;
2425
import static bio.overture.song.core.exceptions.ServerException.buildServerException;
2526
import static bio.overture.song.core.exceptions.ServerException.checkServer;
2627
import static bio.overture.song.core.exceptions.ServerException.checkServerOptional;
@@ -220,14 +221,23 @@ public String save(@NonNull String studyId, @NonNull Donor donor) {
220221
val donorWithSpecimens = new DonorWithSpecimens();
221222
donorWithSpecimens.setDonor(donor);
222223
String donorId;
223-
if (!donorIdResult.isPresent()) {
224+
if (donorIdResult.isEmpty()) {
224225
donorId = create(donorWithSpecimens);
225226
} else {
226227
donorId = donorIdResult.get();
227-
val updateDonor = donorWithSpecimens.createDonor();
228-
updateDonor.setDonorId(donorId);
229-
update(updateDonor);
228+
val existingDonor = unsecuredRead(donorId);
229+
donor.setDonorId(donorId);
230+
checkSameDonor(existingDonor, donor);
230231
}
231232
return donorId;
232233
}
234+
235+
private void checkSameDonor(Donor existing, Donor input) {
236+
checkServer(
237+
existing.equals(input),
238+
getClass(),
239+
MISMATCHING_DONOR_DATA,
240+
"Input Donor data does not match the existing Donor data for submitterDonorId '%s'. Ensure the data matches.",
241+
existing.getSubmitterDonorId());
242+
}
233243
}

song-server/src/main/java/bio/overture/song/server/service/InfoService.java

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import static bio.overture.song.core.utils.JsonUtils.toJsonNode;
2424
import static bio.overture.song.server.model.entity.Info.createInfo;
2525
import static bio.overture.song.server.model.entity.InfoPK.createInfoPK;
26-
import static bio.overture.song.server.model.enums.InfoTypes.SEQUENCING_READ;
2726
import static java.util.stream.Collectors.toList;
2827
import static java.util.stream.Collectors.toMap;
2928

@@ -159,5 +158,4 @@ public static class FileInfoService extends InfoService {
159158
super(InfoTypes.FILE, repo);
160159
}
161160
}
162-
163161
}

song-server/src/test/java/bio/overture/song/server/controller/AbstractEnforcedTester.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ public abstract class AbstractEnforcedTester {
7777
private boolean initialized;
7878
private JsonNode variantCallSchema;
7979

80+
protected abstract boolean isLoggingEnabled();
81+
8082
@Before
8183
public void beforeEachTest() {
8284
this.mockMvc = MockMvcBuilders.webAppContextSetup(getWebApplicationContext()).build();
8385
this.randomGenerator = createRandomGenerator(getClass().getSimpleName());
84-
this.endpointTester = createEndpointTester(mockMvc, true);
86+
this.endpointTester = createEndpointTester(mockMvc, isLoggingEnabled());
8587
lazyInit();
8688
}
8789

0 commit comments

Comments
 (0)