Download sample application with working Business Logic Group defined for Employees EO - BusinessGroups.zip.
In order to define Business Logic Group, you need to specify which attribute from EO will be used as discriminator to choose between available Business Logic Units:
Next step is to define Business Logic Unit. Its very important at this step to enter correct Unit Name. It should reflect discriminator value for this Business Logic Unit. In my case it is IT_PROG, for employees working as programmers. It is a place where you need to specify discriminator:
In sample application I have created two Business Logic Units, one for IT_PROG and another for ST_CLERK JobId's:
In Business Logic Unit, you need to override attributes you want to change. Then you can change those attributes properties, add validation rules. In this example I have created validation rule for overridden Salary attribute:
Another validation rule for Salary attribute is defined in ST_CLERK Business Logic Unit:
I have specified different Salary attribute labels for IT_PROG and ST_CLERK Business Logic Units:
Additionally through Business Logic Unit you can implement custom behavior in Business Logic Unit Java class:
On runtime you can see Business Logic Group related behavior for IT_PROG:
And for ST_CLERK:
Hello Andrejus,
ReplyDeleteGreat topic, and very nice good feature, but when i create a new business logic group I can't choose DepartmentId to be discrimintor attribute and it forced me to choose firstName,LastName,Email,JobId and PhoneNumber only(HR schema)
Thank you
Karim Hasan
Hi Karim,
ReplyDeleteYes, it seems it works only on String type attributes.
Regards,
Andrejus
I think its actually logical to have on String type for discriminator.
ReplyDeleteAndrejus
Hello Andrejus,
ReplyDeleteIn my application, Business Unit Logic(BLU) Component is in different project and the entity is in another project. Implemented beforePost() in BLU. When I am trying to save a record, beforePost() in BLU is not getting called. Same works properly when both BLU and entity are in same project. Please provide the inputs on how to overcome the issue when both components are in different project.
Thank you,
Rahul