Commit c65f94ac authored by Eduardo Macarron's avatar Eduardo Macarron

Initial import.

parent 33f0cf3f
This diff is collapsed.
iBATIS
This product includes software developed by
The Apache Software Foundation (http://www.apache.org/).
Copyright 2010 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
OGNL
//--------------------------------------------------------------------------
// Copyright (c) 2004, Drew Davidson and Luke Blanshard
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the Drew Davidson nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
// AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//--------------------------------------------------------------------------
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.mybatis</groupId>
<artifactId>jpetstore</artifactId>
<packaging>war</packaging>
<version>6.0-SNAPSHOT</version>
<name>JPetStore Demo 6</name>
<url>http://www.mybatis.org</url>
<dependencies>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.10</version>
</dependency>
<dependency>
<groupId>net.sourceforge.stripes</groupId>
<artifactId>stripes</artifactId>
<version>1.5.4</version>
<exclusions>
<exclusion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<exclusions>
<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.0.0-RC3</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<finalName>jpetstore</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<overwrite>true</overwrite>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
package org.mybatis.jpetstore.domain;
import java.io.Serializable;
import net.sourceforge.stripes.validation.Validate;
public class Account implements Serializable {
private static final long serialVersionUID = 8751282105532159742L;
private String username;
private String password;
private String email;
private String firstName;
private String lastName;
private String status;
private String address1;
private String address2;
private String city;
private String state;
private String zip;
private String country;
private String phone;
private String favouriteCategoryId;
private String languagePreference;
private boolean listOption;
private boolean bannerOption;
private String bannerName;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFirstName() {
return firstName;
}
@Validate(required=true, on={"newAccount", "editAccount"})
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
@Validate(required=true, on={"newAccount", "editAccount"})
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getAddress1() {
return address1;
}
public void setAddress1(String address1) {
this.address1 = address1;
}
public String getAddress2() {
return address2;
}
public void setAddress2(String address2) {
this.address2 = address2;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getFavouriteCategoryId() {
return favouriteCategoryId;
}
public void setFavouriteCategoryId(String favouriteCategoryId) {
this.favouriteCategoryId = favouriteCategoryId;
}
public String getLanguagePreference() {
return languagePreference;
}
public void setLanguagePreference(String languagePreference) {
this.languagePreference = languagePreference;
}
public boolean isListOption() {
return listOption;
}
public void setListOption(boolean listOption) {
this.listOption = listOption;
}
public boolean isBannerOption() {
return bannerOption;
}
public void setBannerOption(boolean bannerOption) {
this.bannerOption = bannerOption;
}
public String getBannerName() {
return bannerName;
}
public void setBannerName(String bannerName) {
this.bannerName = bannerName;
}
}
package org.mybatis.jpetstore.domain;
//import com.ibatis.common.util.PaginatedArrayList;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class Cart implements Serializable {
private static final long serialVersionUID = 8329559983943337176L;
private final Map<String, CartItem> itemMap = Collections.synchronizedMap(new HashMap<String, CartItem>());
private final List<CartItem> itemList = new ArrayList<CartItem>();
public Iterator<CartItem> getCartItems() {
return itemList.iterator();
}
public List<CartItem> getCartItemList() {
return itemList;
}
public int getNumberOfItems() {
return itemList.size();
}
public Iterator<CartItem> getAllCartItems() {
return itemList.iterator();
}
public boolean containsItemId(String itemId) {
return itemMap.containsKey(itemId);
}
public void addItem(Item item, boolean isInStock) {
CartItem cartItem = (CartItem) itemMap.get(item.getItemId());
if (cartItem == null) {
cartItem = new CartItem();
cartItem.setItem(item);
cartItem.setQuantity(0);
cartItem.setInStock(isInStock);
itemMap.put(item.getItemId(), cartItem);
itemList.add(cartItem);
}
cartItem.incrementQuantity();
}
public Item removeItemById(String itemId) {
CartItem cartItem = (CartItem) itemMap.remove(itemId);
if (cartItem == null) {
return null;
} else {
itemList.remove(cartItem);
return cartItem.getItem();
}
}
public void incrementQuantityByItemId(String itemId) {
CartItem cartItem = (CartItem) itemMap.get(itemId);
cartItem.incrementQuantity();
}
public void setQuantityByItemId(String itemId, int quantity) {
CartItem cartItem = (CartItem) itemMap.get(itemId);
cartItem.setQuantity(quantity);
}
public BigDecimal getSubTotal() {
BigDecimal subTotal = new BigDecimal("0");
Iterator<CartItem> items = getAllCartItems();
while (items.hasNext()) {
CartItem cartItem = (CartItem) items.next();
Item item = cartItem.getItem();
BigDecimal listPrice = item.getListPrice();
BigDecimal quantity = new BigDecimal(String.valueOf(cartItem.getQuantity()));
subTotal = subTotal.add(listPrice.multiply(quantity));
}
return subTotal;
}
}
package org.mybatis.jpetstore.domain;
import java.io.Serializable;
import java.math.BigDecimal;
public class CartItem implements Serializable {
private static final long serialVersionUID = 6620528781626504362L;
private Item item;
private int quantity;
private boolean inStock;
private BigDecimal total;
public boolean isInStock() {
return inStock;
}
public void setInStock(boolean inStock) {
this.inStock = inStock;
}
public BigDecimal getTotal() {
return total;
}
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
calculateTotal();
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
calculateTotal();
}
public void incrementQuantity() {
quantity++;
calculateTotal();
}
private void calculateTotal() {
if (item != null && item.getListPrice() != null) {
total = item.getListPrice().multiply(new BigDecimal(quantity));
} else {
total = null;
}
}
}
package org.mybatis.jpetstore.domain;
import java.io.Serializable;
public class Category implements Serializable {
private static final long serialVersionUID = 3992469837058393712L;
private String categoryId;
private String name;
private String description;
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String toString() {
return getCategoryId();
}
}
package org.mybatis.jpetstore.domain;
import java.io.Serializable;
import java.math.BigDecimal;
public class Item implements Serializable {
private static final long serialVersionUID = -2159121673445254631L;
private String itemId;
private String productId;
private BigDecimal listPrice;
private BigDecimal unitCost;
private int supplierId;
private String status;
private String attribute1;
private String attribute2;
private String attribute3;
private String attribute4;
private String attribute5;
private Product product;
private int quantity;
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId.trim();
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public Product getProduct() {
return product;
}
public void setProduct(Product product) {
this.product = product;
}
public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public int getSupplierId() {
return supplierId;
}
public void setSupplierId(int supplierId) {
this.supplierId = supplierId;
}
public BigDecimal getListPrice() {
return listPrice;
}
public void setListPrice(BigDecimal listPrice) {
this.listPrice = listPrice;
}
public BigDecimal getUnitCost() {
return unitCost;
}
public void setUnitCost(BigDecimal unitCost) {
this.unitCost = unitCost;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getAttribute1() {
return attribute1;
}
public void setAttribute1(String attribute1) {
this.attribute1 = attribute1;
}
public String getAttribute2() {
return attribute2;
}
public void setAttribute2(String attribute2) {
this.attribute2 = attribute2;
}
public String getAttribute3() {
return attribute3;
}
public void setAttribute3(String attribute3) {
this.attribute3 = attribute3;
}
public String getAttribute4() {
return attribute4;
}
public void setAttribute4(String attribute4) {
this.attribute4 = attribute4;
}
public String getAttribute5() {
return attribute5;
}
public void setAttribute5(String attribute5) {
this.attribute5 = attribute5;
}
public String toString() {
return "(" + getItemId() + "-" + getProductId() + ")";
}
}
package org.mybatis.jpetstore.domain;
import java.io.Serializable;
import java.math.BigDecimal;
public class LineItem implements Serializable {
private static final long serialVersionUID = 6804536240033522156L;
private int orderId;
private int lineNumber;
private int quantity;
private String itemId;
private BigDecimal unitPrice;
private Item item;
private BigDecimal total;
public LineItem() {
}
public LineItem(int lineNumber, CartItem cartItem) {
this.lineNumber = lineNumber;
this.quantity = cartItem.getQuantity();
this.itemId = cartItem.getItem().getItemId();
this.unitPrice = cartItem.getItem().getListPrice();
this.item = cartItem.getItem();
}
public int getOrderId() {
return orderId;
}
public void setOrderId(int orderId) {
this.orderId = orderId;
}
public int getLineNumber() {
return lineNumber;
}