Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-5279 - Port Patch 2.8.5 -> 2.12.1 (XB 1.6.6 -> 1.10.1) #2360

Merged
merged 11 commits into from
Nov 22, 2023
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2023-11-13 OpenCB
* Copyright 2015-2023-11-21 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-11-13 OpenCB
* Copyright 2015-2023-11-21 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 @@ -88,22 +88,14 @@ public void print(RestResponse queryResponse) {
throw new RuntimeException(e);
}

/* // if (queryResponse != null && queryResponse.getType().equals(QueryType.VOID)) {
if (queryResponse.getEvents() != null) {
for (Event event : ((RestResponse<Object>)queryResponse.getResponses().get(0)).getEvents()) {
if (StringUtils.isNotEmpty(event.getMessage())) {
if (event.getType().equals(Event.Type.ERROR)) {
PrintUtils.printError(event.getMessage());
} else {
PrintUtils.printInfo(event.getMessage());
}
} else {
PrintUtils.printError(event.getMessage());
}
if (queryResponse != null && queryResponse.getType().equals(QueryType.VOID)) {
if (queryResponse.getResponses() != null && queryResponse.getResponses().size() > 0) {
manageEvents(((RestResponse<Object>) queryResponse.getResponses().get(0)).getEvents());
} else if (queryResponse.getEvents() != null && queryResponse.getEvents().size() > 0) {
manageEvents(queryResponse.getEvents());
}
return;
}
// return;
// }
if (checkErrors(queryResponse) && queryResponse.allResultsSize() == 0) {
return;
}
Expand All @@ -112,11 +104,9 @@ public void print(RestResponse queryResponse) {
return;
}


ps.print(printMetadata(queryResponse));
*/
List<DataResult> queryResultList = queryResponse.getResponses();

List<DataResult> queryResultList = queryResponse.getResponses();

if (CollectionUtils.isNotEmpty(queryResultList) && ((OpenCGAResult) queryResultList.get(0)) != null
&& ((OpenCGAResult) queryResultList.get(0)).getNumMatches() > -1 && !isEdition(queryResultList) && isNotAnIdOrMessage(queryResultList)) {
Expand Down Expand Up @@ -183,6 +173,20 @@ public void print(RestResponse queryResponse) {
}
}

private void manageEvents(final List<Event> events) {
for (Event event : events) {
if (StringUtils.isNotEmpty(event.getMessage())) {
if (event.getType().equals(Event.Type.ERROR)) {
PrintUtils.printError(event.getMessage());
} else {
PrintUtils.printInfo(event.getMessage());
}
} else {
PrintUtils.printError(event.getMessage());
}
}
}

private boolean isNotAnIdOrMessage(List<DataResult> queryResultList) {
return !(queryResultList.get(0).getResultType().equals("java.lang.String") &&
((OpenCGAResult) queryResultList.get(0)).getNumMatches() == 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3712,16 +3712,23 @@ OpenCGAResult<File> registerFile(Study study, String filePath, URI fileUri, Stri

File.Type type = filePath.endsWith("/") ? File.Type.DIRECTORY : File.Type.FILE;

File subfile = new File(Paths.get(filePath).getFileName().toString(), type, File.Format.UNKNOWN,
File.Bioformat.NONE, fileUri, filePath, "", TimeUtils.getTime(), TimeUtils.getTime(),
"", isExternal(study, filePath, fileUri), size, new Software(), new FileExperiment(), Collections.emptyList(),
Collections.emptyList(), jobId, studyManager.getCurrentRelease(study), Collections.emptyList(), Collections.emptyList(),
new FileQualityControl(), Collections.emptyMap(), new Status(), FileInternal.init(), Collections.emptyMap());
File.Format format = org.opencb.opencga.catalog.managers.FileUtils.detectFormat(fileUri);
File.Bioformat bioformat = org.opencb.opencga.catalog.managers.FileUtils.detectBioformat(fileUri);
File subfile = new File(Paths.get(filePath).getFileName().toString(), type, format, bioformat, fileUri, filePath, "",
TimeUtils.getTime(), TimeUtils.getTime(), "", isExternal(study, filePath, fileUri), size, new Software(),
new FileExperiment(), Collections.emptyList(), Collections.emptyList(), jobId, studyManager.getCurrentRelease(study),
Collections.emptyList(), Collections.emptyList(), new FileQualityControl(), Collections.emptyMap(), new Status(),
FileInternal.init(), Collections.emptyMap());
subfile.setUuid(UuidUtils.generateOpenCgaUuid(UuidUtils.Entity.FILE));
checkHooks(subfile, study.getFqn(), HookConfiguration.Stage.CREATE);

// Improve metadata information and extract samples if any
new FileMetadataReader(catalogManager).addMetadataInformation(study.getFqn(), subfile);
try {
new FileMetadataReader(catalogManager).addMetadataInformation(study.getFqn(), subfile);
} catch (CatalogException e) {
subfile.getInternal().setStatus(new FileStatus(FileStatus.ERROR, "Could not extract metadata information: " + e.getMessage()));
logger.warn("Could not extract metadata information from file {}: {}", fileUri, e.getMessage(), e);
}
List<Sample> existingSamples = new LinkedList<>();
List<Sample> nonExistingSamples = new LinkedList<>();
validateNewSamples(study, subfile, existingSamples, nonExistingSamples, token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private FileUpdateParams extractMetadataInformation(String studyId, File file) t
VariantFileMetadata fileMetadata;
try {
fileMetadata = readVariantFileMetadata(file, file.getUri());
} catch (IOException e) {
} catch (Exception e) {
throw new CatalogIOException("Unable to read VariantSource", e);
}
if (fileMetadata != null) {
Expand Down
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-11-13
# Autogenerated on: 2023-11-21
#
# 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-11-13
# Autogenerated on: 2023-11-21
#
# 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
20 changes: 10 additions & 10 deletions opencga-client/src/main/R/R/AllGenerics.R
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
# ##############################################################################
## UserClient
setGeneric("userClient", function(OpencgaR, user, filterId, users, endpointName, params=NULL, ...)
setGeneric("userClient", function(OpencgaR, filterId, user, users, endpointName, params=NULL, ...)
standardGeneric("userClient"))

# ##############################################################################
## ProjectClient
setGeneric("projectClient", function(OpencgaR, project, projects, endpointName, params=NULL, ...)
setGeneric("projectClient", function(OpencgaR, projects, project, endpointName, params=NULL, ...)
standardGeneric("projectClient"))

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

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

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

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

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

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

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

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

# ##############################################################################
## ClinicalClient
setGeneric("clinicalClient", function(OpencgaR, clinicalAnalyses, interpretations, clinicalAnalysis, members, interpretation, endpointName, params=NULL, ...)
setGeneric("clinicalClient", function(OpencgaR, clinicalAnalysis, clinicalAnalyses, members, interpretation, interpretations, 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-11-13
# Autogenerated on: 2023-11-21
#
# 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, clinicalAnalyses, interpretations, clinicalAnalysis, members, interpretation, endpointName, params=NULL, ...) {
setMethod("clinicalClient", "OpencgaR", function(OpencgaR, clinicalAnalysis, clinicalAnalyses, members, interpretation, interpretations, 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-11-13
# Autogenerated on: 2023-11-21
#
# 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, cohort, annotationSet, members, cohorts, endpointName, params=NULL, ...) {
setMethod("cohortClient", "OpencgaR", function(OpencgaR, cohorts, members, cohort, annotationSet, 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-11-13
# Autogenerated on: 2023-11-21
#
# 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, annotationSet, members, family, 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-11-13
# Autogenerated on: 2023-11-21
#
# 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, file, members, folder, files, annotationSet, endpointName, params=NULL, ...) {
setMethod("fileClient", "OpencgaR", function(OpencgaR, folder, members, file, annotationSet, 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-11-13
# Autogenerated on: 2023-11-21
#
# 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-11-13
# Autogenerated on: 2023-11-21
#
# 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, annotationSet, individuals, members, endpointName, params=NULL, ...) {
setMethod("individualClient", "OpencgaR", function(OpencgaR, individual, members, individuals, 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-11-13
# Autogenerated on: 2023-11-21
#
# 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, jobs, members, endpointName, params=NULL, ...) {
setMethod("jobClient", "OpencgaR", function(OpencgaR, jobs, members, 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-11-13
# Autogenerated on: 2023-11-21
#
# 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-11-13
# Autogenerated on: 2023-11-21
#
# 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-11-13
# Autogenerated on: 2023-11-21
#
# 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/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-11-13
# Autogenerated on: 2023-11-21
#
# 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 @@ -34,7 +34,7 @@
#' [*]: Required parameter
#' @export

setMethod("projectClient", "OpencgaR", function(OpencgaR, project, projects, endpointName, params=NULL, ...) {
setMethod("projectClient", "OpencgaR", function(OpencgaR, projects, project, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/projects/create:
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-11-13
# Autogenerated on: 2023-11-21
#
# 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, sample, annotationSet, members, samples, endpointName, params=NULL, ...) {
setMethod("sampleClient", "OpencgaR", function(OpencgaR, annotationSet, members, samples, sample, endpointName, params=NULL, ...) {
switch(endpointName,

#' @section Endpoint /{apiVersion}/samples/acl/{members}/update:
Expand Down
4 changes: 2 additions & 2 deletions opencga-client/src/main/R/R/Study-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-11-13
# Autogenerated on: 2023-11-21
#
# 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 @@ -46,7 +46,7 @@
#' [*]: Required parameter
#' @export

setMethod("studyClient", "OpencgaR", function(OpencgaR, templateId, group, members, variableSet, studies, study, endpointName, params=NULL, ...) {
setMethod("studyClient", "OpencgaR", function(OpencgaR, templateId, members, studies, variableSet, study, group, endpointName, params=NULL, ...) {
switch(endpointName,

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