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

FLPATH-473:set additional info for report urls #449

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 @@ -56,7 +56,9 @@ public enum Resource {

WORKFLOW_OPTIONS(Visibility.PUBLIC),

PARENT_WORKFLOW;
PARENT_WORKFLOW,

ADDITIONAL_INFO;
// @formatter:on

private final Visibility visibility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public Map<String, String> getAllParameters(WorkContext workContext) {
return WorkContextUtils.getAllParameters(workContext, name);
}

public void addAdditionInfo(String key, String value) {
WorkContextUtils.addAdditionalInfo(workContext, key, value);
}

/**
* Get Parameters specific to this WorkFlowTask, this is a required parameter
* @param parameterName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,32 @@ public static void addParameter(WorkContext workContext, String key, String valu
WorkContextDelegate.Resource.ARGUMENTS, parameterMap);
}

/**
* add additional info for the workflow, e.g. result links
* @param workContext
* @param key
* @param value
*/
public static void addAdditionalInfo(WorkContext workContext, String key, String value) {
Map<String, String> additionalInfoMap = Optional
.ofNullable(new ObjectMapper().convertValue(
WorkContextDelegate.read(workContext, WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION,
WorkContextDelegate.Resource.ADDITIONAL_INFO),
new TypeReference<HashMap<String, String>>() {
}))
.orElse(new HashMap<>());
additionalInfoMap.put(key, value);
WorkContextDelegate.write(workContext, WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION,
WorkContextDelegate.Resource.ADDITIONAL_INFO, additionalInfoMap);
}

public static Map<String, String> getAdditionalInfo(WorkContext workContext) {
return new ObjectMapper().convertValue(WorkContextDelegate.read(workContext,
WorkContextDelegate.ProcessType.WORKFLOW_EXECUTION, WorkContextDelegate.Resource.ADDITIONAL_INFO),
new TypeReference<>() {
});
}

/**
* get all available parameters for a task
* @param workContext work context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ else if (result instanceof Result.Success<App> success) {
workContext.put("application", success.value());
taskLogger.logInfoWithSlf4j("MTA client returned success result for application creation: {}",
success.value().name());
addAdditionInfo("VCS branch", repo);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What VCS is standing for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

version control system

return new DefaultWorkReport(WorkStatus.COMPLETED, workContext);
}
throw new IllegalArgumentException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ else if (result instanceof Result.Success<TaskGroup> success) {
success.value().tasks()[0].application().id(), success.value().data().output());
taskLogger.logInfoWithSlf4j("MTA client returned success result with report url: {}", reportURL);
addParameter("reportURL", reportURL);
addAdditionInfo("MTA assessment report", reportURL);
notificationSender.send("Migration Analysis Report Completed",
"[Migration analysis report](%s) completed.".formatted(reportURL));
return new DefaultWorkReport(WorkStatus.COMPLETED, workContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class DoNothingWorkFlowTask extends BaseInfrastructureWorkFlowTask {
@Override
public WorkReport execute(WorkContext workContext) {
log.info("DoNothingWorkFlowTask execution should return COMPLETE");
addAdditionInfo("DoNothing", null);
return new DefaultWorkReport(WorkStatus.COMPLETED, workContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class PendingWithAlertMessageWorkFlowTask extends BaseInfrastructureWorkF
@Override
public WorkReport execute(WorkContext workContext) {
log.info("FailedWithAlertMessageWorkFlowTask execution should return PENDING");
addAdditionInfo("Alert message", "http://localhost:8080");
return new DefaultWorkReport(WorkStatus.PENDING, workContext, "[link](http://localhost:8080)");
}

Expand Down
1 change: 1 addition & 0 deletions workflow-service-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Class | Method | HTTP request | Description
- [AccessResponseDTO](docs/AccessResponseDTO.md)
- [AccessStatusRequestDTO](docs/AccessStatusRequestDTO.md)
- [AccessStatusResponseDTO](docs/AccessStatusResponseDTO.md)
- [AdditionalInfo](docs/AdditionalInfo.md)
- [ArgumentRequestDTO](docs/ArgumentRequestDTO.md)
- [ErrorMessageDTO](docs/ErrorMessageDTO.md)
- [ProjectDTO](docs/ProjectDTO.md)
Expand Down
20 changes: 20 additions & 0 deletions workflow-service-sdk/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@ paths:
- STATUS
- WORKFLOW_OPTIONS
- PARENT_WORKFLOW
- ADDITIONAL_INFO
type: string
type: array
style: form
Expand Down Expand Up @@ -930,6 +931,16 @@ components:
- REJECTED
type: string
type: object
AdditionalInfo:
example:
value: value
key: key
properties:
key:
type: string
value:
type: string
type: object
ArgumentRequestDTO:
example:
value: value
Expand Down Expand Up @@ -1523,13 +1534,22 @@ components:
WorkFlowResponseDTO:
example:
workStatus: FAILED
additionalInfos:
- value: value
key: key
- value: value
key: key
workFlowName: workFlowName
executeBy: executeBy
endDate: endDate
workFlowExecutionId: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
projectId: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
startDate: startDate
properties:
additionalInfos:
items:
$ref: '#/components/schemas/AdditionalInfo'
type: array
endDate:
type: string
executeBy:
Expand Down
14 changes: 14 additions & 0 deletions workflow-service-sdk/docs/AdditionalInfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


# AdditionalInfo


## Properties

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**key** | **String** | | [optional] |
|**value** | **String** | | [optional] |



1 change: 1 addition & 0 deletions workflow-service-sdk/docs/WorkFlowResponseDTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
|**additionalInfos** | [**List&lt;AdditionalInfo&gt;**](AdditionalInfo.md) | | [optional] |
|**endDate** | **String** | | [optional] |
|**executeBy** | **String** | | [optional] |
|**projectId** | **UUID** | | [optional] |
Expand Down
2 changes: 1 addition & 1 deletion workflow-service-sdk/docs/WorkflowApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public class Example {
| Name | Type | Description | Notes |
|------------- | ------------- | ------------- | -------------|
| **workFlowExecutionId** | **UUID**| | |
| **param** | [**List&lt;String&gt;**](String.md)| | [enum: ID, NAME, PARAMETERS, ARGUMENTS, STATUS, WORKFLOW_OPTIONS, PARENT_WORKFLOW] |
| **param** | [**List&lt;String&gt;**](String.md)| | [enum: ID, NAME, PARAMETERS, ARGUMENTS, STATUS, WORKFLOW_OPTIONS, PARENT_WORKFLOW, ADDITIONAL_INFO] |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
new com.redhat.parodos.sdk.model.AccessStatusRequestDTO.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(
new com.redhat.parodos.sdk.model.AccessStatusResponseDTO.CustomTypeAdapterFactory());
gsonBuilder
.registerTypeAdapterFactory(new com.redhat.parodos.sdk.model.AdditionalInfo.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(
new com.redhat.parodos.sdk.model.ArgumentRequestDTO.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(
Expand Down
Loading