Example how to wrap a Business Task into Business Entity interface?
 
Forums / SmartComponent Library - Developer Forum / Example how to wrap a Business Task into Business Entity interface?

Example how to wrap a Business Task into Business Entity interface?

4 posts, 2 answered
  1. Patrik Wikström
    Patrik Wikström avatar
    68 posts
    Registered:
    15 Oct 2018
    11 May 2023
    Link to this post
    I remember Mike showed us, or then you have an example somewhere that we can't find anymore about how to wrap a Business Task into a Business Entity service? Could you help us with this one please?
  2. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    Answered
    11 May 2023 in reply to Patrik Wikström
    Link to this post
    I don't think you want to wrap a Business Task in a Business Entity. In the OERA model a Business Task can be the container for a number of Business Entities.

    What you may want to do is to write a Business Task that implements the IBusinessEntity Interface. When you are in the Business Entity Designer, the Consultingwerk.BusinessEntityDesigner.Plugins.BusinessEntityBusinessTaskGeneratorPlugin is a wizard that generates a Business Task implementing the IBusinessEntity interface based on the BusinessEntityBusinessTask base class. 
  3. Patrik Wikström
    Patrik Wikström avatar
    68 posts
    Registered:
    15 Oct 2018
    12 May 2023
    Link to this post
    One more question comes into my mind, which use cases does this solve? 
    Why would one want to use this approach?
  4. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    Answered
    12 May 2023 in reply to Patrik Wikström
    Link to this post
    Architecture choices. 

    There's a school of thought saying that a Business Entity should never call into another Business Entity.

    When a request requires data from multiple Business Entities, that should be coordinated by a Business Task. And if that combined data needs to be exposed for instance to a JSDO read request, then the Business Tasks needs to implement the IBusinessEntity Interface.

    Another school of though says that during a read request it's o.k. to call other Business Entities from a Business Entity.

    But what when an update to one table needs to trigger an update in a table that's part of another Business Entity? In that case again, a BT could implement IBusinessEntity:SaveChanges() and coordinate the SaveChanges in the two BE's in response to the JSDO updateData request. 

    But again another school of though says, that in those cases, the first BE can coordinate the update in th second. 

    Each development team needs to define the architecture and standards they follow. 
4 posts, 2 answered