Skip to content

Commit

Permalink
REVERT ME: Remove the need for session service dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
pvannierop committed Dec 15, 2021
1 parent 2315278 commit a11cfd6
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 29 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,12 @@
<artifactId>simple-java-bitly</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.github.cbioportal</groupId>
<artifactId>session-service</artifactId>
<classifier>model</classifier>
<version>v0.5.0</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.github.cbioportal</groupId>-->
<!-- <artifactId>session-service</artifactId>-->
<!-- <classifier>model</classifier>-->
<!-- <version>v0.5.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions portal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
16 changes: 16 additions & 0 deletions utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,27 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>bson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
</dependencies>

</project>
90 changes: 90 additions & 0 deletions utils/src/main/java/org/cbioportal/utils/removeme/Session.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package org.cbioportal.utils.removeme;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonView;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.bson.Document;
import org.springframework.data.annotation.Id;
import org.springframework.util.DigestUtils;

// TODO this class was taken from session service. The session service dependency had to be dropped
// since it forced cbioportal into autoconfiguration of mongoDB connections.
// When session service is updated reinstate the correct session service dependency.

@JsonInclude(JsonInclude.Include.NON_NULL)
public class Session {

public enum SessionType {
main_session,
virtual_study,
group,
comparison_session,
settings,
custom_data,
genomic_chart,
custom_gene_list
}

@Id
private String id;
@NotNull
private String checksum;
@NotNull
private Object data;
@NotNull
@Size(min=3, message="source has a minimum length of 3")
private String source;
@NotNull
private SessionType type;


@JsonView(Session.Views.IdOnly.class)
public String getId() {
return id;
}

public String getChecksum() {
return checksum;
}

public void setData(Object data) {
if(data instanceof String) {
this.data = Document.parse((String)data);
} else {
this.data = data;
}
this.checksum = DigestUtils.md5DigestAsHex(this.data.toString().getBytes());
}

@JsonView(Session.Views.Full.class)
public Object getData() {
return data;
}

public void setType(SessionType type) {
this.type = type;
}

@JsonView(org.cbioportal.utils.removeme.Session.Views.Full.class)
public SessionType getType() {
return type;
}

public void setSource(String source) {
this.source = source;
}

@JsonView(Session.Views.Full.class)
public String getSource() {
return source;
}

public static final class Views {
// show only id
public interface IdOnly {}

// show all data
public interface Full extends Session.Views.IdOnly {}
}
}
18 changes: 11 additions & 7 deletions web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<groupId>org.cbioportal</groupId>
<artifactId>model</artifactId>
</dependency>
<dependency>
<groupId>org.cbioportal</groupId>
<artifactId>utils</artifactId>
</dependency>
<dependency>
<groupId>org.cbioportal</groupId>
<artifactId>service</artifactId>
Expand All @@ -54,14 +58,14 @@
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.github.cbioportal</groupId>-->
<!-- <artifactId>session-service</artifactId>-->
<!-- <classifier>model</classifier>-->
<!-- </dependency>-->
<dependency>
<groupId>com.github.cbioportal</groupId>
<artifactId>session-service</artifactId>
<classifier>model</classifier>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.apache.commons.logging.LogFactory;
import org.cbioportal.web.parameter.*;
import org.cbioportal.web.util.SessionServiceRequestHandler;
import org.cbioportal.session_service.domain.Session;
import org.cbioportal.session_service.domain.SessionType;
import org.cbioportal.utils.removeme.Session;
import org.cbioportal.utils.removeme.Session.SessionType;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
import org.cbioportal.model.Sample;
import org.cbioportal.model.SampleList;
import org.cbioportal.model.TypeOfCancer;
import org.cbioportal.session_service.domain.Session;
import org.cbioportal.utils.removeme.Session;
import org.cbioportal.web.CustomAttributeWithData;
import org.cbioportal.web.mixin.CancerStudyMixin;
import org.cbioportal.web.mixin.ClinicalAttributeCountMixin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cbioportal.session_service.domain.Session;
import org.cbioportal.session_service.domain.SessionType;
import org.cbioportal.utils.removeme.Session;
import org.cbioportal.web.CustomAttributeWithData;

import com.fasterxml.jackson.annotation.JsonIgnore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cbioportal.session_service.domain.Session;
import org.cbioportal.session_service.domain.SessionType;
import org.cbioportal.utils.removeme.Session;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cbioportal.session_service.domain.Session;
import org.cbioportal.session_service.domain.SessionType;
import org.cbioportal.utils.removeme.Session;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cbioportal.session_service.domain.Session;
import org.cbioportal.session_service.domain.SessionType;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.cbioportal.utils.removeme.Session;

@JsonIgnoreProperties(ignoreUnknown = true)
public class VirtualStudy extends Session {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.cbioportal.web.studyview;

import static org.cbioportal.utils.removeme.Session.*;


import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand All @@ -14,7 +17,6 @@
import org.cbioportal.model.ClinicalDataCountItem;
import org.cbioportal.model.Patient;
import org.cbioportal.service.PatientService;
import org.cbioportal.session_service.domain.SessionType;
import org.cbioportal.web.config.annotation.InternalApi;
import org.cbioportal.web.parameter.ClinicalDataCountFilter;
import org.cbioportal.web.parameter.ClinicalDataFilter;
Expand Down Expand Up @@ -83,7 +85,8 @@ public ResponseEntity<List<ClinicalDataCountItem>> fetchCustomDataCounts(
List<CompletableFuture<CustomDataSession>> postFutures = attributes.stream().map(clinicalDataFilter -> {
return CompletableFuture.supplyAsync(() -> {
try {
return (CustomDataSession) sessionServiceRequestHandler.getSession(SessionType.custom_data,
return (CustomDataSession) sessionServiceRequestHandler.getSession(
SessionType.custom_data,
clinicalDataFilter.getAttributeId());
} catch (Exception e) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.cbioportal.web.util;

import static org.cbioportal.utils.removeme.Session.*;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -11,7 +14,6 @@
import org.apache.commons.collections.map.MultiKeyMap;
import org.cbioportal.service.ClinicalDataService;
import org.cbioportal.service.PatientService;
import org.cbioportal.session_service.domain.SessionType;
import org.cbioportal.web.parameter.ClinicalDataFilter;
import org.cbioportal.web.parameter.CustomDataSession;
import org.cbioportal.web.parameter.SampleIdentifier;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.cbioportal.web.util;

import static org.cbioportal.utils.removeme.Session.*;


import java.nio.charset.Charset;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.cbioportal.session_service.domain.Session;
import org.cbioportal.session_service.domain.SessionType;
import org.cbioportal.utils.removeme.*;
import org.cbioportal.web.parameter.CustomDataSession;
import org.cbioportal.web.parameter.CustomGeneList;
import org.cbioportal.web.parameter.PageSettings;
Expand Down

0 comments on commit a11cfd6

Please sign in to comment.