6 Copyright © 2004, Oracle. All rights reserved. Adding Custom Validation.

Slides:



Advertisements
Similar presentations
6 Copyright © 2005, Oracle. All rights reserved. Building Applications with Oracle JDeveloper 10g.
Advertisements

Microsoft® Access® 2010 Training
Copyright  Oracle Corporation, All rights reserved. 1 Creating an Application: The AppBuilder for Java IDE.
Copyright Ó Oracle Corporation, All rights reserved Sharing Objects and Code.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
The Database Approach u Emphasizes the integration of data across the organization.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
5 Copyright © 2009, Oracle. All rights reserved. Defining ETL Mappings for Staging Data.
1 System for Administration, Training, and Educational Resources for NASA Managing Access.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
Copyright Ó Oracle Corporation, All rights reserved. 55 Working with Data Blocks and Frames.
Database Management System Lecture 6 The Relational Database Model – Keys, Integrity Rules.
System-level and RESA Administrators Functions. Topics Manually creating new student account Manually creating new teacher account Importing data Viewing.
Copyright  Oracle Corporation, All rights reserved. 5 CMIS Powell Oracle Designer: Design Editor and Building the Database and Table API CMIS.
Developing Workflows with SharePoint Designer David Coe Application Development Consultant Microsoft Corporation.
1 CHAPTER 10 More Complex Business Rules. 2 More Complex Business Rules Entity objects can do more than just be representations of data. They can also.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Concepts and Terminology Introduction to Database.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
2 Copyright © Oracle Corporation, All rights reserved. Restricting and Sorting Data.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
11 Copyright © 2007, Oracle. All rights reserved. Creating Other Schema Objects.
10 Copyright © 2009, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
1 Copyright © 2006, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Lesson 12: Creating a Manual and Using Mail Merge.
Copyright  Oracle Corporation, All rights reserved. 4 Accessing a Database Using JBCL.
Chapter 17 Creating a Database.
11 Copyright © Oracle Corporation, All rights reserved. Creating Views.
6 Extraction, Transformation, and Loading (ETL) Transformation.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Page 1. Data Integration Using Oracle Streams A Case Study Session #:
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
9 Copyright © 2009, Oracle. All rights reserved. Deploying and Reporting on ETL Jobs.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
19 Copyright © 2004, Oracle. All rights reserved. Validation.
13 Copyright © 2004, Oracle. All rights reserved. Adding Validation and Error Handling.
11 Copyright © 2004, Oracle. All rights reserved. Customizing Actions.
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
23 Copyright © 2009, Oracle. All rights reserved. Oracle Business Intelligence Answers: Advanced Features.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
8 Copyright © 2004, Oracle. All rights reserved. Making the Model Secure.
22 Copyright © 2008, Oracle. All rights reserved. Multi-User Development.
RELATIONAL TABLE NORMALIZATION. Key Concepts Guidelines for Primary Keys Deletion anomaly Update anomaly Insertion anomaly Functional dependency Transitive.
Lecture 4: Logical Database Design and the Relational Model 1.
Copyright Ó Oracle Corporation, All rights reserved. 77 Creating LOVs and Editors.
5 Copyright © 2008, Oracle. All rights reserved. Testing and Validating a Repository.
12 Copyright © 2004, Oracle. All rights reserved. Using ADF Struts Components.
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
14 Copyright © 2004, Oracle. All rights reserved. Achieving State Management in the Business Tier.
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
19 Copyright © 2004, Oracle. All rights reserved. Coding PL/SQL Triggers.
11 Copyright © 2004, Oracle. All rights reserved. Performing a Migration Using Oracle Migration Workbench (Part II)
2 Copyright © 2005, Oracle. All rights reserved. Installing Oracle Software and Creating the Database.
13 Copyright © 2004, Oracle. All rights reserved. Migrating SQL Statements.
16 Copyright © 2004, Oracle. All rights reserved. Building ADF UIX View Components.
AOIT Database Design Unit 3, Lesson 9 Data Integrity Copyright © 2009–2011 National Academy Foundation. All rights reserved.
CompSci 280 S Introduction to Software Development
Log for Patron Record Changes
Introduction to Triggers
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
eSeries Entities By Julie Ladner
Presentation transcript:

6 Copyright © 2004, Oracle. All rights reserved. Adding Custom Validation

6-2 Copyright © 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Add custom methods to validate business data Use the typesafe data access methods Use entity associations in business logic Traverse entity associations

6-3 Copyright © 2004, Oracle. All rights reserved. Customers Id Name Status Business Rule Overview Entity Object Orders Id CustomerId OrderMode OrderTotal Validation Type Attribute Method Validator Name must not be longer than 50 characters Customer must exist If the OrderMode is "ONLINE" Domain must contain an and "." Entity Method Validator

6-4 Copyright © 2004, Oracle. All rights reserved. Adding Validation to an Entity There are a number of places you can put validation: Predefined validators: For simple XML-based rules Custom method validators: For more complex attribute and entity rules Attribute setter method: For complex attribute rules Override EntityImpl.java methods: For more complex entity rules and custom behaviors Domains: Can be used for multiple attributes across multiple entity objects

6-5 Copyright © 2004, Oracle. All rights reserved. Validating Attributes To create custom validation for attributes, you can either: Create a MethodValidator in the EntityImpl.java file or Modify the setter() method of the attribute in the EntityImpl.java file

6-6 Copyright © 2004, Oracle. All rights reserved. Creating a MethodValidator for an Attribute To create a custom validator, create a new method in the EntityImpl.java file. Select the EntityImpl.java file in the Structure pane or select Go to Entity Object Class from the context menu.

6-7 Copyright © 2004, Oracle. All rights reserved. Creating a MethodValidator for an Attribute To create the custom validation as a MethodValidator, the method must: Be defined as public Accept a single argument of the same type as the attribute Return a Boolean value Start with validate public boolean validate (String value) { return != -1 ); }

6-8 Copyright © 2004, Oracle. All rights reserved. Utilizing Typesafe Methods EntityImpl.java contains typesafe methods to get and set each of the entity’s attributes. To override the setter method in the EntityImpl.java file: Add custom validation code in the methods. Call setAttributeInternal() to set the attribute value after your validation code. public void setCreditLimit(Number value) { // add your custom code here setAttributeInternal(CREDITLIMIT, value); }

6-9 Copyright © 2004, Oracle. All rights reserved. Validating Entity Objects MethodValidators can also be created in the EntityImpl.java file to validate entity objects. Custom entity validation methods must: Be defined as public Return a Boolean value public boolean validateOrder() { String date = new java.util.Date().toString(); if( (getOrderStatus().equals("2")) && (getOrderDate().toString() == date )) {return true; } else {return false;}}

6-10 Copyright © 2004, Oracle. All rights reserved. public boolean checkOrderMode(){ if ( ("ONLINE".equals(getOrderMode())) || !(getCustomer () == null)) { //success } else { // Error - online order must have address }} Validating Entity Objects If entity MethodValidators are too limiting, create a custom method in the EntityImpl.java file:

6-11 Copyright © 2004, Oracle. All rights reserved. Call EntityImpl Methods You can also override other methods in EntityImpl.java. For example: doDML() —Log changes in another entity beforeCommit() —Validate multiple instances of the same entity remove() —Record a deletion in another entity

6-12 Copyright © 2004, Oracle. All rights reserved. Validation Order Attribute validation occurs in the following order: Domain validation: On instantiation of an entity object Setter method: On creation or modification of an attribute Predefined validators: On a call to setAttributeInternal() Attribute MethodValidators validateEntity() method Entity MethodValidators doDML() method beforeCommit() method

6-13 Copyright © 2004, Oracle. All rights reserved. Associations Associations define a relationship between entity objects. Associations: Facilitate access to data in related entity objects May be based on database constraints May be independent of database constraints Consist of a source (master) and a destination (detail) entity

6-14 Copyright © 2004, Oracle. All rights reserved. Associations Associations define a relationship between entity objects. Associations: Facilitate access to data in related entity objects May be based on database constraints May be independent of database constraints Consist of a source (master) and a destination (detail) entity

6-15 Copyright © 2004, Oracle. All rights reserved. SourceDestination Association CustomersOrders Association Example A customer can place one or many orders. An order is placed by just one customer. OrderPlacedBy

6-16 Copyright © 2004, Oracle. All rights reserved. Accessor Methods Are optional methods created by the Association Wizard Provide access to data from the associated entity Are bidirectional For example: –Get all orders for a customer –Get customer information from an order

6-17 Copyright © 2004, Oracle. All rights reserved. Association Types Association –Entities are related but not completely dependent. –Either end of the association can exist without the other. –It is usually a categorization. Composition –Destination entity is completely dependent on the source entity. –The source entity owns the destination entity. –No destination entity can be created without the owning entity existing first.

6-18 Copyright © 2004, Oracle. All rights reserved. Determining the Association Type Two questions to ask: Can a destination entity object exist without the source? –If yes, the source is associated to the destination. –If no, the source is composed of the destination. When I delete the source, do I delete the destination? –If yes, the relationship is a composition. –If no, the relationship is an association.

6-19 Copyright © 2004, Oracle. All rights reserved. The “one” side of the association The “many” side of the association Creating Entity Associations

6-20 Copyright © 2004, Oracle. All rights reserved. The “One” side of the association The “Many” side of the association Creating Entity Associations

6-21 Copyright © 2004, Oracle. All rights reserved. Creating Entity Associations

6-22 Copyright © 2004, Oracle. All rights reserved. Creating Entity Associations

6-23 Copyright © 2004, Oracle. All rights reserved. public String getTrackingNo() { return getOrd().getTrackingNo(); } Traversing Associations: Destination to Source The destination entity’s EntityImpl.java file contains methods to get and set the source entity. For example, LineItemImpl.java contains getOrd() and setOrd(). You can add a method to LineItemImpl.java to get the tracking number of the order containing this item: getLineItem() Order ItemOrderedOnAssoc LineItem getTrackingNo()

6-24 Copyright © 2004, Oracle. All rights reserved. Traversing Associations: Source to Destination The source entity’s EntityImpl.java file contains a method to get the destination entity. For example, OrdImpl.java contains the method: Use the methods of RowIterator to step from row to row and get individual attribute values. public oracle.jbo.RowIterator getLineItem() getLineItem() Order ItemOrderedOnAssoc LineItem

6-25 Copyright © 2004, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Add business rules to ADF Business Components Validate entities, attributes, and domains Test the validation rules

6-26 Copyright © 2004, Oracle. All rights reserved. Practice 6-1: Overview This practice covers the following topics: Enforcing ListValidator rules Creating domain validation code Testing the validation rules

6-27 Copyright © 2004, Oracle. All rights reserved. Practice 6-1

6-28 Copyright © 2004, Oracle. All rights reserved. Practice 6-1

6-29 Copyright © 2004, Oracle. All rights reserved. Practice 6-1

6-30 Copyright © 2004, Oracle. All rights reserved.