Vous êtes sur la page 1sur 51

Utilities Practice @ HCL

ORACLE Technical
Training
 560 – ORACLE V2 for
Developers

Version 1.0
Agenda
1. Introduction to ORACLE Framework
2. ORACLE Services
3. Business Entities
4. Artifact Generator
5. Introduction to Eclipse
6. Change Handlers Part I – Validation Rules
7. Unit Testing
8. Change Handlers Part II – Conditional Validation
9. Messages

2
Agenda
10. Change Handlers Part III – Conditions
11. Change Handlers Part IV – Custom Validation Rule
12. Change Handlers Part V – Cascading Changes
13. Algorithms Part I – Validation
14. Algorithms Part II – Validation & Formatting
15. ORACLE Batch Part I – Simple Batch
16. ORACLE Batch Part II – ToDo Creation
17. Custom User Interface (UI)

3
Utilities Practice @ HCL

Algorithms
Part I
 ORACLE Technical
Training
Algorithms - Overview
 Where system requires customization, ORACLE provides for
customizable algorithms (a.k.a plug-ins)
 Base algorithms exist, but can be cloned and modified
 Like “user exits”, but …
 Unlike Change Handlers, more related to business functions
and events
 Also, unlike Change Handlers, use configurable (“soft”)
parameters
 For example …
 In CC&B world, if CSR requests customers recommended
deposit amount, system calls “deposit recommendation
algorithm” to calculate amount
 If base version of algorithm not appropriate, new algorithm can
be coded to replace base on
 At upgrades, custom algorithms will not be overwritten

5
Algorithms - Overview
 Some more examples where algorithms are used
 Validating the format of a phone number entered by a user
 Validating the format of a latitude/longitude geographic code
entered by a user.
 Calculating late payment charges in ORACLE CC&B
 Calculating the recommended deposit amount in ORACLE
CC&B
 Constructing your GL account during the interface of financial
transactions to your GL in ORACLE CC&B
 And many other functions...
 Let’s take a look at how algorithms work internally …

6
Algorithms - Overview
 Algorithms are defined in 2 places
1. Database tables
2. ORACLE Framework (Java classes / COBOL programs)
 Online Admin menu used to define database components
1. Algorithm Types
2. Algorithms
3. Event / activity to which algorithm applies (e.g. FT freeze,
phone number validation, etc.)
 ORACLE Framework requires “implementation” class and various
generated artifacts
 Let’s take a look at the online definitions first …

7
Algorithm Database Model
1 CI_ALG_TYPE CI_ALG Customized Entity
PK ALG_TYPE_CD PK ALG_CD

PGM_NAME FK1 ALG_TYPE_CD FK1 ALG_CD


ALG_ENTITY_FLG VERSION
PGM_TYPE_FLG

CI_ALG_PARM
CI_ALG_TYPE_PRM PK,FK2 ALG_CD
PK,FK1 ALG_TYPE_CD PK EFFDT
PK SEQNO PK,FK1 SEQNO

PARM_REQ_SW ALG_PARM_VAL
FK1 ALG_TYPE_CD
 Algorithm database tables
1. Algorithm Type defines …
 Entity – e.g. Char Type – Adhoc Value Validation, SA
Type – SA Creation, etc.
 Program name
 Program type – JAVA or COBOL
8
Algorithm Database Model
1 CI_ALG_TYPE CI_ALG Customized Entity
PK ALG_TYPE_CD PK ALG_CD

PGM_NAME FK1 ALG_TYPE_CD FK1 ALG_CD


ALG_ENTITY_FLG VERSION
PGM_TYPE_FLG

CI_ALG_PARM
2 CI_ALG_TYPE_PRM PK,FK2 ALG_CD
PK,FK1 ALG_TYPE_CD PK EFFDT
PK SEQNO PK,FK1 SEQNO

PARM_REQ_SW ALG_PARM_VAL
FK1 ALG_TYPE_CD

 Algorithm database tables


2. Algorithm Type Parameter defines …
 Parameters expected by algorithm program
 Required / optional
