Skip to content

Commit

Permalink
fix a lot of bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dert1129 committed Nov 11, 2024
1 parent 58b04df commit d3c1a87
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public SpatialViewerDatasetDisplay(SpatialViewerFileDataset svFile){
configType = svFile.getConfigType();
imageType = svFile.getImageType();
dataType = svFile.getDataType();
dlFileId = svFile.getId().getDlFileId();
dlFileId = svFile.getDlFileId();
fileName = svFile.getFileName();
packageId = svFile.getPackageId();
fileSize = svFile.getFileSize();
Expand Down Expand Up @@ -86,7 +86,7 @@ public SpatialViewerDatasetDisplay(SpatialViewerFileDataset svFile){
race = new HashSet<String>();


redcapId.add(svFile.getId().getRedcapId());
redcapId.add(svFile.getRedcapId());
if(shouldAdd(svFile.getAge())){
age.add(svFile.getAge());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public List<SpatialViewerDataset> getSpatialViewerDataset() throws Exception {
Map<String, SpatialViewerDatasetDisplay> displayFiles = new HashMap<>();
Map<String, SpatialViewerExternalLinkDatasetDisplay> displayLinks = new HashMap<>();
for(SpatialViewerFileDataset spatialViewerFileDataset : datasetFiles){
if(displayFiles.containsKey(spatialViewerFileDataset.getId().getDlFileId())){
if(displayFiles.containsKey(spatialViewerFileDataset.getDlFileId())){
// update all of the list items in that display file
SpatialViewerDatasetDisplay displayFile = displayFiles.get(spatialViewerFileDataset.getId().getDlFileId());
SpatialViewerDatasetDisplay displayFile = displayFiles.get(spatialViewerFileDataset.getDlFileId());
displayFile.addA1c(spatialViewerFileDataset.getA1c());
displayFile.addAge(spatialViewerFileDataset.getAge());
displayFile.addAlbuminuria(spatialViewerFileDataset.getAlbuminuria());
Expand All @@ -92,30 +92,35 @@ public List<SpatialViewerDataset> getSpatialViewerDataset() throws Exception {
displayFile.addProteinuria(spatialViewerFileDataset.getProteinuria());
displayFile.addProtocol(spatialViewerFileDataset.getProtocol());
displayFile.addRace(spatialViewerFileDataset.getRace());
displayFile.addRedcapId(spatialViewerFileDataset.getId().getRedcapId());
displayFile.addRedcapId(spatialViewerFileDataset.getRedcapId());
displayFile.addSampleType(spatialViewerFileDataset.getSampleType());
displayFile.addSex(spatialViewerFileDataset.getSex());
displayFile.addTissueSource(spatialViewerFileDataset.getTissueSource());
displayFiles.put(spatialViewerFileDataset.getId().getDlFileId(), displayFile);
displayFiles.put(spatialViewerFileDataset.getDlFileId(), displayFile);
}else{
SpatialViewerDatasetDisplay displayFile = new SpatialViewerDatasetDisplay(spatialViewerFileDataset);
if(Double.compare(spatialViewerFileDataset.getReleaseVersion(), maxReleaseVersion) == EQUALITY_OPERATOR){
displayFile.setReleaseVersion("Recently Released - " + recentlyReleasedDate);
}else {
displayFile.setReleaseVersion(null);
}
displayFiles.put(spatialViewerFileDataset.getId().getDlFileId(), displayFile);
displayFiles.put(spatialViewerFileDataset.getDlFileId(), displayFile);
}

}
for(SpatialViewerExternalLinkDataset spatialViewerExternalLinkDataset : datasetLinks){
if(displayLinks.containsKey(spatialViewerExternalLinkDataset.getDlFileId())){
// update all of the list items in that display link
SpatialViewerExternalLinkDatasetDisplay displayLink = displayLinks.get(spatialViewerExternalLinkDataset.getDlFileId());
// do adders
}
SpatialViewerExternalLinkDatasetDisplay displayLink = new SpatialViewerExternalLinkDatasetDisplay(spatialViewerExternalLinkDataset);
if(Double.compare(spatialViewerExternalLinkDataset.getReleaseVersion(), maxLinkReleaseVersion) == EQUALITY_OPERATOR){
displayLink.setReleaseVersion("Recently Released - " + recentlyReleasedDate);
}else{
displayLink.setReleaseVersion(null);
}
displayLinks.put(spatialViewerExternalLinkDataset.getId().getDlFileId(), displayLink);
displayLinks.put(spatialViewerExternalLinkDataset.getId().getRedcapId(), displayLink);
}
datasetsFinal.addAll(displayFiles.values());
datasetsFinal.addAll(displayLinks.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class SpatialViewerExternalLinkDataset {
private String imageType;
private String dataType;
private String spectrackSampleId;
private String redcapId;
private int participantId;
private String age;
private String protocol;
Expand All @@ -33,6 +32,7 @@ public class SpatialViewerExternalLinkDataset {
private String tissueSource;
private String enrollmentCategory;
private Double releaseVersion;
@Column(name = "primary_adjudicated_cat")
private String primaryAdjudicatedCategory;
private String kdigoStage;
private String baselineEgfr;
Expand Down Expand Up @@ -196,15 +196,6 @@ public void setSpectrackSampleId(String spectrackSampleId) {
}


public String getRedcapId() {
return redcapId;
}

public void setRedcapId(String redcapId) {
this.redcapId = redcapId;
}


public int getParticipantId() {
return participantId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,11 @@

import java.io.Serializable;

import jakarta.persistence.Column;
// import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
@Embeddable
public class SpatialViewerExternalLinkId implements Serializable{
private String dlFileId;
private String redcapId;
private String experimentalStrategy;
private String doi;

@Column(name = "dl_file_id")
public String getDlFileId() {
return this.dlFileId;
}

public void setDlFileId(String dlFileId) {
this.dlFileId = dlFileId;
}

public String getRedcapId() {
return this.redcapId;
Expand All @@ -27,22 +15,4 @@ public String getRedcapId() {
public void setRedcapId(String redcapId) {
this.redcapId = redcapId;
}

public String getExperimentalStrategy() {
return this.experimentalStrategy;
}

public void setExperimentalStrategy(String experimentalStrategy) {
this.experimentalStrategy = experimentalStrategy;
}

public String getDoi() {
return this.doi;
}

public void setDoi(String doi) {
if (doi != null && !doi.isEmpty()){
this.doi = doi;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
@Table(name = "sv_file_v")
public class SpatialViewerFileDataset {



@EmbeddedId
private SpatialViewerFileDatasetId id;
@Id
@Column(name = "file_id")
private int fileId;
Expand Down Expand Up @@ -69,15 +65,6 @@ public class SpatialViewerFileDataset {
)
@ManyToMany(fetch = FetchType.EAGER)
private List<File> relatedFiles;

public SpatialViewerFileDatasetId getId(){
return this.id;
}

public void setId(SpatialViewerFileDatasetId id){
this.id = id;
}


public int getFileId() {
return fileId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
public class SpatialViewerFileDatasetId implements Serializable{
private String dlFileId;
private String redcapId;
private String experimentalStrategy;
private String doi;

@Column(name = "dl_file_id")
public String getDlFileId() {
Expand All @@ -27,22 +25,4 @@ public String getRedcapId() {
public void setRedcapId(String redcapId) {
this.redcapId = redcapId;
}

public String getExperimentalStrategy() {
return this.experimentalStrategy;
}

public void setExperimentalStrategy(String experimentalStrategy) {
this.experimentalStrategy = experimentalStrategy;
}

public String getDoi() {
return this.doi;
}

public void setDoi(String doi) {
if (doi != null && !doi.isEmpty()){
this.doi = doi;
}
}
}
46 changes: 35 additions & 11 deletions src/main/resources/graphql/knowledge_environment.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ type SpatialViewerDataset {
configType: String
imageType: String
dataType: String
redcapId: String
age: String
protocol: String
redcapId: [String]
age: [String]
protocol: [String]
sampleType: String
sex: String
tissueSource: String
enrollmentCategory: String
sex: [String]
tissueSource: [String]
enrollmentCategory: [String]
spectrackSampleId: String
level: String # may be null
relatedFiles: [File] # may be null
Expand All @@ -34,6 +34,18 @@ type SpatialViewerDataset {
fileNameSort: String
participantIdSort: Int
imageTypeSort: String
primaryAdjudicatedCategory: String
kdigoStage: String
baselineEgfr: String
proteinuria: String
a1c: String
albuminuria: String
diabetesDuration: String
diabetesHistory: String
hypertensionDuration: String
hypertensionHistory: String
race: String
onRaasBlockade: String
}

type SpatialViewerExternalLink {
Expand All @@ -42,15 +54,27 @@ type SpatialViewerExternalLink {
imageType: String
dataType: String
spectrackSampleId: String
redcapId: String
redcapId: [String]
participantId: Int
age: String
protocol: String
protocol: [String]
sampleType: String
sex: String
tissueSource: String
enrollmentCategory: String
sex: [String]
tissueSource: [String]
enrollmentCategory: [String]
participantIdSort: Int
imageTypeSort: String
releaseVersion: String
primaryAdjudicatedCategory: String
kdigoStage: String
baselineEgfr: String
proteinuria: String
a1c: String
albuminuria: String
diabetesDuration: String
diabetesHistory: String
hypertensionDuration: String
hypertensionHistory: String
race: String
onRaasBlockade: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class SpatialViewerDatasetDisplayTest {
public void setUp() throws Exception {
MockitoAnnotations.openMocks(this);

when(spatialViewerFileDataset.getId()).thenReturn(spatialViewerFileDatasetId);
spatialViewerDatasetDisplay = new SpatialViewerDatasetDisplay(spatialViewerFileDataset);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.json.JSONException;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -68,38 +69,30 @@ public void testGetSpatialViewerFileDataset() throws JSONException, Exception {
assertEquals(expectedResult, service.getSpatialViewerFileDataset());
}

@Test
@SuppressWarnings("unchecked")
@Test
public void testLoadEnterpriseSearch() throws JSONException, Exception {
when(env.getProperty("ES_API_TOKEN")).thenReturn("TOKEN");
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer "+ "TOKEN");
headers.setContentType(MediaType.APPLICATION_JSON);

ArrayList<SpatialViewerDataset> results = new ArrayList<>();
List<SpatialViewerExternalLinkDataset> expectedResult1 = new ArrayList<>();
List<SpatialViewerFileDataset> expectedResult2 = new ArrayList<>();
SpatialViewerExternalLinkDataset spatialViewerDataset1 = new SpatialViewerExternalLinkDataset();
SpatialViewerExternalLinkDataset spatialViewerDataset2 = new SpatialViewerExternalLinkDataset();
SpatialViewerFileDataset spatialViewerDataset3 = new SpatialViewerFileDataset();
spatialViewerDataset3.setDlFileId("DlFileId");
spatialViewerDataset3.setReleaseVersion(45.0);
SpatialViewerFileDataset spatialViewerDataset4 = new SpatialViewerFileDataset();
spatialViewerDataset4.setReleaseVersion(34.0);
spatialViewerDataset4.setDlFileId("DlFileId2");
expectedResult1.add(spatialViewerDataset1);
expectedResult1.add(spatialViewerDataset2);
expectedResult2.add(spatialViewerDataset3);
expectedResult2.add(spatialViewerDataset4);
when(fileRepo.max()).thenReturn(34.0);
when(externalLinkRepo.findAll()).thenReturn(expectedResult1);
when(fileRepo.findAll()).thenReturn(expectedResult2);
results.addAll(expectedResult1);
results.addAll(expectedResult2);
ArrayList<SpatialViewerDataset> results = new ArrayList<>();
List<SpatialViewerFileDataset> datasetFiles = new ArrayList<>();
List<SpatialViewerExternalLinkDataset> datasetLinks = new ArrayList<>();
SpatialViewerFileDataset spatialViewerFileDataset = new SpatialViewerFileDataset();
SpatialViewerExternalLinkDataset spatialViewerExternalLinkDataset = new SpatialViewerExternalLinkDataset();
datasetFiles.add(spatialViewerFileDataset);
datasetLinks.add(spatialViewerExternalLinkDataset);
when(fileRepo.findAll()).thenReturn(datasetFiles);
when(externalLinkRepo.findAll()).thenReturn(datasetLinks);


HttpEntity<Object> entity = new HttpEntity<>(results, headers);
SpatialViewerDatasetService.ESResponse[] esResponses = {new SpatialViewerDatasetService.ESResponse()};
when(restTemplate.postForObject("host/api/as/v1/engines/search-engine/documents", entity, SpatialViewerDatasetService.ESResponse[].class)).thenReturn(esResponses);
service.loadEnterpriseSearch();
verify(restTemplate).postForObject("host/api/as/v1/engines/search-engine/documents", entity, SpatialViewerDatasetService.ESResponse[].class);
}

}
Loading

0 comments on commit d3c1a87

Please sign in to comment.