introduction to enterprise objects framework

59
Temporary image Introduction to Enterprise Objects Framework Session 703

Upload: others

Post on 21-Jan-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Enterprise Objects Framework

Temporary image

Introduction toEnterprise Objects Framework

Session 703

Page 2: Introduction to Enterprise Objects Framework

Introduction toEnterprise Objects Framework

James DempseyOperations Engineer

Apple Software Customer Seeding

Page 3: Introduction to Enterprise Objects Framework

What You’ll Learn•An overview of the purpose and benefits of EOF•Introduction to basic database operations•Working with persistent objects•Demonstration of desktop EOF applications•A conceptual model of how EOF works

Page 4: Introduction to Enterprise Objects Framework

Technology Framework•An introduction to the EOAccess and

EOControl frameworks of EOF•These frameworks form the core of

database access in• HTML and XML-based

WebObjects applications• Cocoa EOF applications• Java Client applications

Page 5: Introduction to Enterprise Objects Framework

4/29/004/29/00

firstNamefirstName “Fred”“Fred”

startDatestartDate

salarysalary 60,00060,000

departmentdepartment

DepartmentDepartment

1,000,0001,000,000

namename “Sales”“Sales”

budgetbudget

Object-Oriented Applications•Different classes of

objects to modeldifferent types

•Each object stores data•Each class of object has

behavior—business logic•How does object state

persist between uses?

EmployeeEmployee

Page 6: Introduction to Enterprise Objects Framework

NAME BUDGETDEPT_ID

DEPARTMENT

R&D 4,000,000501

Sales 1,200,000502

NAME SALRY SDATE DEPT_IDE_ID

EMPLOYEE

Fred 60,000 4/29/00 503101

Beth 65,000 1/19/00 501102

•Different tables modeldifferent types of data

•Each row stores data•Database can execute

stored procedures•How to use the data

in an object-orientedmanner?

Database-Driven Applications

Page 7: Introduction to Enterprise Objects Framework

An object-relational persistence layer

Enterprise Objects Framework

•Uses the natural mapping between objectsand relational databases

•Abstracts business logic and database operations•Preserves object-oriented nature of

persistent objects•Sophisticated, mature, object-oriented

architecture

Page 8: Introduction to Enterprise Objects Framework

4/29/004/29/00

firstNamefirstName “Fred”“Fred”

startDatestartDate

salarysalary 60,00060,000

departmentdepartment

EmployeeEmployee

Enterprise Objects

•Implement theEOEnterpriseObjectinterface

•Objects with built-inpersistence

Affectionately known as EOs

Page 9: Introduction to Enterprise Objects Framework

NAME SALARY ST_DATE DEPT_IDEMP_ID

EMPLOYEE

Fred 60,000 4/29/00 503101

Beth 65,000 1/19/00 501102

Entities and Attributes

1/19/001/19/00

firstNamefirstName “Beth”“Beth”

startDatestartDate

salarysalary 65,00065,000

departmentdepartment

EmployeeEmployee

4/29/004/29/00

firstNamefirstName “Fred”“Fred”

startDatestartDate

salarysalary 60,00060,000

departmentdepartment

EmployeeEmployee

Page 10: Introduction to Enterprise Objects Framework

4/29/004/29/00

firstNamefirstName “Fred”“Fred”

startDatestartDate

salarysalary 60,00060,000

departmentdepartment

EmployeeEmployee

Relationship by Reference

DepartmentDepartment

1,000,0001,000,000

namename “Sales”“Sales”

budgetbudget

A unique reference to another object

Page 11: Introduction to Enterprise Objects Framework

NAME BUDGETDEPT_ID

DEPARTMENT

R&D 4,000,000501

Sales 1,200,000502

NAME SALARY ST_DATE DEPT_IDEMP_ID

EMPLOYEE

Fred 60,000 4/29/00 503101

Beth 65,000 1/19/00 501102

Relationship by JoinA unique primary key value in another table

