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

[vrotsc] (#340) Add Workflow canvas Workflow End item #348

Merged
merged 8 commits into from
Jul 22, 2024

Conversation

akantchev
Copy link
Contributor

@akantchev akantchev commented Jul 18, 2024

*New @WorkflowEndItem decorator for Workflows

The decorator is used to specify a custom workflow end item.

Supported Parameters
  • endMode - End mode of the component, could be one of 0 or 1, where 0 is exit success and 1 is error.
  • exceptionVariable - Exception variable that will hold the exception data when triggered.
  • businessStatus - Value of the business status in the end component.

In order to bind inputs and outputs, you do it with the @Out decorator. This is the same way we do it for other items.

Example:

import { Workflow, RootItem, WorkflowEndItem } from "vrotsc-annotations";

@Workflow({
	name: "Workflow End Exception",
	path: "VMware/PSCoE",
	description: "Workflow with root and end item with end mode 1",
	attributes: {
		errorMessage: {
			type: "string"
		},
		businessStatus: {
			type: "string"
		},
		endMode: {
			type: "number"
		}
	}
})
export class WorkflowEnd {

	@RootItem()
	public initiateWorkflow() {
		// NOOP
	}

	@WorkflowEndItem({
		endMode: 1,
		exceptionVariable: "errorMessage",
		businessStatus: "Bad"
	})
	public workflowEnd() {
		// NOOP
	}
}

Checklist

  • I have added relevant error handling and logging messages to help troubleshooting
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation, relevant usage information (if applicable)
  • I have updated the PR title with affected component, related issue number and a short summary of the changes introduced
  • I have added labels for implementation kind (kind/) and version type (version/)
  • I have tested against live environment, if applicable
  • I have my changes rebased and squashed to the minimal number of relevant commits. Notice: don't squash all commits
  • I have added a descriptive commit message with a short title, including a Fixed #XXX - or Closed #XXX - prefix to auto-close the issue

Testing

Added e2e tests to the PR and also tested on an actual environment. Testing process on live environment:

  1. Create project of archetype typescript-project-all.
  2. Add a typescript representation of a workflow as shown in the example above.
  3. Push project to a live environment with vRO.

Release Notes

*New @WorkflowEndItem decorator for Workflows

The decorator is used to specify a custom workflow end item.

Supported Parameters
  • endMode - End mode of the component, could be one of 0 or 1, where 0 is exit success and 1 is error.
  • exceptionVariable - Exception variable that will hold the exception data when triggered.
  • businessStatus - Value of the business status assigned with the end.

In order to bind inputs and outputs, you do it with the @Out decorator. This is the same way we do it for other items.

Related issues and PRs

Implementation of #340

@akantchev akantchev requested a review from a team as a code owner July 18, 2024 12:37
@github-actions github-actions bot added the kind/feature New Feature to the project label Jul 18, 2024
Signed-off-by: Alexander Kantchev <[email protected]>
@akantchev akantchev self-assigned this Jul 18, 2024
@akantchev akantchev added area/vrotsc Relates to `vrotsc` module version/minor Introduces a non-breaking feature or change labels Jul 18, 2024
Signed-off-by: Alexander Kantchev <[email protected]>
@Michaelpalacce
Copy link
Collaborator

Michaelpalacce commented Jul 19, 2024

In the example, why do we have:

@WorkflowEndItem({
    endMode: 1,
    exception: "errorMessage",
  })
  public workflowEnd(@In endMode: number, @Out errorMessage: string) {
    // NOOP
  }

@In endMode?

@@ -19,6 +19,9 @@ import { Workflow, Out, In, Item, RootItem, DecisionItem, WaitingTimerItem, Work
},
result: {
type: "number"
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why modify this test? I see you may be confused but this test is to test the WorkflowItem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually this serves as an integration test for the currently supported components.

exception: "errorMessage",
businessStatus: "Bad"
})
public workflowEnd(@In endMode: number, @Out errorMessage: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is endMode needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is required by the XML representation of the component.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is an input parameter, end-mode is a property of the workflow item. It makes no sense to have it as an input too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code updated.

@WorkflowEndItem({
endMode: 0
})
public workflowEnd(@In endMode: number) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is required by the XML representation of the component.

const endMode = itemInfo?.canvasItemPolymorphicBag?.endMode;
const exceptionVariable = itemInfo?.canvasItemPolymorphicBag?.exception;
const businessStatus = itemInfo?.canvasItemPolymorphicBag?.businessStatus;
const hasException = (exceptionVariable !== null && exceptionVariable !== undefined && exceptionVariable);
Copy link
Collaborator

Choose a reason for hiding this comment

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

! exceptionVariable Checks for all of these

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code updated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not

const hasBusinessStatus = (businessStatus !== null && businessStatus !== undefined && businessStatus);

stringBuilder.append(`<workflow-item name="item${pos}" type="end" end-mode="${endMode}" `);
if (hasException) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

only for endmode 1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually not, you can support endMode = 1 and without throwing of an exception, in case the error is handled in another workflow.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In the UI this is not present, I found no way to do this


interface VroWorkflowEndItemConfiguration {
endMode?: WorkflowEndMode;
exception?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

exception will mean sth else in other items... can we rename this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Code updated.

@akantchev
Copy link
Contributor Author

akantchev commented Jul 19, 2024

In the example, why do we have:

@WorkflowEndItem({
    endMode: 1,
    exception: "errorMessage",
  })
  public workflowEnd(@In endMode: number, @Out errorMessage: string) {
    // NOOP
  }

endMode?

To control the end mode of the end component, this could support the following scenarios:

  1. endMode = 0, success
  2. endMode = 1, error with support of exception throwing.
  3. endMode = 1, error without support of exception throwing.

The use case 3 can be used when the workflow is controlled by other workflow and does not need exception throwing when the exit code is 1

@Michaelpalacce
Copy link
Collaborator

@In endMode: number,

I am ok with it being in the decorator, I meant @In endMode: number,

@akantchev akantchev merged commit 356aa9f into main Jul 22, 2024
14 checks passed
@VenelinBakalov VenelinBakalov deleted the feature/340-canvas-item-end-workflow branch July 29, 2024 07:16
@VenelinBakalov VenelinBakalov changed the title [vrotsc] (#340) Added a new canvas item for workflow end. [vrotsc] (#340) Add Workflow canvas Workflow End item Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vrotsc Relates to `vrotsc` module kind/feature New Feature to the project version/minor Introduces a non-breaking feature or change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants