Skip to content

Conversation

@sjvans
Copy link
Contributor

@sjvans sjvans commented Oct 13, 2025

summary

makes use of new status-transition flows feature of cds^9.5:

  • check entry state(s) for action → previously unchecked
  • set to exit state for action → remove custom handlers
  • automatically add ui artifacts → remove unnecessary annotations

cds w --profile flow

extends to a more complex flow incl. usage of @to: $flow.previous.
for that, status InReview and Blocked as well as actions reviewTravel, reopenTravel, blockTravel, and unblockTravel were added in order to create a scenario where the previous state of Blocked can be either Open or InReview.

visualization of the flow:
image


related

@sjvans sjvans changed the title feat: add status transition flows feat: add status transition flows (incl. @to: $flow.previous) Nov 23, 2025
@sjvans sjvans changed the title feat: add status transition flows (incl. @to: $flow.previous) feat: status transition flows Dec 1, 2025
@sjvans sjvans changed the title feat: status transition flows feat: status-transition flows Dec 1, 2025
@sjvans sjvans marked this pull request as ready for review December 1, 2025 00:21
Copy link
Member

@danjoa danjoa left a comment

Choose a reason for hiding this comment

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

Looks good. 👍
Please see my comments before merging...

Comment on lines 18 to 24
// Define flow for Travels
annotate Travels with @flow.status: Status actions {
rejectTravel @from: #Open @to: #Canceled;
acceptTravel @from: #Open @to: #Accepted;
deductDiscount @from: #Open;
};

Copy link
Member

Choose a reason for hiding this comment

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

Should we move that to a separate file srv/travel-flow.cds ?

Copy link
Contributor Author

@sjvans sjvans Dec 3, 2025

Choose a reason for hiding this comment

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

unfortunately leads to an interesting error with profile flow:

xtravels % cds w --profile flow

cds serve all --with-mocks --in-memory? --profile flow 
( live reload enabled for browsers ) 

        ___________________________
 
[ERROR] srv/travel-flow.cds:5:20-24: Duplicate assignment with “@from” (in annotate:“TravelService.Travels”/action:“rejectTravel”)
[ERROR] srv/travel-flow.cds:6:20-24: Duplicate assignment with “@from” (in annotate:“TravelService.Travels”/action:“acceptTravel”)
[ERROR] xmpls/flow/flow-previous.cds:18:20-24: Duplicate assignment with “@from” (in annotate:“TravelService.Travels”/action:“acceptTravel”)
[ERROR] xmpls/flow/flow-previous.cds:19:20-24: Duplicate assignment with “@from” (in annotate:“TravelService.Travels”/action:“rejectTravel”)

→ i'll follow up with the compiler team

@sjvans sjvans merged commit 8e129e4 into main Dec 4, 2025
3 checks passed
@sjvans sjvans deleted the flows branch December 4, 2025 10:14
sjvans added a commit to capire/xtravels-java that referenced this pull request Dec 15, 2025
### summary

makes use of new status-transition flows feature of cds-services^4.5 and
cds^9.5:
- check entry state(s) for action → previously unchecked → TODO: true?
- set to exit state for action → remove custom handlers
- automatically add ui artifacts → remove unnecessary annotations

### `CDS_ENV=flow mvn cds:watch`

extends to a more complex flow incl. usage of `@to: $flow.previous`.
for that, status `InReview` and `Blocked` as well as actions
`reviewTravel`, `reopenTravel`, `blockTravel`, and `unblockTravel` were
added in order to create a scenario where the previous state of
`Blocked` can be either `Open` or `InReview`.

visualization of the flow:
<img width="913" height="444" alt="image"
src="https://github.com/user-attachments/assets/8dd98cdf-7a01-4e55-85bc-a2a7d69fdd16"
/>

---

### related

- capire/xtravels#12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants