├── .gitignore ├── README.md ├── pom.xml └── src └── main ├── java └── ik │ └── am │ └── jpetstore │ ├── app │ ├── account │ │ ├── AccountController.java │ │ ├── AccountForm.java │ │ ├── AccountHelper.java │ │ └── PasswordEqualsValidator.java │ ├── cart │ │ ├── CartController.java │ │ ├── CartForm.java │ │ └── CartHelper.java │ ├── catalog │ │ ├── CatalogController.java │ │ └── ProductSearchForm.java │ ├── common │ │ └── session │ │ │ ├── EnableSynchronizeOnSessionPostProcessor.java │ │ │ └── HttpSessionEventLoggingListener.java │ └── order │ │ ├── OrderController.java │ │ ├── OrderForm.java │ │ └── OrderHelper.java │ └── domain │ ├── common │ └── exception │ │ └── ResourceNotFoundException.java │ ├── model │ ├── Account.java │ ├── Cart.java │ ├── CartItem.java │ ├── Category.java │ ├── Item.java │ ├── LineItem.java │ ├── Order.java │ ├── Product.java │ ├── Sequence.java │ └── UserDetails.java │ ├── repository │ ├── account │ │ └── AccountRepository.java │ ├── category │ │ └── CategoryRepository.java │ ├── item │ │ ├── ItemRepository.java │ │ └── LineItemRepository.java │ ├── order │ │ └── OrderRepository.java │ ├── product │ │ └── ProductRepository.java │ └── sequence │ │ └── SequenceRepository.java │ └── service │ ├── account │ ├── AccountService.java │ └── AccountServiceImpl.java │ ├── catalog │ ├── CatalogService.java │ └── CatalogServiceImpl.java │ ├── order │ ├── OrderService.java │ └── OrderServiceImpl.java │ └── user │ └── UserDetailsServiceImpl.java ├── resources ├── META-INF │ ├── dozer │ │ └── account-mapping.xml │ ├── resources │ │ ├── css │ │ │ └── jpetstore.css │ │ └── images │ │ │ ├── banner_birds.gif │ │ │ ├── banner_cats.gif │ │ │ ├── banner_dogs.gif │ │ │ ├── banner_fish.gif │ │ │ ├── banner_reptiles.gif │ │ │ ├── bird1.gif │ │ │ ├── bird2.gif │ │ │ ├── birds_icon.gif │ │ │ ├── cart.gif │ │ │ ├── cat1.gif │ │ │ ├── cat2.gif │ │ │ ├── cats_icon.gif │ │ │ ├── dog1.gif │ │ │ ├── dog2.gif │ │ │ ├── dog3.gif │ │ │ ├── dog4.gif │ │ │ ├── dog5.gif │ │ │ ├── dog6.gif │ │ │ ├── dogs.gif │ │ │ ├── dogs_icon.gif │ │ │ ├── fish.gif │ │ │ ├── fish1.gif │ │ │ ├── fish2.gif │ │ │ ├── fish3.gif │ │ │ ├── fish4.gif │ │ │ ├── fish_icon.gif │ │ │ ├── lizard1.gif │ │ │ ├── logo-topbar.gif │ │ │ ├── poweredby.gif │ │ │ ├── reptiles_icon.gif │ │ │ ├── separator.gif │ │ │ ├── sm_birds.gif │ │ │ ├── sm_cats.gif │ │ │ ├── sm_dogs.gif │ │ │ ├── sm_fish.gif │ │ │ ├── sm_reptiles.gif │ │ │ ├── snake1.gif │ │ │ └── splash.gif │ └── spring │ │ ├── application.properties │ │ ├── applicationContext.xml │ │ ├── spring-jpetstore-domain.xml │ │ ├── spring-jpetstore-env.xml │ │ ├── spring-jpetstore-infra.properties │ │ ├── spring-jpetstore-infra.xml │ │ ├── spring-mvc.xml │ │ └── spring-security.xml ├── database │ ├── H2-dataload.sql │ └── H2-schema.sql ├── i18n │ └── application-messages.properties ├── ik │ └── am │ │ └── jpetstore │ │ └── domain │ │ └── repository │ │ ├── account │ │ └── AccountRepository.xml │ │ ├── category │ │ └── CategoryRepository.xml │ │ ├── item │ │ ├── ItemRepository.xml │ │ └── LineItemRepository.xml │ │ ├── order │ │ └── OrderRepository.xml │ │ ├── product │ │ └── ProductRepository.xml │ │ └── sequence │ │ └── SequenceRepository.xml ├── log4jdbc.properties └── logback.xml └── webapp ├── WEB-INF ├── views │ ├── account │ │ ├── EditAccountForm.jsp │ │ ├── IncludeAccountFields.jsp │ │ ├── NewAccountForm.jsp │ │ └── SignonForm.jsp │ ├── cart │ │ ├── Cart.jsp │ │ ├── Checkout.jsp │ │ └── IncludeMyList.jsp │ ├── catalog │ │ ├── Category.jsp │ │ ├── Item.jsp │ │ ├── Main.jsp │ │ ├── Product.jsp │ │ └── SearchProducts.jsp │ ├── common │ │ ├── Error.jsp │ │ ├── IncludeBottom.jsp │ │ ├── IncludeTop.jsp │ │ └── include.jsp │ ├── notFoundError.jsp │ ├── order │ │ ├── ConfirmOrder.jsp │ │ ├── ListOrders.jsp │ │ ├── NewOrderForm.jsp │ │ ├── ShippingForm.jsp │ │ └── ViewOrder.jsp │ └── systemError.jsp └── web.xml └── index.jsp /.gitignore: -------------------------------------------------------------------------------- 1 | log 2 | target 3 | .settings 4 | .classpath 5 | .project 6 | .springBeans 7 | src/main/webapp/upload/* 8 | message 9 | mecab-ipadic* 10 | *~ 11 | .git 12 | .idea 13 | .DS_Store 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | spring-jpetstore 2 | ================ 3 | 4 | JPetStore 6 is a full web application built on top of Spring, Spring MVC, MyBatis 3, and Spring Security. 5 | This is another implementation of MyBatis sample application (https://github.com/mybatis/jpetstore-6). 6 | 7 | Original application is available for downloading in the downloads section of MyBatis project site. 8 | In this section we will walk through this sample to understand how is it built and learn how to run it. 9 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/account/AccountController.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.account; 2 | 3 | import ik.am.jpetstore.app.account.AccountForm.EditAccount; 4 | import ik.am.jpetstore.app.account.AccountForm.NewAccount; 5 | import ik.am.jpetstore.domain.model.Account; 6 | import ik.am.jpetstore.domain.model.UserDetails; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Collections; 10 | import java.util.List; 11 | 12 | import javax.inject.Inject; 13 | import javax.validation.groups.Default; 14 | 15 | import org.dozer.Mapper; 16 | import org.springframework.security.core.context.SecurityContextHolder; 17 | import org.springframework.stereotype.Controller; 18 | import org.springframework.validation.BindingResult; 19 | import org.springframework.validation.annotation.Validated; 20 | import org.springframework.web.bind.WebDataBinder; 21 | import org.springframework.web.bind.annotation.InitBinder; 22 | import org.springframework.web.bind.annotation.ModelAttribute; 23 | import org.springframework.web.bind.annotation.RequestMapping; 24 | 25 | @Controller 26 | @RequestMapping("account") 27 | public class AccountController { 28 | 29 | private static final List LANGUAGE_LIST; 30 | 31 | private static final List CATEGORY_LIST; 32 | 33 | @Inject 34 | protected Mapper beanMapper; 35 | 36 | @Inject 37 | protected AccountHelper accountHelper; 38 | 39 | @Inject 40 | protected PasswordEqualsValidator passwordEqualsValidator; 41 | 42 | static { 43 | List langList = new ArrayList(); 44 | langList.add("english"); 45 | langList.add("japanese"); 46 | LANGUAGE_LIST = Collections.unmodifiableList(langList); 47 | 48 | List catList = new ArrayList(); 49 | catList.add("FISH"); 50 | catList.add("DOGS"); 51 | catList.add("REPTILES"); 52 | catList.add("CATS"); 53 | catList.add("BIRDS"); 54 | CATEGORY_LIST = Collections.unmodifiableList(catList); 55 | } 56 | 57 | @InitBinder("accountForm") 58 | public void initBinder(WebDataBinder webDataBinder) { 59 | webDataBinder.addValidators(passwordEqualsValidator); 60 | } 61 | 62 | @ModelAttribute("languageList") 63 | public List getLanguageList() { 64 | return LANGUAGE_LIST; 65 | } 66 | 67 | @ModelAttribute("categoryList") 68 | public List getCategoryList() { 69 | return CATEGORY_LIST; 70 | } 71 | 72 | @ModelAttribute 73 | public AccountForm setUpForm() { 74 | return new AccountForm(); 75 | } 76 | 77 | @RequestMapping("signonForm") 78 | public String signonForm() { 79 | return "account/SignonForm"; 80 | } 81 | 82 | @RequestMapping("newAccountForm") 83 | public String newAccountForm() { 84 | return "account/NewAccountForm"; 85 | } 86 | 87 | @RequestMapping("newAccount") 88 | public String newAccount( 89 | @Validated({ NewAccount.class, Default.class }) AccountForm form, 90 | BindingResult result) { 91 | if (result.hasErrors()) { 92 | return "account/NewAccountForm"; 93 | } 94 | accountHelper.newAccount(form); 95 | return "redirect:/account/signonForm"; 96 | } 97 | 98 | @RequestMapping("editAccountForm") 99 | public String editAccountForm(AccountForm form) { 100 | UserDetails userDetails = (UserDetails) SecurityContextHolder 101 | .getContext().getAuthentication().getPrincipal(); 102 | Account account = userDetails.getAccount(); 103 | beanMapper.map(account, form); 104 | form.setPassword(""); 105 | return "account/EditAccountForm"; 106 | } 107 | 108 | @RequestMapping("editAccount") 109 | public String editAccount( 110 | @Validated({ EditAccount.class, Default.class }) AccountForm form, 111 | BindingResult result) { 112 | if (result.hasErrors()) { 113 | UserDetails userDetails = (UserDetails) SecurityContextHolder 114 | .getContext().getAuthentication().getPrincipal(); 115 | form.setUsername(userDetails.getUsername()); 116 | return "account/EditAccountForm"; 117 | } 118 | accountHelper.editAccount(form); 119 | return "redirect:/account/editAccountForm"; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/account/AccountForm.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.account; 2 | 3 | import javax.validation.constraints.NotNull; 4 | import javax.validation.constraints.Null; 5 | import javax.validation.constraints.Size; 6 | 7 | import org.hibernate.validator.constraints.Email; 8 | 9 | public class AccountForm { 10 | public static interface NewAccount { 11 | 12 | } 13 | 14 | public static interface EditAccount { 15 | 16 | } 17 | 18 | @Null(groups = EditAccount.class) 19 | @NotNull(groups = NewAccount.class) 20 | @Size(min = 1, max = 25) 21 | private String username; 22 | 23 | @NotNull 24 | @Size.List({ @Size(min = 1, max = 25, groups = NewAccount.class), 25 | @Size(min = 0, max = 25, groups = EditAccount.class) }) 26 | private String password; 27 | 28 | @NotNull 29 | @Size.List({ @Size(min = 1, max = 25, groups = NewAccount.class), 30 | @Size(min = 0, max = 25, groups = EditAccount.class) }) 31 | private String repeatedPassword; 32 | 33 | @NotNull 34 | @Size(min = 1, max = 80) 35 | private String firstName; 36 | 37 | @NotNull 38 | @Size(min = 1, max = 80) 39 | private String lastName; 40 | 41 | @NotNull 42 | @Size(min = 1, max = 80) 43 | @Email 44 | private String email; 45 | 46 | @NotNull 47 | @Size(min = 1, max = 80) 48 | private String phone; 49 | 50 | @NotNull 51 | @Size(min = 1, max = 80) 52 | private String address1; 53 | 54 | @NotNull 55 | @Size(min = 1, max = 40) 56 | private String address2; 57 | 58 | @NotNull 59 | @Size(min = 1, max = 80) 60 | private String city; 61 | 62 | @NotNull 63 | @Size(min = 1, max = 80) 64 | private String state; 65 | 66 | @NotNull 67 | @Size(min = 1, max = 20) 68 | private String zip; 69 | 70 | @NotNull 71 | @Size(min = 1, max = 20) 72 | private String country; 73 | 74 | @NotNull 75 | @Size(min = 1, max = 80) 76 | private String languagePreference; 77 | 78 | @NotNull 79 | @Size(min = 1, max = 30) 80 | private String favouriteCategoryId; 81 | 82 | private boolean listOption; 83 | 84 | private boolean bannerOption; 85 | 86 | public String getUsername() { 87 | return username; 88 | } 89 | 90 | public void setUsername(String username) { 91 | this.username = username; 92 | } 93 | 94 | public String getPassword() { 95 | return password; 96 | } 97 | 98 | public void setPassword(String password) { 99 | this.password = password; 100 | } 101 | 102 | public String getRepeatedPassword() { 103 | return repeatedPassword; 104 | } 105 | 106 | public void setRepeatedPassword(String repeatedPassword) { 107 | this.repeatedPassword = repeatedPassword; 108 | } 109 | 110 | public String getFirstName() { 111 | return firstName; 112 | } 113 | 114 | public void setFirstName(String firstName) { 115 | this.firstName = firstName; 116 | } 117 | 118 | public String getLastName() { 119 | return lastName; 120 | } 121 | 122 | public void setLastName(String lastName) { 123 | this.lastName = lastName; 124 | } 125 | 126 | public String getEmail() { 127 | return email; 128 | } 129 | 130 | public void setEmail(String email) { 131 | this.email = email; 132 | } 133 | 134 | public String getPhone() { 135 | return phone; 136 | } 137 | 138 | public void setPhone(String phone) { 139 | this.phone = phone; 140 | } 141 | 142 | public String getAddress1() { 143 | return address1; 144 | } 145 | 146 | public void setAddress1(String address1) { 147 | this.address1 = address1; 148 | } 149 | 150 | public String getAddress2() { 151 | return address2; 152 | } 153 | 154 | public void setAddress2(String address2) { 155 | this.address2 = address2; 156 | } 157 | 158 | public String getCity() { 159 | return city; 160 | } 161 | 162 | public void setCity(String city) { 163 | this.city = city; 164 | } 165 | 166 | public String getState() { 167 | return state; 168 | } 169 | 170 | public void setState(String state) { 171 | this.state = state; 172 | } 173 | 174 | public String getZip() { 175 | return zip; 176 | } 177 | 178 | public void setZip(String zip) { 179 | this.zip = zip; 180 | } 181 | 182 | public String getCountry() { 183 | return country; 184 | } 185 | 186 | public void setCountry(String country) { 187 | this.country = country; 188 | } 189 | 190 | public String getLanguagePreference() { 191 | return languagePreference; 192 | } 193 | 194 | public void setLanguagePreference(String languagePreference) { 195 | this.languagePreference = languagePreference; 196 | } 197 | 198 | public String getFavouriteCategoryId() { 199 | return favouriteCategoryId; 200 | } 201 | 202 | public void setFavouriteCategoryId(String favouriteCategoryId) { 203 | this.favouriteCategoryId = favouriteCategoryId; 204 | } 205 | 206 | public boolean isListOption() { 207 | return listOption; 208 | } 209 | 210 | public void setListOption(boolean listOption) { 211 | this.listOption = listOption; 212 | } 213 | 214 | public boolean isBannerOption() { 215 | return bannerOption; 216 | } 217 | 218 | public void setBannerOption(boolean bannerOption) { 219 | this.bannerOption = bannerOption; 220 | } 221 | } 222 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/account/AccountHelper.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.account; 2 | 3 | import java.util.List; 4 | 5 | import javax.inject.Inject; 6 | 7 | import ik.am.jpetstore.domain.model.Account; 8 | import ik.am.jpetstore.domain.model.Product; 9 | import ik.am.jpetstore.domain.model.UserDetails; 10 | import ik.am.jpetstore.domain.service.account.AccountService; 11 | import ik.am.jpetstore.domain.service.catalog.CatalogService; 12 | 13 | import org.dozer.Mapper; 14 | import org.springframework.security.core.context.SecurityContextHolder; 15 | import org.springframework.stereotype.Component; 16 | 17 | @Component 18 | public class AccountHelper { 19 | 20 | @Inject 21 | protected Mapper beanMapper; 22 | 23 | @Inject 24 | protected AccountService accountService; 25 | 26 | @Inject 27 | protected CatalogService catalogService; 28 | 29 | public void newAccount(AccountForm form) { 30 | Account account = beanMapper.map(form, Account.class); 31 | accountService.insertAccount(account); 32 | } 33 | 34 | public void editAccount(AccountForm form) { 35 | UserDetails userDetails = (UserDetails) SecurityContextHolder 36 | .getContext().getAuthentication().getPrincipal(); 37 | Account account = userDetails.getAccount(); 38 | 39 | // does not map "username" to use that of session object 40 | beanMapper.map(form, account, "accountExcludeUsername"); 41 | accountService.updateAccount(account); 42 | 43 | // reflect new value to session object 44 | beanMapper.map(accountService.getAccount(account.getUsername()), 45 | account); 46 | List myList = catalogService.getProductListByCategory(account 47 | .getFavouriteCategoryId()); 48 | // update MyList 49 | userDetails.getMyList().clear(); 50 | userDetails.getMyList().addAll(myList); 51 | 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/account/PasswordEqualsValidator.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.account; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.validation.Errors; 5 | import org.springframework.validation.Validator; 6 | 7 | @Component 8 | public class PasswordEqualsValidator implements Validator { 9 | 10 | @Override 11 | public boolean supports(Class clazz) { 12 | return AccountForm.class.isAssignableFrom(clazz); 13 | } 14 | 15 | @Override 16 | public void validate(Object target, Errors errors) { 17 | AccountForm form = (AccountForm) target; 18 | String password = form.getPassword(); 19 | String repeatedPassword = form.getRepeatedPassword(); 20 | if (password == null || repeatedPassword == null) { 21 | return; 22 | } 23 | if (!password.equals(repeatedPassword)) { 24 | errors.rejectValue("password", 25 | "PasswordEqualsValidator.accountForm.password", 26 | "password no match"); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/cart/CartController.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.cart; 2 | 3 | import javax.inject.Inject; 4 | 5 | import ik.am.jpetstore.domain.model.Cart; 6 | import ik.am.jpetstore.domain.service.catalog.CatalogService; 7 | 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.Model; 10 | import org.springframework.web.bind.annotation.ModelAttribute; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | 14 | @Controller 15 | @RequestMapping("cart") 16 | public class CartController { 17 | @Inject 18 | protected CartHelper cartHelper; 19 | 20 | @Inject 21 | protected CatalogService catalogService; 22 | 23 | @Inject 24 | protected Cart cart; 25 | 26 | @ModelAttribute 27 | public CartForm setUpForm() { 28 | return new CartForm(); 29 | } 30 | 31 | @ModelAttribute 32 | public Cart getCart() { 33 | return cart; 34 | } 35 | 36 | @RequestMapping("viewCart") 37 | public String viewCart() { 38 | return "cart/Cart"; 39 | } 40 | 41 | @RequestMapping("addItemToCart") 42 | public String addItemToCart( 43 | @RequestParam("workingItemId") String workingItemId) { 44 | cartHelper.addItemToCart(workingItemId, cart); 45 | return "redirect:/cart/viewCart"; 46 | } 47 | 48 | @RequestMapping("updateCartQuantities") 49 | public String updateCartQuantities(CartForm cartForm, Model model) { 50 | cartHelper.updateCartQuantities(cartForm, cart); 51 | return "redirect:/cart/viewCart"; 52 | } 53 | 54 | @RequestMapping("removeItemFromCart") 55 | public String removeItemFromCart(@RequestParam("cartItem") String cartItem) { 56 | cart.removeItemById(cartItem); 57 | return "redirect:/cart/viewCart"; 58 | } 59 | 60 | @RequestMapping("checkOut") 61 | public String checkOut() { 62 | return "cart/Checkout"; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/cart/CartForm.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.cart; 2 | 3 | import java.util.Map; 4 | 5 | public class CartForm { 6 | private Map quantity; 7 | 8 | public void setQuantity(Map quantity) { 9 | this.quantity = quantity; 10 | } 11 | 12 | public Map getQuantity() { 13 | return quantity; 14 | } 15 | 16 | @Override 17 | public String toString() { 18 | return "CartForm [quantity=" + quantity + "]"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/cart/CartHelper.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.cart; 2 | 3 | import java.util.Iterator; 4 | 5 | import javax.inject.Inject; 6 | 7 | import ik.am.jpetstore.domain.model.Cart; 8 | import ik.am.jpetstore.domain.model.CartItem; 9 | import ik.am.jpetstore.domain.model.Item; 10 | import ik.am.jpetstore.domain.service.catalog.CatalogService; 11 | 12 | import org.springframework.stereotype.Component; 13 | 14 | @Component 15 | public class CartHelper { 16 | @Inject 17 | protected CatalogService catalogService; 18 | 19 | public void addItemToCart(String workingItemId, Cart cart) { 20 | if (cart.containsItemId(workingItemId)) { 21 | cart.incrementQuantityByItemId(workingItemId); 22 | } else { 23 | // isInStock is a "real-time" property that must be updated 24 | // every time an item is added to the cart, even if other 25 | // item details are cached. 26 | boolean isInStock = catalogService.isItemInStock(workingItemId); 27 | Item item = catalogService.getItem(workingItemId); 28 | cart.addItem(item, isInStock); 29 | } 30 | } 31 | 32 | public void updateCartQuantities(CartForm cartForm, Cart cart) { 33 | Iterator cartItems = cart.getAllCartItems(); 34 | while (cartItems.hasNext()) { 35 | CartItem cartItem = (CartItem) cartItems.next(); 36 | String itemId = cartItem.getItem().getItemId(); 37 | try { 38 | int quantity = cartForm.getQuantity().get(itemId); 39 | cart.setQuantityByItemId(itemId, quantity); 40 | if (quantity < 1) { 41 | cartItems.remove(); 42 | } 43 | } catch (Exception e) { 44 | // ignore parse exceptions on purpose 45 | } 46 | } 47 | } 48 | 49 | public void removeItemFromCart(String cartItem, Cart cart) { 50 | cart.removeItemById(cartItem); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/catalog/CatalogController.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.catalog; 2 | 3 | import java.util.List; 4 | 5 | import ik.am.jpetstore.domain.model.Category; 6 | import ik.am.jpetstore.domain.model.Item; 7 | import ik.am.jpetstore.domain.model.Product; 8 | import ik.am.jpetstore.domain.service.catalog.CatalogService; 9 | 10 | import javax.inject.Inject; 11 | 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.ui.Model; 14 | import org.springframework.validation.BindingResult; 15 | import org.springframework.validation.annotation.Validated; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RequestParam; 18 | 19 | @Controller 20 | @RequestMapping("catalog") 21 | public class CatalogController { 22 | @Inject 23 | protected CatalogService catalogService; 24 | 25 | @RequestMapping 26 | public String main() { 27 | return "catalog/Main"; 28 | } 29 | 30 | @RequestMapping("viewCategory") 31 | public String viewCategory(@RequestParam("categoryId") String categoryId, 32 | Model model) { 33 | List productList = catalogService 34 | .getProductListByCategory(categoryId); 35 | Category category = catalogService.getCategory(categoryId); 36 | model.addAttribute("productList", productList); 37 | model.addAttribute("category", category); 38 | return "catalog/Category"; 39 | } 40 | 41 | @RequestMapping("viewProduct") 42 | public String viewProduct(@RequestParam("productId") String productId, 43 | Model model) { 44 | List itemList = catalogService.getItemListByProduct(productId); 45 | Product product = catalogService.getProduct(productId); 46 | model.addAttribute("itemList", itemList); 47 | model.addAttribute("product", product); 48 | return "catalog/Product"; 49 | } 50 | 51 | @RequestMapping("viewItem") 52 | public String viewItem(@RequestParam("itemId") String itemId, Model model) { 53 | Item item = catalogService.getItem(itemId); 54 | Product product = item.getProduct(); 55 | model.addAttribute("item", item); 56 | model.addAttribute("product", product); 57 | return "catalog/Item"; 58 | } 59 | 60 | @RequestMapping(params = "keyword") 61 | public String searchProducts(@Validated ProductSearchForm form, 62 | BindingResult result, Model model) { 63 | if (result.hasErrors()) { 64 | return "common/Error"; 65 | } 66 | String keyword = form.getKeyword().toLowerCase(); 67 | List productList = catalogService.searchProductList(keyword); 68 | model.addAttribute("productList", productList); 69 | return "catalog/SearchProducts"; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/catalog/ProductSearchForm.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.catalog; 2 | 3 | import javax.validation.constraints.NotNull; 4 | import javax.validation.constraints.Size; 5 | 6 | public class ProductSearchForm { 7 | @NotNull(message = "Please enter a keyword to search for, then press the search button.") 8 | @Size(min = 1, message = "Please enter a keyword to search for, then press the search button.") 9 | private String keyword; 10 | 11 | public void setKeyword(String keyword) { 12 | this.keyword = keyword; 13 | } 14 | 15 | public String getKeyword() { 16 | return keyword; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/common/session/EnableSynchronizeOnSessionPostProcessor.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.common.session; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.BeansException; 6 | import org.springframework.beans.factory.config.BeanPostProcessor; 7 | import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; 8 | 9 | public class EnableSynchronizeOnSessionPostProcessor implements BeanPostProcessor { 10 | private static final Logger logger = LoggerFactory 11 | .getLogger(EnableSynchronizeOnSessionPostProcessor.class); 12 | 13 | @Override 14 | public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { 15 | // NO-OP 16 | return bean; 17 | } 18 | 19 | @Override 20 | public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { 21 | if (bean instanceof RequestMappingHandlerAdapter) { 22 | RequestMappingHandlerAdapter adapter = (RequestMappingHandlerAdapter) bean; 23 | logger.info("enable synchronizeOnSession => {}", adapter); 24 | adapter.setSynchronizeOnSession(true); 25 | } 26 | return bean; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/common/session/HttpSessionEventLoggingListener.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.common.session; 2 | 3 | import javax.servlet.http.HttpSession; 4 | import javax.servlet.http.HttpSessionActivationListener; 5 | import javax.servlet.http.HttpSessionAttributeListener; 6 | import javax.servlet.http.HttpSessionBindingEvent; 7 | import javax.servlet.http.HttpSessionBindingListener; 8 | import javax.servlet.http.HttpSessionEvent; 9 | import javax.servlet.http.HttpSessionListener; 10 | 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | 14 | public class HttpSessionEventLoggingListener implements HttpSessionListener, 15 | HttpSessionAttributeListener, 16 | HttpSessionBindingListener, 17 | HttpSessionActivationListener { 18 | 19 | private static final Logger logger = LoggerFactory 20 | .getLogger(HttpSessionEventLoggingListener.class); 21 | 22 | @Override 23 | public void sessionWillPassivate(HttpSessionEvent se) { 24 | if (logger.isDebugEnabled()) { 25 | HttpSession session = se.getSession(); 26 | logger.debug("sessionId={}\tsessionWillPassivate\t{}", session 27 | .getId(), se.getSource()); 28 | } 29 | } 30 | 31 | @Override 32 | public void sessionDidActivate(HttpSessionEvent se) { 33 | if (logger.isDebugEnabled()) { 34 | HttpSession session = se.getSession(); 35 | logger.debug("sessionId={}\tsessionDidActivate\t{}", session 36 | .getId(), se.getSource()); 37 | } 38 | } 39 | 40 | @Override 41 | public void valueBound(HttpSessionBindingEvent event) { 42 | if (logger.isDebugEnabled()) { 43 | HttpSession session = event.getSession(); 44 | logger.debug("sessionId={}\tvalueBound\t{}={}", new Object[] { 45 | session.getId(), event.getName(), event.getValue() }); 46 | } 47 | } 48 | 49 | @Override 50 | public void valueUnbound(HttpSessionBindingEvent event) { 51 | if (logger.isDebugEnabled()) { 52 | HttpSession session = event.getSession(); 53 | logger.debug("sessionId={}\tvalueUnbound\t{}={}", new Object[] { 54 | session.getId(), event.getName(), event.getValue() }); 55 | } 56 | } 57 | 58 | @Override 59 | public void attributeAdded(HttpSessionBindingEvent se) { 60 | if (logger.isDebugEnabled()) { 61 | HttpSession session = se.getSession(); 62 | logger.debug("sessionId={}\tattributeAdded\t{}={}", new Object[] { 63 | session.getId(), se.getName(), se.getValue() }); 64 | } 65 | } 66 | 67 | @Override 68 | public void attributeRemoved(HttpSessionBindingEvent se) { 69 | if (logger.isDebugEnabled()) { 70 | HttpSession session = se.getSession(); 71 | logger.debug("sessionId={}\tattributeRemoved\t{}={}", new Object[] { 72 | session.getId(), se.getName(), se.getValue() }); 73 | } 74 | } 75 | 76 | @Override 77 | public void attributeReplaced(HttpSessionBindingEvent se) { 78 | // NO-OP 79 | } 80 | 81 | @Override 82 | public void sessionCreated(HttpSessionEvent se) { 83 | if (logger.isDebugEnabled()) { 84 | HttpSession session = se.getSession(); 85 | logger.debug("sessionId={}\tsessionCreated\t{}", session.getId(), 86 | se.getSource()); 87 | } 88 | } 89 | 90 | @Override 91 | public void sessionDestroyed(HttpSessionEvent se) { 92 | if (logger.isDebugEnabled()) { 93 | HttpSession session = se.getSession(); 94 | logger.debug("sessionId={}\tsessionDestroyed\t{}", session.getId(), 95 | se.getSource()); 96 | } 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/order/OrderController.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.order; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import ik.am.jpetstore.domain.model.Account; 8 | import ik.am.jpetstore.domain.model.Cart; 9 | import ik.am.jpetstore.domain.model.Order; 10 | import ik.am.jpetstore.domain.model.UserDetails; 11 | import ik.am.jpetstore.domain.service.order.OrderService; 12 | 13 | import javax.inject.Inject; 14 | 15 | import org.dozer.Mapper; 16 | import org.springframework.security.core.context.SecurityContextHolder; 17 | import org.springframework.stereotype.Controller; 18 | import org.springframework.ui.Model; 19 | import org.springframework.web.bind.annotation.ModelAttribute; 20 | import org.springframework.web.bind.annotation.RequestMapping; 21 | import org.springframework.web.bind.annotation.RequestParam; 22 | import org.springframework.web.bind.annotation.SessionAttributes; 23 | import org.springframework.web.bind.support.SessionStatus; 24 | import org.springframework.web.servlet.mvc.support.RedirectAttributes; 25 | 26 | @Controller 27 | @RequestMapping("order") 28 | @SessionAttributes("scopedTarget.cart") 29 | public class OrderController { 30 | 31 | private static final List CARD_TYPE_LIST; 32 | 33 | @Inject 34 | protected OrderHelper orderHelper; 35 | 36 | @Inject 37 | protected OrderService orderService; 38 | 39 | @Inject 40 | protected Mapper beanMapper; 41 | 42 | @Inject 43 | protected Cart cart; 44 | 45 | static { 46 | List cardList = new ArrayList(); 47 | cardList.add("Visa"); 48 | cardList.add("MasterCard"); 49 | cardList.add("American Express"); 50 | CARD_TYPE_LIST = Collections.unmodifiableList(cardList); 51 | } 52 | 53 | @ModelAttribute 54 | public OrderForm setUpForm() { 55 | return new OrderForm(); 56 | } 57 | 58 | @ModelAttribute("creditCardTypes") 59 | public List getCardTypeList() { 60 | return CARD_TYPE_LIST; 61 | } 62 | 63 | @RequestMapping("newOrderForm") 64 | public String newOrderForm(OrderForm orderForm, Model model) { 65 | UserDetails userDetails = (UserDetails) SecurityContextHolder 66 | .getContext().getAuthentication().getPrincipal(); 67 | Account account = userDetails.getAccount(); 68 | 69 | Order order = new Order(); 70 | order.initOrder(account, cart); 71 | beanMapper.map(order, orderForm); 72 | model.addAttribute(order); 73 | 74 | return "order/NewOrderForm"; 75 | } 76 | 77 | @RequestMapping(value = "newOrder") 78 | public String confirmOrder(OrderForm orderForm, Order order) { 79 | return "order/ConfirmOrder"; 80 | } 81 | 82 | @RequestMapping(value = "newOrder", params = "shippingAddressRequired=true") 83 | public String shippingForm(OrderForm orderForm, Order order) { 84 | return "order/ShippingForm"; 85 | } 86 | 87 | @RequestMapping(value = "newOrder", params = "confirmed") 88 | public String newOrder(OrderForm orderForm, SessionStatus status, 89 | RedirectAttributes attributes) { 90 | Order order = orderHelper.newOrder(orderForm, cart); 91 | 92 | attributes.addAttribute("orderId", order.getOrderId()); 93 | attributes.addFlashAttribute("message", 94 | "Thank you, your order has been submitted."); 95 | status.setComplete(); 96 | return "redirect:/order/viewOrder"; 97 | } 98 | 99 | @RequestMapping("viewOrder") 100 | public String viewOrder(@RequestParam("orderId") int orderId, Model model) { 101 | Order order = orderService.getOrder(orderId); 102 | 103 | UserDetails userDetails = (UserDetails) SecurityContextHolder 104 | .getContext().getAuthentication().getPrincipal(); 105 | Account account = userDetails.getAccount(); 106 | if (account.getUsername().equals(order.getUsername())) { 107 | model.addAttribute(order); 108 | return "order/ViewOrder"; 109 | } else { 110 | // TODO 111 | model.addAttribute("You may only view your own orders."); 112 | return "common/Error"; 113 | } 114 | } 115 | 116 | @RequestMapping("listOrders") 117 | public String listOrders(Model model) { 118 | UserDetails userDetails = (UserDetails) SecurityContextHolder 119 | .getContext().getAuthentication().getPrincipal(); 120 | String username = userDetails.getUsername(); 121 | List orderList = orderService.getOrdersByUsername(username); 122 | model.addAttribute("orderList", orderList); 123 | return "order/ListOrders"; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/order/OrderForm.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.order; 2 | 3 | public class OrderForm { 4 | private String cardType; 5 | 6 | private String creditCard; 7 | 8 | private String expiryDate; 9 | 10 | private String billToFirstName; 11 | 12 | private String billToLastName; 13 | 14 | private String billAddress1; 15 | 16 | private String billAddress2; 17 | 18 | private String billCity; 19 | 20 | private String billState; 21 | 22 | private String billZip; 23 | 24 | private String billCountry; 25 | 26 | private String shipToFirstName; 27 | 28 | private String shipToLastName; 29 | 30 | private String shipAddress1; 31 | 32 | private String shipAddress2; 33 | 34 | private String shipCity; 35 | 36 | private String shipState; 37 | 38 | private String shipZip; 39 | 40 | private String shipCountry; 41 | 42 | private boolean shippingAddressRequired; 43 | 44 | public String getCardType() { 45 | return cardType; 46 | } 47 | 48 | public void setCardType(String cardType) { 49 | this.cardType = cardType; 50 | } 51 | 52 | public String getCreditCard() { 53 | return creditCard; 54 | } 55 | 56 | public void setCreditCard(String creditCard) { 57 | this.creditCard = creditCard; 58 | } 59 | 60 | public String getExpiryDate() { 61 | return expiryDate; 62 | } 63 | 64 | public void setExpiryDate(String expiryDate) { 65 | this.expiryDate = expiryDate; 66 | } 67 | 68 | public String getBillToFirstName() { 69 | return billToFirstName; 70 | } 71 | 72 | public void setBillToFirstName(String billToFirstName) { 73 | this.billToFirstName = billToFirstName; 74 | } 75 | 76 | public String getBillToLastName() { 77 | return billToLastName; 78 | } 79 | 80 | public void setBillToLastName(String billToLastName) { 81 | this.billToLastName = billToLastName; 82 | } 83 | 84 | public String getBillAddress1() { 85 | return billAddress1; 86 | } 87 | 88 | public void setBillAddress1(String billAddress1) { 89 | this.billAddress1 = billAddress1; 90 | } 91 | 92 | public String getBillAddress2() { 93 | return billAddress2; 94 | } 95 | 96 | public void setBillAddress2(String billAddress2) { 97 | this.billAddress2 = billAddress2; 98 | } 99 | 100 | public String getBillCity() { 101 | return billCity; 102 | } 103 | 104 | public void setBillCity(String billCity) { 105 | this.billCity = billCity; 106 | } 107 | 108 | public String getBillState() { 109 | return billState; 110 | } 111 | 112 | public void setBillState(String billState) { 113 | this.billState = billState; 114 | } 115 | 116 | public String getBillZip() { 117 | return billZip; 118 | } 119 | 120 | public void setBillZip(String billZip) { 121 | this.billZip = billZip; 122 | } 123 | 124 | public String getBillCountry() { 125 | return billCountry; 126 | } 127 | 128 | public void setBillCountry(String billCountry) { 129 | this.billCountry = billCountry; 130 | } 131 | 132 | public String getShipToFirstName() { 133 | return shipToFirstName; 134 | } 135 | 136 | public void setShipToFirstName(String shipToFirstName) { 137 | this.shipToFirstName = shipToFirstName; 138 | } 139 | 140 | public String getShipToLastName() { 141 | return shipToLastName; 142 | } 143 | 144 | public void setShipToLastName(String shipToLastName) { 145 | this.shipToLastName = shipToLastName; 146 | } 147 | 148 | public String getShipAddress1() { 149 | return shipAddress1; 150 | } 151 | 152 | public void setShipAddress1(String shipAddress1) { 153 | this.shipAddress1 = shipAddress1; 154 | } 155 | 156 | public String getShipAddress2() { 157 | return shipAddress2; 158 | } 159 | 160 | public void setShipAddress2(String shipAddress2) { 161 | this.shipAddress2 = shipAddress2; 162 | } 163 | 164 | public String getShipCity() { 165 | return shipCity; 166 | } 167 | 168 | public void setShipCity(String shipCity) { 169 | this.shipCity = shipCity; 170 | } 171 | 172 | public String getShipState() { 173 | return shipState; 174 | } 175 | 176 | public void setShipState(String shipState) { 177 | this.shipState = shipState; 178 | } 179 | 180 | public String getShipZip() { 181 | return shipZip; 182 | } 183 | 184 | public void setShipZip(String shipZip) { 185 | this.shipZip = shipZip; 186 | } 187 | 188 | public String getShipCountry() { 189 | return shipCountry; 190 | } 191 | 192 | public void setShipCountry(String shipCountry) { 193 | this.shipCountry = shipCountry; 194 | } 195 | 196 | public boolean isShippingAddressRequired() { 197 | return shippingAddressRequired; 198 | } 199 | 200 | public void setShippingAddressRequired(boolean shippingAddressRequired) { 201 | this.shippingAddressRequired = shippingAddressRequired; 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/app/order/OrderHelper.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.app.order; 2 | 3 | import javax.inject.Inject; 4 | 5 | import ik.am.jpetstore.domain.model.Account; 6 | import ik.am.jpetstore.domain.model.Cart; 7 | import ik.am.jpetstore.domain.model.Order; 8 | import ik.am.jpetstore.domain.model.UserDetails; 9 | import ik.am.jpetstore.domain.service.order.OrderService; 10 | 11 | import org.dozer.Mapper; 12 | import org.springframework.security.core.context.SecurityContextHolder; 13 | import org.springframework.stereotype.Component; 14 | 15 | @Component 16 | public class OrderHelper { 17 | @Inject 18 | protected OrderService orderService; 19 | 20 | @Inject 21 | protected Mapper beanMapper; 22 | 23 | public Order newOrder(OrderForm orderForm, Cart cart) { 24 | UserDetails userDetails = (UserDetails) SecurityContextHolder 25 | .getContext().getAuthentication().getPrincipal(); 26 | Account account = userDetails.getAccount(); 27 | 28 | Order order = new Order(); 29 | order.initOrder(account, cart); 30 | beanMapper.map(orderForm, order); 31 | orderService.insertOrder(order); 32 | return order; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/common/exception/ResourceNotFoundException.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.domain.common.exception; 2 | 3 | public class ResourceNotFoundException extends RuntimeException { 4 | /** 5 | * serialVersionUID 6 | */ 7 | private static final long serialVersionUID = 1L; 8 | 9 | public ResourceNotFoundException(String message) { 10 | super(message); 11 | } 12 | 13 | public ResourceNotFoundException(String message, Throwable cause) { 14 | super(message, cause); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/Account.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.model; 18 | 19 | import java.io.Serializable; 20 | 21 | //import net.sourceforge.stripes.validation.Validate; 22 | 23 | /** 24 | * @author Eduardo Macarron 25 | */ 26 | public class Account implements Serializable { 27 | 28 | private static final long serialVersionUID = 8751282105532159742L; 29 | 30 | private String username; 31 | 32 | private String password; 33 | 34 | private String email; 35 | 36 | private String firstName; 37 | 38 | private String lastName; 39 | 40 | private String status; 41 | 42 | private String address1; 43 | 44 | private String address2; 45 | 46 | private String city; 47 | 48 | private String state; 49 | 50 | private String zip; 51 | 52 | private String country; 53 | 54 | private String phone; 55 | 56 | private String favouriteCategoryId; 57 | 58 | private String languagePreference; 59 | 60 | private boolean listOption; 61 | 62 | private boolean bannerOption; 63 | 64 | private String bannerName; 65 | 66 | public String getUsername() { 67 | return username; 68 | } 69 | 70 | public void setUsername(String username) { 71 | this.username = username; 72 | } 73 | 74 | public String getPassword() { 75 | return password; 76 | } 77 | 78 | public void setPassword(String password) { 79 | this.password = password; 80 | } 81 | 82 | public String getEmail() { 83 | return email; 84 | } 85 | 86 | public void setEmail(String email) { 87 | this.email = email; 88 | } 89 | 90 | public String getFirstName() { 91 | return firstName; 92 | } 93 | 94 | // @Validate(required=true, on={"newAccount", "editAccount"}) 95 | public void setFirstName(String firstName) { 96 | this.firstName = firstName; 97 | } 98 | 99 | public String getLastName() { 100 | return lastName; 101 | } 102 | 103 | // @Validate(required=true, on={"newAccount", "editAccount"}) 104 | public void setLastName(String lastName) { 105 | this.lastName = lastName; 106 | } 107 | 108 | public String getStatus() { 109 | return status; 110 | } 111 | 112 | public void setStatus(String status) { 113 | this.status = status; 114 | } 115 | 116 | public String getAddress1() { 117 | return address1; 118 | } 119 | 120 | public void setAddress1(String address1) { 121 | this.address1 = address1; 122 | } 123 | 124 | public String getAddress2() { 125 | return address2; 126 | } 127 | 128 | public void setAddress2(String address2) { 129 | this.address2 = address2; 130 | } 131 | 132 | public String getCity() { 133 | return city; 134 | } 135 | 136 | public void setCity(String city) { 137 | this.city = city; 138 | } 139 | 140 | public String getState() { 141 | return state; 142 | } 143 | 144 | public void setState(String state) { 145 | this.state = state; 146 | } 147 | 148 | public String getZip() { 149 | return zip; 150 | } 151 | 152 | public void setZip(String zip) { 153 | this.zip = zip; 154 | } 155 | 156 | public String getCountry() { 157 | return country; 158 | } 159 | 160 | public void setCountry(String country) { 161 | this.country = country; 162 | } 163 | 164 | public String getPhone() { 165 | return phone; 166 | } 167 | 168 | public void setPhone(String phone) { 169 | this.phone = phone; 170 | } 171 | 172 | public String getFavouriteCategoryId() { 173 | return favouriteCategoryId; 174 | } 175 | 176 | public void setFavouriteCategoryId(String favouriteCategoryId) { 177 | this.favouriteCategoryId = favouriteCategoryId; 178 | } 179 | 180 | public String getLanguagePreference() { 181 | return languagePreference; 182 | } 183 | 184 | public void setLanguagePreference(String languagePreference) { 185 | this.languagePreference = languagePreference; 186 | } 187 | 188 | public boolean isListOption() { 189 | return listOption; 190 | } 191 | 192 | public void setListOption(boolean listOption) { 193 | this.listOption = listOption; 194 | } 195 | 196 | public boolean isBannerOption() { 197 | return bannerOption; 198 | } 199 | 200 | public void setBannerOption(boolean bannerOption) { 201 | this.bannerOption = bannerOption; 202 | } 203 | 204 | public String getBannerName() { 205 | return bannerName; 206 | } 207 | 208 | public void setBannerName(String bannerName) { 209 | this.bannerName = bannerName; 210 | } 211 | 212 | } 213 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/Cart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.model; 18 | 19 | import java.io.Serializable; 20 | import java.math.BigDecimal; 21 | import java.util.ArrayList; 22 | import java.util.Collections; 23 | import java.util.HashMap; 24 | import java.util.Iterator; 25 | import java.util.List; 26 | import java.util.Map; 27 | 28 | /** 29 | * @author Eduardo Macarron 30 | */ 31 | public class Cart implements Serializable { 32 | 33 | private static final long serialVersionUID = 8329559983943337176L; 34 | 35 | private final Map itemMap = Collections 36 | .synchronizedMap(new HashMap()); 37 | 38 | private final List itemList = new ArrayList(); 39 | 40 | public Iterator getCartItems() { 41 | return itemList.iterator(); 42 | } 43 | 44 | public List getCartItemList() { 45 | return itemList; 46 | } 47 | 48 | public int getNumberOfItems() { 49 | return itemList.size(); 50 | } 51 | 52 | public Iterator getAllCartItems() { 53 | return itemList.iterator(); 54 | } 55 | 56 | public boolean containsItemId(String itemId) { 57 | return itemMap.containsKey(itemId); 58 | } 59 | 60 | public void addItem(Item item, boolean isInStock) { 61 | CartItem cartItem = (CartItem) itemMap.get(item.getItemId()); 62 | if (cartItem == null) { 63 | cartItem = new CartItem(); 64 | cartItem.setItem(item); 65 | cartItem.setQuantity(0); 66 | cartItem.setInStock(isInStock); 67 | itemMap.put(item.getItemId(), cartItem); 68 | itemList.add(cartItem); 69 | } 70 | cartItem.incrementQuantity(); 71 | } 72 | 73 | public Item removeItemById(String itemId) { 74 | CartItem cartItem = (CartItem) itemMap.remove(itemId); 75 | if (cartItem == null) { 76 | return null; 77 | } else { 78 | itemList.remove(cartItem); 79 | return cartItem.getItem(); 80 | } 81 | } 82 | 83 | public void incrementQuantityByItemId(String itemId) { 84 | CartItem cartItem = (CartItem) itemMap.get(itemId); 85 | cartItem.incrementQuantity(); 86 | } 87 | 88 | public void setQuantityByItemId(String itemId, int quantity) { 89 | CartItem cartItem = (CartItem) itemMap.get(itemId); 90 | cartItem.setQuantity(quantity); 91 | } 92 | 93 | public BigDecimal getSubTotal() { 94 | BigDecimal subTotal = new BigDecimal("0"); 95 | Iterator items = getAllCartItems(); 96 | while (items.hasNext()) { 97 | CartItem cartItem = (CartItem) items.next(); 98 | Item item = cartItem.getItem(); 99 | BigDecimal listPrice = item.getListPrice(); 100 | BigDecimal quantity = new BigDecimal(String.valueOf(cartItem 101 | .getQuantity())); 102 | subTotal = subTotal.add(listPrice.multiply(quantity)); 103 | } 104 | return subTotal; 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/CartItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.model; 18 | 19 | import java.io.Serializable; 20 | import java.math.BigDecimal; 21 | 22 | /** 23 | * @author Eduardo Macarron 24 | */ 25 | public class CartItem implements Serializable { 26 | 27 | private static final long serialVersionUID = 6620528781626504362L; 28 | 29 | private Item item; 30 | 31 | private int quantity; 32 | 33 | private boolean inStock; 34 | 35 | private BigDecimal total; 36 | 37 | public boolean isInStock() { 38 | return inStock; 39 | } 40 | 41 | public void setInStock(boolean inStock) { 42 | this.inStock = inStock; 43 | } 44 | 45 | public BigDecimal getTotal() { 46 | return total; 47 | } 48 | 49 | public Item getItem() { 50 | return item; 51 | } 52 | 53 | public void setItem(Item item) { 54 | this.item = item; 55 | calculateTotal(); 56 | } 57 | 58 | public int getQuantity() { 59 | return quantity; 60 | } 61 | 62 | public void setQuantity(int quantity) { 63 | this.quantity = quantity; 64 | calculateTotal(); 65 | } 66 | 67 | public void incrementQuantity() { 68 | quantity++; 69 | calculateTotal(); 70 | } 71 | 72 | private void calculateTotal() { 73 | if (item != null && item.getListPrice() != null) { 74 | total = item.getListPrice().multiply(new BigDecimal(quantity)); 75 | } else { 76 | total = null; 77 | } 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/Category.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.model; 18 | 19 | import java.io.Serializable; 20 | 21 | /** 22 | * @author Eduardo Macarron 23 | */ 24 | public class Category implements Serializable { 25 | 26 | private static final long serialVersionUID = 3992469837058393712L; 27 | 28 | private String categoryId; 29 | 30 | private String name; 31 | 32 | private String description; 33 | 34 | public String getCategoryId() { 35 | return categoryId; 36 | } 37 | 38 | public void setCategoryId(String categoryId) { 39 | this.categoryId = categoryId.trim(); 40 | } 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public void setName(String name) { 47 | this.name = name; 48 | } 49 | 50 | public String getDescription() { 51 | return description; 52 | } 53 | 54 | public void setDescription(String description) { 55 | this.description = description; 56 | } 57 | 58 | public String toString() { 59 | return getCategoryId(); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/Item.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.model; 18 | 19 | import java.io.Serializable; 20 | import java.math.BigDecimal; 21 | 22 | /** 23 | * @author Eduardo Macarron 24 | */ 25 | public class Item implements Serializable { 26 | 27 | private static final long serialVersionUID = -2159121673445254631L; 28 | 29 | private String itemId; 30 | 31 | private String productId; 32 | 33 | private BigDecimal listPrice; 34 | 35 | private BigDecimal unitCost; 36 | 37 | private int supplierId; 38 | 39 | private String status; 40 | 41 | private String attribute1; 42 | 43 | private String attribute2; 44 | 45 | private String attribute3; 46 | 47 | private String attribute4; 48 | 49 | private String attribute5; 50 | 51 | private Product product; 52 | 53 | private int quantity; 54 | 55 | public String getItemId() { 56 | return itemId; 57 | } 58 | 59 | public void setItemId(String itemId) { 60 | this.itemId = itemId.trim(); 61 | } 62 | 63 | public int getQuantity() { 64 | return quantity; 65 | } 66 | 67 | public void setQuantity(int quantity) { 68 | this.quantity = quantity; 69 | } 70 | 71 | public Product getProduct() { 72 | return product; 73 | } 74 | 75 | public void setProduct(Product product) { 76 | this.product = product; 77 | } 78 | 79 | public String getProductId() { 80 | return productId; 81 | } 82 | 83 | public void setProductId(String productId) { 84 | this.productId = productId; 85 | } 86 | 87 | public int getSupplierId() { 88 | return supplierId; 89 | } 90 | 91 | public void setSupplierId(int supplierId) { 92 | this.supplierId = supplierId; 93 | } 94 | 95 | public BigDecimal getListPrice() { 96 | return listPrice; 97 | } 98 | 99 | public void setListPrice(BigDecimal listPrice) { 100 | this.listPrice = listPrice; 101 | } 102 | 103 | public BigDecimal getUnitCost() { 104 | return unitCost; 105 | } 106 | 107 | public void setUnitCost(BigDecimal unitCost) { 108 | this.unitCost = unitCost; 109 | } 110 | 111 | public String getStatus() { 112 | return status; 113 | } 114 | 115 | public void setStatus(String status) { 116 | this.status = status; 117 | } 118 | 119 | public String getAttribute1() { 120 | return attribute1; 121 | } 122 | 123 | public void setAttribute1(String attribute1) { 124 | this.attribute1 = attribute1; 125 | } 126 | 127 | public String getAttribute2() { 128 | return attribute2; 129 | } 130 | 131 | public void setAttribute2(String attribute2) { 132 | this.attribute2 = attribute2; 133 | } 134 | 135 | public String getAttribute3() { 136 | return attribute3; 137 | } 138 | 139 | public void setAttribute3(String attribute3) { 140 | this.attribute3 = attribute3; 141 | } 142 | 143 | public String getAttribute4() { 144 | return attribute4; 145 | } 146 | 147 | public void setAttribute4(String attribute4) { 148 | this.attribute4 = attribute4; 149 | } 150 | 151 | public String getAttribute5() { 152 | return attribute5; 153 | } 154 | 155 | public void setAttribute5(String attribute5) { 156 | this.attribute5 = attribute5; 157 | } 158 | 159 | public String toString() { 160 | return "(" + getItemId() + "-" + getProductId() + ")"; 161 | } 162 | 163 | } 164 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/LineItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.model; 18 | 19 | import java.io.Serializable; 20 | import java.math.BigDecimal; 21 | 22 | /** 23 | * @author Eduardo Macarron 24 | */ 25 | public class LineItem implements Serializable { 26 | 27 | private static final long serialVersionUID = 6804536240033522156L; 28 | 29 | private int orderId; 30 | 31 | private int lineNumber; 32 | 33 | private int quantity; 34 | 35 | private String itemId; 36 | 37 | private BigDecimal unitPrice; 38 | 39 | private Item item; 40 | 41 | private BigDecimal total; 42 | 43 | public LineItem() { 44 | } 45 | 46 | public LineItem(int lineNumber, CartItem cartItem) { 47 | this.lineNumber = lineNumber; 48 | this.quantity = cartItem.getQuantity(); 49 | this.itemId = cartItem.getItem().getItemId(); 50 | this.unitPrice = cartItem.getItem().getListPrice(); 51 | this.item = cartItem.getItem(); 52 | } 53 | 54 | public int getOrderId() { 55 | return orderId; 56 | } 57 | 58 | public void setOrderId(int orderId) { 59 | this.orderId = orderId; 60 | } 61 | 62 | public int getLineNumber() { 63 | return lineNumber; 64 | } 65 | 66 | public void setLineNumber(int lineNumber) { 67 | this.lineNumber = lineNumber; 68 | } 69 | 70 | public String getItemId() { 71 | return itemId; 72 | } 73 | 74 | public void setItemId(String itemId) { 75 | this.itemId = itemId; 76 | } 77 | 78 | public BigDecimal getUnitPrice() { 79 | return unitPrice; 80 | } 81 | 82 | public void setUnitPrice(BigDecimal unitprice) { 83 | this.unitPrice = unitprice; 84 | } 85 | 86 | public BigDecimal getTotal() { 87 | return total; 88 | } 89 | 90 | public Item getItem() { 91 | return item; 92 | } 93 | 94 | public void setItem(Item item) { 95 | this.item = item; 96 | calculateTotal(); 97 | } 98 | 99 | public int getQuantity() { 100 | return quantity; 101 | } 102 | 103 | public void setQuantity(int quantity) { 104 | this.quantity = quantity; 105 | calculateTotal(); 106 | } 107 | 108 | private void calculateTotal() { 109 | if (item != null && item.getListPrice() != null) { 110 | total = item.getListPrice().multiply(new BigDecimal(quantity)); 111 | } else { 112 | total = null; 113 | } 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/Order.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.model; 18 | 19 | import java.io.Serializable; 20 | import java.math.BigDecimal; 21 | import java.util.ArrayList; 22 | import java.util.Date; 23 | import java.util.Iterator; 24 | import java.util.List; 25 | 26 | /** 27 | * @author Eduardo Macarron 28 | */ 29 | public class Order implements Serializable { 30 | 31 | private static final long serialVersionUID = 6321792448424424931L; 32 | 33 | private int orderId; 34 | 35 | private String username; 36 | 37 | private Date orderDate; 38 | 39 | private String shipAddress1; 40 | 41 | private String shipAddress2; 42 | 43 | private String shipCity; 44 | 45 | private String shipState; 46 | 47 | private String shipZip; 48 | 49 | private String shipCountry; 50 | 51 | private String billAddress1; 52 | 53 | private String billAddress2; 54 | 55 | private String billCity; 56 | 57 | private String billState; 58 | 59 | private String billZip; 60 | 61 | private String billCountry; 62 | 63 | private String courier; 64 | 65 | private BigDecimal totalPrice; 66 | 67 | private String billToFirstName; 68 | 69 | private String billToLastName; 70 | 71 | private String shipToFirstName; 72 | 73 | private String shipToLastName; 74 | 75 | private String creditCard; 76 | 77 | private String expiryDate; 78 | 79 | private String cardType; 80 | 81 | private String locale; 82 | 83 | private String status; 84 | 85 | private List lineItems = new ArrayList(); 86 | 87 | public int getOrderId() { 88 | return orderId; 89 | } 90 | 91 | public void setOrderId(int orderId) { 92 | this.orderId = orderId; 93 | } 94 | 95 | public String getUsername() { 96 | return username; 97 | } 98 | 99 | public void setUsername(String username) { 100 | this.username = username; 101 | } 102 | 103 | public Date getOrderDate() { 104 | return orderDate; 105 | } 106 | 107 | public void setOrderDate(Date orderDate) { 108 | this.orderDate = orderDate; 109 | } 110 | 111 | public String getShipAddress1() { 112 | return shipAddress1; 113 | } 114 | 115 | public void setShipAddress1(String shipAddress1) { 116 | this.shipAddress1 = shipAddress1; 117 | } 118 | 119 | public String getShipAddress2() { 120 | return shipAddress2; 121 | } 122 | 123 | public void setShipAddress2(String shipAddress2) { 124 | this.shipAddress2 = shipAddress2; 125 | } 126 | 127 | public String getShipCity() { 128 | return shipCity; 129 | } 130 | 131 | public void setShipCity(String shipCity) { 132 | this.shipCity = shipCity; 133 | } 134 | 135 | public String getShipState() { 136 | return shipState; 137 | } 138 | 139 | public void setShipState(String shipState) { 140 | this.shipState = shipState; 141 | } 142 | 143 | public String getShipZip() { 144 | return shipZip; 145 | } 146 | 147 | public void setShipZip(String shipZip) { 148 | this.shipZip = shipZip; 149 | } 150 | 151 | public String getShipCountry() { 152 | return shipCountry; 153 | } 154 | 155 | public void setShipCountry(String shipCountry) { 156 | this.shipCountry = shipCountry; 157 | } 158 | 159 | public String getBillAddress1() { 160 | return billAddress1; 161 | } 162 | 163 | public void setBillAddress1(String billAddress1) { 164 | this.billAddress1 = billAddress1; 165 | } 166 | 167 | public String getBillAddress2() { 168 | return billAddress2; 169 | } 170 | 171 | public void setBillAddress2(String billAddress2) { 172 | this.billAddress2 = billAddress2; 173 | } 174 | 175 | public String getBillCity() { 176 | return billCity; 177 | } 178 | 179 | public void setBillCity(String billCity) { 180 | this.billCity = billCity; 181 | } 182 | 183 | public String getBillState() { 184 | return billState; 185 | } 186 | 187 | public void setBillState(String billState) { 188 | this.billState = billState; 189 | } 190 | 191 | public String getBillZip() { 192 | return billZip; 193 | } 194 | 195 | public void setBillZip(String billZip) { 196 | this.billZip = billZip; 197 | } 198 | 199 | public String getBillCountry() { 200 | return billCountry; 201 | } 202 | 203 | public void setBillCountry(String billCountry) { 204 | this.billCountry = billCountry; 205 | } 206 | 207 | public String getCourier() { 208 | return courier; 209 | } 210 | 211 | public void setCourier(String courier) { 212 | this.courier = courier; 213 | } 214 | 215 | public BigDecimal getTotalPrice() { 216 | return totalPrice; 217 | } 218 | 219 | public void setTotalPrice(BigDecimal totalPrice) { 220 | this.totalPrice = totalPrice; 221 | } 222 | 223 | public String getBillToFirstName() { 224 | return billToFirstName; 225 | } 226 | 227 | public void setBillToFirstName(String billToFirstName) { 228 | this.billToFirstName = billToFirstName; 229 | } 230 | 231 | public String getBillToLastName() { 232 | return billToLastName; 233 | } 234 | 235 | public void setBillToLastName(String billToLastName) { 236 | this.billToLastName = billToLastName; 237 | } 238 | 239 | public String getShipToFirstName() { 240 | return shipToFirstName; 241 | } 242 | 243 | public void setShipToFirstName(String shipFoFirstName) { 244 | this.shipToFirstName = shipFoFirstName; 245 | } 246 | 247 | public String getShipToLastName() { 248 | return shipToLastName; 249 | } 250 | 251 | public void setShipToLastName(String shipToLastName) { 252 | this.shipToLastName = shipToLastName; 253 | } 254 | 255 | public String getCreditCard() { 256 | return creditCard; 257 | } 258 | 259 | public void setCreditCard(String creditCard) { 260 | this.creditCard = creditCard; 261 | } 262 | 263 | public String getExpiryDate() { 264 | return expiryDate; 265 | } 266 | 267 | public void setExpiryDate(String expiryDate) { 268 | this.expiryDate = expiryDate; 269 | } 270 | 271 | public String getCardType() { 272 | return cardType; 273 | } 274 | 275 | public void setCardType(String cardType) { 276 | this.cardType = cardType; 277 | } 278 | 279 | public String getLocale() { 280 | return locale; 281 | } 282 | 283 | public void setLocale(String locale) { 284 | this.locale = locale; 285 | } 286 | 287 | public String getStatus() { 288 | return status; 289 | } 290 | 291 | public void setStatus(String status) { 292 | this.status = status; 293 | } 294 | 295 | public void setLineItems(List lineItems) { 296 | this.lineItems = lineItems; 297 | } 298 | 299 | public List getLineItems() { 300 | return lineItems; 301 | } 302 | 303 | public void initOrder(Account account, Cart cart) { 304 | 305 | username = account.getUsername(); 306 | orderDate = new Date(); 307 | 308 | shipToFirstName = account.getFirstName(); 309 | shipToLastName = account.getLastName(); 310 | shipAddress1 = account.getAddress1(); 311 | shipAddress2 = account.getAddress2(); 312 | shipCity = account.getCity(); 313 | shipState = account.getState(); 314 | shipZip = account.getZip(); 315 | shipCountry = account.getCountry(); 316 | 317 | billToFirstName = account.getFirstName(); 318 | billToLastName = account.getLastName(); 319 | billAddress1 = account.getAddress1(); 320 | billAddress2 = account.getAddress2(); 321 | billCity = account.getCity(); 322 | billState = account.getState(); 323 | billZip = account.getZip(); 324 | billCountry = account.getCountry(); 325 | 326 | totalPrice = cart.getSubTotal(); 327 | 328 | creditCard = "999 9999 9999 9999"; 329 | expiryDate = "12/03"; 330 | cardType = "Visa"; 331 | courier = "UPS"; 332 | locale = "CA"; 333 | status = "P"; 334 | 335 | Iterator i = cart.getAllCartItems(); 336 | while (i.hasNext()) { 337 | CartItem cartItem = (CartItem) i.next(); 338 | addLineItem(cartItem); 339 | } 340 | 341 | } 342 | 343 | public void addLineItem(CartItem cartItem) { 344 | LineItem lineItem = new LineItem(lineItems.size() + 1, cartItem); 345 | addLineItem(lineItem); 346 | } 347 | 348 | public void addLineItem(LineItem lineItem) { 349 | lineItems.add(lineItem); 350 | } 351 | 352 | } 353 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/Product.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.model; 18 | 19 | import java.io.Serializable; 20 | 21 | /** 22 | * @author Eduardo Macarron 23 | */ 24 | public class Product implements Serializable { 25 | 26 | private static final long serialVersionUID = -7492639752670189553L; 27 | 28 | private String productId; 29 | 30 | private String categoryId; 31 | 32 | private String name; 33 | 34 | private String description; 35 | 36 | public String getProductId() { 37 | return productId; 38 | } 39 | 40 | public void setProductId(String productId) { 41 | this.productId = productId.trim(); 42 | } 43 | 44 | public String getCategoryId() { 45 | return categoryId; 46 | } 47 | 48 | public void setCategoryId(String categoryId) { 49 | this.categoryId = categoryId; 50 | } 51 | 52 | public String getName() { 53 | return name; 54 | } 55 | 56 | public void setName(String name) { 57 | this.name = name; 58 | } 59 | 60 | public String getDescription() { 61 | return description; 62 | } 63 | 64 | public void setDescription(String description) { 65 | this.description = description; 66 | } 67 | 68 | public String toString() { 69 | return getName(); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/Sequence.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.model; 18 | 19 | import java.io.Serializable; 20 | 21 | /** 22 | * @author Eduardo Macarron 23 | */ 24 | public class Sequence implements Serializable { 25 | 26 | private static final long serialVersionUID = 8278780133180137281L; 27 | 28 | private String name; 29 | 30 | private int nextId; 31 | 32 | public Sequence() { 33 | } 34 | 35 | public Sequence(String name, int nextId) { 36 | this.name = name; 37 | this.nextId = nextId; 38 | } 39 | 40 | public String getName() { 41 | return name; 42 | } 43 | 44 | public void setName(String name) { 45 | this.name = name; 46 | } 47 | 48 | public int getNextId() { 49 | return nextId; 50 | } 51 | 52 | public void setNextId(int nextId) { 53 | this.nextId = nextId; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/model/UserDetails.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.domain.model; 2 | 3 | import java.util.Collection; 4 | import java.util.Collections; 5 | import java.util.List; 6 | import java.util.concurrent.CopyOnWriteArrayList; 7 | 8 | import org.springframework.security.core.GrantedAuthority; 9 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 10 | 11 | public class UserDetails 12 | implements 13 | org.springframework.security.core.userdetails.UserDetails { 14 | private static final long serialVersionUID = 1L; 15 | 16 | private final Account account; 17 | 18 | private final List myList; 19 | 20 | public UserDetails(Account account, List myList) { 21 | this.account = account; 22 | this.myList = new CopyOnWriteArrayList(myList); 23 | } 24 | 25 | @Override 26 | public Collection getAuthorities() { 27 | return Collections 28 | .singletonList(new SimpleGrantedAuthority("ROLE_USER")); 29 | } 30 | 31 | @Override 32 | public String getPassword() { 33 | return account.getPassword(); 34 | } 35 | 36 | @Override 37 | public String getUsername() { 38 | return account.getUsername(); 39 | } 40 | 41 | @Override 42 | public boolean isAccountNonExpired() { 43 | return true; 44 | } 45 | 46 | @Override 47 | public boolean isAccountNonLocked() { 48 | return true; 49 | } 50 | 51 | @Override 52 | public boolean isCredentialsNonExpired() { 53 | return true; 54 | } 55 | 56 | @Override 57 | public boolean isEnabled() { 58 | return true; 59 | } 60 | 61 | public Account getAccount() { 62 | return account; 63 | } 64 | 65 | public List getMyList() { 66 | return myList; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/repository/account/AccountRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.repository.account; 18 | 19 | import ik.am.jpetstore.domain.model.Account; 20 | 21 | /** 22 | * @author Eduardo Macarron 23 | */ 24 | public interface AccountRepository { 25 | 26 | Account getAccountByUsername(String username); 27 | 28 | Account getAccountByUsernameAndPassword(String username, String password); 29 | 30 | void insertAccount(Account account); 31 | 32 | void insertProfile(Account account); 33 | 34 | void insertSignon(Account account); 35 | 36 | void updateAccount(Account account); 37 | 38 | void updateProfile(Account account); 39 | 40 | void updateSignon(Account account); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/repository/category/CategoryRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.repository.category; 18 | 19 | import ik.am.jpetstore.domain.model.Category; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author Eduardo Macarron 25 | */ 26 | public interface CategoryRepository { 27 | 28 | List getCategoryList(); 29 | 30 | Category getCategory(String categoryId); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/repository/item/ItemRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.repository.item; 18 | 19 | import ik.am.jpetstore.domain.model.Item; 20 | 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | /** 25 | * @author Eduardo Macarron 26 | */ 27 | public interface ItemRepository { 28 | 29 | void updateInventoryQuantity(Map param); 30 | 31 | int getInventoryQuantity(String itemId); 32 | 33 | List getItemListByProduct(String productId); 34 | 35 | Item getItem(String itemId); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/repository/item/LineItemRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.repository.item; 18 | 19 | import ik.am.jpetstore.domain.model.LineItem; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author Eduardo Macarron 25 | */ 26 | public interface LineItemRepository { 27 | 28 | List getLineItemsByOrderId(int orderId); 29 | 30 | void insertLineItem(LineItem lineItem); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/repository/order/OrderRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.repository.order; 18 | 19 | import ik.am.jpetstore.domain.model.Order; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author Eduardo Macarron 25 | */ 26 | public interface OrderRepository { 27 | 28 | List getOrdersByUsername(String username); 29 | 30 | Order getOrder(int orderId); 31 | 32 | void insertOrder(Order order); 33 | 34 | void insertOrderStatus(Order order); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/repository/product/ProductRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.repository.product; 18 | 19 | import ik.am.jpetstore.domain.model.Product; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * @author Eduardo Macarron 25 | */ 26 | public interface ProductRepository { 27 | 28 | List getProductListByCategory(String categoryId); 29 | 30 | Product getProduct(String productId); 31 | 32 | List searchProductList(String keywords); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/repository/sequence/SequenceRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.repository.sequence; 18 | 19 | import ik.am.jpetstore.domain.model.Sequence; 20 | 21 | /** 22 | * @author Eduardo Macarron 23 | */ 24 | public interface SequenceRepository { 25 | 26 | Sequence getSequence(Sequence sequence); 27 | 28 | void updateSequence(Sequence sequence); 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/service/account/AccountService.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.domain.service.account; 2 | 3 | import ik.am.jpetstore.domain.model.Account; 4 | 5 | public interface AccountService { 6 | 7 | Account getAccount(String username); 8 | 9 | Account getAccount(String username, String password); 10 | 11 | void insertAccount(Account account); 12 | 13 | void updateAccount(Account account); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/service/account/AccountServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.service.account; 18 | 19 | import javax.inject.Inject; 20 | 21 | import ik.am.jpetstore.domain.model.Account; 22 | import ik.am.jpetstore.domain.repository.account.AccountRepository; 23 | 24 | import org.springframework.stereotype.Service; 25 | import org.springframework.transaction.annotation.Transactional; 26 | 27 | /** 28 | * @author Eduardo Macarron 29 | */ 30 | @Service 31 | public class AccountServiceImpl implements AccountService { 32 | 33 | @Inject 34 | private AccountRepository accountRepository; 35 | 36 | /* 37 | * (non-Javadoc) 38 | * @see ik.am.jpetstore.domain.service.account.AccountService#getAccount(java.lang.String) 39 | */ 40 | @Override 41 | public Account getAccount(String username) { 42 | return accountRepository.getAccountByUsername(username); 43 | } 44 | 45 | /* 46 | * (non-Javadoc) 47 | * @see ik.am.jpetstore.domain.service.account.AccountService#getAccount(java.lang.String, java.lang.String) 48 | */ 49 | @Override 50 | public Account getAccount(String username, String password) { 51 | return accountRepository.getAccountByUsernameAndPassword(username, 52 | password); 53 | } 54 | 55 | /* 56 | * (non-Javadoc) 57 | * @see ik.am.jpetstore.domain.service.account.AccountService#insertAccount(ik.am.jpetstore.domain.model.Account) 58 | */ 59 | @Override 60 | @Transactional 61 | public void insertAccount(Account account) { 62 | accountRepository.insertAccount(account); 63 | accountRepository.insertProfile(account); 64 | accountRepository.insertSignon(account); 65 | } 66 | 67 | /* 68 | * (non-Javadoc) 69 | * @see ik.am.jpetstore.domain.service.account.AccountService#updateAccount(ik.am.jpetstore.domain.model.Account) 70 | */ 71 | @Override 72 | @Transactional 73 | public void updateAccount(Account account) { 74 | accountRepository.updateAccount(account); 75 | accountRepository.updateProfile(account); 76 | 77 | if (account.getPassword() != null && account.getPassword().length() > 0) { 78 | accountRepository.updateSignon(account); 79 | } 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/service/catalog/CatalogService.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.domain.service.catalog; 2 | 3 | import ik.am.jpetstore.domain.model.Category; 4 | import ik.am.jpetstore.domain.model.Item; 5 | import ik.am.jpetstore.domain.model.Product; 6 | 7 | import java.util.List; 8 | 9 | public interface CatalogService { 10 | 11 | List getCategoryList(); 12 | 13 | Category getCategory(String categoryId); 14 | 15 | Product getProduct(String productId); 16 | 17 | List getProductListByCategory(String categoryId); 18 | 19 | // TODO enable using more than one keyword 20 | List searchProductList(String keyword); 21 | 22 | List getItemListByProduct(String productId); 23 | 24 | Item getItem(String itemId); 25 | 26 | boolean isItemInStock(String itemId); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/service/catalog/CatalogServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.service.catalog; 18 | 19 | import ik.am.jpetstore.domain.model.Category; 20 | import ik.am.jpetstore.domain.model.Item; 21 | import ik.am.jpetstore.domain.model.Product; 22 | import ik.am.jpetstore.domain.repository.category.CategoryRepository; 23 | import ik.am.jpetstore.domain.repository.item.ItemRepository; 24 | import ik.am.jpetstore.domain.repository.product.ProductRepository; 25 | 26 | import java.util.List; 27 | 28 | import javax.inject.Inject; 29 | import org.springframework.stereotype.Service; 30 | 31 | /** 32 | * @author Eduardo Macarron 33 | */ 34 | @Service 35 | public class CatalogServiceImpl implements CatalogService { 36 | 37 | @Inject 38 | private CategoryRepository categoryRepository; 39 | 40 | @Inject 41 | private ItemRepository itemRepository; 42 | 43 | @Inject 44 | private ProductRepository productRepository; 45 | 46 | /* 47 | * (non-Javadoc) 48 | * @see ik.am.jpetstore.domain.service.catalog.CategoryService#getCategoryList() 49 | */ 50 | @Override 51 | public List getCategoryList() { 52 | return categoryRepository.getCategoryList(); 53 | } 54 | 55 | /* 56 | * (non-Javadoc) 57 | * @see ik.am.jpetstore.domain.service.catalog.CategoryService#getCategory(java.lang.String) 58 | */ 59 | @Override 60 | public Category getCategory(String categoryId) { 61 | return categoryRepository.getCategory(categoryId); 62 | } 63 | 64 | /* 65 | * (non-Javadoc) 66 | * @see ik.am.jpetstore.domain.service.catalog.CategoryService#getProduct(java.lang.String) 67 | */ 68 | @Override 69 | public Product getProduct(String productId) { 70 | return productRepository.getProduct(productId); 71 | } 72 | 73 | /* 74 | * (non-Javadoc) 75 | * @see ik.am.jpetstore.domain.service.catalog.CategoryService#getProductListByCategory(java.lang.String) 76 | */ 77 | @Override 78 | public List getProductListByCategory(String categoryId) { 79 | return productRepository.getProductListByCategory(categoryId); 80 | } 81 | 82 | // TODO enable using more than one keyword 83 | /* 84 | * (non-Javadoc) 85 | * @see ik.am.jpetstore.domain.service.catalog.CategoryService#searchProductList(java.lang.String) 86 | */ 87 | @Override 88 | public List searchProductList(String keyword) { 89 | return productRepository.searchProductList("%" + keyword.toLowerCase() 90 | + "%"); 91 | } 92 | 93 | /* 94 | * (non-Javadoc) 95 | * @see ik.am.jpetstore.domain.service.catalog.CategoryService#getItemListByProduct(java.lang.String) 96 | */ 97 | @Override 98 | public List getItemListByProduct(String productId) { 99 | return itemRepository.getItemListByProduct(productId); 100 | } 101 | 102 | /* 103 | * (non-Javadoc) 104 | * @see ik.am.jpetstore.domain.service.catalog.CategoryService#getItem(java.lang.String) 105 | */ 106 | @Override 107 | public Item getItem(String itemId) { 108 | return itemRepository.getItem(itemId); 109 | } 110 | 111 | /* 112 | * (non-Javadoc) 113 | * @see ik.am.jpetstore.domain.service.catalog.CategoryService#isItemInStock(java.lang.String) 114 | */ 115 | @Override 116 | public boolean isItemInStock(String itemId) { 117 | return itemRepository.getInventoryQuantity(itemId) > 0; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/service/order/OrderService.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.domain.service.order; 2 | 3 | import ik.am.jpetstore.domain.model.Order; 4 | 5 | import java.util.List; 6 | 7 | public interface OrderService { 8 | 9 | void insertOrder(Order order); 10 | 11 | Order getOrder(int orderId); 12 | 13 | List getOrdersByUsername(String username); 14 | 15 | int getNextId(String name); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/service/order/OrderServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010-2013 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package ik.am.jpetstore.domain.service.order; 18 | 19 | import ik.am.jpetstore.domain.model.Item; 20 | import ik.am.jpetstore.domain.model.LineItem; 21 | import ik.am.jpetstore.domain.model.Order; 22 | import ik.am.jpetstore.domain.model.Sequence; 23 | import ik.am.jpetstore.domain.repository.item.ItemRepository; 24 | import ik.am.jpetstore.domain.repository.item.LineItemRepository; 25 | import ik.am.jpetstore.domain.repository.order.OrderRepository; 26 | import ik.am.jpetstore.domain.repository.sequence.SequenceRepository; 27 | 28 | import java.util.HashMap; 29 | import java.util.List; 30 | import java.util.Map; 31 | 32 | import javax.inject.Inject; 33 | 34 | import org.springframework.stereotype.Service; 35 | import org.springframework.transaction.annotation.Transactional; 36 | 37 | /** 38 | * @author Eduardo Macarron 39 | */ 40 | @Service 41 | public class OrderServiceImpl implements OrderService { 42 | 43 | @Inject 44 | private ItemRepository itemRepository; 45 | 46 | @Inject 47 | private OrderRepository orderRepository; 48 | 49 | @Inject 50 | private SequenceRepository sequenceRepository; 51 | 52 | @Inject 53 | private LineItemRepository lineItemRepository; 54 | 55 | /* 56 | * (non-Javadoc) 57 | * @see ik.am.jpetstore.domain.service.order.OrderService#insertOrder(ik.am.jpetstore.domain.model.Order) 58 | */ 59 | @Override 60 | @Transactional 61 | public void insertOrder(Order order) { 62 | order.setOrderId(getNextId("ordernum")); 63 | for (int i = 0; i < order.getLineItems().size(); i++) { 64 | LineItem lineItem = (LineItem) order.getLineItems().get(i); 65 | String itemId = lineItem.getItemId(); 66 | Integer increment = new Integer(lineItem.getQuantity()); 67 | Map param = new HashMap(2); 68 | param.put("itemId", itemId); 69 | param.put("increment", increment); 70 | itemRepository.updateInventoryQuantity(param); 71 | } 72 | 73 | orderRepository.insertOrder(order); 74 | orderRepository.insertOrderStatus(order); 75 | for (int i = 0; i < order.getLineItems().size(); i++) { 76 | LineItem lineItem = (LineItem) order.getLineItems().get(i); 77 | lineItem.setOrderId(order.getOrderId()); 78 | lineItemRepository.insertLineItem(lineItem); 79 | } 80 | } 81 | 82 | /* 83 | * (non-Javadoc) 84 | * @see ik.am.jpetstore.domain.service.order.OrderService#getOrder(int) 85 | */ 86 | @Override 87 | @Transactional 88 | public Order getOrder(int orderId) { 89 | Order order = orderRepository.getOrder(orderId); 90 | order.setLineItems(lineItemRepository.getLineItemsByOrderId(orderId)); 91 | 92 | for (int i = 0; i < order.getLineItems().size(); i++) { 93 | LineItem lineItem = (LineItem) order.getLineItems().get(i); 94 | Item item = itemRepository.getItem(lineItem.getItemId()); 95 | item.setQuantity(itemRepository.getInventoryQuantity(lineItem 96 | .getItemId())); 97 | lineItem.setItem(item); 98 | } 99 | 100 | return order; 101 | } 102 | 103 | /* 104 | * (non-Javadoc) 105 | * @see ik.am.jpetstore.domain.service.order.OrderService#getOrdersByUsername(java.lang.String) 106 | */ 107 | @Override 108 | public List getOrdersByUsername(String username) { 109 | return orderRepository.getOrdersByUsername(username); 110 | } 111 | 112 | /* 113 | * (non-Javadoc) 114 | * @see ik.am.jpetstore.domain.service.order.OrderService#getNextId(java.lang.String) 115 | */ 116 | @Override 117 | public int getNextId(String name) { 118 | Sequence sequence = new Sequence(name, -1); 119 | sequence = (Sequence) sequenceRepository.getSequence(sequence); 120 | if (sequence == null) { 121 | throw new RuntimeException("Error: A null sequence was returned from the database (could not get next " 122 | + name + " sequence)."); 123 | } 124 | Sequence parameterObject = new Sequence(name, sequence.getNextId() + 1); 125 | sequenceRepository.updateSequence(parameterObject); 126 | return sequence.getNextId(); 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/ik/am/jpetstore/domain/service/user/UserDetailsServiceImpl.java: -------------------------------------------------------------------------------- 1 | package ik.am.jpetstore.domain.service.user; 2 | 3 | import java.util.List; 4 | 5 | import ik.am.jpetstore.domain.model.Account; 6 | import ik.am.jpetstore.domain.model.Product; 7 | import ik.am.jpetstore.domain.service.account.AccountService; 8 | import ik.am.jpetstore.domain.service.catalog.CatalogService; 9 | 10 | import javax.inject.Inject; 11 | 12 | import org.springframework.security.core.userdetails.UserDetails; 13 | import org.springframework.security.core.userdetails.UserDetailsService; 14 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 15 | import org.springframework.stereotype.Service; 16 | 17 | @Service("userDetailsService") 18 | public class UserDetailsServiceImpl implements UserDetailsService { 19 | @Inject 20 | protected AccountService accountService; 21 | 22 | @Inject 23 | protected CatalogService catalogService; 24 | 25 | @Override 26 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 27 | Account account = accountService.getAccount(username); 28 | if (account == null) { 29 | throw new UsernameNotFoundException(username + " is not found."); 30 | } 31 | List myList = catalogService.getProductListByCategory(account 32 | .getFavouriteCategoryId()); 33 | return new ik.am.jpetstore.domain.model.UserDetails(account, myList); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/dozer/account-mapping.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | ik.am.jpetstore.app.account.AccountForm 6 | ik.am.jpetstore.domain.model.Account 7 | usernameusername 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/css/jpetstore.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0ex 10ex 0ex 10ex; 3 | padding: 0ex; 4 | font-family: helvetica, tahoma, arial, verdana, sans-serif; 5 | font-size: 2ex; 6 | color: #333; 7 | background-color: #444; 8 | } 9 | 10 | pre { 11 | font-family: "Courier New", Courier, mono; 12 | 13 | font-style: normal; 14 | background-color: #FFFFFF; 15 | white-space: pre 16 | } 17 | 18 | h1 { 19 | margin: 1ex 0ex 1ex 0ex; 20 | padding: 0ex; 21 | 22 | line-height: 3ex; 23 | font-weight: 900; 24 | color: #666; 25 | } 26 | 27 | h2 { 28 | margin: 2ex 0ex 1ex 0ex; 29 | padding: 0ex; 30 | 31 | line-height: 2ex; 32 | font-weight: 700; 33 | color: #444; 34 | } 35 | 36 | h3 { 37 | margin: 1ex 0ex 1ex 0ex; 38 | padding: 0ex; 39 | 40 | line-height: 1.6ex; 41 | font-weight: 700; 42 | color: #222; 43 | } 44 | 45 | p { 46 | font-family: helvetica, tahoma, arial, verdana, sans-serif; 47 | 48 | margin: 0ex 0ex 0ex 0ex; 49 | padding: 2ex; 50 | } 51 | 52 | img { 53 | border: 0; 54 | } 55 | 56 | li { 57 | font-family: helvetica, tahoma, arial, verdana, sans-serif; 58 | 59 | margin: 0ex 0ex 0ex 0ex; 60 | padding: 0ex; 61 | } 62 | 63 | table { 64 | border-width: 0; 65 | empty-cells: show; 66 | } 67 | 68 | td, th { 69 | empty-cells: show; 70 | padding: .3ex .3ex; 71 | vertical-align: top; 72 | text-align: left; 73 | border-width: 0; 74 | border-spacing: 0; 75 | background-color: #ececec 76 | } 77 | 78 | th { 79 | font-weight: bold; 80 | background-color: #e2e2e2; 81 | } 82 | 83 | a, a:visited, a:link { 84 | color: #039; 85 | 86 | text-decoration: none; 87 | font-family: helvetica, tahoma, arial, verdana, sans-serif; 88 | } 89 | 90 | a:hover { 91 | color: #69f; 92 | } 93 | 94 | a.Button, a.Button:link, a.Button:visited { 95 | padding: .3ex; 96 | color: #fff; 97 | background-color: #005e21; 98 | text-decoration: none; 99 | font-family: helvetica, tahoma, arial, verdana, sans-serif; 100 | font-size: 1.5ex; 101 | } 102 | 103 | a.Button:hover { 104 | color: #000; 105 | background-color: #54c07a; 106 | } 107 | 108 | #Logo { 109 | width: 33%; 110 | height: 9ex; 111 | margin: 0ex 0ex 0ex 0ex; 112 | padding: 0ex 0ex 0ex 0ex; 113 | border-width: 0ex 0ex .3ex 0px; 114 | border-style: solid; 115 | border-color: #ccc; 116 | float: left; 117 | background-color: #000; 118 | color: #fff; 119 | line-height: 9ex; 120 | voice-family: "\"}\""; 121 | voice-family: inherit; 122 | height: 9ex; 123 | } 124 | 125 | body>#Logo { 126 | height: 9ex; 127 | } 128 | 129 | #Menu { 130 | width: 33%; 131 | height: 9ex; 132 | margin: 0ex 0ex 0ex 0ex; 133 | padding: 0ex 0ex 0ex 0ex; 134 | border-width: 0ex 0ex .3ex 0px; 135 | border-style: solid; 136 | border-color: #ccc; 137 | float: left; 138 | background-color: #000; 139 | color: #eaac00; 140 | text-decoration: none; 141 | font-family: helvetica, tahoma, arial, verdana, sans-serif; 142 | text-align: center; 143 | line-height: 9ex; 144 | voice-family: "\"}\""; 145 | voice-family: inherit; 146 | height: 9ex; 147 | } 148 | 149 | #Menu, #Menu a, #Menu a:link, #Menu a:visited, #Menu a:hover { 150 | color: #eaac00; 151 | text-decoration: none; 152 | font-family: helvetica, tahoma, arial, verdana, sans-serif; 153 | } 154 | 155 | body>#Menu { 156 | height: 9ex; 157 | } 158 | 159 | { 160 | } 161 | 162 | #Search { 163 | width: 33%; 164 | height: 9ex; 165 | margin: 0ex 0ex 0ex 0ex; 166 | padding: 0ex 0ex 0ex 0ex; 167 | border-width: 0ex 0ex .3ex 0px; 168 | border-style: solid; 169 | border-color: #ccc; 170 | float: left; 171 | text-align: center; 172 | background-color: #000; 173 | color: #eaac00; 174 | line-height: 9ex; 175 | voice-family: "\"}\""; 176 | voice-family: inherit; 177 | height: 9ex; 178 | } 179 | 180 | body>#Search { 181 | height: 9ex; 182 | } 183 | 184 | #Search input { 185 | border-width: .1ex .1ex .1ex .1ex; 186 | border-style: solid; 187 | border-color: #aaa; 188 | background-color: #666; 189 | color: #eaac00; 190 | } 191 | 192 | #QuickLinks { 193 | text-align: center; 194 | background-color: #FFF; 195 | width: 99%; 196 | } 197 | 198 | #PoweredBy { 199 | width: 30%; 200 | height: 9ex; 201 | margin: 0ex 0ex 0ex 0ex; 202 | padding: 0ex 0ex 0ex 0ex; 203 | border-width: .3ex 0ex .3ex 0px; 204 | border-style: solid; 205 | border-color: #ccc; 206 | float: left; 207 | background-color: #000; 208 | color: #fff; 209 | line-height: 9ex; 210 | voice-family: "\"}\""; 211 | voice-family: inherit; 212 | height: 9ex; 213 | } 214 | 215 | body>#PoweredBy { 216 | height: 9ex; 217 | } 218 | 219 | #Banner { 220 | width: 69%; 221 | height: 9ex; 222 | margin: 0ex 0ex 0ex 0ex; 223 | padding: 0ex 0ex 0ex 0ex; 224 | border-width: .3ex 0ex .3ex 0px; 225 | border-style: solid; 226 | border-color: #ccc; 227 | float: left; 228 | background-color: #000; 229 | color: #fff; 230 | line-height: 9ex; 231 | voice-family: "\"}\""; 232 | voice-family: inherit; 233 | height: 9ex; 234 | } 235 | 236 | body>#Banner { 237 | height: 9ex; 238 | } 239 | 240 | #Content { 241 | margin: 0; 242 | padding: 0ex 0ex 0ex 0ex; 243 | width: 99%; 244 | color: #333; 245 | background-color: #FFF; 246 | border-width: 0; 247 | } 248 | 249 | #Separator { 250 | clear:both; 251 | margin: 0; 252 | height:0; 253 | } 254 | 255 | #Main { 256 | margin: 0; 257 | padding: 1ex; 258 | color: #333; 259 | background-color: #FFF; 260 | border-width: 1ex 0ex 2ex 0px; 261 | border-style: solid; 262 | border-color: #fff; 263 | } 264 | 265 | #Sidebar { 266 | float: left; 267 | background:inherit; 268 | width: 30%; 269 | } 270 | 271 | #MainImage { 272 | float: left; 273 | background:inherit; 274 | text-align:center; 275 | width: 50%; 276 | } 277 | 278 | #Catalog { 279 | padding: 1ex; 280 | background:inherit; 281 | text-align:center; 282 | } 283 | 284 | #Catalog input[type="submit"]{ 285 | padding: .3ex; 286 | color: #fff; 287 | background-color: #005e21; 288 | text-decoration: none; 289 | font-family: helvetica, tahoma, arial, verdana, sans-serif; 290 | font-size: 1.5ex; 291 | border-width:0; 292 | } 293 | #Catalog input[type="submit"]:hover { 294 | color: #000; 295 | background-color: #54c07a; 296 | cursor:pointer; 297 | } 298 | 299 | #Catalog table{ 300 | margin-left:auto; 301 | margin-right:auto; 302 | } 303 | 304 | #BackLink{ 305 | padding: 1ex; 306 | float: right; 307 | border-width: .1ex 0ex .1ex 0px; 308 | border-style: solid; 309 | border-color: #000; 310 | } 311 | 312 | #Cart{ 313 | width: 69.99%; 314 | float: left; 315 | background-color:#fff; 316 | } 317 | 318 | #MyList{ 319 | width: 30%; 320 | float: left; 321 | background-color:#ccc; 322 | text-align:left; 323 | } 324 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/banner_birds.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/banner_birds.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/banner_cats.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/banner_cats.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/banner_dogs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/banner_dogs.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/banner_fish.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/banner_fish.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/banner_reptiles.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/banner_reptiles.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/bird1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/bird1.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/bird2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/bird2.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/birds_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/birds_icon.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/cart.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/cart.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/cat1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/cat1.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/cat2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/cat2.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/cats_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/cats_icon.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/dog1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/dog1.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/dog2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/dog2.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/dog3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/dog3.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/dog4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/dog4.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/dog5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/dog5.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/dog6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/dog6.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/dogs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/dogs.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/dogs_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/dogs_icon.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/fish.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/fish.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/fish1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/fish1.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/fish2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/fish2.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/fish3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/fish3.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/fish4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/fish4.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/fish_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/fish_icon.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/lizard1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/lizard1.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/logo-topbar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/logo-topbar.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/poweredby.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/poweredby.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/reptiles_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/reptiles_icon.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/separator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/separator.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/sm_birds.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/sm_birds.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/sm_cats.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/sm_cats.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/sm_dogs.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/sm_dogs.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/sm_fish.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/sm_fish.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/sm_reptiles.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/sm_reptiles.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/snake1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/snake1.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/images/splash.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/making/spring-jpetstore/f1d604956793e1cf532d34c81d979e7403946641/src/main/resources/META-INF/resources/images/splash.gif -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/application.properties: -------------------------------------------------------------------------------- 1 | ## properties for settings used in application layer 2 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/applicationContext.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 14 | 15 | 16 | i18n/application-messages 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/spring-jpetstore-domain.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/spring-jpetstore-env.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/spring-jpetstore-infra.properties: -------------------------------------------------------------------------------- 1 | ## properties for environment dependent settings used in infrastructure layer 2 | 3 | # for development environment on local PC 4 | database=H2 5 | database.url=jdbc:h2:mem:spring-petstore;MODE=PostgreSQL 6 | database.username=sa 7 | database.password= 8 | database.driverClassName=org.h2.Driver 9 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/spring-jpetstore-infra.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/spring-mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/spring/spring-security.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 14 | 16 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/resources/database/H2-dataload.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2010-2013 the original author or authors. 3 | -- 4 | -- Licensed under the Apache License, Version 2.0 (the "License"); 5 | -- you may not use this file except in compliance with the License. 6 | -- You may obtain a copy of the License at 7 | -- 8 | -- http://www.apache.org/licenses/LICENSE-2.0 9 | -- 10 | -- Unless required by applicable law or agreed to in writing, software 11 | -- distributed under the License is distributed on an "AS IS" BASIS, 12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | -- See the License for the specific language governing permissions and 14 | -- limitations under the License. 15 | -- 16 | 17 | INSERT INTO sequence VALUES('ordernum', 1000); 18 | 19 | INSERT INTO signon VALUES('j2ee','j2ee'); 20 | INSERT INTO signon VALUES('ACID','ACID'); 21 | 22 | INSERT INTO account VALUES('j2ee','yourname@yourdomain.com','ABC', 'XYX', 'OK', '901 San Antonio Road', 'MS UCUP02-206', 'Palo Alto', 'CA', '94303', 'USA', '555-555-5555'); 23 | INSERT INTO account VALUES('ACID','acid@yourdomain.com','ABC', 'XYX', 'OK', '901 San Antonio Road', 'MS UCUP02-206', 'Palo Alto', 'CA', '94303', 'USA', '555-555-5555'); 24 | 25 | INSERT INTO profile VALUES('j2ee','english','DOGS',1,1); 26 | INSERT INTO profile VALUES('ACID','english','CATS',1,1); 27 | 28 | INSERT INTO bannerdata VALUES ('FISH',''); 29 | INSERT INTO bannerdata VALUES ('CATS',''); 30 | INSERT INTO bannerdata VALUES ('DOGS',''); 31 | INSERT INTO bannerdata VALUES ('REPTILES',''); 32 | INSERT INTO bannerdata VALUES ('BIRDS',''); 33 | 34 | INSERT INTO category VALUES ('FISH','Fish',' Fish'); 35 | INSERT INTO category VALUES ('DOGS','Dogs',' Dogs'); 36 | INSERT INTO category VALUES ('REPTILES','Reptiles',' Reptiles'); 37 | INSERT INTO category VALUES ('CATS','Cats',' Cats'); 38 | INSERT INTO category VALUES ('BIRDS','Birds',' Birds'); 39 | 40 | INSERT INTO product VALUES ('FI-SW-01','FISH','Angelfish','Salt Water fish from Australia'); 41 | INSERT INTO product VALUES ('FI-SW-02','FISH','Tiger Shark','Salt Water fish from Australia'); 42 | INSERT INTO product VALUES ('FI-FW-01','FISH', 'Koi','Fresh Water fish from Japan'); 43 | INSERT INTO product VALUES ('FI-FW-02','FISH', 'Goldfish','Fresh Water fish from China'); 44 | INSERT INTO product VALUES ('K9-BD-01','DOGS','Bulldog','Friendly dog from England'); 45 | INSERT INTO product VALUES ('K9-PO-02','DOGS','Poodle','Cute dog from France'); 46 | INSERT INTO product VALUES ('K9-DL-01','DOGS', 'Dalmation','Great dog for a Fire Station'); 47 | INSERT INTO product VALUES ('K9-RT-01','DOGS', 'Golden Retriever','Great family dog'); 48 | INSERT INTO product VALUES ('K9-RT-02','DOGS', 'Labrador Retriever','Great hunting dog'); 49 | INSERT INTO product VALUES ('K9-CW-01','DOGS', 'Chihuahua','Great companion dog'); 50 | INSERT INTO product VALUES ('RP-SN-01','REPTILES','Rattlesnake','Doubles as a watch dog'); 51 | INSERT INTO product VALUES ('RP-LI-02','REPTILES','Iguana','Friendly green friend'); 52 | INSERT INTO product VALUES ('FL-DSH-01','CATS','Manx','Great for reducing mouse populations'); 53 | INSERT INTO product VALUES ('FL-DLH-02','CATS','Persian','Friendly house cat, doubles as a princess'); 54 | INSERT INTO product VALUES ('AV-CB-01','BIRDS','Amazon Parrot','Great companion for up to 75 years'); 55 | INSERT INTO product VALUES ('AV-SB-02','BIRDS','Finch','Great stress reliever'); 56 | 57 | INSERT INTO supplier VALUES (1,'XYZ Pets','AC','600 Avon Way','','Los Angeles','CA','94024','212-947-0797'); 58 | INSERT INTO supplier VALUES (2,'ABC Pets','AC','700 Abalone Way','','San Francisco ','CA','94024','415-947-0797'); 59 | 60 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-1','FI-SW-01',16.50,10.00,1,'P','Large'); 61 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-2','FI-SW-01',16.50,10.00,1,'P','Small'); 62 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-3','FI-SW-02',18.50,12.00,1,'P','Toothless'); 63 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-4','FI-FW-01',18.50,12.00,1,'P','Spotted'); 64 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-5','FI-FW-01',18.50,12.00,1,'P','Spotless'); 65 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-6','K9-BD-01',18.50,12.00,1,'P','Male Adult'); 66 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-7','K9-BD-01',18.50,12.00,1,'P','Female Puppy'); 67 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-8','K9-PO-02',18.50,12.00,1,'P','Male Puppy'); 68 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-9','K9-DL-01',18.50,12.00,1,'P','Spotless Male Puppy'); 69 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-10','K9-DL-01',18.50,12.00,1,'P','Spotted Adult Female'); 70 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-11','RP-SN-01',18.50,12.00,1,'P','Venomless'); 71 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-12','RP-SN-01',18.50,12.00,1,'P','Rattleless'); 72 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-13','RP-LI-02',18.50,12.00,1,'P','Green Adult'); 73 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-14','FL-DSH-01',58.50,12.00,1,'P','Tailless'); 74 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-15','FL-DSH-01',23.50,12.00,1,'P','With tail'); 75 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-16','FL-DLH-02',93.50,12.00,1,'P','Adult Female'); 76 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-17','FL-DLH-02',93.50,12.00,1,'P','Adult Male'); 77 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-18','AV-CB-01',193.50,92.00,1,'P','Adult Male'); 78 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-19','AV-SB-02',15.50, 2.00,1,'P','Adult Male'); 79 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-20','FI-FW-02',5.50, 2.00,1,'P','Adult Male'); 80 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-21','FI-FW-02',5.29, 1.00,1,'P','Adult Female'); 81 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-22','K9-RT-02',135.50, 100.00,1,'P','Adult Male'); 82 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-23','K9-RT-02',145.49, 100.00,1,'P','Adult Female'); 83 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-24','K9-RT-02',255.50, 92.00,1,'P','Adult Male'); 84 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-25','K9-RT-02',325.29, 90.00,1,'P','Adult Female'); 85 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-26','K9-CW-01',125.50, 92.00,1,'P','Adult Male'); 86 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-27','K9-CW-01',155.29, 90.00,1,'P','Adult Female'); 87 | INSERT INTO item (itemid, productid, listprice, unitcost, supplier, status, attr1) VALUES('EST-28','K9-RT-01',155.29, 90.00,1,'P','Adult Female'); 88 | 89 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-1',10000); 90 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-2',10000); 91 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-3',10000); 92 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-4',10000); 93 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-5',10000); 94 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-6',10000); 95 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-7',10000); 96 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-8',10000); 97 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-9',10000); 98 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-10',10000); 99 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-11',10000); 100 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-12',10000); 101 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-13',10000); 102 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-14',10000); 103 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-15',10000); 104 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-16',10000); 105 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-17',10000); 106 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-18',10000); 107 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-19',10000); 108 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-20',10000); 109 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-21',10000); 110 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-22',10000); 111 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-23',10000); 112 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-24',10000); 113 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-25',10000); 114 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-26',10000); 115 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-27',10000); 116 | INSERT INTO inventory (itemid, qty ) VALUES ('EST-28',10000); 117 | 118 | commit 119 | -------------------------------------------------------------------------------- /src/main/resources/database/H2-schema.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2010-2013 the original author or authors. 3 | -- 4 | -- Licensed under the Apache License, Version 2.0 (the "License"); 5 | -- you may not use this file except in compliance with the License. 6 | -- You may obtain a copy of the License at 7 | -- 8 | -- http://www.apache.org/licenses/LICENSE-2.0 9 | -- 10 | -- Unless required by applicable law or agreed to in writing, software 11 | -- distributed under the License is distributed on an "AS IS" BASIS, 12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | -- See the License for the specific language governing permissions and 14 | -- limitations under the License. 15 | -- 16 | 17 | create table supplier ( 18 | suppid int not null, 19 | name varchar(80) null, 20 | status varchar(2) not null, 21 | addr1 varchar(80) null, 22 | addr2 varchar(80) null, 23 | city varchar(80) null, 24 | state varchar(80) null, 25 | zip varchar(5) null, 26 | phone varchar(80) null, 27 | constraint pk_supplier primary key (suppid) 28 | ); 29 | 30 | create table signon ( 31 | username varchar(25) not null, 32 | password varchar(25) not null, 33 | constraint pk_signon primary key (username) 34 | ); 35 | 36 | create table account ( 37 | userid varchar(80) not null, 38 | email varchar(80) not null, 39 | firstname varchar(80) not null, 40 | lastname varchar(80) not null, 41 | status varchar(2) null, 42 | addr1 varchar(80) not null, 43 | addr2 varchar(40) null, 44 | city varchar(80) not null, 45 | state varchar(80) not null, 46 | zip varchar(20) not null, 47 | country varchar(20) not null, 48 | phone varchar(80) not null, 49 | constraint pk_account primary key (userid) 50 | ); 51 | 52 | create table profile ( 53 | userid varchar(80) not null, 54 | langpref varchar(80) not null, 55 | favcategory varchar(30), 56 | mylistopt int, 57 | banneropt int, 58 | constraint pk_profile primary key (userid) 59 | ); 60 | 61 | create table bannerdata ( 62 | favcategory varchar(80) not null, 63 | bannername varchar(255) null, 64 | constraint pk_bannerdata primary key (favcategory) 65 | ); 66 | 67 | create table orders ( 68 | orderid int not null, 69 | userid varchar(80) not null, 70 | orderdate date not null, 71 | shipaddr1 varchar(80) not null, 72 | shipaddr2 varchar(80) null, 73 | shipcity varchar(80) not null, 74 | shipstate varchar(80) not null, 75 | shipzip varchar(20) not null, 76 | shipcountry varchar(20) not null, 77 | billaddr1 varchar(80) not null, 78 | billaddr2 varchar(80) null, 79 | billcity varchar(80) not null, 80 | billstate varchar(80) not null, 81 | billzip varchar(20) not null, 82 | billcountry varchar(20) not null, 83 | courier varchar(80) not null, 84 | totalprice decimal(10,2) not null, 85 | billtofirstname varchar(80) not null, 86 | billtolastname varchar(80) not null, 87 | shiptofirstname varchar(80) not null, 88 | shiptolastname varchar(80) not null, 89 | creditcard varchar(80) not null, 90 | exprdate varchar(7) not null, 91 | cardtype varchar(80) not null, 92 | locale varchar(80) not null, 93 | constraint pk_orders primary key (orderid) 94 | ); 95 | 96 | create table orderstatus ( 97 | orderid int not null, 98 | linenum int not null, 99 | timestamp date not null, 100 | status varchar(2) not null, 101 | constraint pk_orderstatus primary key (orderid, linenum) 102 | ); 103 | 104 | create table lineitem ( 105 | orderid int not null, 106 | linenum int not null, 107 | itemid varchar(10) not null, 108 | quantity int not null, 109 | unitprice decimal(10,2) not null, 110 | constraint pk_lineitem primary key (orderid, linenum) 111 | ); 112 | 113 | create table category ( 114 | catid varchar(10) not null, 115 | name varchar(80) null, 116 | descn varchar(255) null, 117 | constraint pk_category primary key (catid) 118 | ); 119 | 120 | create table product ( 121 | productid varchar(10) not null, 122 | category varchar(10) not null, 123 | name varchar(80) null, 124 | descn varchar(255) null, 125 | constraint pk_product primary key (productid), 126 | constraint fk_product_1 foreign key (category) 127 | references category (catid) 128 | ); 129 | 130 | create index productCat on product (category); 131 | create index productName on product (name); 132 | 133 | create table item ( 134 | itemid varchar(10) not null, 135 | productid varchar(10) not null, 136 | listprice decimal(10,2) null, 137 | unitcost decimal(10,2) null, 138 | supplier int null, 139 | status varchar(2) null, 140 | attr1 varchar(80) null, 141 | attr2 varchar(80) null, 142 | attr3 varchar(80) null, 143 | attr4 varchar(80) null, 144 | attr5 varchar(80) null, 145 | constraint pk_item primary key (itemid), 146 | constraint fk_item_1 foreign key (productid) 147 | references product (productid), 148 | constraint fk_item_2 foreign key (supplier) 149 | references supplier (suppid) 150 | ); 151 | 152 | create index itemProd on item (productid); 153 | 154 | create table inventory ( 155 | itemid varchar(10) not null, 156 | qty int not null, 157 | constraint pk_inventory primary key (itemid) 158 | ); 159 | 160 | CREATE TABLE sequence 161 | ( 162 | name varchar(30) not null, 163 | nextid int not null, 164 | constraint pk_sequence primary key (name) 165 | ); 166 | -------------------------------------------------------------------------------- /src/main/resources/i18n/application-messages.properties: -------------------------------------------------------------------------------- 1 | ## screen messages and validation messages 2 | -------------------------------------------------------------------------------- /src/main/resources/ik/am/jpetstore/domain/repository/account/AccountRepository.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 50 | 51 | 78 | 79 | 80 | UPDATE ACCOUNT SET 81 | EMAIL = #{email}, 82 | FIRSTNAME = #{firstName}, 83 | LASTNAME = #{lastName}, 84 | STATUS = #{status}, 85 | ADDR1 = #{address1}, 86 | ADDR2 = #{address2,jdbcType=VARCHAR}, 87 | CITY = #{city}, 88 | STATE = #{state}, 89 | ZIP = #{zip}, 90 | COUNTRY = #{country}, 91 | PHONE = #{phone} 92 | WHERE USERID = #{username} 93 | 94 | 95 | 96 | INSERT INTO ACCOUNT 97 | (EMAIL, FIRSTNAME, LASTNAME, STATUS, ADDR1, ADDR2, CITY, STATE, ZIP, COUNTRY, PHONE, USERID) 98 | VALUES 99 | (#{email}, #{firstName}, #{lastName}, #{status}, #{address1}, #{address2,jdbcType=VARCHAR}, #{city}, #{state}, #{zip}, #{country}, #{phone}, #{username}) 100 | 101 | 102 | 103 | UPDATE PROFILE SET 104 | LANGPREF = #{languagePreference}, 105 | FAVCATEGORY = #{favouriteCategoryId}, 106 | MYLISTOPT = #{listOption}, 107 | BANNEROPT = #{bannerOption} 108 | WHERE USERID = #{username} 109 | 110 | 111 | 112 | INSERT INTO PROFILE (LANGPREF, FAVCATEGORY, MYLISTOPT, BANNEROPT, USERID) 113 | VALUES (#{languagePreference}, #{favouriteCategoryId}, #{listOption}, #{bannerOption}, #{username}) 114 | 115 | 116 | 117 | UPDATE SIGNON SET PASSWORD = #{password} 118 | WHERE USERNAME = #{username} 119 | 120 | 121 | 122 | INSERT INTO SIGNON (PASSWORD,USERNAME) 123 | VALUES (#{password}, #{username}) 124 | 125 | 126 | -------------------------------------------------------------------------------- /src/main/resources/ik/am/jpetstore/domain/repository/category/CategoryRepository.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 32 | 33 | 40 | 41 | -------------------------------------------------------------------------------- /src/main/resources/ik/am/jpetstore/domain/repository/item/ItemRepository.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 44 | 45 | 67 | 68 | 73 | 74 | 75 | UPDATE INVENTORY SET 76 | QTY = QTY - #{increment} 77 | WHERE ITEMID = #{itemId} 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/main/resources/ik/am/jpetstore/domain/repository/item/LineItemRepository.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 34 | 35 | 36 | INSERT INTO LINEITEM (ORDERID, LINENUM, ITEMID, QUANTITY, UNITPRICE) 37 | VALUES (#{orderId}, #{lineNumber}, #{itemId}, #{quantity}, #{unitPrice}) 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/resources/ik/am/jpetstore/domain/repository/order/OrderRepository.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 56 | 57 | 90 | 91 | 92 | INSERT INTO ORDERS (ORDERID, USERID, ORDERDATE, SHIPADDR1, SHIPADDR2, SHIPCITY, SHIPSTATE, 93 | SHIPZIP, SHIPCOUNTRY, BILLADDR1, BILLADDR2, BILLCITY, BILLSTATE, BILLZIP, BILLCOUNTRY, 94 | COURIER, TOTALPRICE, BILLTOFIRSTNAME, BILLTOLASTNAME, SHIPTOFIRSTNAME, SHIPTOLASTNAME, 95 | CREDITCARD, EXPRDATE, CARDTYPE, LOCALE) 96 | VALUES(#{orderId}, #{username}, #{orderDate}, #{shipAddress1}, #{shipAddress2,jdbcType=VARCHAR}, #{shipCity}, 97 | #{shipState}, #{shipZip}, #{shipCountry}, #{billAddress1}, #{billAddress2,jdbcType=VARCHAR}, #{billCity}, 98 | #{billState}, #{billZip}, #{billCountry}, #{courier}, #{totalPrice}, #{billToFirstName}, #{billToLastName}, 99 | #{shipToFirstName}, #{shipToLastName}, #{creditCard}, #{expiryDate}, #{cardType}, #{locale}) 100 | 101 | 102 | 103 | INSERT INTO ORDERSTATUS (ORDERID, LINENUM, TIMESTAMP, STATUS) 104 | VALUES (#{orderId,jdbcType=NUMERIC}, #{orderId,jdbcType=NUMERIC}, #{orderDate,jdbcType=TIMESTAMP}, #{status,jdbcType=VARCHAR}) 105 | 106 | 107 | -------------------------------------------------------------------------------- /src/main/resources/ik/am/jpetstore/domain/repository/product/ProductRepository.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 33 | 34 | 43 | 44 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/ik/am/jpetstore/domain/repository/sequence/SequenceRepository.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | UPDATE SEQUENCE 32 | SET NEXTID = #{nextId} 33 | WHERE NAME = #{name} 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/log4jdbc.properties: -------------------------------------------------------------------------------- 1 | log4jdbc.dump.sql.maxlinelength=0 2 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | UTF-8 12 | log/spring-jpetstore.log 13 | 15 | log/spring-petstore-%d{yyyyMMdd}.log 16 | 17 | 2 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/account/EditAccountForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 |
4 | 6 | 7 |

User Information

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
User ID:${f:h(accountForm.username)}
New password:
Repeat password:
23 | <%@ include file="IncludeAccountFields.jsp"%> 24 | 25 | 27 | 28 |
29 | My 30 | Orders 31 |
32 | 33 | <%@ include file="../common/IncludeBottom.jsp"%> 34 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/account/IncludeAccountFields.jsp: -------------------------------------------------------------------------------- 1 |

Account Information

2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 51 | 52 |
First name:
Last name:
Email:
Phone:
Address 1:
Address 2:
City:
State:
Zip:
Country:
53 | 54 |

Profile Information

55 | 56 | 57 | 58 | 59 | 62 | 63 | 64 | 65 | 68 | 69 | 70 | 71 | 73 | 74 | 75 | 76 | 78 | 79 |
Language Preference:
Favourite Category:
Enable MyList
Enable MyBanner
80 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/account/NewAccountForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 |
4 | 6 | 7 |

User Information

8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 24 | 25 |
User ID:
New password:
Repeat password:
26 | 27 | <%@ include file="IncludeAccountFields.jsp"%> 28 | 29 | 31 |
32 |
33 | 34 | <%@ include file="../common/IncludeBottom.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/account/SignonForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 |
4 | 5 |
6 |

Login error!

7 | ${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message} 8 |
9 |
10 |
12 | 13 |

Please enter your username and password.

14 |

15 | Username: 16 |
Password: 18 |

19 | 20 |
21 | Need a user name and password? Register 23 | Now! 24 |
25 | 26 | <%@ include file="../common/IncludeBottom.jsp"%> 27 | 28 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/cart/Cart.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 | 7 | 8 |
9 | 10 |
11 | 12 |

Shopping Cart

13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 38 | 39 | 45 | 46 | 50 | 53 | 56 | 59 | 60 | 61 | 62 | 65 | 66 | 67 |
Item IDProduct IDDescriptionIn Stock?QuantityList PriceTotal Cost 
Your cart is empty.
37 | ${f:h(cartItem.item.itemId)}${f:h(cartItem.item.product.productId)}${f:h(cartItem.item.attribute1)} 40 | ${f:h(cartItem.item.attribute2)} 41 | ${f:h(cartItem.item.attribute3)} 42 | ${f:h(cartItem.item.attribute4)} 43 | ${f:h(cartItem.item.attribute5)} 44 | ${f:h(cartItem.item.product.name)}${f:h(cartItem.inStock)}Remove 58 |
Sub Total: 64 |  
68 |
69 | 70 | Proceed 72 | to Checkout 73 | 74 |
75 | 76 | 77 | 78 |
79 | 81 | <%@ include file="IncludeMyList.jsp"%> 82 | 83 |
84 |
85 | 86 |
 
87 |
88 | 89 | <%@ include file="../common/IncludeBottom.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/cart/Checkout.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 | 7 | 8 |
9 | 10 | 11 | 55 | 56 | 57 |
12 |

Checkout Summary

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 31 | 32 | 38 | 39 | 40 | 43 | 46 | 47 | 48 | 49 | 52 | 53 |
Item IDProduct IDDescriptionIn Stock?QuantityList PriceTotal Cost
30 | ${f:h(cartItem.item.itemId)}${f:h(cartItem.item.product.productId)}${f:h(cartItem.item.attribute1)} 33 | ${f:h(cartItem.item.attribute2)} 34 | ${f:h(cartItem.item.attribute3)} 35 | ${f:h(cartItem.item.attribute4)} 36 | ${f:h(cartItem.item.attribute5)} 37 | ${f:h(cartItem.item.product.name)}${f:h(cartItem.inStock)}${f:h(cartItem.quantity)}
Sub Total:
54 |
 
58 | 59 |
60 | 61 | <%@ include file="../common/IncludeBottom.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/cart/IncludeMyList.jsp: -------------------------------------------------------------------------------- 1 | 2 |

3 | Pet Favorites
Shop for more of your favorite pets here. 4 |

5 | 13 |
14 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/catalog/Category.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 | 7 | 8 |
9 | 10 |

${f:h(category.name)}

11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 |
Product IDName
${f:h(product.productId)}${f:h(product.name)}
25 | 26 |
27 | 28 | <%@ include file="../common/IncludeBottom.jsp"%> 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/catalog/Item.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 43 | 44 |
${product.description}<%-- XSS Vulnerable! --%>
${f:h(item.itemId)}
20 | ${f:h(item.attribute1)} ${f:h(item.attribute2)} 21 | ${f:h(item.attribute3)} ${f:h(item.attribute4)} 22 | ${f:h(item.attribute5)} ${f:h(product.name)}
${f:h(product.name)}
29 | Back ordered. 30 | 31 | ${f:h(item.quantity)} in stock. 32 |
42 | Add to Cart
45 | 46 |
47 | 48 | <%@ include file="../common/IncludeBottom.jsp"%> 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/catalog/Main.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 |
4 |
5 | 6 | 7 | Welcome ${sessionScope.accountBean.account.firstName}! 8 | 9 | 10 |
11 |
12 | 13 |
14 | 34 | 35 |
36 |
37 | 38 | Birds 41 | Fish 44 | Dogs 47 | Reptiles 50 | Cats 53 | Birds 56 | 57 | 60 |
61 |
62 | 63 |
 
64 |
65 | 66 | <%@ include file="../common/IncludeBottom.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/catalog/Product.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 | 8 | 9 |
10 | 11 |

${actionBean.product.name}

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 | 30 | 33 | 36 | 37 | 38 |
Item IDProduct IDDescriptionList Price 
25 | ${f:h(item.itemId)} ${f:h(item.product.productId)}${f:h(item.attribute1)}${f:h(item.attribute2)} 28 | ${f:h(item.attribute3)} ${f:h(item.attribute4)} 29 | ${f:h(item.attribute5)} ${f:h(product.name)} 35 | Add to Cart
39 | 40 |
41 | 42 | <%@ include file="../common/IncludeBottom.jsp"%> 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/catalog/SearchProducts.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 25 | 26 | 27 | 28 |
 Product IDName
${product.description}<%-- XSS Vulnerable! --%> 23 | ${f:h(product.productId)} 24 | ${f:h(product.name)}
29 | 30 |
31 | 32 | <%@ include file="../common/IncludeBottom.jsp"%> 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/common/Error.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 | 4 | 5 | 6 | 7 | <%@ include file="../common/IncludeBottom.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/common/IncludeBottom.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/common/IncludeTop.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | JPetStore Demo 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 98 | 99 |
100 | 101 |

${f:h(message)}

102 |
-------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/common/include.jsp: -------------------------------------------------------------------------------- 1 | <%-- <%@ page contentType="text/html; charset=UTF-8"%> --%> 2 | <%-- <%@ page pageEncoding="UTF-8"%> --%> 3 | <%-- <%@ page session="false"%> --%> 4 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 5 | <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> 6 | <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> 7 | <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> 8 | <%@ taglib uri="http://www.springframework.org/security/tags" prefix="sec"%> 9 | <%@ taglib uri="http://amateras.sf.jp/functions" prefix="f"%> 10 | 11 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/notFoundError.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="./common/IncludeTop.jsp"%> 2 | 3 |

Your request is not found...

4 |

5 | Go to TOP 6 |

7 | <%@ include file="./common/IncludeBottom.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/order/ConfirmOrder.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 | 7 | 8 |
9 | Please confirm the information below and then press continue... 10 | 12 | 13 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 37 | 38 | 39 | 40 | 42 | 43 | 44 | 45 | 47 | 48 | 49 | 50 | 52 | 53 | 54 | 55 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 70 | 71 | 72 | 73 | 76 | 77 | 78 | 79 | 81 | 82 | 83 | 84 | 86 | 87 | 88 | 89 | 91 | 92 | 93 | 94 | 96 | 97 | 98 | 99 | 101 | 102 | 103 | 104 | 106 | 107 | 108 |
Order 15 |
Billing Address
First name:${f:h(orderForm.billToFirstName)}
Last name:${f:h(orderForm.billToLastName)}
Address 1:${f:h(orderForm.billAddress1)}
Address 2:${f:h(orderForm.billAddress2)}
City:${f:h(orderForm.billCity)}
State:${f:h(orderForm.billState)}
Zip:${f:h(orderForm.billZip)}
Country:${f:h(orderForm.billCountry)}
Shipping Address
First name:${f:h(orderForm.shipToFirstName)}
Last name:${f:h(orderForm.shipToLastName)} 75 |
Address 1:${f:h(orderForm.shipAddress1)}
Address 2:${f:h(orderForm.shipAddress2)}
City:${f:h(orderForm.shipCity)}
State:${f:h(orderForm.shipState)}
Zip:${f:h(orderForm.shipZip)}
Country:${f:h(orderForm.shipCountry)}
109 | 110 | 111 | 112 | 113 | 114 |
115 |
116 | 117 | <%@ include file="../common/IncludeBottom.jsp"%> 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/order/ListOrders.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 |

My Orders

4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 18 | 20 | 21 | 22 |
Order IDDateTotal Price
${f:h(order.orderId)}
23 | 24 | <%@ include file="../common/IncludeBottom.jsp"%> 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/order/NewOrderForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 |
4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 67 | 68 | 69 |
Payment Details
Card Type: 15 |
Card Number: * Use a fake 20 | number!
Expiry Date (MM/YYYY):
Billing Address
First name:
Last name:
Address 1:
Address 2:
City:
State:
Zip:
Country:
Ship to 66 | different address...
70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
81 |
82 | 83 | <%@ include file="../common/IncludeBottom.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/order/ShippingForm.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 |
4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
Shipping Address
First name:
Last name:
Address 1:
Address 2:
City:
State:
Zip:
Country:
45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
58 |
59 | 60 | <%@ include file="../common/IncludeBottom.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/order/ViewOrder.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="../common/IncludeTop.jsp"%> 2 | 3 | 7 | 8 |
9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 152 | 153 | 154 |
Order #${order.orderId} 13 | 15 |
Payment Details
Card Type:${f:h(order.cardType)}
Card Number:${f:h(order.creditCard)}*Fakenumber!
Expiry Date (MM/YYYY):${f:h(order.expiryDate)}
Billing Address
First name:${f:h(order.billToFirstName)}
Last name:${f:h(order.billToLastName)}
Address 1:${f:h(order.billAddress1)}
Address 2:${f:h(order.billAddress2)}
City:${f:h(order.billCity)}
State:${f:h(order.billState)}
Zip:${f:h(order.billZip)}
Country:${f:h(order.billCountry)}
Shipping Address
First name:${f:h(order.shipToFirstName)}
Last name:${f:h(order.shipToLastName)}
Address 1:${f:h(order.shipAddress1)}
Address 2:${f:h(order.shipAddress2)}
City:${f:h(order.shipCity)}
State:${f:h(order.shipState)}
Zip:${f:h(order.shipZip)}
Country:${f:h(order.shipCountry)}
Courier:${f:h(order.courier)}
Status: ${f:h(order.status)}
111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 124 | 135 | 136 | 137 | 140 | 143 | 144 | 145 | 146 | 149 | 150 |
Item IDDescriptionQuantityPriceTotal Cost
123 | ${f:h(lineItem.item.itemId)} 126 | ${f:h(lineItem.item.attribute1)} 127 | ${f:h(lineItem.item.attribute2)} 128 | ${f:h(lineItem.item.attribute3)} 129 | ${f:h(lineItem.item.attribute4)} 130 | ${f:h(lineItem.item.attribute5)} 131 | ${f:h(lineItem.item.product.name)} 132 | 133 | {description unavailable} 134 | ${f:h(lineItem.quantity)}
Total:
151 |
155 | 156 |
157 | 158 | <%@ include file="../common/IncludeBottom.jsp"%> 159 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/systemError.jsp: -------------------------------------------------------------------------------- 1 | <%@ include file="./common/IncludeTop.jsp"%> 2 | 3 |

System Error...

4 |

5 | Go to TOP 6 |

7 | <%@ include file="./common/IncludeBottom.jsp"%> -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ik.am.jpetstore.app.common.session.HttpSessionEventLoggingListener 10 | 11 | 12 | 13 | org.springframework.web.context.request.RequestContextListener 14 | 15 | 16 | 17 | org.springframework.web.context.ContextLoaderListener 18 | 19 | 20 | 21 | contextConfigLocation 22 | 23 | classpath*:META-INF/spring/applicationContext.xml 24 | classpath*:META-INF/spring/spring-security.xml 25 | 26 | 27 | 28 | 29 | CharacterEncodingFilter 30 | org.springframework.web.filter.CharacterEncodingFilter 31 | 32 | encoding 33 | UTF-8 34 | 35 | 36 | forceEncoding 37 | true 38 | 39 | 40 | 41 | CharacterEncodingFilter 42 | /* 43 | 44 | 45 | HttpMethodFilter 46 | org.springframework.web.filter.HiddenHttpMethodFilter 47 | 48 | 49 | HttpMethodFilter 50 | /* 51 | 52 | 53 | 54 | springSecurityFilterChain 55 | org.springframework.web.filter.DelegatingFilterProxy 56 | 57 | 58 | springSecurityFilterChain 59 | /* 60 | 61 | 62 | 63 | appServlet 64 | org.springframework.web.servlet.DispatcherServlet 65 | 66 | contextConfigLocation 67 | classpath*:META-INF/spring/spring-mvc.xml 68 | 69 | 1 70 | 71 | 72 | appServlet 73 | / 74 | 75 | 76 | 77 | 78 | *.jsp 79 | false 80 | UTF-8 81 | false 82 | /WEB-INF/views/common/include.jsp 83 | 84 | 85 | 86 | 404 87 | /WEB-INF/views/notFoundError.jsp 88 | 89 | 90 | 500 91 | /WEB-INF/views/systemError.jsp 92 | 93 | 94 | -------------------------------------------------------------------------------- /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | --------------------------------------------------------------------------------