Page 12: Introduction to Enterprise Objects Framework

4/29/004/29/00

firstNamefirstName “Fred”“Fred”

startDatestartDate

salarysalary 60,00060,000

departmentdepartment

EmployeeEmployee

NAME SALARY ST_DATE DEPT_IDEMP_ID

EMPLOYEE

Fred 60,000 4/29/00 503101

From Row to EO and Back

Page 13: Introduction to Enterprise Objects Framework

Model Defines the MappingDefine object-relational mapping in EOModeler

Page 14: Introduction to Enterprise Objects Framework

DatabaseDatabase

HTML-Based

WebObjects

Application

HTML-Based

WebObjects

Application

XML-Based

WebObjects

Application

XML-Based

WebObjects

Application

Cocoa

EOF

Application

Cocoa

EOF

Application

Java Client

EOF

Application

Java Client

EOF

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

Multiple Views, Same Data

Page 15: Introduction to Enterprise Objects Framework

Logic Written in Standard Java

DatabaseDatabase

HTML-Based

WebObjects

Application

HTML-Based

WebObjects

Application

XML-Based

WebObjects

Application

XML-Based

WebObjects

Application

Cocoa

EOF

Application

Cocoa

EOF

Application

Java Client

EOF

Application

Java Client

EOF

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

Object-oriented design in a widely used language

Page 16: Introduction to Enterprise Objects Framework

Distributed ProcessingOff-load logic processing to applications

DatabaseDatabase

HTML-Based

WebObjects

Application

HTML-Based

WebObjects

Application

XML-Based

WebObjects

Application

XML-Based

WebObjects

Application

Cocoa

EOF

Application

Cocoa

EOF

Application

Java Client

EOF

Application

Java Client

EOF

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

Page 17: Introduction to Enterprise Objects Framework

Dynamically Generated SQL

DatabaseDatabase

HTML-Based

WebObjects

Application

HTML-Based

WebObjects

Application

XML-Based

WebObjects

Application

XML-Based

WebObjects

Application

Cocoa

EOF

Application

Cocoa

EOF

Application

Java Client

EOF

Application

Java Client

EOF

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

Transactions and statements generated by EOF

Page 18: Introduction to Enterprise Objects Framework

Access to Database FeaturesCan access stored procedures and execute customSQL from within EOF as needed

DatabaseDatabase

HTML-Based

WebObjects

Application

HTML-Based

WebObjects

Application

XML-Based

WebObjects

Application

XML-Based

WebObjects

Application

Cocoa

EOF

Application

Cocoa

EOF

Application

Java Client

EOF

Application

Java Client

EOF

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

Page 19: Introduction to Enterprise Objects Framework

Multiple Data Sources

DatabaseDatabase

HTML-Based

WebObjects

Application

HTML-Based

WebObjects

Application

XML-Based

WebObjects

Application

XML-Based

WebObjects

Application

Cocoa

EOF

Application

Cocoa

EOF

Application

Java Client

EOF

Application

Java Client

EOF

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

Using data from different sources abstracted at alow level—programmatic interface remains the same

DatabaseDatabaseDatabaseDatabase

Page 20: Introduction to Enterprise Objects Framework

Editing

Context

Editing

ContextEditing

Context

Editing

ContextEditing

Context

Editing

ContextEditing

Context

Editing

ContextEditing

Context

Editing

ContextEditing

Context

Editing

Context

Separate ‘Scratch Pad’ Per User

DatabaseDatabase

HTML-Based

WebObjects

Application

HTML-Based

WebObjects

Application

XML-Based

WebObjects

Application

XML-Based

WebObjects

Application

Cocoa

EOF

Application

Cocoa

EOF

Application

Java Client

EOF

Application

Java Client

EOF

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

EOF-based

Application

Each user provided a separate context for makingedits and canceling changes

Page 21: Introduction to Enterprise Objects Framework

Basic EOF Operations•Fetch•Insert•Update•Delete•Save•Revert

