rdo,ado & tdo in orpos

23
RDO,ADO & TDO IN ORPOS After completing this lesson, you should be able to: Differentiate between Retail Domain Objects, Application Domain Objects, and Tour Data Objects Instantiate and use the different object types Explain hierarchical relationships in objects necessary to represent a new tender type

Upload: tanuj-kathuria

Post on 23-Oct-2015

917 views

Category:

Documents


17 download

DESCRIPTION

RDO,ADO & TDO IN ORPOS

TRANSCRIPT

Page 1: Rdo,Ado & Tdo in Orpos

RDO,ADO & TDO IN ORPOS

After completing this lesson, you should be able to:Differentiate between Retail Domain Objects, Application Domain

Objects, and Tour Data ObjectsInstantiate and use the different object types

Explain hierarchical relationships in objects necessary to represent a new tender type

Page 2: Rdo,Ado & Tdo in Orpos

RETAIL DOMAIN OBJECTS

Every business entity has a class

• ITEM

• TENDER

• CUSTOMER

• EMPLOYEE

Retail Domain objects are primary objects in POS , mainly stored in the cargo of the bus and contain the business logic for the entity.

Base has many RDO’s written in domain.jar file.

Page 3: Rdo,Ado & Tdo in Orpos

HOW TO CREATE OBJECTS OF RDO

RETAIL DOMAIN OBJECTDOMAIN OBJECT

FACTORY

DOMAIN GATEWAY

INSTANCE OF RDO CAN BE CREATED IN 2 WAYS

•Object can be obtained from DOMAIN OBJECT FACTORY

A handle to the domain object factory can be obtained from Domain Gateway (singleton class)which maintains the application state information(like currency types, locales,logger etc).

•RDO’S own clone method.

Page 4: Rdo,Ado & Tdo in Orpos

Domain Object Factory

•Common object model used by the POS follows the factory design pattern

•Domain Object factory object is created from Domain Gateway as follows:DomainObjectFactory domainFactory=DomainGateway.getFactory();

•The getFactory() method of Domain Gateway looks up the domain.properties file. It finds the path of the DomainObjectFactory implementation and creates its instance.This instance is returned by the getFactory() method.

Page 5: Rdo,Ado & Tdo in Orpos

DOMAIN.PROPERTIESThis file contains Domain Level Information such as:

• Country specific information such as length of postal code , phone numbers etc

• Registry of DataTransactionIfc implementations.

• Other parameters and their values eg DiscountIncludedInSubtotal whose boolean value decides whether the discount to be included in subtotal or not

Page 6: Rdo,Ado & Tdo in Orpos

DOMAIN OBJECT FACTORY pseudocode

public class DomainObjectFactory implements DomainObjectFactoryIfc{

public DomainObjectFactory(){}public myRetailDomainObjectIfc getMyRetailDomainObjectIfc (){return (new myRetailDomainObject());}

Other methods…}

It contains get______Instance() methods for each of the RDOs which would return a new instance of the particular object.Eg. getTenderInstance()

Page 7: Rdo,Ado & Tdo in Orpos

EntityRDO code for ex TenderRDOpublic class NewTenderRetailDomainObject extends NewTenderRetailDomainObject implements AbstractTenderLineItem{protected String newTenderAttribute=null;

public NewTenderRetailDomainObject (){typeCode=TenderLineItemIfc.NEW_TENDER_RDO;amountTender=DomainGateway.getBaseCurrencyInstance();}Public Sring getTenderAttribute(){return (this.tenderAttribute);}}

All the tenderRDO extends AbstractTenderLineItem, the amount of the tender must be set at the proper level for it to function correctly.The attribute “newTenderAttribute” in the above code is specific to this new tender type. Getters and setters are declared for these newly created attributes.The “type code” is a constant that needs to be set to let the system know which tender type this RDO represents.

Page 8: Rdo,Ado & Tdo in Orpos

RDO INTERFACE CODE

Public interface NewTenderRetailDomainObjectIfc extends TenderLineItemIfc { public String getNewTenderAttribute();

public void setNewTenderAttribute(String value);public boolean equals(Object obj);public Object clone();public String toString();

}

•All the tender RDO interfaces extend the standard TenderLineItemIfc interface.•Getters and setters for the new attributes of the RDO along with clone(), equals() and toString() methods are also declared in this interface.

Page 9: Rdo,Ado & Tdo in Orpos

KEY INTERFACE FOR ALL RDO’spublic interface EYSDomainIfc extends Serializable, Cloneable{

// the following methods must be derfined for all

// domain classespublic Object clone();public boolean equals(Object obj);public String toString();

}

• Every Retail Domain Object implements either the EYSDomainIfc interface or one of the other interfaces that extends EYSDomainIfc.• Since EYSDomainIfc contains the methods clone(), equals() and toString() methods declared, all the classes that implement it or one of its subclasses, will have to implement them.• The clone() method is especially important because the framework calls it frequently in base product and hence should be implemented correctly for the Retail Domain Object to function properly.

Page 10: Rdo,Ado & Tdo in Orpos

APPLICATION DOMAIN OBJECTS

•Application Domain Objects are an additional layer of abstraction provided to RDO ‘s.•An ADO contains application logic for dealing with tender types and operates on the tender RDO’S•For ex. Getting new instance types from Factory, validating an RDO , setting up tender attributes from hashmap. validate();initializeTenderRDO();get/setTenderAttributes();getJournalMemento();etc..•Every ADO is associated with a tender RDO (except for StoreADO and RegisterADO).•E.g. check whether credit card can be accepted for the given transaction

Page 11: Rdo,Ado & Tdo in Orpos

The initializeTenderRDO() Method

This method is used to get an instance of the RDO from the factory.

protected void initializeTenderRDO(){

DomainObjectFactoryIfc domainFactory =DomainGeteway.getFactory();

tenderRDO =

domainFactory.getMyRetailDomainObjectInstance();}

This method sets the tenderRDO attribute to the appropriate tender RDO type.

Page 12: Rdo,Ado & Tdo in Orpos

The getTenderType() MethodThis method is used to get the type of Tender that the ADO represents

public TenderTypeEnum getTenderType(){

return TenderTypeEnum.MINE;}

The getTenderType() method of an ADO returns a constant defined in the com._360commerce.pos.ado.tender.TenderTypeEnum class.Every ADO has a constant which depicts its type, hard coded in it. This value is returned by the getTenderType() method.

Page 13: Rdo,Ado & Tdo in Orpos

The validate() Method

This method is used to perform tender specific validation on the RDO.

public void validate() throws TenderException{

//If the tender is valid, this function exits

//without incident. Otherwise, a TenderException

//is thrown.}

Page 14: Rdo,Ado & Tdo in Orpos

TENDER GROUPS

•Every ADO belongs to a particular Tender Group•Tender Group code takes extraneous manager/technician code out of the Tour code to more strongly enforce the MVC pattern•Tender Group contains parameters and methods that are used by several tender types

Tender GroupsOften, several tender types make use of the same parameters.Tender Groups are the ideal objects for these methods because they can deal with the ADOs directly

Page 15: Rdo,Ado & Tdo in Orpos

TENDER GROUP FUNCTIONS

• public void validateLimits(HashMap tenderAttributes,

• CurrencyIfc balanceDue);• public TenderTypeEnum getGroupType();• public TenderTypeEnum getVoidType();• public EYSDomainIfc toLegacy();• public EYSDomainIfc toLegacy(Class type);

• public void fromLegacy(EYSDomainIfc rdo);

Page 16: Rdo,Ado & Tdo in Orpos

TENDER GROUP FUNCTIONS• Tender Group objects have many common methods, such as the

following:• validateLimits(): Checks to see whether the tender type referred to is within

limits. The limit values are taken from the preset parameters.• getGroupType()/getVoidType(): Returns the constant that tells which group

type is being dealt with.

• Whenever a tour is launched, the RDO is converted into its corresponding ADO. The following methods are used for this purpose:• toLegacy(): Returns the RDO from the tenderRDO attribute of the ADO. • fromLegacy(): Accepts an RDO as a parameter, which it then uses to build the

ADO• Data of the RDO is stored as a hash table in the ADO.

Page 17: Rdo,Ado & Tdo in Orpos

Tender Group Code• Public class TenderGroupMineADO• extends AbstractTenderGroupADO• implements TenderGroupMineIfc• {• public void validateLimits(HashMap tenderAttributes,• CurrencyIfc balanceDue)• throws TenderException• {• if(evaluateTenderLimits == Boolean.TRUE)• {• //evaluation code goes here• //throw exception if the tender is invalid• }• else• {• evaluateTenderLimits = Boolean.TRUE;• }• }• //more code here…• }

• Here, the validateLimits() method is implemented, which looks up parameters for the group and throws an exception if the amount of the tender falls outside those bounds.

Page 18: Rdo,Ado & Tdo in Orpos

TOUR DATA OBJECTS

• Tour Data Objects holds the information about a particular tour.

• This information can be used in multiple sites in a tour.

• Utilizing these objects make refactoring and customizing the tour very simple, we can enable or disable the buttons using them.

Page 19: Rdo,Ado & Tdo in Orpos

TENDER ATTRIBUTES• ADOs have setTenderAttributes() and getTenderAttributes()

methods.• Both these methods work with Hashmaps containing all the

information necessary to create an ADO.• Cargo also contains tender attribute hashmap.• TenderCargo cargo = (TenderCargo)bus.getCargo();

HashMap tenderAttributes = cargo.getTenderAttributes();

tenderAttributes.put(TenderConstants.TENDER_TYPE,TenderTypeEnum.MYTYPE);

Page 20: Rdo,Ado & Tdo in Orpos

TENDER ATTRIBUTES• DataInputBeanModel model = •

(DataInputBeanModel)ui.getModel(SCREEN_CONSTANT);

• Hashmap tenderAttributes = cargo.getTenderAttributes();

• tenderAttributes.put(TenderConstants.TENDER_TYPE,

• TenderTypeEnum.TYPE);• tenderAttributes.put(TenderConstants.ACCOUNT_NU

MBER,• model.getValue(“myID”));• cargo.setTenderAttributes(tenderAttributes);

Page 21: Rdo,Ado & Tdo in Orpos

TENDERADO CREATION• TenderCargo cargo = (TenderCargo)bus.getCargo();HashMap tenderAttributes =

cargo.getTenderAttributes();TenderADOIfc myTender = null;try{

TenderFactoryIfc factory = (TenderFactoryIfc)ADOFactoryComplex.getFactory(“factory.tender”);

myTender = factory.createTender(tenderAttributes);}catch(ADOException adoe){

adoe.printStackTrace();}

Page 22: Rdo,Ado & Tdo in Orpos

SOME MORE INFO ON RDO

• Tour code gets RDO instance from a factory.• If RDO is needed at more than one Tour

element, then the RDO is stored on the cargo.

Page 23: Rdo,Ado & Tdo in Orpos

BASIC QUESTIONS

• What is an RDO?• What is an ADO?• What is the relationship between RDOs and

ADOs?• What is a TDO?• What code do you write to obtain an instance

of an RDO?