Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Update Project id format to UUID #297

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,8 @@ public void execute(@NonNull ApiCallback<WorkFlowStatusResponseDTO> callback) th
@Nullable
public static ProjectResponseDTO getProjectByNameAndDescription(List<ProjectResponseDTO> projects,
String projectName, String projectDescription) {
return projects.stream()
.filter(prj -> projectName.equals(prj.getName()) && projectDescription.equals(prj.getDescription())
&& prj.getUsername() == null && !Strings.isNullOrEmpty(prj.getId()))
return projects.stream().filter(prj -> projectName.equals(prj.getName())
&& projectDescription.equals(prj.getDescription()) && prj.getUsername() == null && prj.getId() != null)
.findAny().orElse(null);
}

Expand Down
7 changes: 5 additions & 2 deletions workflow-service-sdk/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ paths:
name: id
required: true
schema:
format: uuid
type: string
style: simple
responses:
Expand Down Expand Up @@ -363,7 +364,7 @@ components:
modifyDate: 2000-01-23T04:56:07.000+00:00
name: name
description: description
id: id
id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
createDate: 2000-01-23T04:56:07.000+00:00
status: status
username: username
Expand All @@ -374,6 +375,7 @@ components:
description:
type: string
id:
format: uuid
type: string
modifyDate:
format: date-time
Expand Down Expand Up @@ -894,13 +896,14 @@ components:
key: key
- value: value
key: key
projectId: projectId
projectId: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
properties:
arguments:
items:
$ref: '#/components/schemas/ArgumentRequestDTO'
type: array
projectId:
format: uuid
type: string
workFlowName:
type: string
Expand Down
4 changes: 2 additions & 2 deletions workflow-service-sdk/docs/ProjectApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class Example {
defaultClient.setBasePath("http://localhost:8080");

ProjectApi apiInstance = new ProjectApi(defaultClient);
String id = "id_example"; // String |
UUID id = UUID.randomUUID(); // UUID |
try {
ProjectResponseDTO result = apiInstance.getProjectById(id);
System.out.println(result);
Expand All @@ -110,7 +110,7 @@ public class Example {

| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **id** | **String**| | |
| **id** | **UUID**| | |

### Return type

Expand Down
2 changes: 1 addition & 1 deletion workflow-service-sdk/docs/ProjectResponseDTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
|------------ | ------------- | ------------- | -------------|
|**createDate** | **Date** | | [optional] |
|**description** | **String** | | [optional] |
|**id** | **String** | | [optional] |
|**id** | **UUID** | | [optional] |
|**modifyDate** | **Date** | | [optional] |
|**name** | **String** | | [optional] |
|**status** | **String** | | [optional] |
Expand Down
2 changes: 1 addition & 1 deletion workflow-service-sdk/docs/WorkFlowRequestDTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**arguments** | [**List&lt;ArgumentRequestDTO&gt;**](ArgumentRequestDTO.md) | | [optional] |
|**projectId** | **String** | | [optional] |
|**projectId** | **UUID** | | [optional] |
|**workFlowName** | **String** | | [optional] |
|**works** | [**List&lt;WorkRequestDTO&gt;**](WorkRequestDTO.md) | | [optional] |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import com.redhat.parodos.sdk.model.ProjectRequestDTO;
import com.redhat.parodos.sdk.model.ProjectResponseDTO;
import java.util.UUID;

import java.lang.reflect.Type;
import java.util.ArrayList;
Expand Down Expand Up @@ -288,7 +289,7 @@ public okhttp3.Call createProjectAsync(ProjectRequestDTO projectRequestDTO,
* </tr>
* </table>
*/
public okhttp3.Call getProjectByIdCall(String id, final ApiCallback _callback) throws ApiException {
public okhttp3.Call getProjectByIdCall(UUID id, final ApiCallback _callback) throws ApiException {
String basePath = null;
// Operation Servers
String[] localBasePaths = new String[] {};
Expand Down Expand Up @@ -335,7 +336,7 @@ else if (localBasePaths.length > 0) {
}

@SuppressWarnings("rawtypes")
private okhttp3.Call getProjectByIdValidateBeforeCall(String id, final ApiCallback _callback) throws ApiException {
private okhttp3.Call getProjectByIdValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException {
// verify the required parameter 'id' is set
if (id == null) {
throw new ApiException("Missing the required parameter 'id' when calling getProjectById(Async)");
Expand Down Expand Up @@ -375,7 +376,7 @@ private okhttp3.Call getProjectByIdValidateBeforeCall(String id, final ApiCallba
* </tr>
* </table>
*/
public ProjectResponseDTO getProjectById(String id) throws ApiException {
public ProjectResponseDTO getProjectById(UUID id) throws ApiException {
ApiResponse<ProjectResponseDTO> localVarResp = getProjectByIdWithHttpInfo(id);
return localVarResp.getData();
}
Expand Down Expand Up @@ -410,7 +411,7 @@ public ProjectResponseDTO getProjectById(String id) throws ApiException {
* </tr>
* </table>
*/
public ApiResponse<ProjectResponseDTO> getProjectByIdWithHttpInfo(String id) throws ApiException {
public ApiResponse<ProjectResponseDTO> getProjectByIdWithHttpInfo(UUID id) throws ApiException {
okhttp3.Call localVarCall = getProjectByIdValidateBeforeCall(id, null);
Type localVarReturnType = new TypeToken<ProjectResponseDTO>() {
}.getType();
Expand Down Expand Up @@ -448,7 +449,7 @@ public ApiResponse<ProjectResponseDTO> getProjectByIdWithHttpInfo(String id) thr
* </tr>
* </table>
*/
public okhttp3.Call getProjectByIdAsync(String id, final ApiCallback<ProjectResponseDTO> _callback)
public okhttp3.Call getProjectByIdAsync(UUID id, final ApiCallback<ProjectResponseDTO> _callback)
throws ApiException {

okhttp3.Call localVarCall = getProjectByIdValidateBeforeCall(id, _callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Date;
import java.util.UUID;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -62,7 +63,7 @@ public class ProjectResponseDTO {
public static final String SERIALIZED_NAME_ID = "id";

@SerializedName(SERIALIZED_NAME_ID)
private String id;
private UUID id;

public static final String SERIALIZED_NAME_MODIFY_DATE = "modifyDate";

Expand Down Expand Up @@ -127,7 +128,7 @@ public void setDescription(String description) {
this.description = description;
}

public ProjectResponseDTO id(String id) {
public ProjectResponseDTO id(UUID id) {

this.id = id;
return this;
Expand All @@ -139,11 +140,11 @@ public ProjectResponseDTO id(String id) {
**/
@javax.annotation.Nullable

public String getId() {
public UUID getId() {
return id;
}

public void setId(String id) {
public void setId(UUID id) {
this.id = id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
Expand Down Expand Up @@ -60,7 +61,7 @@ public class WorkFlowRequestDTO {
public static final String SERIALIZED_NAME_PROJECT_ID = "projectId";

@SerializedName(SERIALIZED_NAME_PROJECT_ID)
private String projectId;
private UUID projectId;

public static final String SERIALIZED_NAME_WORK_FLOW_NAME = "workFlowName";

Expand Down Expand Up @@ -103,7 +104,7 @@ public void setArguments(List<ArgumentRequestDTO> arguments) {
this.arguments = arguments;
}

public WorkFlowRequestDTO projectId(String projectId) {
public WorkFlowRequestDTO projectId(UUID projectId) {

this.projectId = projectId;
return this;
Expand All @@ -115,11 +116,11 @@ public WorkFlowRequestDTO projectId(String projectId) {
**/
@javax.annotation.Nullable

public String getProjectId() {
public UUID getProjectId() {
return projectId;
}

public void setProjectId(String projectId) {
public void setProjectId(UUID projectId) {
this.projectId = projectId;
}

Expand Down
9 changes: 6 additions & 3 deletions workflow-service/generated/openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
"name" : "id",
"required" : true,
"schema" : {
"type" : "string"
"type" : "string",
"format" : "uuid"
}
} ],
"responses" : {
Expand Down Expand Up @@ -458,7 +459,8 @@
"type" : "string"
},
"id" : {
"type" : "string"
"type" : "string",
"format" : "uuid"
},
"modifyDate" : {
"type" : "string",
Expand Down Expand Up @@ -706,7 +708,8 @@
}
},
"projectId" : {
"type" : "string"
"type" : "string",
"format" : "uuid"
},
"workFlowName" : {
"type" : "string"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/
package com.redhat.parodos.project.controller;

import com.redhat.parodos.project.dto.ProjectRequestDTO;
import com.redhat.parodos.project.dto.ProjectResponseDTO;
import com.redhat.parodos.project.service.ProjectServiceImpl;
import javax.validation.Valid;
import java.net.URI;
import java.util.List;
import java.util.UUID;

import com.redhat.parodos.project.dto.ProjectRequestDTO;
import com.redhat.parodos.project.dto.ProjectResponseDTO;
import com.redhat.parodos.project.service.ProjectServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
Expand Down Expand Up @@ -94,8 +94,8 @@ public ResponseEntity<List<ProjectResponseDTO>> getProjects() {
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content),
@ApiResponse(responseCode = "404", description = "Not found", content = @Content) })
@GetMapping("/{id}")
public ResponseEntity<ProjectResponseDTO> getProjectById(@PathVariable String id) {
ProjectResponseDTO projectResponseDTO = projectService.getProjectById(UUID.fromString(id));
public ResponseEntity<ProjectResponseDTO> getProjectById(@PathVariable UUID id) {
ProjectResponseDTO projectResponseDTO = projectService.getProjectById(id);
if (projectResponseDTO == null) {
return ResponseEntity.notFound().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package com.redhat.parodos.project.dto;

import java.util.Date;
import java.util.UUID;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -36,7 +36,7 @@
@NoArgsConstructor
public class ProjectResponseDTO {

private String id;
private UUID id;

private String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,11 @@ public List<ProjectResponseDTO> getProjects() {
return projects.stream().map(project -> {
WorkFlowExecution workFlowExecution = workFlowRepository
.findFirstByProjectIdAndMainWorkFlowExecutionIsNullOrderByStartDateDesc(project.getId());
return ProjectResponseDTO.builder().id(project.getId().toString()).name(project.getName())
return ProjectResponseDTO.builder().id(project.getId()).name(project.getName())
.createDate(project.getCreateDate()).modifyDate(project.getModifyDate())
.description(project.getDescription())
.status(null == workFlowExecution ? "" : workFlowExecution.getStatus().name()).build();
}).collect(Collectors.toList());
// return modelMapper.map(projectRepository.findAll(), new
// TypeToken<List<ProjectResponseDTO>>() {
// }.getType());
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.redhat.parodos.workflow.execution.aspect;

import java.util.UUID;

import com.redhat.parodos.workflow.context.WorkContextDelegate;
import com.redhat.parodos.workflow.definition.entity.WorkFlowCheckerMappingDefinition;
import com.redhat.parodos.workflow.definition.entity.WorkFlowDefinition;
Expand Down Expand Up @@ -58,13 +60,13 @@ public WorkReport handlePostWorkFlowExecution() {
* cron expression or stop if done
*/
startOrStopWorkFlowCheckerOnSchedule(workFlow, workFlowDefinition.getCheckerWorkFlowDefinition(), workStatus,
workContext, workFlowExecution.getProjectId().toString(), mainWorkFlowExecution);
workContext, workFlowExecution.getProjectId(), mainWorkFlowExecution);
return null;
}

private void startOrStopWorkFlowCheckerOnSchedule(WorkFlow workFlow,
WorkFlowCheckerMappingDefinition workFlowCheckerMappingDefinition, WorkStatus workStatus,
WorkContext workContext, String projectId, WorkFlowExecution mainWorkFlowExecution) {
WorkContext workContext, UUID projectId, WorkFlowExecution mainWorkFlowExecution) {
/*
* if this workflow is a checker, schedule workflow checker for dynamic run on
* cron expression or stop if done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public WorkReport executeAroundAdvice(ProceedingJoinPoint proceedingJoinPoint, W
if (workFlowExecution.getStatus().equals(WorkFlowStatus.COMPLETED)) {
// skip the workflow if it is already successful
if (workFlowDefinition.getType().equals(WorkFlowType.CHECKER)) {
workFlowSchedulerService.stop(workFlowExecution.getProjectId().toString(),
workFlowSchedulerService.stop(workFlowExecution.getProjectId(),
(WorkFlow) proceedingJoinPoint.getTarget());
}
log.info("skipping workflow: {} is already completed", workFlowDefinition.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
*/
package com.redhat.parodos.workflow.execution.aspect;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.redhat.parodos.workflow.context.WorkContextDelegate;
import com.redhat.parodos.workflow.definition.entity.WorkFlowCheckerMappingDefinition;
import com.redhat.parodos.workflow.definition.entity.WorkFlowTaskDefinition;
Expand All @@ -41,10 +45,6 @@
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
* Aspect pointcut to perform state management for a workflow task executions
*
Expand Down Expand Up @@ -170,7 +170,7 @@ private void handleChecker(ProceedingJoinPoint proceedingJoinPoint, WorkContext
// schedule workflow checker for dynamic run on cron expression
List<WorkFlow> checkerWorkFlows = ((BaseWorkFlowTask) proceedingJoinPoint.getTarget())
.getWorkFlowCheckers();
startCheckerOnSchedule(mainWorkFlowExecution.getProjectId().toString(),
startCheckerOnSchedule(mainWorkFlowExecution.getProjectId(),
workFlowTaskDefinition.getWorkFlowCheckerMappingDefinition().getCheckWorkFlow().getName(),
checkerWorkFlows, workFlowTaskDefinition.getWorkFlowCheckerMappingDefinition(), workContext);
}
Expand All @@ -188,7 +188,7 @@ private WorkFlowExecution handleParentWorkflowUseCase(WorkContext workContext,

// Iterate through the all the Checkers in the workflow and start them based on their
// schedules
private void startCheckerOnSchedule(String projectId, String workFlowName, List<WorkFlow> workFlows,
private void startCheckerOnSchedule(UUID projectId, String workFlowName, List<WorkFlow> workFlows,
WorkFlowCheckerMappingDefinition workFlowCheckerMappingDefinition, WorkContext workContext) {
log.info("Schedule workflow checker: {} to run per cron expression: {}", workFlowName,
workFlowCheckerMappingDefinition.getCronExpression());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
public interface AsyncWorkFlowContinuer {

@Async
void executeAsync(String projectId, String workflowName, WorkContext workContext, UUID executionId);
void executeAsync(UUID projectId, String workflowName, WorkContext workContext, UUID executionId);

}
Loading