Skip to content

[Improvement-18224][API] Migrate WorkflowDefinitionService Map<String,Object> returns to typed returns#18236

Merged
SbloodyS merged 1 commit into
apache:devfrom
ruanwenjun:chore/api-workflow-definition-service-typed-returns
May 11, 2026
Merged

[Improvement-18224][API] Migrate WorkflowDefinitionService Map<String,Object> returns to typed returns#18236
SbloodyS merged 1 commit into
apache:devfrom
ruanwenjun:chore/api-workflow-definition-service-typed-returns

Conversation

@ruanwenjun
Copy link
Copy Markdown
Member

Was this PR generated or assisted by AI?

YES, ops 4.7

Purpose of the pull request

Migrate 19 methods from Map<String, Object> returns to typed returns or void with ServiceException, following the established pattern.

Methods migrated:

  • createWorkflowDefinition / updateWorkflowDefinition -> WorkflowDefinition
  • queryWorkflowDefinitionList / queryAllWorkflowDefinitionByProjectCode -> List
  • queryWorkflowDefinitionSimpleList -> ArrayNode
  • queryWorkflowDefinitionByCode / queryWorkflowDefinitionByName -> DagData
  • getTaskNodeListByDefinitionCode -> List
  • getNodeListMapByDefinitionCodes -> Map<Long, List>
  • queryWorkflowDefinitionListByProjectCode -> List
  • queryTaskDefinitionListByWorkflowDefinitionCode -> List
  • viewTree -> TreeViewDto
  • viewVariables -> WorkflowDefinitionVariablesDTO (new DTO)
  • verifyWorkflowDefinitionName -> void (throws on NAME_EXIST)
  • checkWorkflowNodeList -> void (throws on validation failure)
  • switchWorkflowDefinitionVersion -> void
  • batchCopyWorkflowDefinition / batchMoveWorkflowDefinition -> void
  • batchDeleteWorkflowDefinitionByCodes -> void

A new private requireProjectAndWritePerm helper unwraps the Map-style permission check from ProjectService into ServiceException.

Cascading caller updates:

  • WorkflowDefinitionController: 25+ endpoints updated to forward typed returns via Result.success / Result.success(...)
  • PythonGateway.createWorkflowDefinition: simplified to direct typed return; errors auto-throw via ServiceException
  • PythonGateway.getWorkflow: replaced Map status check with try/catch on ServiceException to detect WORKFLOW_DEFINITION_NAME_EXIST
  • WorkflowInstanceServiceImpl.updateWorkflowInstance: drops Map result check around checkWorkflowNodeList - validation failures propagate via ServiceException
  • doBatchOperateWorkflowDefinition: switches per-workflow Map status inspection to try/catch + failedWorkflowList accumulation

Full module test suite: 682 tests, 0 failures.

Brief change log

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

