Você está na página 1de 24

Practices for Lesson 3:

Employee Business Object


Overview

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 1 of 24

Rev 1

Practices for Lesson 3


Distribution
*

Job Title

Ownership
The Job Title [list@YourCompany.com?Subject=Practices for Lesson 3: Employee Business
Object: 030_Employee_Business_Object.doc] is responsible for ensuring this document is
necessary, reflects actual practice, and supports corporate policy.

Lesson Overview
This walk through describes how to define a new Business Object, starting with the creation of
the Business Entity Java class and then defining a simple Maintenance Object, along with the
infrastructure to add new objects of this type.

Lesson Objectives
By the end of this chapter, you will be able to:

Create a Business Entity Java class

Create an Entity Page Maintenance Java class

Define the Service metadata

Define the metadata for a custom Maintenance Object

Define a Business Object for a Maintenance Object that includes custom fields mapped to
an XML column.

Create a maintenance UI map for the business object.

Invoke this maintenance map to add data.

Note that many of the names of definitions used in these exercises contain ZZ (e.g.
CM_ZZ_). The instructor may advise you to use your initials, or some other unique
identifier, in place of ZZ to prevent conflicts with the definitions of other students.

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 2 of 24

Rev 1

Practice 3-1: Create the Employee Business Entity


Overview
In this walk through, you will create the Employee Business Entity Java classes.

Tasks
1.

Create the Employee Business Entity

For these exercises, we will create package com.splwg.cm.domain.hr. Right-click on


the java source folder and select the New -> Package menu item

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 3 of 24

Rev 1

Type the new package name com.splwg.cm.domain.hr in the Name field and click
Finish.

Select the newly created com.splwg.cm.domain.hr package (so that it is highlighted as


shown in the next screenshot) and then click on the New button

It is VERY IMPORTANT that you always work in the java folder in this project, and NOT the gen folder.
The gen folder is reserved for the Artifact Generator. If you accidentally create files in the gen folder,
they will be erased when you next run the Artifact Generator.

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 4 of 24

Rev 1

On the New dialog, select the Entity wizard under the Oracle Utilities, Customizations
node and click Next

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 5 of 24

Rev 1

The New Entity wizard dialog will show. Populate it as shown below and click Finish
(confirm with the instructor what you should substitute for ZZ in these names)

This will generate a Java class that should look as follows

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 6 of 24

Rev 1

Now run Artifact Generator to generate CmZZEmployee_Gen and the rest of the
supporting files. Click on the Run button

and select the _Generate Artifacts run configuration (the name will be prefixed with the
name of your project, Training in the example below)

If this dialog appears, click Proceed

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 7 of 24

Rev 1

Monitor the artifact generation run in the Console view and wait for it to end

Verify that the following Java files were generated in the gen folder

Click on the Training project and hit F5 to refresh (and compile) the project. This should
generate the binary code for the newly created java files.

The Business Entity for Employee should now be created and there should be no errors
in the project

You have now created your first business entity. In the next walk through you will create an
entity page maintenance that uses this new business entity.

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 8 of 24

Rev 1

Practice 3-2: Create the Employee Entity Page Maintenance


Overview
In this walk through, you will create the Employee Entity Page Maintenance Java classes.

Tasks
1.

Create the Employee Entity Page Maintenance Java file and generate the service XML. As
with the creation of the Business Entity in the previous walk through, select the
com.splwg.cm.domain.hr package so that it is highlighted and click the New button. On
the New dialog, select the Page Service wizard and click Next

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 9 of 24

Rev 1

Select Page Type Entity and click Next

Populate the fields as shown here and click the Edit DataElement button

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 10 of 24

Rev 1

Click the Edit contents button

Click the + button to add a new child annotation entry

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 11 of 24

Rev 1

Select Row and click OK

Supply the entity name as shown here and click Finish

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 12 of 24

Rev 1

Continue clicking Finish to close all the dialogs until the New Page Service dialog again
has the focus, then click the Add button next to the Modules text box

Click the Search by value button, select value DV and click OK

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 13 of 24

Rev 1

