Permalink
Browse files

Bookstore first attempt.

  • Loading branch information...
1 parent 42441ac commit d65f182b0ee39fdec341eba1811f0b9dfde8de3d @mdeinum committed Jan 11, 2012
Showing with 1,863 additions and 689 deletions.
  1. +4 −0 bookstore-shared/.gitignore
  2. +4 −20 ...d/src/main/java/com/apress/prospringmvc/bookstore}/config/InfrastructureContextConfiguration.java
  3. +85 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/domain/Address.java
  4. +79 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/domain/Book.java
  5. +29 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/domain/Category.java
  6. +87 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/domain/Customer.java
  7. +138 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/domain/Order.java
  8. +58 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/domain/OrderDetail.java
  9. +16 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/repository/BookRepository.java
  10. +12 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/repository/CategoryRepository.java
  11. +13 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/repository/CustomerRepository.java
  12. +47 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/repository/JpaBookRepository.java
  13. +31 −0 ...tore-shared/src/main/java/com/apress/prospringmvc/bookstore/repository/JpaCategoryRepository.java
  14. +45 −0 ...tore-shared/src/main/java/com/apress/prospringmvc/bookstore/repository/JpaCustomerRepository.java
  15. +38 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/repository/JpaOrderRepository.java
  16. +14 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/repository/OrderRepository.java
  17. +4 −0 ...store-shared/src/main/java/com/apress/prospringmvc/bookstore/service/AuthenticationException.java
  18. +14 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/service/BookService.java
  19. +40 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/service/BookServiceImpl.java
  20. +11 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/service/CategoryService.java
  21. +24 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/service/CategoryServiceImpl.java
  22. +17 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/service/CustomerService.java
  23. +34 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/bookstore/service/CustomerServiceImpl.java
  24. +17 −0 bookstore-shared/src/main/java/com/apress/prospringmvc/context/RequestHandledEventListener.java
  25. +1 −1 {chapter4-bookstore → bookstore-shared}/src/main/resources/logback.xml
  26. 0 bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/css/styles.css
  27. BIN ...store-web-resources/src/main/resources/META-INF/{web-resources → backup}/fonts/MyriadPro-Bold.otf
  28. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/fonts/Romy.ttf
  29. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/fonts/tahoma.ttf
  30. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/fonts/tahomabd.ttf
  31. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/images/arrow.gif
  32. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/images/b_header.jpg
  33. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/images/b_main.jpg
  34. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/images/bullet_m.gif
  35. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/images/h_pizza.gif
  36. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/images/h_welcome.gif
  37. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/images/img_pizza-10.jpg
  38. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/images/img_pizza.jpg
  39. BIN bookstore-web-resources/src/main/resources/META-INF/{web-resources → backup}/images/logo.jpg
  40. +557 −0 bookstore-web-resources/src/main/resources/META-INF/web-resources/css/style.css
  41. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/Thumbs.db
  42. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/about.gif
  43. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/banner.gif
  44. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/big_pic.jpg
  45. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/blank.gif
  46. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/border.gif
  47. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/box_bottom.gif
  48. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/box_center.gif
  49. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/box_top.gif
  50. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/bullet1.gif
  51. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/bullet2.gif
  52. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/bullet3.gif
  53. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/bullet4.gif
  54. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/bullet5.gif
  55. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/bullet6.gif
  56. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/cart.gif
  57. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/cart_thumb.gif
  58. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/center_bg.gif
  59. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/close.gif
  60. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/closelabel.gif
  61. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/color1.gif
  62. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/color2.gif
  63. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/color3.gif
  64. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/contact_bt.gif
  65. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/csscreme.gif
  66. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/de.gif
  67. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/footer_bg.gif
  68. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/footer_logo.gif
  69. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/fr.gif
  70. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/gb.gif
  71. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/header.jpg
  72. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/left_menu_bullet.gif
  73. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/loading.gif
  74. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/logo.gif
  75. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/new_icon.gif
  76. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/new_prod_box.gif
  77. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/next.gif
  78. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/nextlabel.gif
  79. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/order_now.gif
  80. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/prev.gif
  81. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/prevlabel.gif
  82. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/prod1.gif
  83. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/prod2.gif
  84. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/promo_icon.gif
  85. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/register_bt.gif
  86. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/special_icon.gif
  87. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/thumb1.gif
  88. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/thumb2.gif
  89. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/thumb3.gif
  90. BIN bookstore-web-resources/src/main/resources/META-INF/web-resources/images/zoom.gif
  91. +5 −9 build.gradle
  92. +0 −43 chapter4-bookstore/src/main/java/com/apress/prospringmvc/aop/PerformanceMonitoringAspect.java
  93. +4 −4 .../PizzasRUsWebApplicationInitializer.java → bookstore/web/BookstoreWebApplicationInitializer.java}
  94. +21 −2 ...in/java/com/apress/prospringmvc/{pizzarus → bookstore}/web/config/WebMvcContextConfiguration.java
  95. +20 −0 ...ter4-bookstore/src/main/java/com/apress/prospringmvc/bookstore/web/controller/BookController.java
  96. +35 −0 ...store/src/main/java/com/apress/prospringmvc/bookstore/web/controller/CustomerLoginController.java
  97. +53 −0 ...rc/main/java/com/apress/prospringmvc/bookstore/web/controller/CustomerRegistrationController.java
  98. +34 −0 ...rc/main/java/com/apress/prospringmvc/bookstore/web/interceptor/CommonDataHandlerIntereceptor.java
  99. +0 −48 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/domain/AbstractEntity.java
  100. +0 −124 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/domain/Order.java
  101. +0 −53 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/domain/OrderLine.java
  102. +0 −45 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/domain/Pizza.java
  103. +0 −15 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/repository/OrderRepository.java
  104. +0 −27 ...ter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/repository/OrderRepositoryImpl.java
  105. +0 −18 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/repository/PizzaRepository.java
  106. +0 −30 ...ter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/repository/PizzaRepositoryImpl.java
  107. +0 −15 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/service/OrderService.java
  108. +0 −28 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/service/OrderServiceImpl.java
  109. +0 −17 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/service/PizzaService.java
  110. +0 −30 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/service/PizzaServiceImpl.java
  111. +0 −46 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/web/OrderController.java
  112. +0 −22 chapter4-bookstore/src/main/java/com/apress/prospringmvc/pizzarus/web/PizzasController.java
  113. +0 −53 chapter4-bookstore/src/main/resources/META-INF/css/pizzas.css
  114. BIN chapter4-bookstore/src/main/resources/META-INF/images/slice_of_pizza.jpg
  115. +0 −3 chapter4-bookstore/src/main/resources/META-INF/sql/data.sql
  116. +39 −0 chapter4-bookstore/src/main/webapp/WEB-INF/layout/backup/default.jsp
  117. +97 −25 chapter4-bookstore/src/main/webapp/WEB-INF/layout/default.jsp
  118. +1 −9 chapter4-bookstore/src/main/webapp/WEB-INF/view/index.jsp
  119. +1 −1 gradlew
  120. +1 −1 gradlew.bat
  121. BIN template/PizzaRUs/fonts/MyriadPro-Bold.otf
  122. BIN template/PizzaRUs/fonts/Romy.ttf
  123. BIN template/PizzaRUs/fonts/tahoma.ttf
  124. BIN template/PizzaRUs/fonts/tahomabd.ttf
  125. +68 −0 template/PizzaRUs/html/css/styles.css
  126. BIN template/PizzaRUs/html/images/arrow.gif
  127. BIN template/PizzaRUs/html/images/b_header.jpg
  128. BIN template/PizzaRUs/html/images/b_main.jpg
  129. BIN template/PizzaRUs/html/images/btn_1.gif
  130. BIN template/PizzaRUs/html/images/btn_1_over.gif
  131. BIN template/PizzaRUs/html/images/btn_2.gif
  132. BIN template/PizzaRUs/html/images/btn_2_over.gif
  133. BIN template/PizzaRUs/html/images/btn_3.gif
  134. BIN template/PizzaRUs/html/images/btn_3_over.gif
  135. BIN template/PizzaRUs/html/images/btn_4.gif
  136. BIN template/PizzaRUs/html/images/btn_4_over.gif
  137. BIN template/PizzaRUs/html/images/btn_5.gif
  138. BIN template/PizzaRUs/html/images/btn_5_over.gif
  139. BIN template/PizzaRUs/html/images/bullet_m.gif
  140. BIN template/PizzaRUs/html/images/h_pizza.gif
  141. BIN template/PizzaRUs/html/images/h_welcome.gif
  142. BIN template/PizzaRUs/html/images/img_pizza-10.jpg
  143. BIN template/PizzaRUs/html/images/img_pizza.jpg
  144. BIN template/PizzaRUs/html/images/logo.jpg
  145. +65 −0 template/PizzaRUs/html/index.html
  146. BIN template/PizzaRUs/psd/index.psd
@@ -1 +1,5 @@
/build/
+/*.project
+/*.classpath
+/.settings/
+/bin/
@@ -1,4 +1,4 @@
-package com.apress.prospringmvc.pizzarus.config;
+package com.apress.prospringmvc.bookstore.config;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@@ -8,13 +8,9 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Profile;
-import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
-import org.springframework.jdbc.datasource.init.DataSourceInitializer;
-import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
@@ -29,8 +25,8 @@
*/
@Configuration
@EnableTransactionManagement
-@ComponentScan(basePackages = { "com.apress.prospringmvc.pizzarus.service",
- "com.apress.prospringmvc.pizzarus.repository" })
+@ComponentScan(basePackages = { "com.apress.prospringmvc.bookstore.service",
+ "com.apress.prospringmvc.bookstore.repository" })
public class InfrastructureContextConfiguration {
@Autowired
@@ -44,7 +40,7 @@
LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
localContainerEntityManagerFactoryBean.setDataSource(this.dataSource);
// localContainerEntityManagerFactoryBean.setPersistenceUnitName("pizzas-r-us");
- localContainerEntityManagerFactoryBean.setPackagesToScan("com.apress.prospringmvc.pizzarus.domain");
+ localContainerEntityManagerFactoryBean.setPackagesToScan("com.apress.prospringmvc.bookstore.domain");
localContainerEntityManagerFactoryBean.setJpaVendorAdapter(jpaVendorAdapter());
return localContainerEntityManagerFactoryBean;
}
@@ -65,18 +61,6 @@ public PlatformTransactionManager transactionManager() {
return transactionManager;
}
- @Bean
- @DependsOn(value = "entityManagerFactory")
- public DataSourceInitializer dataSourceInitializer() {
- DataSourceInitializer initializer = new DataSourceInitializer();
- initializer.setDataSource(this.dataSource);
- initializer.setEnabled(true);
- ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
- populator.addScript(new ClassPathResource("/META-INF/sql/data.sql"));
- initializer.setDatabasePopulator(populator);
- return initializer;
- }
-
@Configuration
@Profile("test")
public static class TestDataSourceConfiguration {
@@ -0,0 +1,85 @@
+package com.apress.prospringmvc.bookstore.domain;
+
+import java.io.Serializable;
+
+import javax.persistence.Embeddable;
+
+/**
+ * A component which resembles the address of a {@link Customer}
+ *
+ * @author Koen Serneels
+ */
+
+@Embeddable
+public class Address implements Serializable {
+
+ private String street;
+ private String houseNumber;
+ private String boxNumber;
+ private String city;
+ private String postalCode;
+ private String country;
+
+ public Address() {
+ super();
+ }
+
+ public Address(Address source) {
+ super();
+ this.street = source.street;
+ this.houseNumber = source.houseNumber;
+ this.boxNumber = source.boxNumber;
+ this.city = source.city;
+ this.postalCode = source.postalCode;
+ this.country = source.country;
+ }
+
+ public String getStreet() {
+ return this.street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getHouseNumber() {
+ return this.houseNumber;
+ }
+
+ public void setHouseNumber(String houseNumber) {
+ this.houseNumber = houseNumber;
+ }
+
+ public String getBoxNumber() {
+ return this.boxNumber;
+
+ }
+
+ public void setBoxNumber(String boxNumber) {
+ this.boxNumber = boxNumber;
+ }
+
+ public String getCity() {
+ return this.city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getPostalCode() {
+ return this.postalCode;
+ }
+
+ public void setPostalCode(String postalCode) {
+ this.postalCode = postalCode;
+ }
+
+ public String getCountry() {
+ return this.country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+}
@@ -0,0 +1,79 @@
+package com.apress.prospringmvc.bookstore.domain;
+
+import java.math.BigDecimal;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+@Entity
+public class Book {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ private String title;
+ private String description;
+ private BigDecimal price;
+ private Integer year;
+ private String author;
+
+ @ManyToOne(optional = false)
+ private Category category;
+
+ public Long getId() {
+ return this.id;
+ }
+
+ public String getTitle() {
+ return this.title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public BigDecimal getPrice() {
+ return this.price;
+ }
+
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+
+ public Integer getYear() {
+ return this.year;
+ }
+
+ public void setYear(Integer year) {
+ this.year = year;
+ }
+
+ public String getAuthor() {
+ return this.author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public Category getCategory() {
+ return this.category;
+ }
+
+ public void setCategory(Category category) {
+ this.category = category;
+ }
+
+}
@@ -0,0 +1,29 @@
+package com.apress.prospringmvc.bookstore.domain;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Category {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ private String name;
+
+ public Long getId() {
+ return this.id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+}
@@ -0,0 +1,87 @@
+package com.apress.prospringmvc.bookstore.domain;
+
+import java.io.Serializable;
+
+import javax.persistence.Embedded;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ * A customer resembles an authenticated user of our system. A customer is able to submit orders. A customer is
+ * identified by his or her username. When authenticating the user supplies its username and password. Besides
+ * identification information we also store basic legal information such as address, firstname, lastname and email
+ * address.
+ *
+ * @author Koen Serneels
+ */
+
+@Entity
+public class Customer implements Serializable {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ private String firstName;
+ private String lastName;
+
+ @Embedded
+ private Address address;
+ private String emailAddress;
+ private String username;
+ private String password;
+
+ public Long getId() {
+ return this.id;
+ }
+
+ public String getFirstName() {
+ return this.firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return this.lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getEmailAddress() {
+ return this.emailAddress;
+ }
+
+ public void setEmailAddress(String emailAddress) {
+ this.emailAddress = emailAddress;
+ }
+
+ public String getUsername() {
+ return this.username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return this.password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public Address getAddress() {
+ return this.address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+}
Oops, something went wrong.

0 comments on commit d65f182

Please sign in to comment.