9
Algorithm Database Model
1 CI_ALG_TYPE 3 CI_ALG Customized Entity
PK ALG_TYPE_CD PK ALG_CD

PGM_NAME FK1 ALG_TYPE_CD FK1 ALG_CD


ALG_ENTITY_FLG VERSION
PGM_TYPE_FLG

4 CI_ALG_PARM
2 CI_ALG_TYPE_PRM PK,FK2 ALG_CD
PK,FK1 ALG_TYPE_CD PK EFFDT
PK SEQNO PK,FK1 SEQNO

PARM_REQ_SW ALG_PARM_VAL
FK1 ALG_TYPE_CD

 Algorithm database tables


3. Algorithm defines an “instance” of algorithm type – many
algorithms may exist for one algorithm type
4. Algorithm Parameter defines parameter values for the
instance

10
Algorithm Database Model
1 CI_ALG_TYPE 3 CI_ALG 5 Customized Entity
PK ALG_TYPE_CD PK ALG_CD

PGM_NAME FK1 ALG_TYPE_CD FK1 ALG_CD


ALG_ENTITY_FLG VERSION
PGM_TYPE_FLG

4 CI_ALG_PARM
2 CI_ALG_TYPE_PRM PK,FK2 ALG_CD Examples
PK,FK1 ALG_TYPE_CD PK EFFDT
PK SEQNO PK,FK1 SEQNO Characteristic Type
PARM_REQ_SW ALG_PARM_VAL SA Type
FK1 ALG_TYPE_CD
Etc.
 Algorithm database tables
5. Algorithm code is specified on customized entity’s
configuration table – algorithm will be invoked based on this
specification
 Let’s look at an example …

11
Algorithm Phone Format
Example
Phone format - algorithm definition diagram
Algorithm Type:PHN-FMT Algorithm:PHN-FMT-US Phone Type: BUSN
Format 1 – required (999) 999-9999
Format 2 – optional
Format 3 – optional Algorithm:PHN-FMT-UK Phone Type: BUSN_UK
Format 4 thru 9 – optional 999 9999-9999
99999 999999
9999 999-9999

CI_ALG_TYPE CI_ALG Phone Type


PK ALG_TYPE_CD PK ALG_CD

PGM_NAME FK1 ALG_TYPE_CD FK1 ALG_CD


ALG_ENTITY_FLG VERSION
PGM_TYPE_FLG

CI_ALG_PARM
CI_ALG_TYPE_PRM PK,FK2 ALG_CD
PK,FK1 ALG_TYPE_CD PK EFFDT
PK SEQNO PK,FK1 SEQNO

PARM_REQ_SW ALG_PARM_VAL
FK1 ALG_TYPE_CD
12
Algorithm Phone Format
Example
Admin -> Algorithm Type – Phone format
1

2
3
4

1. Algorithm Type name – 12 characters


2. System will ONLY allow PHN-FMT algorithm type to be
specified on Phone Type entity
Note: Java name for algorithm entity will also be required
for annotations during coding – will see example shortly
3. Program type JAVA (can also be COBOL) 13
Algorithm Phone Format
Example
Admin -> Algorithm Type – Phone format
1

2
3
4

4. Algorithm component interface to format and validate phone


Note: for JAVA class to be specified, class must already
exist as framework component
5. At least one phone format is required
14
Algorithm Phone Format
Example
Admin -> Algorithm – Phone format US
1

4
1. Algorithm name – 1st “instance” of algorithm type
2. Algorithm type parent definition
3. Effective dated – can create multiple sequences, each with
different effective date
4. Phone format for this instance – U.S. has only one phone 15
format
Algorithm Phone Format
Example
Admin -> Algorithm – Phone format UK
1

1. Algorithm name – 2nd “instance” of algorithm type


2. Same algorithm type as for U.S. (i.e. SAME PROGRAM)
3. U.K. has multiple phone formats 16
Algorithm Phone Format
Example
Admin -> Phone Type – Algorithm usage

1
2

 Defines 2 types of business phones


1. U.S. phone numbers to be validated and formatted
by “North American phone format” algorithm
2. U.K. phone numbers to be validated and formatted
by “United Kingdom phone format” algorithm

