In this chapter we are going to create business logic layer for already implemented database entities, repositories, and queries. We are going to prepare transfer-objects and use-cases together with facades and proper component tests.
ATTENTION: When you are new to devonfw, it might be a little tricky to get the packaging right and to understand what should go into api
and what should go into core
. Therefore, please consult the architecture-mapping of the devon4j
documentation.
In the dataaccess exercise you have created the Entity infrastructure. Now, we create transfer-objects.
ATTENTION: We create ETOs in the api
module (not in core
)
For each entity we create an ETO
:
-
OrderEto
forOrderEntity
-
ItemEto
forItemEntity
Add all properties from Entity
to Eto
except for relations.
If you have completed the use-cases and still have some time left, you can create the facade for the ordermanagement
component.
Otherwise you can skip here and simply inject the use-cases directly in the next exercises.
The component facade simplifies such injection as you always just inject the component facade via its interface and can find any use-case method via content assist (tab auto-completion).
If other components or the service-layer want to use these use-cases, we can compose them as component-facade: Ordermanagement[Impl]
-
The interface simply extends all use-case interfaces
-
The implementation gets all use-cases injected and delegates to them in the method implementations.
Example:
@Inject
private UcFindOrder ucFindOrder;
...
@Override
public OrderEto findOrder(IdRef<Order> id) {
return this.ucFindOrder.findOrder(id);
}