Note that the module code of DV is being added here to work around a problem with this
wizard. For customizations, the module code should in fact be empty, but the wizard does
not generate it at all unless it contains a value. You will manually correct this in the
generated annotation in the source code shortly.

Click Finish on the New Page Service

The new Java class should look as below.

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 14 of 24

Rev 1

Now remove the modules value so that the annotation looks as follows (note that the
red-encircled text above, including quotes, has been removed)

Click the Save button to save your Java changes

2.

Run Artifact Generator again to generate the CmZZEmployeeMaintenance_Gen Java


file and CMZZEMPLP service XML. Refer back to task #1 for the steps if needed.

Monitor the Console view and when it is finished, click on the Training project and hit F5
to refresh (and compile) the project.

Verify that the following Java files were generated in the gen folder.

Build and deploy the cm.jar containing your new custom programs to the web application
server.

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 15 of 24

Rev 1

Shutdown your web application server. Your instructor will assist with this if needed.
The application must be shutdown now because in the following steps you will update
the SPLService.ear file and restart the application server.

Click on the External tools drop-down button

and select the _Deploy CM run configuration (the name will be prefixed with the name
of your project, Training in the example below)

Monitor the Console view. It should take no more than a few seconds and should look
similar to the screenshot below when completed.

Restart the Web application server. Again, ask the instructor for assistance if required.

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 16 of 24

Rev 1

Practice 3-3: Define the Employee Maintenance Object


Overview
In this walk through, you will define the Employee Maintenance Object and its Service
Metadata. Practices 1 and 2 above must have been successfully completed before this
exercise can be done.

Tasks
1.

Launch the application using the URL and user Id and password provided by the instructor
E.g. http://localhost:4410/spl/cis.jsp

2.

Define the Service

Open the Service Program page in add mode (Admin menu) and supply the following
Service Name:
Description:
Service Type:

3.

CMZZEMPP (created in the previous walk through)


ZZ's Employee Service Program
Java Based Service

Save your work

Define Application Security for the new service

Open the Application Service page in add mode (Admin menu) and supply the
following
Application Service:
Description:

CMZZEMPP
ZZs Employee Application Service

Access Mode
Add
Change
Delete
Inquire

Save your work

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 17 of 24

Rev 1

Select the Application Security tab. Locate the ALL_SERVICES group in the User
Groups Without Access zone. Click the Grant Access button. You will be navigated to
the User Group Maintenance for ALL_SERVICES. Wait until you see your application
service name.
Set the expiration date to 1/1/2100. Add the following access modes.
Add
Change
Delete
Inquire

Save your work

Flush all caches and refresh your application page to ensure the new security settings
are available. For example
http://localhost:4410/spl/flushAll.jsp

4.

Define the Maintenance Object

Open the Maintenance Object page in add mode (Admin menu) and supply the
following
Maintenance Object:
Description:
Program Com Id:
Service Name:

CMZZEMPLOYEE
ZZs Employee Maintenance Object
CIPYPGDJ
CMZZEMPP

Table
CM_ZZ_EMPLOYEE

Table Role
Primary

Save your work

Select the Options tab and add the following option:


Option Type:
Sequence:
Value:

BO Maintenance (Y/N)
10
Y

Save your work

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 18 of 24

Rev 1

Select the Algorithms tab and add the following algorithm:


System Event:
Sequence:
Algorithm:

Determine BO
10
F1-STD-DTMBO

Save your work

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 19 of 24

Rev 1

Practice 3-4: Create the Employee Business Object


Overview
In this walk through, you will create the Employee Business Object that includes two fields
mapped to XML fields.

Tasks
1.

Create two additional fields that will be mapped to XML columns in the CLOB.