17
Algorithm Phone Format
Example
Main -> Person – Algorithm activation
1

 On Person page, Phone Type now determines algorithm to


invoke for phone number formatting and validation

Next we’ll see how ORACLE Framework components are built


to do this …

18
Algorithm Spots
 “Call out” places in system (e.g. from Person to validate phone
number) are known as algorithm spots
 Each algorithm spot has interface class
 Communication with algorithm takes place through interface
 Interface provides abstraction between base and customization

Business Algorithm
Algorithm Spot
Component Interface Component
PhoneTypeFormat
PhoneTypeFormat
Person Phone ValidationAlgorithmSpot
ValidationAlgComp

19
Algorithm Spots
 Attributes of an algorithm spot interface class
 Internal to framework – only created by Product Development

 API to algorithm component (from base application)

 Specific to algorithm entity type (or system “event”)

 Defines hard input parameters for algorithm

 Defines output parameters that can be retrieved after algorithm


has been invoked

20
Algorithm Spots
 These classes form part of base code
 Invoked from base at appropriate times (events)
 Methods on interface related to algorithm type – e.g.
setPhoneValue() only relevant to
PhoneTypeFormatValidationAlgorithmSpot
«interface»
AdhocCharacteristicValueValidationAlgorithmSpot
+setFormatOnly() : void
+setCharacteristicType() : void
+setAdhocValue() : void
+getReformattedValue() : String
«interface»
+isValidAdhoc() : Boolean
AlgoritmSpot
+invoke()
«interface»
PhoneTypeFormatValidationAlgorithmSpot
+setPhoneValue() : void
+setPhoneType() : void
+isValidPhoneValue() : Boolean
+getPreferredFormatString() : String 21
+getReformattedPhoneValue() : String
Algorithm Components
 Algorithm requires programmatic implementation
 Algorithm Type specifies program name – e.g.
com.ORACLEwg.base.domain.common.phoneType.
PhoneTypeFormatValidationAlgComp
This name in fact specifies another interface – generated from
implementation class
 Implementation class has name = interface name + “Impl” – e.g.
com.ORACLEwg.base.domain.common.phoneType.
PhoneTypeFormatValidationAlgComp_Impl
 Following diagram describes full Phone Type Validation algorithm
component …

22
Algorithm Components – Phone
Type Validation
 Remember …
 Interface is “empty” – requires implementation to perform
appropriate tasks
 Implementation for algorithm spot is Algorithm Component –
i.e. Business Component «interface»
AlgoritmSpot
+invoke()

«interface»
PhoneTypeFormatValidationAlgorithmSpot
+setPhoneValue() : void V2.0.10 +
+setPhoneType() : void
+isValidPhoneValue() : Boolean
+getPreferredFormatString() : String
+getReformattedPhoneValue() : String

V2.0.6
PhoneTypeFormatValidationAlgComp_Gen
PhoneTypeFormatValidationAlgComp_Impl
«interface»
+getPhoneFormat1() : String
PhoneTypeFormatValidationAlgComp
+getPhoneFormat2() : String
+setPhoneValue() : void +invoke() : void
+getPhoneFormat3() : String
+setPhoneType() : void +setPhoneValue() : void
+getPhoneFormat4() : String
+isValidPhoneValue() : Boolean +setPhoneType() : void
+getPhoneFormat5() : String
+getPreferredFormatString() : String +isValidPhoneValue() : Boolean
+getPhoneFormat6() : String
+getReformattedPhoneValue() : String +getPreferredFormatString() : String
+getPhoneFormat7() : String
+getPhoneFormat8() : String
+getReformattedPhoneValue() : String 23
+getPhoneFormat9() : String
Algorithm Components – Phone
Type Validation
1. Implementation class (…_Impl) is hand coded – can be customized
2. Component interfaces generated by artifact generator – customized
versions will be generated for custom “impl” class
3. Algorithm invoked via component interface
«interface»
AlgoritmSpot
+invoke()

