6

BO Inheritance

Copyright © 2009, Oracle. All rights reserved.

Check Point
• You know how to:
• Define a BO's data structure (i.e., its schema)
• Create plug-ins for a BO that hold its more sophisticated business
rules

• In this section, you'll learn additional techniques to avoid
redundant logic
• Note - even more reuse techniques will be unveiled in later
chapters

6-2

Copyright © 2009, Oracle. All rights reserved.

6

Refresher: Stand Alone Data Areas

Copyright © 2009, Oracle. All rights reserved.

. Oracle. </standardTaxpayerElements> Both of the BO's include the stand alone schema's data structure and element rules You can now maintain this data structure in one place rather than in each of the BO's 6-4 <formType mapField="CASE_TYPE_CD" default="1040a. All rights reserved..07" /> <includeDA name="StandardTaxpayerElements"/> <1040page1 type="group" mapXML="BO_DEFN_AREA"> <line1 dataType="number"/> <line2 dataType="number"/> <1040page1/> Form1040ez BO Schema <formType mapField="CASE_TYPE_CD" default="1040ez. .Including Stand Alone Data Areas • You've already learned how you can include stand alone data area schemas in multiple BO's Form1040a BO Schema StandardTaxpayerElements Standalone Schema <standardTaxpayerElements type="group" mapXML="BO_DEFN_AREA"> <ssn required="true" /> <lastName required="true" /> <firstName /> <address1 /> <address2 /> .07" /> <includeDA name="StandardTaxpayerElements"/> <1040ezpage1 type="group" mapXML="BO_DEFN_AREA"> <line1 dataType="number"/> <line2 dataType="number"/> <1040ezpage1/> Copyright © 2009.

Oracle.6 Refresher: Reuse Using Plug-ins Copyright © 2009. . All rights reserved.

All rights reserved.the program type and program name are defined here .Using Algorithms To Avoid Redundant Logic • You've already learned how you can plug-in an algorithm on many different BO's • This is a fine technique to avoid redundant logic Business Object BO / Algorithm Algorithm System Event Algorithm Type Valid Values: • Validation • Pre-processing • Post-processing • Audit • Information Any bug fix / enhancement will automatically apply to all BO's that reference the algorithm type's algorithms 6-6 Copyright © 2009. Oracle. Remember .

All rights reserved.6 Reuse Using Inheritance Copyright © 2009. . Oracle.

Oracle. some object-oriented adherents might argue this is redundant BO: HumanCustomer • • • • • businessName • employerIdentityNbr • … lastName firstName driversLicense … Post Processing: Send welcome letter on add 6-8 BO: BusinessCustomer Post Processing: Send welcome letter on add Copyright © 2009. All rights reserved. we want to send a "welcome letter".Reuse Scenario – Post Processing Rule • Let's assume that whenever a new customer is added. regardless of the type of customer • You've learned you can do this by setting up a post processing algorithm and then plug it in on all relevant BO's • However. .

Put Common Rules On A Parent BO • You can define parent BO's in the meta-data • Some OO adherents would refer to this as a super class • You can then plug-in rules on the parent BO Parent BO: GenericCustomer Post Processing: Send welcome letter on add BO: HumanCustomer • • • • 6-9 lastName firstName driversLicense … A post processing rule defined on a parent BO applies to all of its children BO: BusinessCustomer • businessName • employerIdentityNbr • … Copyright © 2009. . Oracle. All rights reserved.

All rights reserved. the parent's rules automatically apply (no compilation – it's immediate) Parent BO: GenericCustomer Post Processing: Send welcome letter on add BO: HumanCustomer • • • • 6 .10 There's a FK on BO that references a parent BO (this is optional) lastName firstName driversLicense … Copyright © 2009. BO: BusinessCustomer • businessName • employerIdentityNbr • … . the parent and its children must reference the same MO If a BO references a parent BO.Parent BO ERD • A parent BO is simply a BO that is referenced by other BO's Business Object Algorithm • Note. Oracle.

only a welcome letter is sent 6 . Oracle.11 BO: PartnershipCustomer • … When these types of customers are added. . a welcome letter is sent and their credit history is checked Copyright © 2009. All rights reserved.Grandchildren and Great Grandchildren and … • A child BO can have children (and so on) Parent BO: GenericCustomer Post Processing: Send welcome letter on add BO: HumanCustomer • • • • lastName firstName driversLicense … BO: BusinessCustomer Post Processing: Check credit history BO: CorporateCustomer • … When this type of customer is added.

