Skip to content

Commit

Permalink
catalog: allow updating the workflow system, #TASK-6445
Browse files Browse the repository at this point in the history
  • Loading branch information
pfurio committed Sep 19, 2024
1 parent 2da90f8 commit 49ec23e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ enum QueryParams implements QueryParam {
TYPE("type", TEXT, ""),
TAGS("tags", TEXT_ARRAY, ""),
COMMAND_LINE("commandLine", TEXT, ""),
MANAGER("manager", OBJECT, ""),
SCRIPTS("scripts", OBJECT, ""),
VARIABLES("variables", OBJECT, ""),
INTERNAL_REGISTRATION_USER_ID("internal.registrationUserId", TEXT, ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private UpdateDocument parseAndValidateUpdateParams(ObjectMap parameters, QueryO
final String[] acceptedMapParams = {QueryParams.ATTRIBUTES.key()};
filterMapParams(parameters, document.getSet(), acceptedMapParams);

final String[] acceptedListParams = {QueryParams.SCRIPTS.key(), QueryParams.VARIABLES.key()};
final String[] acceptedListParams = {QueryParams.MANAGER.key(), QueryParams.SCRIPTS.key(), QueryParams.VARIABLES.key()};
filterObjectParams(parameters, document.getSet(), acceptedListParams);

// // Check if the scripts exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,10 @@ public OpenCGAResult<Workflow> update(String studyStr, String workflowId, Workfl

JwtPayload tokenPayload = catalogManager.getUserManager().validateToken(token);
CatalogFqn studyFqn = CatalogFqn.extractFqnFromStudy(studyStr, tokenPayload);
ObjectMap updateMap = null;
try {
if (updateParams != null) {
updateMap = new ObjectMap(getUpdateObjectMapper().writeValueAsString(updateParams));
}
} catch (JsonProcessingException e) {
throw new CatalogException("Could not parse WorkflowUpdateParams object: " + e.getMessage(), e);
}

ObjectMap auditParams = new ObjectMap()
.append("workflowId", workflowId)
.append("updateParams", updateMap)
.append("updateParams", updateParams)
.append("options", options)
.append("token", token);

Expand All @@ -208,6 +200,26 @@ public OpenCGAResult<Workflow> update(String studyStr, String workflowId, Workfl
id = workflow.getId();
uuid = workflow.getUuid();

if (updateParams == null) {
throw new CatalogException("Missing parameters to update the workflow.");
}

if (updateParams.getManager() != null) {
if (updateParams.getManager().getId() == null) {
throw new CatalogException("Manager id cannot be left empty.");
}
if (StringUtils.isEmpty(updateParams.getManager().getVersion())) {
throw new CatalogException("Manager version cannot be left empty.");
}
}

ObjectMap updateMap;
try {
updateMap = new ObjectMap(getUpdateObjectMapper().writeValueAsString(updateParams));
} catch (JsonProcessingException e) {
throw new CatalogException("Could not parse WorkflowUpdateParams object: " + e.getMessage(), e);
}

// 2. Update workflow object
OpenCGAResult<Workflow> insert = getWorkflowDBAdaptor(organizationId).update(workflow.getUid(), updateMap, options);
if (options.getBoolean(ParamConstants.INCLUDE_RESULT_PARAM)) {
Expand Down

0 comments on commit 49ec23e

Please sign in to comment.