«interface»
PhoneTypeFormatValidationAlgorithmSpot
+setPhoneValue() : void V2.0.10 +
+setPhoneType() : void
+isValidPhoneValue() : Boolean
+getPreferredFormatString() : String
+getReformattedPhoneValue() : String

2 V2.0.6
PhoneTypeFormatValidationAlgComp_Gen 1
3
PhoneTypeFormatValidationAlgComp_Impl
«interface»
+getPhoneFormat1() : String
PhoneTypeFormatValidationAlgComp
+getPhoneFormat2() : String
+setPhoneValue() : void +invoke() : void
+getPhoneFormat3() : String
+setPhoneType() : void +setPhoneValue() : void
+getPhoneFormat4() : String
+isValidPhoneValue() : Boolean +setPhoneType() : void
+getPhoneFormat5() : String
+getPreferredFormatString() : String +isValidPhoneValue() : Boolean
+getPhoneFormat6() : String
+getReformattedPhoneValue() : String +getPreferredFormatString() : String
+getPhoneFormat7() : String
+getReformattedPhoneValue() : String
+getPhoneFormat8() : String
+getPhoneFormat9() : String 24
Algorithm Components –
Phone Type Validation
1. Implementation class contains hand coded logic
2. _Gen class has methods for “soft” parameters (as specified on
Algorithm Type definition)
Note: Generated from annotations in “_Impl” class
«interface»
AlgoritmSpot
+invoke()

«interface»
PhoneTypeFormatValidationAlgorithmSpot
+setPhoneValue() : void V2.0.10 +
+setPhoneType() : void
+isValidPhoneValue() : Boolean
+getPreferredFormatString() : String
+getReformattedPhoneValue() : String

2 V2.0.6
PhoneTypeFormatValidationAlgComp_Gen 1
PhoneTypeFormatValidationAlgComp_Impl
«interface»
+getPhoneFormat1() : String
PhoneTypeFormatValidationAlgComp
+getPhoneFormat2() : String
+setPhoneValue() : void +invoke() : void
+getPhoneFormat3() : String
+setPhoneType() : void +setPhoneValue() : void
+getPhoneFormat4() : String
+isValidPhoneValue() : Boolean +setPhoneType() : void
+getPhoneFormat5() : String
+getPreferredFormatString() : String +isValidPhoneValue() : Boolean
+getPhoneFormat6() : String
+getReformattedPhoneValue() : String +getPreferredFormatString() : String
+getPhoneFormat7() : String
+getReformattedPhoneValue() : String
+getPhoneFormat8() : String
+getPhoneFormat9() : String 25
Algorithm Components –
Phone Type Validation
3. Generated component interface class also contains “factory”
class to create instance of algorithm component – we’ll see
example shortly
«interface»
AlgoritmSpot
+invoke()

«interface»
PhoneTypeFormatValidationAlgorithmSpot
+setPhoneValue() : void V2.0.10 +
+setPhoneType() : void
+isValidPhoneValue() : Boolean
+getPreferredFormatString() : String
+getReformattedPhoneValue() : String

V2.0.6
PhoneTypeFormatValidationAlgComp_Gen
PhoneTypeFormatValidationAlgComp_Impl
«interface»
+getPhoneFormat1() : String
3
PhoneTypeFormatValidationAlgComp
+getPhoneFormat2() : String
+invoke() : void
+setPhoneValue() : void +getPhoneFormat3() : String
+setPhoneType() : void +setPhoneValue() : void
+getPhoneFormat4() : String
+isValidPhoneValue() : Boolean +setPhoneType() : void
+getPhoneFormat5() : String
+getPreferredFormatString() : String +isValidPhoneValue() : Boolean
+getPhoneFormat6() : String
+getReformattedPhoneValue() : String +getPreferredFormatString() : String
+getPhoneFormat7() : String
+getReformattedPhoneValue() : String
+getPhoneFormat8() : String
+getPhoneFormat9() : String

26
Algorithm Implementation Class
 Base versions of all algorithms provided by ORACLE
 To create new one, easiest to duplicate appropriate base one if
exists and modify
 Basic Java elements of new algorithm …
 “_Impl” class – implementation class that contains logic

 “_Gen” class – implementation class for “soft” parameters –


