1 / 23

By: Rick Varella, Cuong Nguyen, & Henry Giathi

By: Rick Varella, Cuong Nguyen, & Henry Giathi. What is Books Zen Books?. Books Zen Books is an e-commerce web application designed to allow students to buy and sell their textbooks to other local students. . Purpose.

maine
Download Presentation

By: Rick Varella, Cuong Nguyen, & Henry Giathi

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. By: Rick Varella, Cuong Nguyen, & Henry Giathi

  2. What is Books Zen Books? • Books Zen Books is an e-commerce web application designed to allow students to buy and sell their textbooks to other local students.

  3. Purpose • Why sell your books to the campus bookstore and get much less money for them? • Why buy them for a premium price at the bookstore? • Why pay for shipping at an online store? • Have books that the bookstore won’t buy? • Books Zen Books solves all of that.

  4. Features • Login system giving access to certain member-only features to registered users. • Advanced search options for finding books by title, author, ISBN, subject and others. • Users have full control over their listing info. • Shopping cart for saving listings of interest. • Checkout through Google Checkout or PayPal.

  5. Features • Caching system for frequently accessed data. • Admin interface for managing all aspects of the system, including users, books, and settings.

  6. Class Diagram

  7. Usage Scenario #1: Login • Present use case while logging in to the system.

  8. Usage Scenario #1: Login

  9. Usage Scenario #1: Login public User checkCredentials( HttpServletRequest request ) { ResultSet result; User user = null; String email = RequestHelper.getString( "email", request ); String password = RequestHelper.getString( "password", request ); String where = "email = '" + email + "' AND password = '" + DigestHelper.md5( password ) + "'"; /* Query for matching user */ result = bzb.getDriver().select( "user", null, where ); try { /* Make sure there's a result */ if( result.next() ) { user = new User(); user.init( bzb.getDriver() ); user.populate( result ); } } catch( SQLException e ) { } return user; }

  10. Usage Scenario 2: Add New Listing • Present use case while logging in to the system.

  11. Usage Scenario 2: Add New Listing

  12. Usage Scenario 2: Add New Listing

  13. Usage Scenario 2: Add New Listing private void saveListing( BookListing listing, HttpServletRequest request ) { listing.init( bzb.getDriver() ); listing.setActive( true ); listing.setComment( RequestHelper.getString( "comment", request ) ); listing.setCondition( RequestHelper.getString( "condition", request ) ); listing.setCurrency( "usd" ); //@TODO currency should be a system setting listing.setIsbn( listing.getBook().getIsbn() ); listing.setListDate( new java.util.Date() ); listing.setPrice( RequestHelper.getDouble( "price", request ) ); listing.setUserId( ( ( User ) request.getSession().getAttribute( "authUser" ) ).getUserId() ); listing.getBook().setAuthor( listing.getBook().getAuthor().replaceAll( "\n", "|" ).trim() ); listing.save(); if( listing.getBook().isNewObject() ) { listing.getBook().save(); } }

  14. Usage Scenario 3: Add Listing to Cart • Present use case while logging in to the system.

  15. Usage Scenario 3: Add Listing to Cart

  16. Usage Scenario 3: Add Listing to Cart result.close(); fields = new String[] { "COUNT(*) as count" }; result = bzb.getDriver().select( "shoppingcartentry", fields, where ); result.next(); if( result.getInt( "count" ) > 0 ) { isValid = false; } return isValid; } private booleanisValidListing( HttpServletRequest request ) { BookListinglisting; booleanisValid = true; String[] fields = { "*" }; String where = "listId = " + RequestHelper.getInt( "listId", request ); ResultSet result = bzb.getDriver().select( "booklisting", fields, where ); if( result.next() ) { listing = new BookListing(); listing.init( bzb.getDriver() ); listing.populate( result ); if( !listing.isActive() ) { isValid = false; } else if( listing.getUserId() == bzb.getAuthenticatedUser( request ).getUserId() ) { isValid = false; } } else { isValid = false; }

  17. Third Party Tools • dom4j - http://dom4j.sourceforge.net/ • Dom4j is an open source library for working with XML and XSLT files. • We used it for reading our database configuration settings file. This makes it easier to update database details without editing source code. • Also used it for generating and reading our XML schema files for our database mapping class. This made it possible to pass a single ResultSet from the DB to an object, and the object would be populated with the result data.

  18. A Sample XML Schema File <?xml version="1.0" encoding="UTF-8"?> <table name="user" className="business.User"> <field id="0" name="userId" dbType="4" javaType="int" index="pk"/> <field id="1" name="email" dbType="12" javaType="class java.lang.String"/> <field id="2" name="password" dbType="12" javaType="class java.lang.String"/> <field id="3" name="firstName" dbType="12" javaType="class java.lang.String"/> <field id="4" name="lastName" dbType="12" javaType="class java.lang.String"/> <field id="5" name="address" dbType="12" javaType="class java.lang.String"/> <field id="6" name="city" dbType="12" javaType="class java.lang.String"/> <field id="7" name="state" dbType="12" javaType="class java.lang.String"/> <field id="8" name="country" dbType="12" javaType="class java.lang.String"/> <field id="9" name="postalCode" dbType="12" javaType="class java.lang.String"/> <field id="10" name="phone" dbType="12" javaType="class java.lang.String"/> <field id="11" name="joinDate" dbType="93" javaType="class java.util.Date"/> <field id="12" name="birthDate" dbType="91" javaType="class java.util.Date"/> <field id="13" name="validated" dbType="-7" javaType="boolean"/> <field id="14" name="superUser" dbType="-7" javaType="boolean"/> <field id="15" name="validationCode" dbType="12" javaType="class java.lang.String"/> </table>

  19. How dom4j Reads XML Data private SchemaColumnreadSchemaColumn( Element container ) { intcolumnId = 0; intdbType = 0; String javaType = null; String columnName = null; String index = null; Iterator<Attribute> attrIterator = container.attributeIterator(); Attribute attribute; while( attrIterator.hasNext() ) { attribute = ( Attribute )attrIterator.next(); if( attribute.getName().equals( "dbType" ) ) { dbType = Integer.parseInt( attribute.getText() ); } else if( attribute.getName().equals( "name" ) ) { columnName = attribute.getText(); } else if( attribute.getName().equals( "javaType" ) ) { javaType = attribute.getText(); } else if( attribute.getName().equals( "index" ) ) { index = attribute.getText(); } } return new SchemaColumn( columnId, columnName, dbType, javaType, index ); } public SchemaDatagetSchema( String className, Field[] fields ) { … SAXReaderreader = new SAXReader(); Document document = reader.read( file ); xmlRoot= xmlDocument.getRootElement(); columnIterator= xmlRoot.elementIterator(); while( columnIterator.hasNext() ) { columnRoot = columnIterator.next(); column = readSchemaColumn( columnRoot ); columns.put( column.getName(), column ); } … }

  20. Using the Table/Class Mapping ResultSet result = bzb.getDriver().select( "shoppingcartentry e", fields, where, join, null, null, null, 0, 0 ); entry = new ShoppingCartEntry(); entry.init( bzb.getDriver() ); entry.populate( result ); public boolean populate( ResultSet row ) throws SQLException { … for( inti = 1; i <= columnCount; i++ ) { columnName = rsMetaData.getColumnName( i ); if( schema.getColumns().containsKey( columnName ) ) { setField( columnName, row ); } } } private booleansetField( String key, ResultSet row ) { SchemaColumn column = schema.getColumns().get( key ); … if( javaType.equals( "class java.lang.String" ) ) { methodTypes[0] = java.lang.String.class; methodArgs[0] = row.getString( key ); } … methodName = "set" + Util.toUpperCaseFirst( key ); method = this.getClass().getMethod( methodName, methodTypes ); method.invoke( this, methodArgs ); }

  21. Problems Encountered • The NetBeans UML plugin ended up crashing NetBeans, resulting in our UML diagrams getting corrupted and unusable. • Tried out other UML programs like StarUML, Umlet, and ArgoUML, settled on the trial version of Visual Paradigm.

  22. Problems Encountered • Mapping database columns to class members was troublesome. • Getting existing data out of the database and filling the objects worked without an XML schema for the most part, since we could use the column datatype from the ResultSet. • Creating new objects (ie. From user input) to insert into the DB was more difficult, since we didn’t have a ResultSet to refer to when building our queries. So for class datatypes that don’t map to the same column type (eg. Boolean  tinyint), we had issues.

  23. Features That Were Not Implemented • We didn’t implement checkout. We were planning to integrate with PayPal and Google Checkout. • Administration interface. Ideally it would allow the manager to modify settings, update users and books, and change the content of strings that make up the system text. • Email validation for new accounts. Because we need an SMTP server to test it out, we did not get it working.

More Related