Skip to content

Latest commit

 

History

History
63 lines (43 loc) · 1.98 KB

logic.asciidoc

File metadata and controls

63 lines (43 loc) · 1.98 KB

Logic Layer

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 together with use-cases and proper component tests.

Transfer objects

In the dataaccess exercise you have created the dataaccess layer. Now, for the logic layer we create the entity interfaces and transfer-objects in the package org.example.app.task.common.

For each entity we extract interface and create ETO:

  • for TaskListEntity extract interface TaskList and create class TaskListEto.

  • for TaskItemEntity extract interface TaskItem and create class TaskItemEto.

Ensure you have all properties (getters and setters) from Entity in the entity interface except for relations.

TOs

Mappers

You also have to create a Mapstruct mapper per interface, e.g.:

@Mapper(componentModel = "cdi")
public interface TaskItemMapper {

  // Declare your mapper methods here ...
}

The mapper implementation will be generated during build and can be found in the corresponding package under target/generated-sources/annotations.

Use-Cases

Now that we have created ETOs and mappers, we create use-cases for CRUD functionality on our business-objects:

  • UcFindTaskList

  • UcFindTaskItem

  • UcSaveTaskList

  • UcSaveTaskItem

  • UcDeleteTaskList

  • UcDeleteTaskItem

Each of use-case implementation shall be annotated as following:

@ApplicationScoped
@Named
@Transactional