generated by AG
 Component interface class – generated by AG

 Message method if required

27
Algorithm Phone Format
Example
1

3
4

 Annotation specifies …
1. Algorithm entity – i.e. where in system used – corresponds with
entity defined on Algorithm Type (we will see shortly how to
determine this name)
2. Soft parameters expected – correspond with Algorithm Type
28
parameter definitions
Algorithm Phone Format
Example 1

3
4
 Class name …
3. Has Algorithm Component name (as specified on Algorithm
Type) + “_Impl”
4. Extends “_Gen” class – generated by Artifact Generator
29
Algorithm Phone Format
Example
Algorithm Spot interface methods that are implemented in _Impl class

 These methods invoked by business component to set hard


parameters
1. Sets phone number to validate – stored here for use later
2. Sets phone type – ignored in this algorithm
30
Algorithm Phone Format
Example
Algorithm Spot interface methods that are implemented in _Impl class

 invoke() method called to validate and format phone number


1. Sets Boolean based on validity
31
Algorithm Phone Format
Example
Algorithm Spot interface methods that are implemented in _Impl class
1

 These methods called from business component after invoke()


method
1. Returns true/false to indicate validity of phone number
2. Returns reformatted value 32
Algorithm Phone Format
Example
Algorithm Spot interface methods that are implemented in _Impl class
1

 These methods called from business component after invoke()


method
3. Returns default phone format – always first one (e.g. 1st format for
U.K. – “999 9999-9999”)
33
Algorithm Phone Format
Example
Generated artifacts based on _Impl class annotation

 _Gen class has methods for soft parameters


 Methods called from _Impl class to get soft parameter values 34
Algorithm Phone Format
Example
Generated artifacts based on _Impl class annotation

 Component interface defines required methods for _Impl class –


viewed from application (business component)

35
Algorithm Phone Format
Example
Generated artifacts based on _Impl class annotation

1
2

1. Artifact Generator also generates static Factory class in component


interface class file
2. Contains newInstance() method to create instance of algorithm
component at runtime
36
Algorithm Entity
 Determines where in system algorithm is invoked – e.g. phone
number validation, adhoc characteristic validation, SA creation,
etc.
 Entity defined on Algorithm Type definition

 Entity also defined in _Impl class annotation

 Entity name must be determined before implementation class can


be created
 CI_LOOKUP_VAL table contains the name
 Use following query …

37
Algorithm Entity Query

1 2

1. Algorithm Entity specified on Algorithm Type definition


2. algorithmEntityValue set in annotation
38
Algorithm Implementation
Class Review
 Steps to create new class
1. Identify algorithm entity (Algorithm Spot)
2. Determine entity value from CI_LOOKUP_VAL table
3. Create “_Impl” class, extend it from “_Gen” and implement
Algorithm Spot
4. Code annotation @AlgorithmComponent,
@AlgorithmSoftParameter
5. Run Artifact Generator to create “_Gen” and component
interface classes
In Eclipse, MUST refresh project after this!
6. Edit “_Impl” class
 Implement all methods
 Code invoke() method

39
Algorithm Implementation
Class Review
 Steps to create new class
7. Create Algorithm Type definition – Java class name will now
be in Program Name drop-down list
8. Create Algorithm definition
9. Attach algorithm to business component
10. Test

40
Exercise 8 – Geographic
Type Algorithm
 In this exercise you will create a Geographic Type algorithm to
validate geographic type “REGION” on Premise
 Scenario
1. Premises may be in North America or Europe
2. Within North America, country may be U.S.A. or Canada
3. Within Europe, country may be United Kingdom or France
4. Geographic type of “region” must be created to allow for region
code to be specified on premise

41
Exercise 8 – Geographic Type
Algorithm
 Scenario
5. Format of region code is W-CC …
 W = World Region – “N” (North America); “E” (Europe)
 CC = Country Code – “US” (USA); “CN” (Canada); “UK”
(UK); “FR” (France)
Algorithm must validate country code for region – e.g.
E-FR is valid; E-US is invalid
6. Valid region code values must be specified as soft parameters
– i.e. no hardcoding of values in Java
 Following are exercise notes to help guide …

