Task App - Task Overview Projection

Task Overview Projection

1
Select the Use Case Type Projection (P)
  • After selecting an aggregate, click the Use Case Projection (P)
  • Your cursor turns into the P icon
2
Place the Projection
  • Click on the Plan to place the Projection
  • The Projection Use Case will then appear on the Plan

Projection Use Case placed on the Plan

Use Case Sub Menu

1
Select the added Projection (P) Use Case
  • Click the added Projection (P) Use Case.

Projection with open sub elements view

Add Source Events

1
Open the Use Case menu
  • Click the Use Case menu icon on left side.
2
Add 'task added' Event
  • Select the 'task added' source event and press the add button.
3
Add 'task completed' Event
  • Select the 'task completed' source event and press the add button.

Projection 'task overview' with Events

Rename Projection

1
Change the Readmodel name
  • Click the name input of the Readmodel.
  • Type in 'task overview'.
  • Confirm the new name by clicking on 'save'.

API Request with changed name

Schema

1
Add 'task id' property
  • Click the plus icon on the right.
  • Type 'task id' in the name input.
  • Select 'uuid' in the type dropdown.
  • Check the 'primary key' checkbox.
  • Click the ✓ to save the property.
2
Add 'task added' Event properties
  • Click the 'copy to readmodel' button on the 'task added' Event.
  • The properties 'title', 'description' and 'assignee id' will appear in the Readmodel schema.
  • All 3 properties already have the corresponding Values Source.
3
Add 'task status' property
  • Click the plus icon on the right.
  • Type 'task status' in the name input.
  • Select 'enum' in the type dropdown.
  • Select 'task status' in the enum dropdown.
  • Click the ✓ to save the property.

Readmodel with new properties

Project Task Added

Projection Operation

1
Set the Projection operation
  • Keep the option 'upsert one' as Projection Operation.

Projection with Projection Operation 'upsert one'

Condition

1
Add Projection condition for the 'task added' Event
  • Click the plus button next to 'conditions' of the Readmodel on the right of the 'task added' Event
2
Select the Value Target
  • Select the property 'task id'.
The Value Target is a property of the Readmodel schema.
The Value Target provides the property name of the projection WHERE condition.
3
Value Source type
  • Select the Value Source type 'Metadata'.
4
Select the Value Source
  • Select 'task added.aggregate id'.
  • Click the ✓ to save the Condition.
The Value Source provides the property value of the projection WHERE condition.

Projection with condition

Value Sources

1
Set the Value Source for the 'task id' property
  • Click the plus button on the right of the 'task id' property.
2
Value Source type
  • Select the Value Source type 'Metadata'.
3
Select the Value Source
  • Select 'task added.aggregate id'.
  • Click the ✓ to save the Value Source.
4
Set the Value Source for the 'task status' property
  • Click the plus button on the right of the 'task status' property.
5
Set the Value Source type for the 'task status' property
  • Select the Value Source type 'Static'.
6
Set 'open' as Static Value Source for the 'task status' property
  • Select the Value Source value 'open'.
  • Click the ✓ button on the right.

Projection for 'task added' Event

Project Task Completed

Projection Operation

1
Set the Projection operation
  • Set the option 'update one' as Projection Operation.

Projection with Projection Operation 'update one'

Condition

1
Add Projection condition for the 'task completed' Event
  • Click the plus button next to 'conditions' of the Readmodel on the right of the 'task completed' Event
2
Select the Value Target
  • Select the property 'task id'.
The Value Target is a property of the Readmodel schema.
The Value Target provides the property name the projection WHERE condition.
3
Value Source type
  • Select the Value Source type 'Metadata'.
4
Select the Value Source
  • Select 'task completed.aggregate id'.
  • Click the ✓ to save the Condition.
The Value Source provides the property value of the projection WHERE condition.

Projection with condition

Value Sources

1
Set the Value Source for the 'task id' property
  • Click the plus button on the right of the 'task id' property.
2
Value Source type
  • Select the Value Source type 'Metadata'.
3
Select the Value Source
  • Select 'task completed.aggregate id'.
  • Click the ✓ to save the Value Source.
4
Set the Value Source for the 'task status' property
  • Click the plus button on the right of the 'task status' property.
5
Set the Value Source type for the 'task status' property
  • Select the Value Source type 'Static'.
6
Set 'completed' as Static Value Source for the 'task status' property
  • Select the Value Source value 'completed'.
  • Click the ✓ button on the right.

Projection for 'task completed' Event

Set Overview Projection Ready

1
Select task overview projection Use Case
  • Click the task overview projection Use Case.
2
Open the Use Case menu
  • Click the Use Case menu icon on left side.
3
Set generation status to ready
  • Set the generation status from 'planned' to 'ready'.
Planned Use Cases have a blue border, the Code Generator wont generate its code.
Ready Use Cases have a gray border, the Code Generator generates its code.

The three Use Cases are ready for Code Generation

Generate the Code

1
Open the Code Generator menu
  • Click on the 'Code' button to open the Code Generator menu.
2
Start Code Generation
  • Click the 'Generate Code' button.
3
Generating code
  • Wait until the activity indicator disappears and 'Code Generation done' is displayed under the button.
  • Open the selected Path with an IDE or Text Editor.

The generated code

Next
Query Task Overview

© 2024 Codebricks | All rights reserved.