by rick varella cuong nguyen henry giathi
Download
Skip this Video
Download Presentation
By: Rick Varella, Cuong Nguyen, & Henry Giathi

Loading in 2 Seconds...

play fullscreen
1 / 23

By: Rick Varella, Cuong Nguyen, Henry Giathi - PowerPoint PPT Presentation


  • 69 Views
  • Uploaded on

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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'By: Rick Varella, Cuong Nguyen, Henry Giathi' - maine


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
by rick varella cuong nguyen henry giathi
By: Rick Varella,

Cuong Nguyen,

& Henry Giathi

what is books zen books
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
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.
features
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.
features1
Features
  • Caching system for frequently accessed data.
  • Admin interface for managing all aspects of the system, including users, books, and settings.
usage scenario 1 login
Usage Scenario #1: Login
  • Present use case while logging in to the system.
usage scenario 1 login2
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;

}

usage scenario 2 add new listing
Usage Scenario 2: Add New Listing
  • Present use case while logging in to the system.
usage scenario 2 add new listing3
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();

}

}

usage scenario 3 add listing to cart
Usage Scenario 3: Add Listing to Cart
  • Present use case while logging in to the system.
usage scenario 3 add listing to cart2
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;

}

third party tools
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.
a sample xml schema file
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>

how dom4j reads xml data
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 );

}

}

using the table class mapping
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 );

}

problems encountered
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.
problems encountered1
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.
features that were not implemented
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.
ad