Page 22: Introduction to Enterprise Objects Framework

EOEditingContextEOEditingContext

EOEditingContext

•Fetches from the database•Observes updates to all

EOs it has fetched•Tracks inserts and deletes•Keeps changes until they

are saved or reverted

The class you use most for programmatic control

Page 23: Introduction to Enterprise Objects Framework

•Every session in a WebObjects application has adefault editing context

•Editing context for desktop apps lives in nib file•You can create your own as well

EOEditingContext ec =session().defaultEditingContext();

EOEditingContext ec =new EOEditingContext();

Getting an Editing Context

Page 24: Introduction to Enterprise Objects Framework

•Default editing context is automatically lockedand unlocked in WebObjects applications

•Nib-based editing contexts not locked by default•Lock and unlock editing contexts that you create

before and after useec.lock();

// use editing contextec.unlock();

Locking the Editing ContextFor use with multi-threaded applications

Page 25: Introduction to Enterprise Objects Framework

Fetching

•Create a fetch specification•Access an editing context•Tell editing context to fetch

using the specification•Receive an array of retrieved

Enterprise Objects

Many techniques—all with same underlying steps

Page 26: Introduction to Enterprise Objects Framework

Graphical Fetch BuilderDefine fetch graphically in EOModeler

Page 27: Introduction to Enterprise Objects Framework

EOFetchSpecification spec;NSDictionary bindings;NSArray results;

EOEditingContext ec =session().defaultEditingContext();

results =EOUtilities.

objectsWithFetchSpecificationAndBindings(ec, “Customer”, “FetchSpec”, bindings);

Performing the Fetch•Fetching returns an array of EOs

Page 28: Introduction to Enterprise Objects Framework

eo =EOUtilities.createAndInsertInstance

(ec, “Employee”);

Creating and Inserting•Two separate steps combined in one

convenience methodEOEnterpriseObject eo;EOEditingContext ec;

Page 29: Introduction to Enterprise Objects Framework

ec.deleteObject(eo);

Deleting•Tell the editing context to delete the object;

It will be deleted next time changes are savedEOEnterpriseObject eo;EOEditingContext ec;

Page 30: Introduction to Enterprise Objects Framework

•Make changes using standard accessors—the editing context observes all changes

•Key Value Coding provides generic accessors

Employee employee;

employee.setName(“Jerry Long”);

employee.takeValueForKey(“Jerry Long”, “name”);

employee.valueForKey(“name”);

Editing

Page 31: Introduction to Enterprise Objects Framework

•Pending changes are not sent to the databaseuntil you tell editing context to save changes

•Pending changes are discarded by tellingthe editing context to revert

editingContext.saveChanges();

editingContext.revert();

Saving and Reverting Changes

Page 32: Introduction to Enterprise Objects Framework

DemoGenevieve PuruggananWebObjects Engineering

Page 33: Introduction to Enterprise Objects Framework

Using EOs as Objects•Subclass EOGenericRecord and add class-specific

business logic and validation logic•Call methods, put ‘em in collections, hook ‘em

up to user interface elements•Think about them as objects, and leave the

database concepts in the database•Example: Relationships

Page 34: Introduction to Enterprise Objects Framework

NSArrayNSArray

An Example Relationship

4/29/004/29/00

firstNamefirstName “Fred”“Fred”

startDatestartDate

salarysalary 60,00060,000

departmentdepartment

DepartmentDepartment

1,000,0001,000,000

namename “Sales”“Sales”

budgetbudget

EmployeeEmployee

employeesemployees

Page 35: Introduction to Enterprise Objects Framework

EmployeeEmployee

emailemail

ProjectProject

employeeemployee

EmailAddressEmailAddress

addressaddress “[email protected][email protected]

An Example

Page 36: Introduction to Enterprise Objects Framework

SELECT t0.Comments, t0.CreatedBy,

t0.CreatedByMethod, t0.CreationDate, t0.ID,

t0.PortalInvitationText, t0.ModificationDate,

