StrataFrame Forum

Business Object Relationships

http://forum.strataframe.net/Topic713.aspx

By Robert Linton - 3/23/2006

I've got 3 business objects defined as follows:

CaseBO {pkCaseId, CaseDesc, fkClientId, fkContactId}

ClientBO {pkClientId, ClientName}

ContactBO {pkContactId, ContactName, fkClientId

I've created a form, called Case Form

On my Case form I have an instance of all three BO's, successfully related, and as I navigate the CaseBO I can display any number of fields from the related Client and Contact BO's. All's well so far...

Now I create a second form, Client Form.

I drop an instance of the ClientBO and ContactBO and begin to setup the relationships...here's where I run into an issue. In order to setup a relationship between these instances of ClientBO and ContactBO on the new form (clientBO1.pkClientId<->contactBO1.fkClientId), I have to break the relationships I'd set up on the first form (caseBO1.fkClientId<->clientBO1.pkClientId & caseBO1.fkContactId<->contactBO1.pkContactId)

It seems that a BO will only allow one association? I'm sure I'm missing something here, I don't think that's correct because, if it is, I'd have to create a new BO for each kind of association...duplicating a lot of code in the process.

TIA,

Rob

By StrataFrame Team - 3/24/2006

Rob,



Yes, you define the relationship parameters at the class level, so a business object is intended to have the same relationship parameters, no matter what the instance. However, the actual business object that comprises the other end of the relationship is defined on a per-instance basis. So, you define the parent relationship parameters once, which defines the fields that make up the key, and then you assign the parent object on a per-child instance basis.



As you mentioned, however, you can create two different associations by creating two different business object classes... but, you can avoid the code duplication by inheriting one from the other. The subclass would then only need to redefine the relationship parameters.



Now, in the case of a many-to-many relationship, where the link table requires two different relationships at the same time, you can use the BusinessLayerLinkManager class. It allows you to specify the relationships between the 3 business objects that comprise the many-to-many relationship and will maintain the referential integrity between those 3 business objects.
By Kevin Lingofelter - 3/27/2006

Is this just a matter of dropping the link manager on a form and setting the properties?
By Trent L. Taylor - 3/28/2006

Yes.  Drop a BusinessObjectLinkManager on a form and set the respective properties.  You will also need to have the three business objects that you plan to use on the form so they can be associated with the LinkManager.  As you move forward let me know if you have any questions.  We will be releasing the docs for this in the next week.