Skip to content

Commit

Permalink
fix method names and add capitalization logic for weirdly capitalized…
Browse files Browse the repository at this point in the history
… filter data
  • Loading branch information
Dert1129 committed Nov 4, 2024
1 parent d7b60e7 commit b6012b1
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.mysql:mysql-connector-j:8.3.0'
implementation 'org.apache.commons:commons-text:1.12.0'

implementation 'com.graphql-java:graphql-spring-boot-starter:5.0.2'
implementation 'com.graphql-java:graphiql-spring-boot-starter:5.0.2'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package org.kpmp.repositoryDataset;

import java.util.Arrays;
import java.util.HashSet;
import java.util.TreeSet;
import java.util.stream.Collectors;

import org.apache.commons.text.WordUtils;

import java.util.Set;
import com.fasterxml.jackson.annotation.JsonProperty;

Expand Down Expand Up @@ -57,8 +62,8 @@ public RepositoryDatasetDisplay(RepositoryFileDataset repositoryFile) {
if (shouldAdd(repositoryFile.getSampleType())) {
sampleType.add(repositoryFile.getSampleType());
}
if (shouldAdd(repositoryFile.getenrollmentCategory())) {
enrollmentCategory.add(repositoryFile.getenrollmentCategory());
if (shouldAdd(repositoryFile.getEnrollmentCategory())) {
enrollmentCategory.add(repositoryFile.getEnrollmentCategory());
}
if(shouldAdd(repositoryFile.getAgeBinned())){
ageBinned.add(repositoryFile.getAgeBinned());
Expand Down Expand Up @@ -158,7 +163,7 @@ public void setSampleType(Set<String> sampleType) {
this.sampleType = sampleType;
}

public void addenrollmentCategory(String enrollmentCategory) {
public void addEnrollmentCategory(String enrollmentCategory) {
if(enrollmentCategory != null && !enrollmentCategory.isEmpty()){
this.enrollmentCategory.add(enrollmentCategory);
}
Expand Down Expand Up @@ -584,7 +589,7 @@ public String getDiabetesHistory() {
if(this.diabetesHistory == null || this.diabetesHistory.isEmpty()){
return null;
}else{
return this.diabetesHistory;
return fixCapitalizaion(this.diabetesHistory);
}
}

Expand All @@ -597,7 +602,7 @@ public String getHypertensionHistory() {
if(this.hypertensionHistory == null || this.hypertensionHistory.isEmpty()){
return null;
}else{
return this.hypertensionHistory;
return fixCapitalizaion(this.hypertensionHistory);
}
}

Expand Down Expand Up @@ -644,4 +649,7 @@ public void setOnRaasBlockade(String onRaasBlockade) {
this.onRaasBlockade = onRaasBlockade;
}

public String fixCapitalizaion(String input){
return WordUtils.capitalizeFully(input, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public List<RepositoryDatasetDisplay> getRepositoryDataset() throws Exception {
displayFile.addAgeBinned(repositoryDataset.getAgeBinned());
displayFile.addRedCapId(repositoryDataset.getId().getRedcapId());
displayFile.addSampleType(repositoryDataset.getSampleType());
displayFile.addenrollmentCategory(repositoryDataset.getenrollmentCategory());
displayFile.addEnrollmentCategory(repositoryDataset.getEnrollmentCategory());
displayFile.addSex(repositoryDataset.getSex());
displayFile.addProtocol(repositoryDataset.getProtocol());
displayFile.addTissueSource(repositoryDataset.getTissueSource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ public void setSampleType(String sampleType) {
this.sampleType = sampleType;
}

public String getenrollmentCategory() {
public String getEnrollmentCategory() {
return enrollmentCategory;
}

public void setenrollmentCategory(String enrollmentCategory) {
public void setEnrollmentCategory(String enrollmentCategory) {
this.enrollmentCategory = enrollmentCategory;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/kpmp/QueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void testGetRepositoryDataset() throws Exception {
repositoryFileDataset.setSampleType("SampleType");
repositoryFileDataset.setSex("Male");
repositoryFileDataset.setTissueSource("Kidneys");
repositoryFileDataset.setenrollmentCategory("organic");
repositoryFileDataset.setEnrollmentCategory("organic");
repositoryFileDataset.setWorkflowType("workflowType");
repositoryFileDatasetId.setDlFileId("dlFileId");
repositoryFileDataset.setPrimaryAdjudicatedCat("primaryAdjudicatedCategory");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void setSampleType() {
public void testAddenrollmentCategory() {

RepositoryDatasetDisplay repositoryDatasetDisplay = new RepositoryDatasetDisplay(repositoryFile);
repositoryDatasetDisplay.addenrollmentCategory("enrollment_category");
repositoryDatasetDisplay.addEnrollmentCategory("enrollment_category");

assertEquals(1, repositoryDatasetDisplay.getenrollmentCategory().size());
assertEquals(true, repositoryDatasetDisplay.getenrollmentCategory().contains("enrollment_category"));
Expand Down Expand Up @@ -344,8 +344,8 @@ public void setDiabetesDuration() {

@Test
public void setDiabetesHistory() {
repositoryDatasetDisplay.setDiabetesHistory("no");
assertEquals("no", repositoryDatasetDisplay.getDiabetesHistory());
repositoryDatasetDisplay.setDiabetesHistory("dOn't KNoW");
assertEquals("Don't Know", repositoryDatasetDisplay.getDiabetesHistory());
}

@Test
Expand All @@ -357,7 +357,7 @@ public void setHypertensionDuration() {
@Test
public void setHypertensionHistory() {
repositoryDatasetDisplay.setHypertensionHistory("yes");
assertEquals("yes", repositoryDatasetDisplay.getHypertensionHistory());
assertEquals("Yes", repositoryDatasetDisplay.getHypertensionHistory());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public void setSampleType() {

@Test
public void setenrollmentCategory() {
repositoryDataset.setenrollmentCategory("ttype");
assertEquals("ttype", repositoryDataset.getenrollmentCategory());
repositoryDataset.setEnrollmentCategory("ttype");
assertEquals("ttype", repositoryDataset.getEnrollmentCategory());
}

@Test
Expand Down

0 comments on commit b6012b1

Please sign in to comment.