t0.ModifiedBy, t0.ModifiedByMethod,

t0.PrimarySeedEngineer, t0.ProjectDescription,

t0.ProjectInternalName, t0.ProjectName, t0.Status

FROM Projects t0 WHERE t0.Status = "Active"

Some SQL

Page 37: Introduction to Enterprise Objects Framework

SELECT t0.ParticipantProjectMailingAddressID,

t0.Comments, t0.CreatedBy, t0.CreatedByMethod,

t0.CreationDate, t0.DefaultConfigurationID,

t0.ParticipantProjectEmailAddressID, t0.Grade, t0.ID,

t0.ModificationDate, t0.ModifiedBy,

t0.ModifiedByMethod, t0.NumBugsSubmitted,

t0.NumDiscussionEntries, t0.NumIssuesSubmitted,

t0.NumSurveysCompleted,

t0.NumSurveysRequested, t0.ParticipantEndDate,

t0.ParticipantID, t0.ParticipantStartDate, t0.ProjectID,

t0.RanWizard, t0.Status FROM ParticipantProjects t0

WHERE t0.ID = 9145

Some SQL

Page 38: Introduction to Enterprise Objects Framework

SELECT t0.AgeRange, t0.Comments, t0.Company,

t0.CreatedBy, t0.CreatedByMethod, t0.CreationDate,

t0.PrimaryTestingEnvironment, t0.FileMakerID,

t0.FirstName, t0.Gender, t0.ID, t0.JobTitle,

t0.LastName, t0.MiddleInitial, t0.ModificationDate,

t0.ModifiedBy, t0.ModifiedByMethod,

t0.NDADateSigned, t0.NDAVersion, t0.NickName,

t0.Occupation, t0.ParticipantGrade,

t0.ProgramStatus, t0.Salutation,

t0.SelectionJustification FROM Participants t0

WHERE t0.ID = 9145

Some SQL

Page 39: Introduction to Enterprise Objects Framework

SELECT t0.CreatedBy, t0.CreatedByMethod,

t0.CreationDate, t0.EmailDescription,

t0.EmailAddress, t0.ID, t0.IsDefault,

t0.EmailAddressIsInvalid, t0.ModificationDate,

t0.ModifiedBy, t0.ModifiedByMethod, t0.ParticipantID

FROM ParticipantEmailAddresses t0 WHERE

t0.ParticipantID = 1516

Some SQL

Page 40: Introduction to Enterprise Objects Framework

project.employee.emailAddress.email

Or a Key Path•Attach a user interface element

Page 41: Introduction to Enterprise Objects Framework

DemoGenevieve PuruggananWebObjects Engineering

Page 42: Introduction to Enterprise Objects Framework

Desktop Database Applications

•Event driven applications demand a moredynamic interface than the web

•In Model-View-Controller design pattern, muchcontroller code is synching view to model

•EOInterface abstracts much of thiscontroller work

A user interface challenge beyond the web

Page 43: Introduction to Enterprise Objects Framework

DemoGenevieve PuruggananWebObjects Engineering

Page 44: Introduction to Enterprise Objects Framework

Fred 60,000 4/29/00 503101

EOAccessEOAccess

EOEO

EOControlEOControl

EOInterfaceEOInterface

The EOF StackWho are the frameworks in your neighborhood?

DatabaseDatabase

Page 45: Introduction to Enterprise Objects Framework

Adaptor LayerAdaptor Layer

Database LayerDatabase Layer

EOModelEOModel

EOAccess Framework

DatabaseDatabase

Page 46: Introduction to Enterprise Objects Framework

EOModelGroupEOModelGroup

EOModelEOModel

EOModelEOModel

Multiple Data Sources

Database LayerDatabase Layer

Adaptor LayerAdaptor Layer

DatabaseDatabase

Database LayerDatabase Layer

Adaptor LayerAdaptor Layer

DatabaseDatabase

Multiple EOModels, one per data source