Refresher: Single versus Multi Spots • Recall that a BO can have > 1 algorithm plugged in for the following system events: • • • • Pre-processing Post-processing Validation Audit • Recall that a BO can have only 1 algorithm plugged in for the following system events: • Info • The next slides describe what happens when a given system event has algorithms plugged in at different levels within a BO hierarchy 6 . . Oracle.12 Copyright © 2009. All rights reserved.

All rights reserved.13 BO: PartnershipCustomer • … Copyright © 2009. Oracle.Multi System Events Are "Top Down" • The framework executes all algorithms at all levels for multi system events • It executes algorithms on the highest level BO's first and then moves on to lower levels Parent BO: GenericCustomer 1 Post Processing: Send 2 welcome letter on add Post Processing: Send welcome letter on add BO: HumanCustomer • • • • lastName firstName driversLicense … BO: BusinessCustomer 3 Post Processing: Check credit history BO: CorporateCustomer • … 6 . .

. it executes the one at the level "nearest" to the BO in question Parent BO: GenericCustomer Info: Include customer name BO: HumanCustomer We'd show the customer name for this type of BO We'd show the employer ID.14 BO: BusinessCustomer Info: Include employer ID. name and credit rating BO: CorporateCustomer We'd show the partnership name and credit rating and partnership date for this type of BO BO: PartnershipCustomer Info: Include partnership name and credit rating and partnership date Copyright © 2009. Oracle. customer name and credit rating for this type of BO 6 .Single System Events Are "Find The Nearest" • The framework executes only one algorithm for single system events • If multiple such algorithms exist in the hierarchy. All rights reserved.

.6 Preventing Instantiation Of Parent BO's Copyright © 2009. All rights reserved. Oracle.

the framework will not prevent it by default • Rather. All rights reserved. you must tell the framework if instances of a BO aren't allowed (and there's a flag on BO – Main for this purpose) Parent BO: GenericCustomer Instantiable: No BO: HumanCustomer BO: BusinessCustomer Instantiable: Yes Instantiable: No BO: CorporateCustomer BO: PartnershipCustomer Instantiable: Yes 6 .Instantiable Flag • While it is good practice to not allow users to create instances of parent BO's. Oracle. Instantiable: Yes .16 Notice that we've set up this BO hierarchy to indicate that only non-abstract business objects can have instances created Copyright © 2009.

. Oracle.6 Inheriting Data Structures Copyright © 2009. All rights reserved.

.. Copyright © 2009. they will NOT be inherited by their children • The children must include their parent BO's schema if they want it • For OO adherents – this means that the instance variables on the superclass are not automatically inherited by the subclasses Parent BO: GenericCustomer <name . /> . . /> <customerId . /> <marketingContact . /> . BO: HumanCustomer BO: BusinessCustomer <includeBO name="GenericCustomer" /> <dateOfBirth ..Data Structures Are NOT Implicitly Inherited • While you can declare schemas on parent BO's........... All rights reserved.Note ... 6 ... /> <mothersMaidenName .18 <includeBO name="GenericCustomer" /> <employerIdentityNumber . Oracle. /> ..

/> .19 Copyright © 2009.. <employerIdentityNumber .....Warnings Are Issued • If you neglect to include an element that exists on a parent BO...... All rights reserved.. A warning will be issued for this BO 6 . the framework will issue a warning when you edit a child BO Parent BO: GenericCustomer <name . /> <marketingContact ..... . /> . /> <mothersMaidenName ... Oracle.. /> <customerId . BO: BusinessCustomer BO: HumanCustomer <includeBO name="GenericCustomer" /> <dateOfBirth . /> .

All rights reserved.6 Inheritance and Ownership Copyright © 2009. Oracle. .

Only The Owning Implementation Can Change A BO's Schema • Refresher: • BO's are owned • The owning implementation is defined on the installation record • You can't change a BO's schema whose owner flag differs from the one on the installation record BO: Customer Owner: C1 (Base) <name . /> <customerId .21 You can only modify this BO's schema if the owner flag on the installation record is C1 (and typically only the base-package team will have such an installation record) Copyright © 2009.. . All rights reserved.... /> ... Oracle. 6 .

. /> <marketingContact ... Copyright © 2009. this is not true. you can add to it by creating a BO and including the other BO's schema Note. You can include a BO in any other BO (but avoid recursion!) BO: Customer Owner: C1 (Base) <name . . All rights reserved.Including A BO You Don't Own • While you can't change the schema of a BO that your implementation doesn't own..22 <includeBO name="Customer" /> <employerIdentityNumber . /> . the implementation will get them too (for better or for worse) 6 . This shows how a "CM" implementation can add additional elements to a base-package BO BO: MyCustomer Owner: CM (Customer) This means that when elements are added to Customer in a future release by the basepackage team. Oracle... /> .... /> <customerId ... this implies that the included BO must be the parent..

