Lesson 05 - Exposing Business Data

Download Report

Transcript Lesson 05 - Exposing Business Data

Exposing Business Data
Copyright © 2004, Oracle. All rights reserved.
Objectives
After completing this lesson, you should be able to
do the following:
• Describe the role of view objects in the business
components framework
• Create view objects
• Customize view objects by using the View Object
Wizard
• Define relationships between view objects
• Add calculated attributes to view objects
• Explain the role of an application module
• Create an application module
5-2
Copyright © 2004, Oracle. All rights reserved.
View Object in the ADF Architecture
Client Tier
Middle Tier
EIS Tier
Web Container
ADF Business Services Tier
Model
Controller
5-3
ADF
Application
Module
ADF
View
Object
ADF
Entity
Object
Copyright © 2004, Oracle. All rights reserved.
Database
Overview
Entity object
View object
Customers
CustomerStatus
SELECT name, status
FROM customers
ORDER BY name
Name
ID
Name
Status
Web site
5-4
Mike
Steve
Susan
ID
NAME
STATUS
WEBSITE
201
202
Steve
Mike
Gold
Silver
http://www...
http://www...
Database
table
Copyright © 2004, Oracle. All rights reserved.
Status
Silver
Gold
Platinum
View Objects
•
•
•
•
Present a view or slice of business data
Are used for joining, filtering, projecting, and
sorting your business data
Can be based on any number of entity objects
Can also be constructed from a SQL statement
PriorityOrder
Order
5-5
CustomerStatus
Customers
Copyright © 2004, Oracle. All rights reserved.
Interaction Between Views and
Entities: Retrieving Data
•
•
The view object queries the database directly.
Data retrieved by the query is saved to the entity
object’s cache.
EO
getAttr()
•
VO
Nonpersistent attributes are stored and retrieved
from the view object's cache.
getCalcAttr() VO
5-6
Copyright © 2004, Oracle. All rights reserved.
Interaction Between Views and
Entities: Updating Data
•
•
The view object updates the entity object’s cache.
The entity object updates the database.
setAttr()
EO
5-7
Copyright © 2004, Oracle. All rights reserved.
VO
Synchronization of View Objects
When an application module is run, multiple views that
reference the same entity stay synchronized.
Order status
is changed in
one view.
New value is immediately
displayed in other views
based on same entity.
5-8
Copyright © 2004, Oracle. All rights reserved.
Creating a View Object
Using the View Object Wizard
5-9
Copyright © 2004, Oracle. All rights reserved.
Classes Related to View Objects
•
ViewObjectImpl
– This is the view object class.
– It represents a view object.
– Use this class to add or override behaviors that
apply to the view object.
•
ViewRowImpl
– This is the view row class.
– It represents a row in a view object.
– Use this class to add or override behaviors that
apply to a row within the view object.
5-10
Copyright © 2004, Oracle. All rights reserved.
Files Generated for the LineItemView
View Object
•
LineItemView.xml: Metadata
– It is always generated.
– The ADF framework retrieves
run-time metadata from this file.
– JDeveloper design time uses this
file for View Object properties.
•
LineItemViewImpl.java: The view class
– It extends ViewObjectImpl.
– Its generation is optional.
•
LineItemViewRowImpl.java: The view row class
– Extends ViewRowImpl
– Generation is optional.
5-11
Copyright © 2004, Oracle. All rights reserved.
Example of a View Object
PriorityOrder View Object
SELECT Cust.ID, Cust.FIRSTNAME,
Cust.LASTNAME, Cust.STATUS
Ord.ID, Ord.ORDERDATE,
Ord.STATUS
FROM CUSTOMERS Cust, ORDERS Ord
WHERE Cust.ID = Ord.CUSTOMER_ID
AND Cust.status = 'Platinum'
ORDER BY Ord.ORDERDATE
5-12
Customers
Orders
ID
FirstName
LastName
Status
Email
ID
Orderdate
Status
Custid
Trackingno
Copyright © 2004, Oracle. All rights reserved.
Practice 5-1: Overview
This practice covers creating and editing a new
view object.
Select entity
objects
Select
attributes
Edit the
query
5-13
Copyright © 2004, Oracle. All rights reserved.
Calculated Attributes in Views
•
•
5-17
You can add nonpersistent (transient) attributes
based on calculated fields and function calls.
Click New on the Attributes tabbed page of the
View Object Editor.
Copyright © 2004, Oracle. All rights reserved.
View Links
•
•
A view link is an active link between view objects.
You can create view links by providing the
following:
– Source and destination views
– Source and destination attributes
5-18
InventoryItem
OrderForItem
LineItem
Source
view object
Link
Destination
view object
Copyright © 2004, Oracle. All rights reserved.
Traversing Links
•
•
•
Links may be traversed in either direction.
ViewRowImpl.java contains a method to get the
associated row iterator.
Use the methods of RowIterator to move from
row to row and get individual attribute values.
For example, OrdersViewRowImpl contains the
method:
public oracle.jbo.RowIterator getOrderItemsView()
•
5-19
This method returns the detail items for an order.
Copyright © 2004, Oracle. All rights reserved.
Using the Business Components Modeler
for View Objects (I)
•
•
Drag view objects from the Applications Navigator
to the diagram.
Source entity object appears in the view object
box.
Source
entity
object
5-20
Copyright © 2004, Oracle. All rights reserved.
Using the Business Components Modeler
for View Objects (II)
1. Create an empty view object from the Component
Palette.
2. Drag entity objects to the view box.
2
1
5-21
Copyright © 2004, Oracle. All rights reserved.
Application Module in the ADF
Architecture
Client Tier
Middle Tier
EIS Tier
Web Container
ADF Business Services Tier
Model
Controller
5-22
ADF
Application
Module
ADF
View
Object
ADF
Entity
Object
Copyright © 2004, Oracle. All rights reserved.
Database
Application Modules
•
•
•
•
•
•
5-24
Represent the data model for clients
Track all changes that affect the database
Have one connection to the database
Provide remotely accessible methods
May be deployed to multiple platforms without
code changes
May contain other application modules
Copyright © 2004, Oracle. All rights reserved.
Creating an Application Module Using the
Application Module Wizard
5-25
Copyright © 2004, Oracle. All rights reserved.
Using the Business Components Modeler
for an Application Module (I)
•
•
5-26
Drag an application module from the Applications
Navigator to the diagram.
Source view objects appear in the Application
Module box.
Copyright © 2004, Oracle. All rights reserved.
Using the Business Components Modeler
for an Application Module (II)
1. Create an empty application module from the
Component Palette.
2. Drag view objects to the Application Module box.
2
1
5-27
Copyright © 2004, Oracle. All rights reserved.
Summary
In this lesson, you should have learned how to:
• Describe the role of view objects in the business
components framework
• Create view objects
• Customize view objects using the View Object
Wizard
• Define relationships between view objects
• Add calculated attributes to view objects
• Explain the role of an application module
• Create an application module
5-28
Copyright © 2004, Oracle. All rights reserved.
Practice 5-2: Overview
This practice covers the following topics:
• Adding a calculated attribute to a view object
• Modifying the source code to recalculate the
attribute when the view row changes
5-29
Copyright © 2004, Oracle. All rights reserved.