Page 47: Introduction to Enterprise Objects Framework

EOObjectStore

Coordinator

EOObjectStore

Coordinator

EOEditingContextEOEditingContext EOEditingContextEOEditingContext EOEditingContextEOEditingContext

EOControl FrameworkEOAccess coordination and programming control

EOModelGroupEOModelGroup

EOModelEOModel

EOModelEOModel

Database LayerDatabase Layer

Adaptor LayerAdaptor Layer

DatabaseDatabase

Database LayerDatabase Layer

Adaptor LayerAdaptor Layer

DatabaseDatabase

Page 48: Introduction to Enterprise Objects Framework

EOInterfaceEOInterface

EOInterface Framework

EOObjectStore

Coordinator

EOObjectStore

Coordinator

EOEditingContextEOEditingContext EOEditingContextEOEditingContext EOEditingContextEOEditingContext

EOModelGroupEOModelGroup

EOModelEOModel

EOModelEOModel

Database LayerDatabase Layer

Adaptor LayerAdaptor Layer

DatabaseDatabase

Database LayerDatabase Layer

Adaptor LayerAdaptor Layer

DatabaseDatabase

Page 49: Introduction to Enterprise Objects Framework

Review

Page 50: Introduction to Enterprise Objects Framework

WebObjects Lab•Located downstairs in Room L•Lab hours

• Monday 12:00pm–6:00pm• Tuesday 9:00am–2:00pm*• Wednesday 9:00am–6:00pm• Thursday 9:00am–6:00pm• Friday 9:00am–6:00pm*Conversion Workshop Tuesday 2-6pm; Sign up in Lab

Page 51: Introduction to Enterprise Objects Framework

Room A1Thurs., 3:30pm

Room A1Thurs., 3:30pm

711 Advanced Data Modelingand Connectivity

Room A1Thurs., 5:00pm

Room A1Thurs., 5:00pm

712 Advanced Enterprise ObjectsFrameworks

Room A1Fri., 10:30am

Room A1Fri., 10:30am

714 Optimizing WebObjects Applications

Roadmap

Page 52: Introduction to Enterprise Objects Framework

Services Consulting, Integration, Training and Certification

(800) [email protected]

Bob FraserWebObjects Product [email protected]

Toni Trujillo VianDirector, WebObjects [email protected]

Who to Contact

http://developer.apple.com/wwdc2002/urls.html

Page 53: Introduction to Enterprise Objects Framework

For More Information•WebObjects Developer Documentation

http://developer.apple.com/techpubs/webobjects

•Apple Professional Services Technical Support(www.apple.com/services/technicalsupport)

•Other places• www.apple.com/webobjects

• developer.apple.com/webobjects

• www.apple.com/services

• www.info.apple.com/webobjects

Subscribe to:[email protected]

Page 54: Introduction to Enterprise Objects Framework

DocumentationEnterprise Objects Framework Develop’s Guide

Page 55: Introduction to Enterprise Objects Framework

How to Access Documentation•Most up-to-date: PDF and HTML

http://developer.apple.com/techpubs/webobjects•Hardcopy print-on-demand

Vervante.com under Related Resources•Product CD

Documents folder and installed in /Developer/Documentation/WebObjects

•In the box (localized) Installation Guides, What’s New, WebObjects Overview, Java Client Desktop Applications, Discovering WebObjects for HTML

•Check ADC News for latest updates http://developer.apple.com/devnews

Page 56: Introduction to Enterprise Objects Framework

Q&A

Toni Trujillo VianDirector, WebObjects Engineering

[email protected]

http://developer.apple.com/wwdc2002/urls.html

Page 57: Introduction to Enterprise Objects Framework

© 2001 and TM Apple Computer, Inc. All rights reserved.

Page 58: Introduction to Enterprise Objects Framework

© 2001 and TM Apple Computer, Inc. All rights reserved.

Page 59: Introduction to Enterprise Objects Framework

© 2001 and TM Apple Computer, Inc. All rights reserved.