/> .. This shows a CM algorithm on a CM business object 6 . BO: MyCustomer Owner: CM (Customer) <includeBO name="Customer" /> <employerIdentityNumber . /> <customerId ...... Oracle.....23 Owner: CM (Customer) Validation: Check My Elements Copyright © 2009. /> ... All rights reserved. .CM Algorithms on CM Objects • Implementations can obviously add algorithms to their BO's BO: Customer Owner: C1 (Base) <name . /> <marketingContact .

24 BO: PartnershipCustomer • … Copyright © 2009. All rights reserved. . but you just want to add additional logic? BO: GenericCustomer Let's assume you just want to add another post-processing algorithm to this BO that's owned by the basepackage… Post Processing: Send welcome letter on add BO: HumanCustomer • • • • lastName firstName driversLicense … BO: BusinessCustomer Post Processing: Check credit history BO: CorporateCustomer • … 6 . what if you're happy with the base-package functionality.Avoiding Unnecessary Child BO's • However. Oracle.

All rights reserved.You Can Add Algorithms To BO's You Don't Own • You can add algorithms to BO's you don't own BO: GenericCustomer Owner: C1 (Base) Owner: C1 (Base) Post Processing: Send welcome letter on add Notice the 2nd algorithm's owner flag (CM) differs from the owner of the BO (C1) We did this so you could add additional validation / processing without having to create a child BO BO: BusinessCustomer Owner: C1 (Base) Owner: C1 (Base) Post Processing: Check credit history Owner: CM (Customer) Post Processing: Create To Do entry 6 . Oracle. .25 Copyright © 2009.

All rights reserved. Oracle.26 Business Object BO / Algorithm Copyright © 2009. There is a sequence number on this table that controls the order of execution . you must define its sequence number (this allows you to position your algorithms before or after other logic) • You must select a unique sequence • After an upgrade. it's possible for your algorithms to have the same sequence number as a base-package algorithm • If this happens. an error will be issued at run time and you must reassign the sequence number (there is no clear upgrade path for duplicate sequences) BO: BusinessCustomer Owner: C1 (Base) Owner: C1 (Base) Post Processing: Check credit history Sequence: 10 Owner: CM (Customer) Post Processing: Create To Do entry Sequence: 15 6 .Algorithm Sequence • When you add an algorithm to a BO.

just accept that you can inactivate a base-package algorithm BO: BusinessCustomer Owner: C1 (Base) Owner: C1 (Base) Post Processing: Check credit history Sequence: 10 Owner: CM (Customer) Post Processing: Create To Do entry Sequence: 15 6 . All rights reserved. there is a way to tell the framework to not execute it • You do this by using a BO option • We only talk about options in chapter 8 so you'll have to wait until then until you learn the technique • For now. . Oracle.Foreshadowing: Disabling Base-Package Algorithms • While you cannot remove a base-package algorithm from a BO.27 There is a way that you can tell the base-package to not execute this algorithm Copyright © 2009.

Oracle.6 Inheriting a Nightmare Copyright © 2009. . All rights reserved.

Oracle.. weigh the reuse benefits against the cost in transparency • It's not easy to maintain a complex hierarchy of BO's • Most base-package architects avoid complex hierarchies as they are typically only clear to the person who designed the hierarchy. . the perceived maintenance benefits are elusive • As a rule of thumb. i.e.Use Parent BO's Wisely • It's intellectually attractive to abstract behavior into parent BO's (super classes) to avoid redundant logic and simplify maintenance • But before doing this. we subject hierarchies with more than 2 layers to intense peer review before implementing them 6 .29 Copyright © 2009. All rights reserved.

. please check the answer in your workbook and ask your instructor to clarify anything you don't understand 6 .30 Copyright © 2009. All rights reserved. Oracle.Team Walk Through (90 minutes) • Add simple validation to a new child BO • Break up into teams and follow the instructions in your workbook Before you start adding any meta-data.

Oracle.Walk Through Addendum • In real life. an implementation would never have to create a child BO to just add some validation because an implementation team can add their own Validation algorithm directly to the base-package BO (and it will survive future upgrades) • This exercise was structured like this so as to avoid concurrency issues 6 .31 Copyright © 2009. . All rights reserved.

.Review Questions 6 . Oracle.32 Copyright © 2009. All rights reserved.

. Oracle.33 Copyright © 2009.6 . All rights reserved.