Open the Field page in add mode (it's on the Admin menu) and add the following field
definitions:
Field Name:
Data Type:
Precision:
Description:
Java Field Name:

CM_ZZ_HOME_PHONE
Character
16
CM ZZ Home Phone
cmZZHomePhone

Save your work


Field Name:
Data Type:
Precision:
Description:
Java Field Name:

CM_ZZ_EMAIL
Character
60
CM ZZ Email
cmZZEmail

Save your work


2.

Create the business object and its schema.

Open the Business Object page in add mode (it's on the Admin menu) and set the
following data on the Main tab:
Business Object:
Description:
Maintenance Object:
Application Service:
Instance Control:

CM_ZZ_EmployeeBO
CM ZZ Employee Business Object
CMZZEMPLOYEE
CMZZEMPP
Allow new instances.

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 20 of 24

Rev 1

Select the Schema tab. In the Dashboard, locate the BO Schema zone, and click the
Generate button. The Schema Editor zone will be updated with the generated schema.

Remove the element cmZZEmployeeDataArea, mapped to the field


CM_ZZ_EMP_DATA_AREA. This is everything between the < and > brackets,
including the brackets.

Add two additional fields, inside a group element named employeeDetail, mapped to
the CM_ZZ_EMP_DATA_AREA field.
element name:
mdField:

cmZZHomePhone
CM_ZZ_HOME_PHONE

element name:
mdField:

cmZZEmail
CM_ZZ_EMAIL

Like this:
<cmZZEmployeeDetail type="group" mapXML="CM_ZZ_EMP_DATA_AREA">
<cmZZHomePhone mdField="CM_ZZ_HOME_PHONE"/>
<cmZZEmailAddress mdField="CM_ZZ_EMAIL"/>
</cmZZEmployeeDetail>

Look for the version element. Add the attribute suppress=true after
mapField=VERSION. This will ensure that no text box will be generated on the UI
this field should not be editable on a UI.
Save your work

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 21 of 24

Rev 1

Practice 3-5: Create the Maintenance UI Map for the Employee


BO, and a Script to invoke it
Overview
In this walk through, you'll create the maintenance (input) UI map for your employee business
object, along with a BPA script that will allow you to add an employee.

Tasks
1.

Create the UI Map.

Open the UI Map page in add mode (it's on the Admin menu) and set the following data
on the Main tab:
UI Map:
Map Type:
Description:

CM_ZZ_EmployeeMaint
Complete HTML Document
ZZs Employee Maintenance UI Map

In the Schema Editor tab, update the schema to include your BO:
<schema>
<includeBO name="CM_ZZ_EmployeeBO"/>
</schema>
Save your work

In the Dashboard, locate the Generate HTML zone, and click the Input Map button.
Click OK if prompted by Confirm: Overwrite existing information? The HTML Editor
zone will be populated with a UI map definition.
Save your work

2.

Click the Test UI Map link to see what your UI map looks like.

Create the BPA script.

Open the Script page in add mode (it's on the Admin menu) and set the following data
on the Main tab:

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 22 of 24

Rev 1

Script:
Description:
Script Type:
Accessibility:
Application Service:
Script Engine Version:

cmZZAddEmp
CM ZZ Add Employee
BPA Script
Accessible from Script Menu
F1-DFLTAPS
1.0

Select the Data Area tab and add your UI Map object:
Schema Type:
UI Map
Object:
CM_ZZ_EmployeeMaint
Save your work

Select the Steps tab and add the following steps:


10:
Set Height to 0 pixels.
20:
Invoke your UI Map CM_ZZ_EmployeeMaint, with Group Name
CM_ZZ_EmployeeMaint, with target = Page Area.
In the Returned Values area, add a row for a Returned Value of CANCEL, which
should be the default, and Next Script Step = 99.
30:
Invoke your Business Object CM_ZZ_EmployeeBO using group name
CM_ZZ_EmployeeMaint, Action = Add. If success, go to step 99. If Error, go to step
20.
99:
Terminate
Save your work

2.

Test your work.

Execute your BPA script. Find the Favorite Scripts zone in the Dashboard. Click the
Search link.

Search for your BPA script, named CM ZZ Add Employee. Click it to execute.

Your UI map should be displayed in the page area. Enter values for employee ID,
name fields, etc. and click the Save button. If the BPA goes away, your Employee data
has been saved. If not, the UI map should be redisplayed with error information.
Correct the problem and submit again.

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 23 of 24

Rev 1

Review Questions

Copyright 2012, Oracle and/or its affiliates. All rights reserved.


Practices for Lesson 3: Employee Business Object
Effective mm/dd/yy

030_EMPLOYEE_BUSINESS_OBJECT.DOC
Page 24 of 24

Rev 1