Map<String, Object> result =
workflowDefinitionService.switchWorkflowDefinitionVersion(loginUser, projectCode, code, version);
return returnDataList(result);
public Result<Void> switchWorkflowDefinitionVersion(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
workflowDefinitionListInProject.get(0).getProjectCode(), codesInProject);
putMsg(result, Status.WORKFLOW_DEFINITION_NOT_EXIST, codes);
return result;
log.error("workflow definitions do not exist in project, codes:{}.", codes);
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode) {
Map<String, Object> result = workflowDefinitionService.queryWorkflowDefinitionListByProjectCode(projectCode);
return returnDataList(result);
public Result<List<DependentSimplifyDefinition>> getWorkflowListByProjectCode(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
Map<String, Object> result = workflowDefinitionService
.queryTaskDefinitionListByWorkflowDefinitionCode(projectCode, workflowDefinitionCode);
return returnDataList(result);
public Result<List<DependentSimplifyDefinition>> getTaskListByWorkflowDefinitionCode(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@PathVariable("code") long code) {
public Result<Void> deleteWorkflowDefinitionByCode(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode,
int timeout,
String taskRelationJson,
String taskDefinitionJson,
String otherParamsJson,
return result;
private void requireProjectAndWritePerm(User loginUser, Project project) {
Map<String, Object> permResult = new HashMap<>();
if (!projectService.hasProjectAndWritePerm(loginUser, project, permResult)) {
@ruanwenjun ruanwenjun added this to the 3.4.2 milestone May 8, 2026
@ruanwenjun ruanwenjun added improvement make more easy to user or prompt friendly refactor labels May 8, 2026
@ruanwenjun ruanwenjun force-pushed the chore/api-workflow-definition-service-typed-returns branch from 9b68d3c to c215d2e Compare May 10, 2026 05:32
SbloodyS
SbloodyS previously approved these changes May 10, 2026
Copy link
Copy Markdown
Member

@SbloodyS SbloodyS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ruanwenjun ruanwenjun force-pushed the chore/api-workflow-definition-service-typed-returns branch from c215d2e to beadfb9 Compare May 10, 2026 10:59
@ruanwenjun ruanwenjun force-pushed the chore/api-workflow-definition-service-typed-returns branch 3 times, most recently from 0de7d65 to 47df46a Compare May 10, 2026 14:18
…,Object> returns to typed returns

Migrate 19 methods from Map<String, Object> returns to typed returns or
void with ServiceException, following the established pattern.

Methods migrated:
- createWorkflowDefinition / updateWorkflowDefinition -> WorkflowDefinition
- queryWorkflowDefinitionList / queryAllWorkflowDefinitionByProjectCode -> List<DagData>
- queryWorkflowDefinitionSimpleList -> ArrayNode
- queryWorkflowDefinitionByCode / queryWorkflowDefinitionByName -> DagData
- getTaskNodeListByDefinitionCode -> List<TaskDefinition>
- getNodeListMapByDefinitionCodes -> Map<Long, List<TaskDefinition>>
- queryWorkflowDefinitionListByProjectCode -> List<DependentSimplifyDefinition>
- queryTaskDefinitionListByWorkflowDefinitionCode -> List<DependentSimplifyDefinition>
- viewTree -> TreeViewDto
- viewVariables -> WorkflowDefinitionVariablesDTO (new DTO)
- verifyWorkflowDefinitionName -> void (throws on NAME_EXIST)
- checkWorkflowNodeList -> void (throws on validation failure)
- switchWorkflowDefinitionVersion -> void
- batchCopyWorkflowDefinition / batchMoveWorkflowDefinition -> void
- batchDeleteWorkflowDefinitionByCodes -> void

A new private requireProjectAndWritePerm helper unwraps the Map-style
permission check from ProjectService into ServiceException.

Cascading caller updates:
- WorkflowDefinitionController: 25+ endpoints updated to forward typed
  returns via Result.success / Result.success(...)
- PythonGateway.createWorkflowDefinition: simplified to direct typed
  return; errors auto-throw via ServiceException
- PythonGateway.getWorkflow: replaced Map status check with try/catch on
  ServiceException to detect WORKFLOW_DEFINITION_NAME_EXIST
- WorkflowInstanceServiceImpl.updateWorkflowInstance: drops Map result
  check around checkWorkflowNodeList - validation failures propagate
  via ServiceException
- doBatchOperateWorkflowDefinition: switches per-workflow Map status
  inspection to try/catch + failedWorkflowList accumulation

Full module test suite: 682 tests, 0 failures.
@ruanwenjun ruanwenjun force-pushed the chore/api-workflow-definition-service-typed-returns branch from 47df46a to 15d6d61 Compare May 11, 2026 01:07
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 60%)

See analysis details on SonarQube Cloud

@SbloodyS SbloodyS merged commit 0524fa7 into apache:dev May 11, 2026
120 of 123 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend improvement make more easy to user or prompt friendly refactor test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants