You are on page 1of 24

ESP

CODE WALKTHROUGH

-AK

Web -Flow
A user browses to the site where ePASS is installed. The web server encounters a file with a .JSP extension, and passes it to the JRun servlet engine for interpretation. The JRun servlet engine checks to see if the JSP file has already been compiled. If the JSP file has been compiled, the JRun servlet engine tells the Java Virtual Machine (JVM) to run the corresponding CLASS file. If the JSP file has not been compiled, the JRun servlet engine translates it into a Java file, that it subsequently compiles. Then the JRun servlet engine tells the JVM to run the resulting CLASS file. When it runs the CLASS file, the JVM builds the HTML document and forwards it to the JRun servlet engine. The JRun servlet engine forwards the HTML document to the web server. The web server displays the HTML files on the browser.

START
Lets Open one JSP page and walkthrough that.. *A very simple JSP file - detail_prod.jsp *Also, open the create item page in UI

JSP location in the build


ePASS\avinamart\com\WebInterface\publi c_html\en

JSP Page
Import Declarations head.jsp section Variable Declarations Logic section HTML section tail.jsp section

EPASS API
When user is creating a new organization or performing any other ePASS operation, the relevant JSP is instancing Java classes and invoking their methods of Epass API.

ApplicationServices Package
This package contains Java interfaces that are frequently instanced in JSPs. Examples: A. OrganizationServiceIntf B. BiddingServiceIntf C. AuctionDataServiceIntf Lets Walkthrough these files

Some more services: MessageServiceIntf - By invoking the methods defined for this interface, a JSP can be used to manipulate messages in context. (lets walkthrough this.. Focus on return type)

Structs Package
The Structs package contains several classes that let you retrieve data from or write data to the ePASS database, through intermediary business objects. IMP: we also need to import these packages in our JSP. Usually, services returns Struct objects.

Struct class examples:


OrganizationStruct (lets walkthrough this) ItemStruct CategoryStruct CatalogStruct AuctionStruct Many more (almost for all the objects)..

BusinessLogic.Key Package
The BusinessLogic.Key package is an additional ePASS package It is used in conjunction with the Structs package. This package contains several classes called KeyImpls. A KeyImpl is used to store the database key of the record where object data is stored.

Examples for Key package:


OrganizationKeyImpl (lets walkthrough this) RoleKeyImpl UserRoleKeyImpl MessageKeyImpl And many more

EPASSReferences
Instances of this class are used to contain information needed by ePASS code throughout the life of a request. An EPASSReferences instance contains the request, response, structures, current context and business service references. Its availabe in below build path:

com/avinamart/WebInterface/EPASSReferences .java

Data Members
HttpServletRequest req HttpServletResponse res UserDataContext userDataContext EPASSStructsReference structs An ePASS object that stores any type of ePASS struct currently used. SessionService sessionService An ePASS object that stores the users session information. EPASSServicesReference serviceRef An ePASS object that stores ePASS Application Services reference. EPASSKeyReference keyRef An ePASS object that stores ePASS object keys being used by this user. OrganizationKeyImpl orgKey An ePASS object that stores the primary key of a database entry describing an organization. And more.

Lets Walkthrough this


Code snippet: /** Creates the EPASSReference object, with HttpServletRequest,HttpServletResponse,SessionService objects sets the jsp action and also creates the CurId */ public EPASSReferences( HttpServletRequest req, HttpServletResponse res, SessionService sessionService) throws EPASSApplicationException { this.req = req; this.res = res; this.sessionService = sessionService; . . . .

Code snippet 2(Action):


public void setAction(String action) throws EPASSApplicationException { if ("null".equals(action) || action == null || action.length() == 0){ this.action = new Integer(-1); } else { getAction(), these are widely used

Possible Actions
com/avinamartWebInterface/EPASSJSPA ctions.java
Lets Walkthrough this

Create Organization and Business User


To create an organization and business user, you must do the following: 1. Create a new EPASSReferences object to store the organization and business data 2. Create a new instance of the Organization user struct and add it to the Epass Reference object. below is the code snippet: ref.structs.organizationStruct = new OrganizationStruct(); 3. Read the contents of the form, stored in the HttpRequest object and copy the data to the Organization struct. Remember HttpReauest Object is accessible by Epassreference object. To make use of the static convertToStruct method, it needs to add a special prefix like EPASSUiAdminServices.ORG_PREFIX to all input fields on the form so that those fields can be identified on the back-end.

Continue
4. Create a new instance of the BusinessUserStruct and add it to the Epass Reference Object 5. Read the contents of the form, stored in the HttpRequest object and copy the data to the BusinessUserStruct. To make use of the static convert- ToStruct method, it needs to add a special prefix to all input fields on the form so that those fields can be specifically identified on the back-end.

6. Call the UIWrapper to add organization. Pass in the reference object, which contains the Organization and Business User struct(step 5). Returned is an Organization key that is used to identify the database record of the newly created Organization and Business user.
OrganizationKeyImpl orgKey = EPASSUiAdminServices.createOrganization(ref ); Note: Struct has all the methods defined to access the data base. Somewhere which calls Service, and Service calls QueryBean.

Continue
Reference Files: com/webinterface/EPASSUiAdminServices.java search for _createOrganization method com/webinterface/OrganizationStruct.java com/webinterface/BusinessUserStruct.java com/avinamart/webinterface/EPASSReferences.java com/avinamart/webinterface/EPASSStructsReference.ja va

Creating RFQ
1. Create a new instance of AuctionStruct, and add it to the Epass Reference object. AuctionStruct auctionxyx = new AuctionStruct(); ref.structs.auctionStruct = auctionxyx; 2. Read the contents of the form, stored in the HttpRequest object and copy the data to the AuctionStruct struct. RequestUtility.convertToStruct(StructSchemaManager.getSchema( AuctionStruct.class),request, ref.structs.auctionStruct);

3. Create an instance of AuctionPolicyStruct: AuctionPolicyStruct auctionPolicy = new AuctionPolicyStruct();


4. Save the auction in the database by using the saveAuction method: AuctionKeyImpl key = auctConfig.saveAuction(ref.sessionService, ref.structs.auctionStruct, auctionPolicy); The method returns an AuctionKeyImpl, the key that is used to identify the database record of the newly created Auction (RFQ).

Continue
Reference Files AuctionConfigurationService has saveAuction Method.

com/avinamart/Struct/AuctionStruct.java com/avinamart/Struct/AuctionPolicyStruct.java com/avinamart/webinterface/EPASSReferences.java com/avinamart/webinterface/EPASSStructsReference.ja va

Sending a message to all participants


1. Create an empty message struct: ref.structs.messageStruct = EPASSUiMessageServices.createMessage ( ref ); 2. Get the description out of the AuctionStruct: String notes = ref.structs.auctionStruct.getDescription(); 3. Set desired attributes, such as context type, recipient group id, etc. ref.structs.messageStruct.setContextType ( MessageContextType.AUCTION ); ref.structs.messageStruct.setRecipientGroupId ( MessageRecipientGroupType.BIDDERS ); ref.structs.messageStruct.setAttribute ( MessageStruct.CONTEXTID, ref.structs.auctionStruct.getId () ); ref.structs.messageStruct.setAttribute (MessageStruct.CONTEXTNAME,ref.structs.auctionStruct.getName () ); EPASSUiMessageServices.addResipients ( ref, ref.structs.messageStruct ); 4. Create an instance of MessageServiceIntf. Then invoke the sendMessage; method of this instance to send the message: MessageServiceIntf msgIntf = ref.serviceRef.getMessageServiceIntf (ref); msgIntf.sendMessage ( ref.sessionService, ref.structs.messageStruct );

THANK YOU !

You might also like