Skip to content

Commit 147b7ef

Browse files
authored
Permit label generator when existing sample label DNE (#135)
* Permit label generator when existing sample label DNE Permits the label generator to run when a sample with existing data does not already have a label assigned to it even if there aren't any changes to the label metadata itself. Signed-off-by: Angelica Ochoa <15623749+ao508@users.noreply.github.com> * PR template update Signed-off-by: Angelica Ochoa <15623749+ao508@users.noreply.github.com> --------- Signed-off-by: Angelica Ochoa <15623749+ao508@users.noreply.github.com>
1 parent 07900be commit 147b7ef

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ Please describe how the workflow and messaging was tested/simulated:
4444

4545
**Describe your testing environment:**
4646

47-
- NATS [local, local docker, dev server, production]
48-
- Neo4j [local, local docker, dev server, production]
49-
- SMILE Server [local, local docker, dev server, production]
50-
- Message publishing simulation [nats cli, docker nats cli, smile publisher tool, other (describe below)]
47+
- NATS: [local, local docker, dev server, production]
48+
- Neo4j: [local, local docker, dev server, production]
49+
- SMILE Server: [local, local docker, dev server, production]
50+
- Message publishing simulation: [nats cli, docker nats cli, smile publisher tool, other (describe below)]
5151

5252
Other: [insert details on how messages were published or simulated for testing]
5353

src/main/java/org/mskcc/smile/service/impl/CmoLabelGeneratorServiceImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,11 @@ public Boolean sampleHasLabelSpecificUpdates(CmoLabelParts sample,
125125
for (CmoLabelParts existingSample : existingPatientSamples) {
126126
if (existingSample.getPrimaryId().equals(sample.getPrimaryId())) {
127127
try {
128-
return !jsonComparator.isConsistent(mapper.writeValueAsString(sample),
128+
// if there are data differences or the existing sample does not have a label then
129+
// return true to permit label generation
130+
Boolean isConsistentData = jsonComparator.isConsistent(mapper.writeValueAsString(sample),
129131
mapper.writeValueAsString(existingSample));
132+
return (!isConsistentData || StringUtils.isBlank(existingSample.getCmoSampleName()));
130133
} catch (JsonProcessingException ex) {
131134
LOG.error("Encountered JSON processing error while comparing sample "
132135
+ "label parts to existing sample label parts.", ex);

src/test/java/org/mskcc/smile/CmoLabelGeneratorServiceTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,11 +734,18 @@ public void testHasApplicableMetadataUpdatesToIsCmoSampleStatus() throws Excepti
734734
// labels should be ignored during comparison
735735
Assertions.assertTrue(
736736
cmoLabelGeneratorService.sampleHasLabelSpecificUpdates(sm1Updated, Arrays.asList(sm1)));
737-
// assert false if isCmoSample is also false (i.e., no change at all in label parts data)
738-
CmoLabelParts sm1UpdatedFalse = initSmileSampleLabelParts("12345_C_7", "", "C-BRCD03", "ABF-89D",
737+
// assert true if no change at all metadata but existing sample does not already have a label
738+
CmoLabelParts sm1NoUpdatesNoLabel = initSmileSampleLabelParts("12345_C_7", "", "C-BRCD03", "ABF-89D",
739739
"Normal", "cfDNA", NucleicAcid.DNA, "Plasma", "cfDNA", "12345_C", "Normal", Boolean.FALSE);
740-
Assertions.assertFalse(
741-
cmoLabelGeneratorService.sampleHasLabelSpecificUpdates(sm1UpdatedFalse, Arrays.asList(sm1)));
740+
Assertions.assertTrue(cmoLabelGeneratorService.sampleHasLabelSpecificUpdates(sm1NoUpdatesNoLabel,
741+
Arrays.asList(sm1)));
742+
743+
// assert false if no change at all in metadata and existing sample already has a label
744+
sm1.setCmoSampleName("C-BRCD03-L001-d01");
745+
CmoLabelParts sm1NoUpdatesWLabel = initSmileSampleLabelParts("12345_C_7", "", "C-BRCD03", "ABF-89D",
746+
"Normal", "cfDNA", NucleicAcid.DNA, "Plasma", "cfDNA", "12345_C", "Normal", Boolean.FALSE);
747+
Assertions.assertFalse(cmoLabelGeneratorService.sampleHasLabelSpecificUpdates(sm1NoUpdatesWLabel,
748+
Arrays.asList(sm1)));
742749
}
743750

744751
private CmoLabelParts getSampleWithPrimaryIdAndLabel(String primaryId, String cmoSampleName)

0 commit comments

Comments
 (0)