-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10039 from BasLee/custom_data_binning_endpoint
Binning of custom data
- Loading branch information
Showing
46 changed files
with
1,979 additions
and
687 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.cbioportal.model; | ||
|
||
/** | ||
* Data that can be binned, clinical or custom | ||
*/ | ||
public interface Binnable { | ||
String getAttrId(); | ||
String getAttrValue(); | ||
String getSampleId(); | ||
String getPatientId(); | ||
String getStudyId(); | ||
Boolean isPatientAttribute(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
service/src/main/java/org/cbioportal/service/AttributeByStudyService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.cbioportal.service; | ||
|
||
import org.cbioportal.model.ClinicalAttribute; | ||
|
||
import java.util.List; | ||
|
||
public interface AttributeByStudyService { | ||
List<ClinicalAttribute> getClinicalAttributesByStudyIdsAndAttributeIds(List<String> studyIds, List<String> attributeIds); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
service/src/main/java/org/cbioportal/service/CustomDataService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.cbioportal.service; | ||
|
||
import org.cbioportal.service.util.CustomDataSession; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public interface CustomDataService { | ||
Map<String, CustomDataSession> getCustomDataSessions(List<String> attributes); | ||
} |
58 changes: 58 additions & 0 deletions
58
service/src/main/java/org/cbioportal/service/impl/CustomDataServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.cbioportal.service.impl; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.cbioportal.service.CustomDataService; | ||
import org.cbioportal.service.util.CustomDataSession; | ||
import org.cbioportal.service.util.SessionServiceRequestHandler; | ||
import org.cbioportal.session_service.domain.SessionType; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.stream.Collectors; | ||
|
||
@Service | ||
public class CustomDataServiceImpl implements CustomDataService { | ||
@Autowired | ||
private SessionServiceRequestHandler sessionServiceRequestHandler; | ||
|
||
@Autowired | ||
private ObjectMapper sessionServiceObjectMapper; | ||
|
||
/** | ||
* Retrieve CustomDataSession from session service for custom data attributes. | ||
* @param customAttributeIds - attribute id/hash of custom data used as session service key. | ||
* @return Map of custom data attribute id to the CustomDataSession | ||
*/ | ||
@Override | ||
public Map<String, CustomDataSession> getCustomDataSessions(List<String> customAttributeIds) { | ||
Map<String, CompletableFuture<CustomDataSession>> postFuturesMap = customAttributeIds.stream() | ||
.collect(Collectors.toMap( | ||
attributeId -> attributeId, | ||
attributeId -> CompletableFuture.supplyAsync(() -> { | ||
try { | ||
String customDataSessionJson = sessionServiceRequestHandler.getSessionDataJson( | ||
SessionType.custom_data, | ||
attributeId | ||
); | ||
return sessionServiceObjectMapper.readValue(customDataSessionJson, CustomDataSession.class); | ||
} catch (Exception e) { | ||
return null; | ||
} | ||
}) | ||
)); | ||
|
||
CompletableFuture.allOf(postFuturesMap.values().toArray(new CompletableFuture[postFuturesMap.size()])).join(); | ||
|
||
Map<String, CustomDataSession> customDataSessions = postFuturesMap.entrySet().stream() | ||
.filter(entry -> entry.getValue().join() != null) | ||
.collect(Collectors.toMap( | ||
entry -> entry.getKey(), | ||
entry -> entry.getValue().join() | ||
)); | ||
|
||
return customDataSessions; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
service/src/main/java/org/cbioportal/service/util/BinnableCustomDataValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.cbioportal.service.util; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import org.cbioportal.model.Binnable; | ||
|
||
import java.io.Serializable; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class BinnableCustomDataValue implements Binnable, Serializable { | ||
|
||
private final CustomDataValue customDataValue; | ||
private final String attrId; | ||
private final Boolean patientAttribute; | ||
|
||
public BinnableCustomDataValue( | ||
CustomDataValue customDataValue, | ||
String attributeId, | ||
Boolean patientAttribute | ||
) { | ||
this.customDataValue = customDataValue; | ||
this.attrId = attributeId; | ||
this.patientAttribute = patientAttribute; | ||
} | ||
|
||
public String getSampleId() { | ||
return customDataValue.getSampleId(); | ||
} | ||
|
||
public String getPatientId() { | ||
return customDataValue.getPatientId(); | ||
} | ||
|
||
public String getStudyId() { | ||
return customDataValue.getStudyId(); | ||
} | ||
|
||
public String getAttrId() { | ||
return attrId; | ||
} | ||
|
||
public Boolean isPatientAttribute() { | ||
return patientAttribute; | ||
} | ||
|
||
public String getAttrValue() { | ||
return customDataValue.getValue(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ioportal/web/CustomAttributeWithData.java → ...service/util/CustomAttributeWithData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
...rtal/web/parameter/CustomDataSession.java → ...ortal/service/util/CustomDataSession.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...portal/web/parameter/CustomDataValue.java → ...oportal/service/util/CustomDataValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.cbioportal.web.parameter; | ||
package org.cbioportal.service.util; | ||
|
||
import java.io.Serializable; | ||
|
||
|
16 changes: 16 additions & 0 deletions
16
service/src/main/java/org/cbioportal/service/util/SessionServiceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.cbioportal.service.util; | ||
|
||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SessionServiceConfig { | ||
|
||
@Bean | ||
public ObjectMapper sessionServiceObjectMapper() { | ||
return new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.