Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
rmadupuri authored Sep 5, 2023
2 parents 47968c9 + f4f5b1c commit 18be7e2
Show file tree
Hide file tree
Showing 46 changed files with 1,650 additions and 559 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Describe changes proposed in this pull request:
- [ ] Has tests or has a separate issue that describes the types of test that should be created. If no test is included it should explicitly be mentioned in the PR why there is no test.
- [ ] The commit log is comprehensible. It follows [7 rules of great commit messages](http://chris.beams.io/posts/git-commit/). For most PRs a single commit should suffice, in some cases multiple topical commits can be useful. During review it is ok to see tiny commits (e.g. Fix reviewer comments), but right before the code gets merged to master or rc branch, any such commits should be squashed since they are useless to the other developers. Definitely avoid [merge commits, use rebase instead.](http://nathanleclaire.com/blog/2014/09/14/dont-be-scared-of-git-rebase/)
- [ ] Is this PR adding logic based on one or more **clinical** attributes? If yes, please make sure validation for this attribute is also present in the data validation / data loading layers (in backend repo) and documented in [File-Formats Clinical data section](https://github.com/cBioPortal/cbioportal/blob/master/docs/File-Formats.md#clinical-data)!
- [ ] Make sure your PR has one of the labels defined in https://github.com/cBioPortal/cbioportal/blob/master/.github/release-drafter.yml

# Any screenshots or GIFs?
If this is a new visual feature please add a before/after screenshot or gif
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- master
- release-*
- rc
- rfc*
- demo-*
- fusion-sv-migration
- redis-branch-up-to-date
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ jobs:
working-directory: ./cbioportal-docker-compose
run: |
cd ./data && ./init.sh && rm -rf ./studies/* && cd ../config && \
cat $PORTAL_SOURCE_DIR/portal/target/portal/WEB-INF/classes/portal.properties | \
sed 's/db.host=.*/db.host=cbioportal-database:3306/g' | \
sed 's|db.connection_string=.*|db.connection_string=jdbc:mysql://cbioportal-database:3306/|g' \
> portal.properties
cat $PORTAL_SOURCE_DIR/portal/target/classes/portal.properties | \
sed 's|db.host=.*||' | \
sed 's|db.portal_db_name=.*||' | \
sed 's|db.use_ssl=.*||' | \
sed 's|db.connection_string=.*|db.connection_string=jdbc:mysql://cbioportal-database:3306/cbioportal?useSSL=false\&allowPublicKeyRetrieval=true|' \
> portal.properties && more portal.properties
- name: 'Start cbioportal-docker-compose'
working-directory: ./cbioportal-docker-compose
run: |
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/label-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This GitHub Actions workflow is designed to automatically check pull requests in the cBioPortal repository for valid labels before they can be merged.
# The workflow ensures that pull requests have labels that are defined in the .github/release-drafter.yml file's "categories" section.
# If a pull request lacks a valid label, the workflow will fail, preventing the merge until valid labels are applied.
name: Label Check

on:
pull_request:
types:
- opened
- synchronize

jobs:
label-check:
runs-on: ubuntu-latest
steps:
- name: Check PR Labels
uses: actions/checkout@v2

- name: Install dependencies
run: |
wget https://github.com/mikefarah/yq/releases/download/v4.34.2/yq_linux_amd64 -O /usr/local/bin/yq
chmod +x /usr/local/bin/yq
- name: Get Labels from release-drafter.yml
id: get_labels
run: |
curl -s "https://raw.githubusercontent.com/cBioPortal/cbioportal/master/.github/release-drafter.yml" | \
yq -r '.categories[].labels[]' > labels.txt
- name: Check Labels
id: check_labels
run: |
PR_NUMBER=$(jq -r ".number" $GITHUB_EVENT_PATH)
PR_LABELS=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" | \
jq -r '.labels[].name')
mapfile -t AVAILABLE_LABELS < labels.txt
for LABEL in ${PR_LABELS[@]}; do
if [[ "$LABEL" == "skip-changelog" ]]; then
echo "PR contains a valid label: skip-changelog"
exit 0 # Valid label found, exit successfully
fi
for AVAILABLE_LABEL in "${AVAILABLE_LABELS[@]}"; do
if [[ "$AVAILABLE_LABEL" == "$LABEL" ]]; then
echo "PR contains a valid label: $LABEL"
exit 0 # Valid label found, exit successfully
fi
done
done
echo "No valid label found on PR."
echo "Available label options from release-drafter.yml:"
cat labels.txt
exit 1 # No valid label found, exit with an error
34 changes: 29 additions & 5 deletions core/src/main/java/org/mskcc/cbio/portal/dao/JdbcDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,44 @@
import org.apache.commons.dbcp2.BasicDataSource;
import org.mskcc.cbio.portal.util.DatabaseProperties;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;

/**
* Data source that self-initializes based on cBioPortal configuration.
*/
public class JdbcDataSource extends BasicDataSource {

public JdbcDataSource () {
DatabaseProperties dbProperties = DatabaseProperties.getInstance();

String host = dbProperties.getDbHost();
String userName = dbProperties.getDbUser();
String password = dbProperties.getDbPassword();
String mysqlDriverClassName = dbProperties.getDbDriverClassName();
String database = dbProperties.getDbName();
String useSSL = (!StringUtils.isBlank(dbProperties.getDbUseSSL())) ? dbProperties.getDbUseSSL() : "false";
String enablePooling = (!StringUtils.isBlank(dbProperties.getDbEnablePooling())) ? dbProperties.getDbEnablePooling(): "false";
String url ="jdbc:mysql://" + host + "/" + database +
"?user=" + userName + "&password=" + password +
"&zeroDateTimeBehavior=convertToNull&useSSL=" + useSSL;
String connectionURL = dbProperties.getConnectionURL();

Assert.isTrue(
!defined(host) && !defined(database) && !defined(dbProperties.getDbUseSSL()),
"\n----------------------------------------------------------------------------------------------------------------" +
"-- Connection error:\n" +
"-- You try to connect to the database using the deprecated 'db.host', 'db.portal_db_name' and 'db.use_ssl' properties.\n" +
"-- Please remove these properties and use the 'db.connection_string' property instead. See https://docs.cbioportal.org/deployment/customization/portal.properties-reference/\n" +
"-- for assistance on building a valid connection string.\n" +
"----------------------------------------------------------------------------------------------------------------\n"
);

Assert.hasText(userName, errorMessage("username", "db.user"));
Assert.hasText(password, errorMessage("password", "db.password"));
Assert.hasText(mysqlDriverClassName, errorMessage("driver class name", "db.driver"));

this.setUrl(connectionURL);

// Set up poolable data source
this.setDriverClassName(mysqlDriverClassName);
this.setUsername(userName);
this.setPassword(password);
this.setUrl(url);
// Disable this to avoid caching statements
this.setPoolPreparedStatements(Boolean.valueOf(enablePooling));
// these are the values cbioportal has been using in their production
Expand All @@ -37,4 +53,12 @@ public JdbcDataSource () {
this.setValidationQuery("SELECT 1");
this.setJmxName("org.cbioportal:DataSource=" + database);
}

private String errorMessage(String displayName, String propertyName) {
return String.format("No %s provided for database connection. Please set '%s' in portal.properties.", displayName, propertyName);
}

private boolean defined(String property) {
return property != null && !property.isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class DatabaseProperties {
private String dbDriverClassName;
private String dbUseSSL;
private String dbEnablePooling;
private String connectionURL;

// No production keys stored in filesystem or code: digest the key; put it in properties; load it into dbms on startup
private static DatabaseProperties dbProperties;
Expand All @@ -63,6 +64,7 @@ public static DatabaseProperties getInstance() {
dbProperties.setDbDriverClassName(GlobalProperties.getProperty("db.driver"));
dbProperties.setDbUseSSL(GlobalProperties.getProperty("db.use_ssl"));
dbProperties.setDbEnablePooling(GlobalProperties.getProperty("db.enable_pooling"));
dbProperties.setConnectionURL(GlobalProperties.getProperty("db.connection_string"));
}
return dbProperties;
}
Expand Down Expand Up @@ -134,4 +136,12 @@ public void setDbEnablePooling(String dbEnablePooling) {
this.dbEnablePooling = dbEnablePooling;
}

public String getConnectionURL() {
return connectionURL;
}

public void setConnectionURL(String connectionURL) {
this.connectionURL = connectionURL;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public class GlobalProperties {
public static final String SKIN_RIGHT_NAV_SHOW_EXAMPLES = "skin.right_nav.show_examples";
public static final String SKIN_RIGHT_NAV_SHOW_TESTIMONIALS = "skin.right_nav.show_testimonials";
public static final String SKIN_RIGHT_NAV_SHOW_WHATS_NEW = "skin.right_nav.show_whats_new";
public static final String SKIN_RIGHT_NAV_SHOW_WEB_TOURS = "skin.right_nav.show_web_tours";
private static String skinAuthorizationMessage;
@Value("${skin.authorization_message:Access to this portal is only available to authorized users.}")
public void setSkinAuthorizationMessage(String property) { skinAuthorizationMessage = property; }
Expand Down Expand Up @@ -182,6 +183,12 @@ public void setOncoprintClinicalTracksConfigJson(String property) {
oncoprintClinicalTracksConfigJson = property;
}

private static String skinPatientViewCustomSampleTypeColorsJson;
@Value("${skin.patient_view.custom_sample_type_colors_json:}") // default is empty string
public void setSkinPatientViewCustomSampleTypeColorsJson(String property) {
skinPatientViewCustomSampleTypeColorsJson = property;
}

// properties for showing the right logo in the header_bar and default logo
public static final String SKIN_RIGHT_LOGO = "skin.right_logo";

Expand Down Expand Up @@ -368,6 +375,16 @@ public static String parseUrl(String url)
@Value("${download_group:}") // default is empty string
public void setDownloadGroup(String property) { downloadGroup = property; }

public static final String DEFAULT_DAT_METHOD = "none";

private static String dataAccessTokenMethod;
@Value("${dat.method:none}") // default is empty string
public void setDataAccessTokenMethod(String property) { dataAccessTokenMethod = property; }

private static String tokenAccessUserRole;
@Value("${dat.filter_user_role:}") // default is empty string
public void setTokenAccessUserRole(String property) { tokenAccessUserRole = property; }

private static Logger LOG = LoggerFactory.getLogger(GlobalProperties.class);
private static ConfigPropertyResolver portalProperties = new ConfigPropertyResolver();
private static Properties mavenProperties = initializeProperties(MAVEN_PROPERTIES_FILE_NAME);
Expand Down Expand Up @@ -795,6 +812,12 @@ public static boolean showRightNavWhatsNew()
return showFlag == null || Boolean.parseBoolean(showFlag);
}

public static boolean showRightNavWebTours()
{
String showFlag = portalProperties.getProperty(SKIN_RIGHT_NAV_SHOW_WEB_TOURS);
return showFlag == null || Boolean.parseBoolean(showFlag);
}

public static String getAuthorizationMessage()
{
return skinAuthorizationMessage;
Expand Down Expand Up @@ -1240,6 +1263,14 @@ public static String getOncoprintClinicalTracksConfigJson() {
}
}

public static String getSkinPatientViewCustomSampleTypeColorsJson() {
if (skinPatientViewCustomSampleTypeColorsJson.length() > 0) {
return readFile(skinPatientViewCustomSampleTypeColorsJson);
} else {
return null;
}
}

public static String getQuerySetsOfGenes() {
String fileName = portalProperties.getProperty(SETSOFGENES_LOCATION, null);
return readFile(fileName);
Expand Down Expand Up @@ -1296,4 +1327,15 @@ public static String getDownloadControl() {
}
}
}

public static String getDataAccessTokenMethod() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

if (authentication != null &&
StringUtils.isNotEmpty(tokenAccessUserRole)) {
return authentication.getAuthorities().contains(new SimpleGrantedAuthority(tokenAccessUserRole)) ? dataAccessTokenMethod : DEFAULT_DAT_METHOD;
} else {
return dataAccessTokenMethod;
}
}
}
26 changes: 10 additions & 16 deletions core/src/main/java/org/mskcc/cbio/portal/util/SpringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,28 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class SpringUtil
{
public class SpringUtil {
private static final Logger log = LoggerFactory.getLogger(SpringUtil.class);

private static AccessControl accessControl;
private static ApplicationContext context;
private static GenericXmlApplicationContext applicationContext;
private static ApplicationContext applicationContext;

@Autowired
public void setAccessControl(AccessControl accessControl) {
log.debug("Setting access control");
SpringUtil.accessControl = accessControl;
}

public static AccessControl getAccessControl()
{
public static AccessControl getAccessControl() {
return accessControl;
}

public static synchronized void initDataSource()
{
if (SpringUtil.context == null) {
context = new ClassPathXmlApplicationContext("classpath:applicationContext-persistenceConnections.xml");
public static synchronized void initDataSource() {
if (SpringUtil.applicationContext == null) {
SpringUtil.applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext-persistenceConnections.xml");
}
}

Expand All @@ -74,7 +69,7 @@ public static synchronized void initDataSource()
* @return the Spring Framework application context
*/
public static ApplicationContext getApplicationContext() {
return context;
return applicationContext;
}

/**
Expand All @@ -84,7 +79,7 @@ public static ApplicationContext getApplicationContext() {
* @param context
*/
public static void setApplicationContext(ApplicationContext context) {
SpringUtil.context = context;
SpringUtil.applicationContext = context;
}

/**
Expand All @@ -93,8 +88,7 @@ public static void setApplicationContext(ApplicationContext context) {
*
* @param context
*/
public static synchronized void initDataSource(ApplicationContext context)
{
SpringUtil.context = context;
public static synchronized void initDataSource(ApplicationContext context) {
SpringUtil.applicationContext = context;
}
}
3 changes: 1 addition & 2 deletions core/src/main/scripts/importer/cbioportalImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ def usage():
'--command [%s] --study_directory <path to directory> '
'--meta_filename <path to metafile>'
'--data_filename <path to datafile>'
'--study_ids <cancer study ids for remove-study command, comma separated>'
'--properties-filename <path to properties file> ' % (COMMANDS)), file=OUTPUT_FILE)
'--study_ids <cancer study ids for remove-study command, comma separated>' % (COMMANDS)), file=OUTPUT_FILE)

def check_args(command):
if command not in COMMANDS:
Expand Down
Loading

0 comments on commit 18be7e2

Please sign in to comment.