Skip to content

Commit

Permalink
Merge pull request #2328 from opencb/TASK-4641
Browse files Browse the repository at this point in the history
TASK-4641- Update according to CellBase changes and remove and use VersionUtils from java-common-libs
  • Loading branch information
jtarraga authored Sep 8, 2023
2 parents ef48f7f + 61a5503 commit 06bad57
Show file tree
Hide file tree
Showing 90 changed files with 280 additions and 396 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public OpenCGAResult<GeneCoverageStats> coverageStats(String studyIdStr, String
String species = projectQueryResult.first().getOrganism().getScientificName();
String assembly = projectQueryResult.first().getOrganism().getAssembly();
String dataRelease = projectQueryResult.first().getCellbase().getDataRelease();
String cellbaseToken = projectQueryResult.first().getCellbase().getToken();
String cellbaseToken = projectQueryResult.first().getCellbase().getApiKey();

for (String geneName : geneNames) {

Expand Down Expand Up @@ -451,7 +451,7 @@ public List<Region> mergeRegions(List<Region> regions, List<String> genes, boole
String species = projectQueryResult.first().getOrganism().getScientificName();
String assembly = projectQueryResult.first().getOrganism().getAssembly();
String dataRelease = projectQueryResult.first().getCellbase().getDataRelease();
String cellbaseToken = projectQueryResult.first().getCellbase().getToken();
String cellbaseToken = projectQueryResult.first().getCellbase().getApiKey();
CellBaseClient cellBaseClient = new CellBaseClient(species, assembly, dataRelease, cellbaseToken,
projectQueryResult.first().getCellbase().toClientConfiguration());
GeneClient geneClient = cellBaseClient.getGeneClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,9 @@ private void setCellbaseConfiguration(VariantStorageEngine engine, String projec
.get(project, new QueryOptions(INCLUDE, ProjectDBAdaptor.QueryParams.CELLBASE.key()), token)
.first().getCellbase();
if (cellbase != null) {
if (StringUtils.isEmpty(cellbase.getToken()) || storageConfiguration.getCellbase() != null) {
cellbase.setToken(storageConfiguration.getCellbase().getToken());
// To ensure that we use the project API key before using the storage API key
if (StringUtils.isEmpty(cellbase.getApiKey()) && storageConfiguration.getCellbase() != null) {
cellbase.setApiKey(storageConfiguration.getCellbase().getApiKey());
}
engine.getConfiguration().setCellbase(cellbase);
engine.reloadCellbaseConfiguration();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023-09-01 OpenCB
* Copyright 2015-2023-09-08 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023-09-01 OpenCB
* Copyright 2015-2023-09-08 OpenCB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private RestResponse<Job> configureCellbase() throws Exception {
putNestedIfNotEmpty(beanParams, "url",commandOptions.url, true);
putNestedIfNotEmpty(beanParams, "version",commandOptions.version, true);
putNestedIfNotEmpty(beanParams, "dataRelease",commandOptions.dataRelease, true);
putNestedIfNotEmpty(beanParams, "token",commandOptions.token, true);
putNestedIfNotEmpty(beanParams, "apiKey",commandOptions.apiKey, true);

cellBaseConfiguration = JacksonUtils.getDefaultObjectMapper().copy()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private RestResponse<Project> create() throws Exception {
putNestedIfNotEmpty(beanParams, "cellbase.url",commandOptions.cellbaseUrl, true);
putNestedIfNotEmpty(beanParams, "cellbase.version",commandOptions.cellbaseVersion, true);
putNestedIfNotEmpty(beanParams, "cellbase.dataRelease",commandOptions.cellbaseDataRelease, true);
putNestedIfNotEmpty(beanParams, "cellbase.token",commandOptions.cellbaseToken, true);
putNestedIfNotEmpty(beanParams, "cellbase.apiKey",commandOptions.cellbaseApiKey, true);
putNestedIfNotNull(beanParams, "attributes",commandOptions.attributes, true);

projectCreateParams = JacksonUtils.getDefaultObjectMapper().copy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public class ConfigureCellbaseCommandOptions {
@Parameter(names = {"--data-release"}, description = "CellBase data release version to be used. If empty, will use the active one", required = false, arity = 1)
public String dataRelease;

@Parameter(names = {"--token"}, description = "CellBase token to access to the licensed/restricted data sources such as COSMIC, HGMD,...", required = false, arity = 1)
public String token;
@Parameter(names = {"--api-key"}, description = "API key to access to the licensed/restricted data sources (COSMIC, HGMD,...) and to manage quota.", required = false, arity = 1)
public String apiKey;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public class CreateCommandOptions {
@Parameter(names = {"--cellbase-data-release"}, description = "CellBase data release version to be used. If empty, will use the active one", required = false, arity = 1)
public String cellbaseDataRelease;

@Parameter(names = {"--cellbase-token"}, description = "CellBase token to access to the licensed/restricted data sources such as COSMIC, HGMD,...", required = false, arity = 1)
public String cellbaseToken;
@Parameter(names = {"--cellbase-api-key"}, description = "API key to access to the licensed/restricted data sources (COSMIC, HGMD,...) and to manage quota.", required = false, arity = 1)
public String cellbaseApiKey;

@DynamicParameter(names = {"--attributes"}, description = "The body web service attributes parameter. Use: --attributes key=value", required = false)
public java.util.Map<java.lang.String,java.lang.Object> attributes = new HashMap<>(); //Dynamic parameters must be initialized;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.opencb.opencga.app.migrations.v2_9_0.catalog;

import com.mongodb.client.model.Projections;
import com.mongodb.client.model.UpdateOneModel;
import com.mongodb.client.model.Updates;
import org.bson.Document;
import org.opencb.opencga.catalog.db.mongodb.MongoDBAdaptorFactory;
import org.opencb.opencga.catalog.migration.Migration;
import org.opencb.opencga.catalog.migration.MigrationTool;

import java.util.List;

import static com.mongodb.client.model.Filters.eq;

@Migration(id = "rename_cellbase_token_2_api_key" ,
description = "Rename CellBase Token to ApiKey",
version = "2.9.0",
domain = Migration.MigrationDomain.CATALOG,
language = Migration.MigrationLanguage.JAVA,
date = 20230829
)
public class RenameCellBaseToken2ApiKey extends MigrationTool {

@Override
protected void run() throws Exception {

migrateCollection(MongoDBAdaptorFactory.USER_COLLECTION,
new Document("projects.id", new Document("$exists", true)),
Projections.include("_id", "projects"),
(userDocument, bulk) -> {
List<Document> projects = userDocument.getList("projects", Document.class);
for (int i = 0; i < projects.size(); i++) {
Document project = projects.get(i);
Document cellbase = project.get("cellbase", Document.class);
if (cellbase != null) {
String token = cellbase.getString("token");
if (token != null) {
bulk.add(new UpdateOneModel<>(
eq("_id", userDocument.get("_id")),
Updates.combine(
Updates.set("projects." + i + ".cellbase.apiKey", token),
Updates.unset("projects." + i + ".cellbase.token")
)));
}
}
}
});
}

}
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/Admin-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/Alignment-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
18 changes: 9 additions & 9 deletions opencga-client/src/main/R/R/AllGenerics.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ##############################################################################
## UserClient
setGeneric("userClient", function(OpencgaR, filterId, users, user, endpointName, params=NULL, ...)
setGeneric("userClient", function(OpencgaR, users, user, filterId, endpointName, params=NULL, ...)
standardGeneric("userClient"))

# ##############################################################################
Expand All @@ -10,37 +10,37 @@ setGeneric("projectClient", function(OpencgaR, projects, project, endpointName,

# ##############################################################################
## StudyClient
setGeneric("studyClient", function(OpencgaR, variableSet, studies, members, group, study, templateId, endpointName, params=NULL, ...)
setGeneric("studyClient", function(OpencgaR, study, group, variableSet, studies, members, templateId, endpointName, params=NULL, ...)
standardGeneric("studyClient"))

# ##############################################################################
## FileClient
setGeneric("fileClient", function(OpencgaR, members, folder, annotationSet, files, file, endpointName, params=NULL, ...)
setGeneric("fileClient", function(OpencgaR, folder, annotationSet, file, members, files, endpointName, params=NULL, ...)
standardGeneric("fileClient"))

# ##############################################################################
## JobClient
setGeneric("jobClient", function(OpencgaR, job, members, jobs, endpointName, params=NULL, ...)
setGeneric("jobClient", function(OpencgaR, members, jobs, job, endpointName, params=NULL, ...)
standardGeneric("jobClient"))

# ##############################################################################
## SampleClient
setGeneric("sampleClient", function(OpencgaR, annotationSet, sample, samples, members, endpointName, params=NULL, ...)
setGeneric("sampleClient", function(OpencgaR, samples, members, sample, annotationSet, endpointName, params=NULL, ...)
standardGeneric("sampleClient"))

# ##############################################################################
## IndividualClient
setGeneric("individualClient", function(OpencgaR, individual, individuals, annotationSet, members, endpointName, params=NULL, ...)
setGeneric("individualClient", function(OpencgaR, individuals, members, individual, annotationSet, endpointName, params=NULL, ...)
standardGeneric("individualClient"))

# ##############################################################################
## FamilyClient
setGeneric("familyClient", function(OpencgaR, families, family, annotationSet, members, endpointName, params=NULL, ...)
setGeneric("familyClient", function(OpencgaR, family, members, families, annotationSet, endpointName, params=NULL, ...)
standardGeneric("familyClient"))

# ##############################################################################
## CohortClient
setGeneric("cohortClient", function(OpencgaR, annotationSet, cohorts, members, cohort, endpointName, params=NULL, ...)
setGeneric("cohortClient", function(OpencgaR, annotationSet, members, cohort, cohorts, endpointName, params=NULL, ...)
standardGeneric("cohortClient"))

# ##############################################################################
Expand All @@ -60,7 +60,7 @@ setGeneric("variantClient", function(OpencgaR, endpointName, params=NULL, ...)

# ##############################################################################
## ClinicalClient
setGeneric("clinicalClient", function(OpencgaR, interpretation, members, interpretations, clinicalAnalysis, clinicalAnalyses, endpointName, params=NULL, ...)
setGeneric("clinicalClient", function(OpencgaR, clinicalAnalyses, interpretation, clinicalAnalysis, interpretations, members, endpointName, params=NULL, ...)
standardGeneric("clinicalClient"))

# ##############################################################################
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Clinical-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -58,7 +58,7 @@
#' [*]: Required parameter
#' @export

setMethod("clinicalClient", "OpencgaR", function(OpencgaR, interpretation, members, interpretations, clinicalAnalysis, clinicalAnalyses, endpointName, params=NULL, ...) {
setMethod("clinicalClient", "OpencgaR", function(OpencgaR, clinicalAnalyses, interpretation, clinicalAnalysis, interpretations, members, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/analysis/clinical/acl/{members}/update:
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Cohort-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -39,7 +39,7 @@
#' [*]: Required parameter
#' @export

setMethod("cohortClient", "OpencgaR", function(OpencgaR, annotationSet, cohorts, members, cohort, endpointName, params=NULL, ...) {
setMethod("cohortClient", "OpencgaR", function(OpencgaR, annotationSet, members, cohort, cohorts, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/cohorts/acl/{members}/update:
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Family-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -38,7 +38,7 @@
#' [*]: Required parameter
#' @export

setMethod("familyClient", "OpencgaR", function(OpencgaR, families, family, annotationSet, members, endpointName, params=NULL, ...) {
setMethod("familyClient", "OpencgaR", function(OpencgaR, family, members, families, annotationSet, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/families/acl/{members}/update:
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/File-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -54,7 +54,7 @@
#' [*]: Required parameter
#' @export

setMethod("fileClient", "OpencgaR", function(OpencgaR, members, folder, annotationSet, files, file, endpointName, params=NULL, ...) {
setMethod("fileClient", "OpencgaR", function(OpencgaR, folder, annotationSet, file, members, files, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/files/acl/{members}/update:
Expand Down
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/GA4GH-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Individual-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -39,7 +39,7 @@
#' [*]: Required parameter
#' @export

setMethod("individualClient", "OpencgaR", function(OpencgaR, individual, individuals, annotationSet, members, endpointName, params=NULL, ...) {
setMethod("individualClient", "OpencgaR", function(OpencgaR, individuals, members, individual, annotationSet, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/individuals/acl/{members}/update:
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Job-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -40,7 +40,7 @@
#' [*]: Required parameter
#' @export

setMethod("jobClient", "OpencgaR", function(OpencgaR, job, members, jobs, endpointName, params=NULL, ...) {
setMethod("jobClient", "OpencgaR", function(OpencgaR, members, jobs, job, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/jobs/acl/{members}/update:
Expand Down
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/Meta-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/Operation-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/Panel-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
2 changes: 1 addition & 1 deletion opencga-client/src/main/R/R/Project-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Sample-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: AUTOGENERATED CODE
#
# This code was generated by a tool.
# Autogenerated on: 2023-09-01
# Autogenerated on: 2023-09-08
#
# Manual changes to this file may cause unexpected behavior in your application.
# Manual changes to this file will be overwritten if the code is regenerated.
Expand Down Expand Up @@ -39,7 +39,7 @@
#' [*]: Required parameter
#' @export

setMethod("sampleClient", "OpencgaR", function(OpencgaR, annotationSet, sample, samples, members, endpointName, params=NULL, ...) {
setMethod("sampleClient", "OpencgaR", function(OpencgaR, samples, members, sample, annotationSet, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/samples/acl/{members}/update:
Expand Down
Loading

0 comments on commit 06bad57

Please sign in to comment.