Commit eb30c28a authored by Reiner Jung's avatar Reiner Jung

Extended jpetstore by kieker

parent 10bb762f
......@@ -113,6 +113,11 @@
<artifactId>hsqldb</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>net.kieker-monitoring</groupId>
<artifactId>kieker</artifactId>
<version>1.9</version>
</dependency>
</dependencies>
<build>
......
......@@ -22,175 +22,175 @@ import net.sourceforge.stripes.validation.Validate;
/**
* @author Eduardo Macarron
*
*
*/
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;
}
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;
}
public void setBannerName(String bannerName) {
this.bannerName = bannerName;
}
}
......@@ -27,79 +27,79 @@ import java.util.Map;
/**
* @author Eduardo Macarron
*
*
*/
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;
}
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;
}
}
......@@ -21,58 +21,58 @@ import java.math.BigDecimal;
/**
* @author Eduardo Macarron
*
*
*/
public class CartItem implements Serializable {
private static final long serialVersionUID = 6620528781626504362L;
private Item item;
private int quantity;
private boolean inStock;
private BigDecimal total;
private static final long serialVersionUID = 6620528781626504362L;
private Item item;
private int quantity;
private boolean inStock;
private BigDecimal total;
public boolean isInStock() {
return inStock;
}
public boolean isInStock() {
return inStock;
}
public void setInStock(boolean inStock) {
this.inStock = inStock;
}
public void setInStock(boolean inStock) {
this.inStock = inStock;
}
public BigDecimal getTotal() {
return total;
}
public BigDecimal getTotal() {
return total;
}
public Item getItem() {
return item;
}
public Item getItem() {
return item;
}
public void setItem(Item item) {
this.item = item;
calculateTotal();
}
public void setItem(Item item) {
this.item = item;
calculateTotal();
}
public int getQuantity() {
return quantity;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
calculateTotal();
}
public void setQuantity(int quantity) {
this.quantity = quantity;
calculateTotal();
}
public void incrementQuantity() {
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;
}
}
private void calculateTotal() {
if (item != null && item.getListPrice() != null) {
total = item.getListPrice().multiply(new BigDecimal(quantity));
} else {
total = null;
}
}
}
......@@ -20,42 +20,42 @@ import java.io.Serializable;
/**
* @author Eduardo Macarron
*
*
*/
public class Category implements Serializable {
private static final long serialVersionUID = 3992469837058393712L;
private static final long serialVersionUID = 3992469837058393712L;
private String categoryId;
private String name;
private String description;
private String categoryId;
private String name;
private String description;
public String getCategoryId() {
return categoryId;
}
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId.trim();
}
public void setCategoryId(String categoryId) {
this.categoryId = categoryId.trim();
}
public String getName() {
return name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void setDescription(String description) {
this.description = description;
}
public String toString() {
return getCategoryId();
}
public String toString() {
return getCategoryId();
}
}
......@@ -21,132 +21,132 @@ import java.math.BigDecimal;
/**
* @author Eduardo Macarron
*
*
*/
public class Item implements Serializable {
private static final long serialVersionUID = -2159121673445254631L;