42
Exercise 8 – Geographic Type
Algorithm
 Java
 Algorithm Entity is “Geographic Type – Value Format Rule”
(determine Java annotation name from this)
 Name your class XXGeoTypeRegionAlgComp_Impl
 Create 2 parameters
1. worldRegion, string, required

Will contain 1-digit world region code


2. countryCodes, string, required

Will contain comma-delimited string of valid country codes


for associated world region
Note: To avoid naming conflicts on the server, use a 2-digit
identifier (e.g. initials) in your Java class names and online
algorithm definitions. Denoted by “XX” in these exercise notes

43
Exercise 8 – Geographic
Type Algorithm
 Online Configuration
 Create Algorithm Type XXGEOREGION with necessary
parameter definitions
 Create 2 Algorithm definitions
1. XXGEOREG-E

Specifies Europe and valid countries


2. XXGEOREG-N

Specifies North America and valid countries

Note: To avoid naming conflicts on the server, use a 2-digit


identifier (e.g. initials) in your Java class names and online
algorithm definitions. Denoted by “XX” in these exercise notes

44
Exercise 8 – Geographic
Type Algorithm
 Online Configuration
 Create 2 new Geographic Types
1. XXREG-E

Validation format algorithm is XXGEOREG-E


2. XXREG-N

Validation format algorithm is XXGEOREG-N


 Test
 When adding/changing a geographic type on Premise,
algorithm should validate format and content of geo type

Note: To avoid naming conflicts on the server, use a 2-digit


identifier (e.g. initials) in your Java class names and online
algorithm definitions. Denoted by “XX” in these exercise notes

45
Utilities Practice @ HCL

Algorithms
Part Il
 ORACLE Technical
Training
Exercise 9 – Adhoc Char
Value Algorithm
 Last exercise could not reformat region code – Geographic Type
algorithm does not provide for that
 In this exercise you will create an Adhoc Characteristic Value
validation algorithm to validate and format a new Premise
Characteristic Type of “REGION”
 Scenario – same as before except …
 Characteristic Type of “region” must be created
 Country code may be entered without world region code
 Algorithm will format region code into W-CC format
 Will display custom error message for invalid region code

47
Exercise 9 – Adhoc Char
Value Algorithm
 Java
 Create new message constant and method for runtime
message (not declarative)
 Message text should be
XX Country code %1 not valid for region %2
(Note: should contain your initials)
 Use message number > 10000
 Add CustomMessages constant for your message
 Add method for message to MessageRepository class in
characteristicType package
Message takes 2 parameters – world region code and
country code – method must substitute them in message
text

48
Exercise 9 – Adhoc Char
Value Algorithm
 Java
 Algorithm Entity is “Char Type - Adhoc Value Validation”
(determine Java annotation name from this)
 Name your class XXAdhocRegionValidationAlg_Impl
 Create same 2 parameters as before
 invoke() method must …
1. Format region code – for example …

“CN” formatted to “N-CN”


“EFR” formatted to “E-FR”
2. Validate it if setFormatOnly() method invoked with true

3. DiORACLEay custom error message if region code invalid

49
Exercise 9 – Adhoc Char
Value Algorithm
 Online Configuration
 Create Algorithm Type XX-AV-REGION with necessary
parameter definitions
 Create 2 Algorithm definitions
1. XX-AV-REG-E - specifies Europe and valid countries

2. XX-AV-REG-N - specifies North America and valid


countries
 Create 2 Characteristic Type definitions …
1. XX-REG-E to validate European region

2. XX-REG-N to validate North American region

Both must be of type “Adhoc Value”


Characteristic Entity (2nd Tab) must be “Premise”

50
Exercise 9 – Adhoc Char
Value Algorithm
 Online Configuration
 Use Admin menu to create new message in category 90000
“XX Country code %1 not valid for region %2”
(place your initials in the message)
 Test
 When adding/changing Premise Characteristic of “region”,
algorithm should format region code, validate and
diORACLEay custom message if invalid

51

Vous aimerez peut-être aussi