From 7c34c4309af8f14761d4386e39671c08b6941c1b Mon Sep 17 00:00:00 2001 From: laxmanp26 Date: Sat, 12 Aug 2017 15:48:09 +0530 Subject: [PATCH] my first --- .editorconfig | 12 + .gitignore | 36 ++ pom.xml | 357 ++++++++++++++++++ .../java/com/mycompany/sos/model/Address.java | 181 +++++++++ .../com/mycompany/sos/model/Customer.java | 227 +++++++++++ .../sos/model/CustomerPaymentDetail.java | 148 ++++++++ .../java/com/mycompany/sos/model/Item.java | 106 ++++++ .../java/com/mycompany/sos/model/Order.java | 91 +++++ .../sos/repository/CustomerRepository.java | 23 ++ .../sos/repository/ItemRepository.java | 16 + .../sos/repository/OrderRepository.java | 16 + .../sos/service/CustomerService.java | 54 +++ .../sos/service/CustomerServiceImpl.java | 93 +++++ .../mycompany/sos/service/ItemService.java | 29 ++ .../sos/service/ItemServiceImpl.java | 42 +++ .../mycompany/sos/service/OrderService.java | 29 ++ .../sos/service/OrderServiceImpl.java | 43 +++ .../mycompany/sos/web/CustomerController.java | 144 +++++++ .../sos/web/CustomerDetailsController.java | 37 ++ .../com/mycompany/sos/web/ItemController.java | 90 +++++ .../mycompany/sos/web/LoginController.java | 45 +++ .../mycompany/sos/web/OrderController.java | 126 +++++++ .../sos/web/validator/OrderFormValidator.java | 46 +++ src/main/resources/error_en.properties | 83 ++++ src/main/resources/log4j.properties | 24 ++ .../resources/scripts/mysql/db-create.sql | 11 + .../scripts/mysql/db-drop-tables.sql | 6 + src/main/resources/scripts/mysql/insert.sql | 65 ++++ .../webapp/WEB-INF/application-context.xml | 11 + .../webapp/WEB-INF/application-datasource.xml | 68 ++++ .../webapp/WEB-INF/application-security.xml | 54 +++ src/main/webapp/WEB-INF/application-web.xml | 49 +++ src/main/webapp/WEB-INF/web.xml | 82 ++++ src/main/webapp/common/common.jsp | 12 + src/main/webapp/common/footer.jsp | 3 + src/main/webapp/common/header.jsp | 25 ++ src/main/webapp/common/index.jsp | 2 + src/main/webapp/common/meta.jsp | 29 ++ src/main/webapp/common/nav.jsp | 10 + src/main/webapp/common/taglibs.jsp | 3 + src/main/webapp/css/login.css | 60 +++ src/main/webapp/css/logout.css | 7 + src/main/webapp/css/sos.css | 83 ++++ src/main/webapp/customers/customerDetails.jsp | 82 ++++ .../customers/customers-createCustomer.jsp | 94 +++++ src/main/webapp/customers/customers.jsp | 53 +++ src/main/webapp/items/items-create.jsp | 34 ++ src/main/webapp/items/items.jsp | 24 ++ src/main/webapp/login/login.jsp | 44 +++ src/main/webapp/orders/orders-createOrder.jsp | 44 +++ src/main/webapp/orders/orders.jsp | 23 ++ 51 files changed, 3076 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 pom.xml create mode 100644 src/main/java/com/mycompany/sos/model/Address.java create mode 100644 src/main/java/com/mycompany/sos/model/Customer.java create mode 100644 src/main/java/com/mycompany/sos/model/CustomerPaymentDetail.java create mode 100644 src/main/java/com/mycompany/sos/model/Item.java create mode 100644 src/main/java/com/mycompany/sos/model/Order.java create mode 100644 src/main/java/com/mycompany/sos/repository/CustomerRepository.java create mode 100644 src/main/java/com/mycompany/sos/repository/ItemRepository.java create mode 100644 src/main/java/com/mycompany/sos/repository/OrderRepository.java create mode 100644 src/main/java/com/mycompany/sos/service/CustomerService.java create mode 100644 src/main/java/com/mycompany/sos/service/CustomerServiceImpl.java create mode 100644 src/main/java/com/mycompany/sos/service/ItemService.java create mode 100644 src/main/java/com/mycompany/sos/service/ItemServiceImpl.java create mode 100644 src/main/java/com/mycompany/sos/service/OrderService.java create mode 100644 src/main/java/com/mycompany/sos/service/OrderServiceImpl.java create mode 100644 src/main/java/com/mycompany/sos/web/CustomerController.java create mode 100644 src/main/java/com/mycompany/sos/web/CustomerDetailsController.java create mode 100644 src/main/java/com/mycompany/sos/web/ItemController.java create mode 100644 src/main/java/com/mycompany/sos/web/LoginController.java create mode 100644 src/main/java/com/mycompany/sos/web/OrderController.java create mode 100644 src/main/java/com/mycompany/sos/web/validator/OrderFormValidator.java create mode 100644 src/main/resources/error_en.properties create mode 100644 src/main/resources/log4j.properties create mode 100644 src/main/resources/scripts/mysql/db-create.sql create mode 100644 src/main/resources/scripts/mysql/db-drop-tables.sql create mode 100644 src/main/resources/scripts/mysql/insert.sql create mode 100644 src/main/webapp/WEB-INF/application-context.xml create mode 100644 src/main/webapp/WEB-INF/application-datasource.xml create mode 100644 src/main/webapp/WEB-INF/application-security.xml create mode 100644 src/main/webapp/WEB-INF/application-web.xml create mode 100644 src/main/webapp/WEB-INF/web.xml create mode 100644 src/main/webapp/common/common.jsp create mode 100644 src/main/webapp/common/footer.jsp create mode 100644 src/main/webapp/common/header.jsp create mode 100644 src/main/webapp/common/index.jsp create mode 100644 src/main/webapp/common/meta.jsp create mode 100644 src/main/webapp/common/nav.jsp create mode 100644 src/main/webapp/common/taglibs.jsp create mode 100644 src/main/webapp/css/login.css create mode 100644 src/main/webapp/css/logout.css create mode 100644 src/main/webapp/css/sos.css create mode 100644 src/main/webapp/customers/customerDetails.jsp create mode 100644 src/main/webapp/customers/customers-createCustomer.jsp create mode 100644 src/main/webapp/customers/customers.jsp create mode 100644 src/main/webapp/items/items-create.jsp create mode 100644 src/main/webapp/items/items.jsp create mode 100644 src/main/webapp/login/login.jsp create mode 100644 src/main/webapp/orders/orders-createOrder.jsp create mode 100644 src/main/webapp/orders/orders.jsp diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8d67bc7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# top-most EditorConfig file +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space + +[*.{java,xml}] +indent_size = 4 +trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7116901 --- /dev/null +++ b/.gitignore @@ -0,0 +1,36 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.project +*.classpath +*.iml + + +.settings/* +.idea/* +target/* + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods + +# Logs and databases # +###################### +*.log + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db +/target/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..5b06b41 --- /dev/null +++ b/pom.xml @@ -0,0 +1,357 @@ + + 4.0.0 + + com.mycompany.sos + online-application + war + 1.0-SNAPSHOT + SalesOrderSystem + http://maven.apache.org + + + 1.8 + 4.1.6.RELEASE + 1.9.1.RELEASE + 3.2.3.RELEASE + 4.12 + 3.4.1 + 1.10.19 + 3.1.0 + 1.2 + 1.1.0.Final + 5.1.9 + 4.3.10.Final + 4.3.10.Final + 4.3.10.Final + 5.2.1.Final + 1.6.1 + 1.0.0 + 1.16.18 + + + + + + + + junit + junit + ${junit.version} + test + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + org.mockito + mockito-all + ${mockito.version} + + + + + org.springframework + spring-core + ${spring.version} + + + + org.springframework + spring-web + ${spring.version} + + + + org.springframework + spring-webmvc + ${spring.version} + + + + org.springframework + spring-orm + ${spring.version} + + + + org.springframework + spring-tx + ${spring.version} + + + + org.springframework + spring-test + ${spring.version} + + + + org.springframework + spring-jdbc + ${spring.version} + + + + org.springframework.data + spring-data-jpa + ${spring.data.version} + + + + + org.springframework.security + spring-security-web + ${spring.security.version} + + + + org.springframework.security + spring-security-config + ${spring.security.version} + + + + + + javax.servlet + javax.servlet-api + ${servlet.version} + provided + + + + + jstl + jstl + ${jstl.version} + + + + + javax.validation + validation-api + ${bean.validation.version} + + + + + + mysql + mysql-connector-java + ${mysql.version} + + + + + org.hibernate + hibernate-core + ${hibernate.core.version} + + + + + org.hibernate + hibernate-entitymanager + ${hibernate.entitymanager.version} + + + + + + + + org.hibernate + hibernate-validator + ${hibernate.validator.version} + + + + + + + + org.slf4j + slf4j-log4j12 + ${slf4j-log4j12.version} + + + + + + com.github.dandelion + datatables-jsp + ${dandelion.datatables.version} + + + + + + + + org.projectlombok + lombok + ${lombok.version} + provided + + + + org.springframework + spring-beans + ${spring.version} + + + + + + + commons-fileupload + commons-fileupload + 1.3.1 + + + + + commons-io + commons-io + 2.4 + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-it-source + pre-integration-test + + add-test-source + + + + src/integration-test/java + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + add-it-resources + pre-integration-test + + copy-resources + + + target/it-test-classes + + + src/integration-test/resources + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${java.version} + ${java.version} + + + + compile-integration-test + pre-integration-test + + testCompile + + + + **/*IT.java + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19 + + false + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.18 + + + integration-test + + integration-test + verify + + + src/integration-test/java + + target/test-classes + + + **/*Test.java + + true + + + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + + + maven-war-plugin + 2.1.1 + + true + classes + + + + + + + + diff --git a/src/main/java/com/mycompany/sos/model/Address.java b/src/main/java/com/mycompany/sos/model/Address.java new file mode 100644 index 0000000..a1c8790 --- /dev/null +++ b/src/main/java/com/mycompany/sos/model/Address.java @@ -0,0 +1,181 @@ + +package com.mycompany.sos.model; + +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; + +import org.hibernate.validator.constraints.NotBlank; +import org.hibernate.validator.constraints.NotEmpty; + +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; + +/** + * {@link Address} class + * + * Address entity + * + * @author Sandeep Bhatt + */ +@Entity +@Table(name = "address") +@NoArgsConstructor +@EqualsAndHashCode(exclude = "customers") +@ToString(exclude = "customers") +public class Address { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "address_id") + private int addressId; + + @NotNull(message = "{error.null.houseFlatNo}") + @Min(value = 1, message = "{error.min.houseFlatNo}") + @Column(name = "house_flat_no", nullable = false) + private int houseFlatNo; + + @NotNull(message = "{error.null.street}") + @NotBlank(message = "{error.blank.street}") + @NotEmpty(message = "{error.empty.street}") + @Pattern(regexp = "[a-zA-Z ]*", message = "{error.invalid.street}") + @Column(name = "street", nullable = false, length = 255) + private String street; + + @NotNull(message = "{error.null.postcode}") + @NotBlank(message = "{error.blank.postcode}") + @NotEmpty(message = "{error.empty.postcode}") + @Pattern(regexp = "[a-zA-Z0-9 ]*", message = "{error.invalid.postcode}") + @Column(name = "postcode", nullable = false, length = 8) + private String postCode; + + @NotNull(message = "{error.null.city}") + @NotBlank(message = "{error.blank.city}") + @NotEmpty(message = "{error.empty.city}") + @Pattern(regexp = "[a-zA-Z]*", message = "{error.invalid.city}") + @Column(name = "city", nullable = false, length = 15) + private String city; + + @NotNull(message = "{error.null.country}") + @NotBlank(message = "{error.blank.country}") + @NotEmpty(message = "{error.empty.country}") + @Pattern(regexp = "[a-zA-Z]*", message = "{error.invalid.country}") + @Column(name = "country", nullable = false, length = 20) + private String country; + + // 1 : M + @OneToMany(fetch = FetchType.LAZY, mappedBy = "address") + private Set customers = new HashSet<>(0); + + /** + * @return the addressId + */ + public int getAddressId() { + return addressId; + } + + /** + * @param addressId + * the addressId to set + */ + public void setAddressId(int addressId) { + this.addressId = addressId; + } + + /** + * @return the houseFlatNo + */ + public int getHouseFlatNo() { + return houseFlatNo; + } + + /** + * @param houseFlatNo + * the houseFlatNo to set + */ + public void setHouseFlatNo(int houseFlatNo) { + this.houseFlatNo = houseFlatNo; + } + + /** + * @return the street + */ + public String getStreet() { + return street; + } + + /** + * @param street + * the street to set + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * @return the postCode + */ + public String getPostCode() { + return postCode; + } + + /** + * @param postCode + * the postCode to set + */ + public void setPostCode(String postCode) { + this.postCode = postCode; + } + + /** + * @return the city + */ + public String getCity() { + return city; + } + + /** + * @param city + * the city to set + */ + public void setCity(String city) { + this.city = city; + } + + /** + * @return the country + */ + public String getCountry() { + return country; + } + + /** + * @param country + * the country to set + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * @return the customers + */ + public Set getCustomers() { + return customers; + } + + + +} diff --git a/src/main/java/com/mycompany/sos/model/Customer.java b/src/main/java/com/mycompany/sos/model/Customer.java new file mode 100644 index 0000000..377f75e --- /dev/null +++ b/src/main/java/com/mycompany/sos/model/Customer.java @@ -0,0 +1,227 @@ + +package com.mycompany.sos.model; + +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Past; +import javax.validation.constraints.Pattern; + +import org.hibernate.validator.constraints.Email; +import org.hibernate.validator.constraints.NotBlank; +import org.hibernate.validator.constraints.NotEmpty; + +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; + +/** + * {@link Customer} class + * + * Customer entity + * + * @author Sandeep Bhatt + */ +@Entity +@Table(name = "customer") +@NoArgsConstructor +@EqualsAndHashCode(exclude = "orders") +@ToString +public class Customer { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "customer_id") + private int customerId; + + @NotNull(message = "{error.null.firstname}") + @NotBlank(message = "{error.blank.firstname}") + @NotEmpty(message = "{error.empty.firstname}") + @Pattern(regexp = "[a-zA-Z]*", message = "{error.invalid.firstname}") + @Column(name = "customer_firstname", nullable = false, length = 50) + private String firstName; + + @NotNull(message = "{error.null.lastname}") + @NotBlank(message = "{error.blank.lastname}") + @NotEmpty(message = "{error.empty.lastname}") + @Pattern(regexp = "[a-zA-Z]*", message = "{error.invalid.lastname}") + @Column(name = "customer_lastname", nullable = false, length = 50) + private String lastName; + + @NotNull(message = "{error.null.dob}") + @Past(message = "{error.past.dob}") + @Temporal(TemporalType.DATE) + @Column(name = "customer_date_of_birth", nullable = false) + private Date dateOfBirth; + + @NotNull(message = "{error.null.email}") + @NotBlank(message = "{error.blank.email}") + @NotEmpty(message = "{error.empty.email}") + @Email(message = "{error.email}") + @Lob + @Column(name = "customer_email_address", nullable = false, columnDefinition = "TEXT") + private String email; + + // M : 1 + @Valid + @ManyToOne(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }) + @JoinColumn(name = "customer_address_id") + private Address address; + + // 1 : 1 + @Valid + @OneToOne(fetch = FetchType.LAZY, mappedBy = "customer", cascade = { CascadeType.ALL }) + private CustomerPaymentDetail customerPaymentDetail; + + // 1 : M + @OneToMany(fetch = FetchType.LAZY, mappedBy = "customer", cascade = { CascadeType.ALL }) + private Set orders = new HashSet<>(0); + + + /** + * @return the customerId + */ + public int getCustomerId() { + return customerId; + } + + /** + * @param customerId + * the customerId to set + */ + public void setCustomerId(int customerId) { + this.customerId = customerId; + } + + /** + * @return the firstName + */ + public String getFirstName() { + return firstName; + } + + /** + * @param firstName + * the firstName to set + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * @return the lastName + */ + public String getLastName() { + return lastName; + } + + /** + * @param lastName + * the lastName to set + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * @return the dateOfBirth + */ + public Date getDateOfBirth() { + return dateOfBirth; + } + + /** + * @param dateOfBirth + * the dateOfBirth to set + */ + public void setDateOfBirth(Date dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + /** + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * @param email + * the email to set + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * @return the address + */ + public Address getAddress() { + return address; + } + + + + /** + * @return the customerPaymentDetail + */ + public CustomerPaymentDetail getCustomerPaymentDetail() { + return customerPaymentDetail; + } + + + + /** + * @return the orders + */ + public Set getOrders() { + return orders; + } + + /** + * @param address the address to set + */ + public void setAddress(Address address) { + this.address = address; + } + + /** + * @param customerPaymentDetail the customerPaymentDetail to set + */ + public void setCustomerPaymentDetail(CustomerPaymentDetail customerPaymentDetail) { + this.customerPaymentDetail = customerPaymentDetail; + } + + /** + * @param orders the orders to set + */ + public void setOrders(Set orders) { + this.orders = orders; + } + + + + + + + + +} diff --git a/src/main/java/com/mycompany/sos/model/CustomerPaymentDetail.java b/src/main/java/com/mycompany/sos/model/CustomerPaymentDetail.java new file mode 100644 index 0000000..8d0aaf1 --- /dev/null +++ b/src/main/java/com/mycompany/sos/model/CustomerPaymentDetail.java @@ -0,0 +1,148 @@ + +package com.mycompany.sos.model; + +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.validation.constraints.Future; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +import org.hibernate.validator.constraints.NotBlank; +import org.hibernate.validator.constraints.NotEmpty; + +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; + +/** + * {@link CustomerPaymentDetail} class + * + * CustomerPaymentDetail entity + * + * @author Sandeep Bhatt + */ +@Entity +@Table(name = "customer_payment_details") +@ToString(exclude = "customer") +@EqualsAndHashCode(exclude = "customer") +@NoArgsConstructor +public class CustomerPaymentDetail { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "customer_payment_details_id") + private int paymentDetailsId; + + @NotNull(message = "{error.null.customerReference}") + @NotBlank(message = "{error.blank.customerReference}") + @NotEmpty(message = "{error.empty.customerReference}") + @Size(min = 1, max = 20, message = "{error.size.customerReference}") + @Column(name = "customer_reference", nullable = false, length = 255) + private String customerReference; + + @NotNull(message = "{error.null.cardNo}") + @NotBlank(message = "{error.blank.cardNo}") + @NotEmpty(message = "{error.empty.cardNo}") + @Size(max = 16, min = 16, message = "{error.invalid.size.cardNo}") + @Pattern(regexp = "[0-9]*", message = "{error.invalid.cardNo}") + @Column(name = "customer_card_number", nullable = false, length = 16) + private String cardNo; + + @NotNull(message = "{error.null.expDate}") + @Future(message = "{error.future.expDate}") + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "customer_card_expiry_date", nullable = false, length = 5) + private Date cardExpiryDate; + + @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "customer_id", nullable = false) + private Customer customer; + + /** + * @return the paymentDetailsId + */ + public int getPaymentDetailsId() { + return paymentDetailsId; + } + + /** + * @param paymentDetailsId + * the paymentDetailsId to set + */ + public void setPaymentDetailsId(int paymentDetailsId) { + this.paymentDetailsId = paymentDetailsId; + } + + /** + * @return the customerReference + */ + public String getCustomerReference() { + return customerReference; + } + + /** + * @param customerReference + * the customerReference to set + */ + public void setCustomerReference(String customerReference) { + this.customerReference = customerReference; + } + + /** + * @return the cardNo + */ + public String getCardNo() { + return cardNo; + } + + /** + * @param cardNo + * the cardNo to set + */ + public void setCardNo(String cardNo) { + this.cardNo = cardNo; + } + + /** + * @return the cardExpiryDate + */ + public Date getCardExpiryDate() { + return cardExpiryDate; + } + + /** + * @param cardExpiryDate + * the cardExpiryDate to set + */ + public void setCardExpiryDate(Date cardExpiryDate) { + this.cardExpiryDate = cardExpiryDate; + } + + /** + * @return the customer + */ + public Customer getCustomer() { + return customer; + } + + /** + * @param customer + * the customer to set + */ + public void setCustomer(Customer customer) { + this.customer = customer; + } + +} diff --git a/src/main/java/com/mycompany/sos/model/Item.java b/src/main/java/com/mycompany/sos/model/Item.java new file mode 100644 index 0000000..54dca42 --- /dev/null +++ b/src/main/java/com/mycompany/sos/model/Item.java @@ -0,0 +1,106 @@ + +package com.mycompany.sos.model; + +import java.math.BigDecimal; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.Table; +import javax.validation.constraints.NotNull; + +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; + +/** + * {@link Item} class + * + * Item entity + * + * @author Sandeep Bhatt + */ +@Entity +@Table(name = "items") +@ToString(exclude = "orders") +@EqualsAndHashCode(exclude = "orders") +@NoArgsConstructor +public class Item { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "item_id") + private int itemId; + + @NotNull(message = "{error.null.itemName}") + @Column(name = "item_name", nullable = false, length = 255) + private String itemName; + + @NotNull(message = "{error.null.itemPrice}") + @Column(name = "item_price", nullable = false) + private BigDecimal itemPrice; + + @ManyToMany(fetch = FetchType.LAZY, mappedBy = "items") + private Set orders = new HashSet<>(); + + /** + * @return the itemId + */ + public int getItemId() { + return itemId; + } + + /** + * @param itemId + * the itemId to set + */ + public void setItemId(int itemId) { + this.itemId = itemId; + } + + /** + * @return the itemName + */ + public String getItemName() { + return itemName; + } + + /** + * @param itemName + * the itemName to set + */ + public void setItemName(String itemName) { + this.itemName = itemName; + } + + /** + * @return the itemPrice + */ + public BigDecimal getItemPrice() { + return itemPrice; + } + + /** + * @param itemPrice + * the itemPrice to set + */ + public void setItemPrice(BigDecimal itemPrice) { + this.itemPrice = itemPrice; + } + + /** + * @return the orders + */ + public Set getOrders() { + return orders; + } + + + +} diff --git a/src/main/java/com/mycompany/sos/model/Order.java b/src/main/java/com/mycompany/sos/model/Order.java new file mode 100644 index 0000000..f2e6e0d --- /dev/null +++ b/src/main/java/com/mycompany/sos/model/Order.java @@ -0,0 +1,91 @@ + +package com.mycompany.sos.model; + +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.ToString; + +/** + * {@link Order} class + * + * Order entity + * + * @author Sandeep Bhatt + */ +@Entity +@Table(name = "orders") +@NoArgsConstructor +@EqualsAndHashCode(exclude = { "customer", "items" }) +@ToString(exclude = "customer") +public class Order { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "order_id") + private int orderId; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "customer_id", nullable = false) + private Customer customer; + + @ManyToMany(fetch = FetchType.LAZY) + @JoinTable(name = "orders_items", joinColumns = { + @JoinColumn(name = "order_id", nullable = false, updatable = false) }, inverseJoinColumns = { + @JoinColumn(name = "item_id", nullable = false, updatable = false) }) + private Set items = new HashSet<>(0); + + /** + * @return the orderId + */ + public int getOrderId() { + return orderId; + } + + /** + * @param orderId + * the orderId to set + */ + public void setOrderId(int orderId) { + this.orderId = orderId; + } + + /** + * @return the customer + */ + public Customer getCustomer() { + return customer; + } + + /** + * @param customer + * the customer to set + */ + public void setCustomer(Customer customer) { + this.customer = customer; + } + + /** + * @return the items + */ + public Set getItems() { + return items; + } + + + +} diff --git a/src/main/java/com/mycompany/sos/repository/CustomerRepository.java b/src/main/java/com/mycompany/sos/repository/CustomerRepository.java new file mode 100644 index 0000000..f5758d5 --- /dev/null +++ b/src/main/java/com/mycompany/sos/repository/CustomerRepository.java @@ -0,0 +1,23 @@ + +package com.mycompany.sos.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import com.mycompany.sos.model.Customer; + +/** + * {@link CustomerRepository} interface + * + * @author Sandeep Bhatt + */ +@Repository +public interface CustomerRepository extends JpaRepository { + + /** + * Finds the {@link Customer} by the customer name (i.e firstname + lastname) + * + * @return {@link Customer} + */ + Customer findByFirstNameAndLastName(String firstName, String lastName); +} diff --git a/src/main/java/com/mycompany/sos/repository/ItemRepository.java b/src/main/java/com/mycompany/sos/repository/ItemRepository.java new file mode 100644 index 0000000..ddea2fd --- /dev/null +++ b/src/main/java/com/mycompany/sos/repository/ItemRepository.java @@ -0,0 +1,16 @@ + +package com.mycompany.sos.repository; + +import com.mycompany.sos.model.Item; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * {@link ItemRepository} interface + * + * @author Sandeep Bhatt + */ +@Repository +public interface ItemRepository extends JpaRepository { + +} diff --git a/src/main/java/com/mycompany/sos/repository/OrderRepository.java b/src/main/java/com/mycompany/sos/repository/OrderRepository.java new file mode 100644 index 0000000..c9dca79 --- /dev/null +++ b/src/main/java/com/mycompany/sos/repository/OrderRepository.java @@ -0,0 +1,16 @@ + +package com.mycompany.sos.repository; + +import com.mycompany.sos.model.Order; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +/** + * {@link OrderRepository} interface + * + * @author Sandeep Bhatt + */ +@Repository +public interface OrderRepository extends JpaRepository { + +} diff --git a/src/main/java/com/mycompany/sos/service/CustomerService.java b/src/main/java/com/mycompany/sos/service/CustomerService.java new file mode 100644 index 0000000..7a833c9 --- /dev/null +++ b/src/main/java/com/mycompany/sos/service/CustomerService.java @@ -0,0 +1,54 @@ + +package com.mycompany.sos.service; + +import com.mycompany.sos.model.Customer; + +import java.util.List; + +/** + * {@link CustomerService} interface + * + * @author Sandeep Bhatt + */ +public interface CustomerService { + + /** + * Adds a customer to the system + *

+ * This makes an underlying call to insert into the database + * + * @param customer the customer to add + * @return true if successful false otherwise + */ + Customer addCustomer(Customer customer); + + /** + * Gets a list of customers + * + * @return a list of customers + */ + List getCustomers(); + + /** + * Finds the Customer by the given customer name + * + * @param customerName the name of the customer + * @return the customer + */ + Customer findCustomerByCustomerName(String customerName); + + /** + * Finds the Customer by the given customer id + * + * @param customerId id identifying the customer + * @return the customer + */ + Customer findCustomerByCustomerId(int customerId); + + /** + * Delete the Customer by the given customer id + * + * @param customerId + */ + void deleteCustomer(int customerId); +} diff --git a/src/main/java/com/mycompany/sos/service/CustomerServiceImpl.java b/src/main/java/com/mycompany/sos/service/CustomerServiceImpl.java new file mode 100644 index 0000000..6043af1 --- /dev/null +++ b/src/main/java/com/mycompany/sos/service/CustomerServiceImpl.java @@ -0,0 +1,93 @@ + +package com.mycompany.sos.service; + +import com.mycompany.sos.model.Customer; +import com.mycompany.sos.repository.CustomerRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + + +/** + * {@link CustomerServiceImpl} class + * + * implementation of the {@link CustomerService} interface + * + * @author Sandeep Bhatt + */ +@Service("customerServiceImpl") +@Transactional +public class CustomerServiceImpl implements CustomerService { + + private static final Logger LOGGER = LoggerFactory.getLogger(CustomerServiceImpl.class); + + @Autowired + private CustomerRepository customerRepository; + + /** + * {@inheritDoc} + */ + @Override + public Customer addCustomer(Customer customer) { + LOGGER.info("Adding new customer to system: " + customer); + return customerRepository.saveAndFlush(customer); + } + + /** + * {@inheritDoc} + */ + @Override + @Transactional(readOnly = true) + public List getCustomers() { + LOGGER.info("Retrieving customers list"); + return customerRepository.findAll(); + } + + /** + * {@inheritDoc} + */ + @Override + public Customer findCustomerByCustomerName(String customerName) { + String[] firstNameAndLastName = customerName.split(" "); + Customer customer = customerRepository.findByFirstNameAndLastName(firstNameAndLastName[0], firstNameAndLastName[1]); + if(customer != null) { + return customer; + } + throw new RuntimeException("Unknown Customer with name: " + customerName); + } + + /** + * {@inheritDoc} + */ + @Override + @Transactional(readOnly = true) + public Customer findCustomerByCustomerId(int customerId) { + Customer customer = customerRepository.findOne(customerId); + + if(customer != null) { + return customer; + } + throw new RuntimeException("Unknown Customer with id: " + customerId); + + } + + @Override + public void deleteCustomer(int customerId) { + Customer customer = customerRepository.findOne(customerId); + + if(customer != null) { + try { + customerRepository.delete(customer); + } catch (Exception e) { + throw new RuntimeException("Error occured in deleteing Customer id: " + customerId); + } + }else{ + throw new RuntimeException("Unknown Customer with id: " + customerId); + } + } + +} diff --git a/src/main/java/com/mycompany/sos/service/ItemService.java b/src/main/java/com/mycompany/sos/service/ItemService.java new file mode 100644 index 0000000..5ca6eac --- /dev/null +++ b/src/main/java/com/mycompany/sos/service/ItemService.java @@ -0,0 +1,29 @@ + +package com.mycompany.sos.service; + +import com.mycompany.sos.model.Item; + +import java.util.List; + +/** + * {@link ItemService} interface + * + * @author Sandeep Bhatt + */ +public interface ItemService { + + /** + * Adds a new item + * + * @param item the new item to add + * @return true if successfully added false otherwise + */ + boolean addItem(Item item); + + /** + * Retrieves a list of items + * + * @return list of items + */ + List getItems(); +} diff --git a/src/main/java/com/mycompany/sos/service/ItemServiceImpl.java b/src/main/java/com/mycompany/sos/service/ItemServiceImpl.java new file mode 100644 index 0000000..61e768f --- /dev/null +++ b/src/main/java/com/mycompany/sos/service/ItemServiceImpl.java @@ -0,0 +1,42 @@ + +package com.mycompany.sos.service; + +import com.mycompany.sos.model.Item; +import com.mycompany.sos.repository.ItemRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * {@link ItemServiceImpl} class + * + * implementation of the {@link ItemService} interface + * + * @author Sandeep Bhatt + */ +@Service("itemServiceImpl") +@Transactional +public class ItemServiceImpl implements ItemService { + + @Autowired + private ItemRepository itemRepository; + + /** + * {@inheritDoc} + */ + @Override + public boolean addItem(Item item) { + return itemRepository.save(item) != null; + } + + /** + * {@inheritDoc} + */ + @Override + public List getItems() { + return itemRepository.findAll(); + } + +} diff --git a/src/main/java/com/mycompany/sos/service/OrderService.java b/src/main/java/com/mycompany/sos/service/OrderService.java new file mode 100644 index 0000000..9b73fb1 --- /dev/null +++ b/src/main/java/com/mycompany/sos/service/OrderService.java @@ -0,0 +1,29 @@ + +package com.mycompany.sos.service; + +import com.mycompany.sos.model.Order; + +import java.util.List; + +/** + * {@link OrderService} interface + * + * @author Sandeep Bhatt + */ +public interface OrderService { + + /** + * Adds a new order + * + * @param order the new order to add + * @return true if successfully added false otherwise + */ + boolean addOrder(Order order); + + /** + * Gets a list of orders + * + * @return list of orders + */ + List getOrders(); +} diff --git a/src/main/java/com/mycompany/sos/service/OrderServiceImpl.java b/src/main/java/com/mycompany/sos/service/OrderServiceImpl.java new file mode 100644 index 0000000..a71b443 --- /dev/null +++ b/src/main/java/com/mycompany/sos/service/OrderServiceImpl.java @@ -0,0 +1,43 @@ + +package com.mycompany.sos.service; + +import com.mycompany.sos.model.Order; +import com.mycompany.sos.repository.OrderRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * {@link OrderServiceImpl} class + * + * implementation of the {@link OrderService} interface + * + * @author Sandeep Bhatt + */ +@Service("orderServiceImpl") +@Transactional +public class OrderServiceImpl implements OrderService { + + @Autowired + private OrderRepository orderRepository; + + /** + * {@inheritDoc} + */ + @Override + public boolean addOrder(Order order) { + return orderRepository.save(order) != null; + } + + /** + * {@inheritDoc} + */ + @Override + @Transactional(readOnly = true) + public List getOrders() { + return orderRepository.findAll(); + } + +} diff --git a/src/main/java/com/mycompany/sos/web/CustomerController.java b/src/main/java/com/mycompany/sos/web/CustomerController.java new file mode 100644 index 0000000..29dece9 --- /dev/null +++ b/src/main/java/com/mycompany/sos/web/CustomerController.java @@ -0,0 +1,144 @@ + +package com.mycompany.sos.web; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import javax.validation.Valid; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.propertyeditors.CustomDateEditor; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + +import com.mycompany.sos.model.Customer; +import com.mycompany.sos.service.CustomerService; + + +/** + * {@link CustomerController} class + * + * @author Sandeep Bhatt + */ +@Controller +public class CustomerController { + + private static final Logger logger = LoggerFactory.getLogger(CustomerController.class); + + @Autowired + @Qualifier("customerServiceImpl") + private CustomerService customerService; + + + @InitBinder + private void initBinder(WebDataBinder binder) { + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); + sdf.setLenient(true); + binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true)); + } + + /** + * Shows the create customer form page + * + * @param modelMap Spring's framework model map object containing the model data + * @return view name + */ + @RequestMapping(value = "/customers/create", method = RequestMethod.GET) + public String showCreateCustomerFormPage(ModelMap modelMap) { + modelMap.addAttribute("createCustomerForm", new Customer()); + logger.info("Accessed Create Customer page"); + logger.debug("Retrieved createCustomerForm"); + return "customers/customers-createCustomer"; + } + + /** + * Handles the create customer form submit + * + * @param customer the customer entity (used as form backing object also) + * @param result Spring's framework binding result object + * @return model and view object + */ + @RequestMapping(value = "/customers/createCustomer", method = RequestMethod.POST) + public ModelAndView createCustomer( + @Valid @ModelAttribute("createCustomerForm") Customer customer, + BindingResult result) { + + ModelAndView modelAndView = new ModelAndView(); + + if(result.hasErrors()) { + modelAndView.setViewName("customers/customers-createCustomer"); + return modelAndView; + } + + logger.debug(customer.toString()); + + customer.getCustomerPaymentDetail().setCustomer(customer); + + Customer customerAdded = customerService.addCustomer(customer); + if(customerAdded != null) { + logger.info("Successfully added customer"); + modelAndView.addObject("submittedCustomerForm", customer); + modelAndView.setViewName("redirect:/customer/" + customer.getCustomerId()); + } else { + logger.warn("Unable to add customer"); + } + + return modelAndView; + } + + /** + * Handles customers list page + * + * @param modelMap Spring's framework model map object containing the model data + * @return view name + */ + @RequestMapping(value = "/customers", method = RequestMethod.GET) + public String listCustomers(ModelMap modelMap) { + logger.info("Fetching customers list"); + List customers = customerService.getCustomers(); + modelMap.addAttribute("customers", customers); + return "customers/customers"; + } + + + /** + * Deleting customer and related orders + * + * @param customerId id identifying the customer + * @param model Spring's framework model object + * @return view name + */ + @RequestMapping(value = "customers/delete/{customerId}", method = RequestMethod.GET) + public ModelAndView deleteCustomer(@PathVariable("customerId") String customerId, Model model) { + customerService.deleteCustomer(Integer.parseInt(customerId)); + return new ModelAndView("redirect:/customers"); + } + + /** + * Displaying of the customer details page + * + * @param customerId id identifying the customer + * @param model Spring's framework model object + * @return view name + */ + @RequestMapping(value = "customers/{customerId}", method = RequestMethod.GET) + public ModelAndView editCustomer(@PathVariable("customerId") String customerId) { + ModelAndView modelAndView = new ModelAndView("customers/customers-createCustomer"); + Customer customer = customerService.findCustomerByCustomerId(Integer.parseInt(customerId)); + modelAndView.addObject("createCustomerForm", customer); + return modelAndView; + } +} diff --git a/src/main/java/com/mycompany/sos/web/CustomerDetailsController.java b/src/main/java/com/mycompany/sos/web/CustomerDetailsController.java new file mode 100644 index 0000000..c4d9cca --- /dev/null +++ b/src/main/java/com/mycompany/sos/web/CustomerDetailsController.java @@ -0,0 +1,37 @@ + +package com.mycompany.sos.web; + +import com.mycompany.sos.model.Customer; +import com.mycompany.sos.service.CustomerService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * {@link CustomerDetailsController} class + * + * @author Sandeep Bhatt + */ +@Controller +public class CustomerDetailsController { + + @Autowired + private CustomerService customerService; + + /** + * Displaying of the customer details page + * + * @param customerId id identifying the customer + * @param model Spring's framework model object + * @return view name + */ + @RequestMapping(value = "customer/{customerId}", method = RequestMethod.GET) + public String getCustomerDetailsPage(@PathVariable("customerId") String customerId, Model model) { + Customer customer = customerService.findCustomerByCustomerId(Integer.parseInt(customerId)); + model.addAttribute("customer", customer); + return "customers/customerDetails"; + } +} diff --git a/src/main/java/com/mycompany/sos/web/ItemController.java b/src/main/java/com/mycompany/sos/web/ItemController.java new file mode 100644 index 0000000..42b8edd --- /dev/null +++ b/src/main/java/com/mycompany/sos/web/ItemController.java @@ -0,0 +1,90 @@ + +package com.mycompany.sos.web; + +import com.mycompany.sos.model.Item; +import com.mycompany.sos.service.ItemService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + +import javax.validation.Valid; +import java.util.List; + +/** + * {@link ItemController} class + * + * @author Sandeep Bhatt + */ +@Controller +public class ItemController { + + private static final Logger logger = LoggerFactory.getLogger(ItemController.class); + + @Autowired + private ItemService itemService; + + + /** + * Shows the items list page + * + * @param model the model + * @return view name + */ + @RequestMapping(value = "/items", method = RequestMethod.GET) + public String showItemsList(ModelMap model) { + List items = itemService.getItems(); + model.addAttribute("items", items); + return "items/items"; + } + + /** + * Shows the create item form page + * + * @param modelMap Spring's framework model map object containing the model data + * @return view name + */ + @RequestMapping(value = "/items/create", method = RequestMethod.GET) + public String showCreateItemPage(ModelMap modelMap) { + modelMap.addAttribute("createItemForm", new Item()); + logger.info("Accessed Create Item page"); + logger.debug("Retrieved createItemForm"); + return "items/items-create"; + } + + /** + * Handles the create item form submit + * + * @param item the item entity (used as the form backing object also) + * @param result Spring's framework binding result object + * @return model and view object + */ + @RequestMapping(value = "/items/createItem", method = RequestMethod.POST) + public ModelAndView createItem( + @Valid @ModelAttribute("createItemForm") Item item, + BindingResult result) { + + ModelAndView modelAndView = new ModelAndView(); + + if(result.hasErrors()) { + modelAndView.setViewName("items-create"); + return modelAndView; + } + + if(itemService.addItem(item)) { + logger.info("Successfully added item"); + // should redirect back to items list page + modelAndView.setViewName("redirect:/items"); + } else { + logger.warn("Unable to add item"); + } + + return modelAndView; + } +} diff --git a/src/main/java/com/mycompany/sos/web/LoginController.java b/src/main/java/com/mycompany/sos/web/LoginController.java new file mode 100644 index 0000000..f117f02 --- /dev/null +++ b/src/main/java/com/mycompany/sos/web/LoginController.java @@ -0,0 +1,45 @@ + +package com.mycompany.sos.web; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; + +/** + * Controller for handling login + * + * @author Sandeep Bhatt + */ +@Controller +public class LoginController { + + /** + * Shows the login page + * + * @param error if there is an error + * @return model and view + */ + @RequestMapping(value = "/login", method = RequestMethod.GET) + public ModelAndView login( + @RequestParam(value = "error", required = false) String error, + @RequestParam(value = "logout", required = false) String logout + ) { + + ModelAndView modelAndView = new ModelAndView(); + + if(error != null) { + modelAndView.addObject("error", "Invalid username and password!"); + } + + if(logout != null) { + modelAndView.addObject("msg", "You've been logged out successfully!"); + } + + modelAndView.setViewName("login/login"); + + return modelAndView; + } + +} diff --git a/src/main/java/com/mycompany/sos/web/OrderController.java b/src/main/java/com/mycompany/sos/web/OrderController.java new file mode 100644 index 0000000..d9a31c8 --- /dev/null +++ b/src/main/java/com/mycompany/sos/web/OrderController.java @@ -0,0 +1,126 @@ + +package com.mycompany.sos.web; + +import com.mycompany.sos.model.Customer; +import com.mycompany.sos.model.Item; +import com.mycompany.sos.model.Order; +import com.mycompany.sos.service.CustomerService; +import com.mycompany.sos.service.ItemService; +import com.mycompany.sos.service.OrderService; +import com.mycompany.sos.web.validator.OrderFormValidator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.servlet.ModelAndView; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + + +/** + * {@link OrderController} class + * + * @author Sandeep Bhatt + */ +@Controller +public class OrderController { + + private static final Logger logger = LoggerFactory.getLogger(OrderController.class); + + @Autowired + @Qualifier("orderServiceImpl") + private OrderService orderService; + + @Autowired + @Qualifier("customerServiceImpl") + private CustomerService customerService; + + @Autowired + @Qualifier("itemServiceImpl") + private ItemService itemService; + + @Autowired + @Qualifier("orderFormValidator") + private OrderFormValidator orderFormValidator; + + + /** + * Shows the create order form page + * + * @param modelMap Spring's framework model map object containing the model data + * @return view name + */ + @RequestMapping(value = "/orders/create", method=RequestMethod.GET) + public String showCreateOrdersForm(ModelMap modelMap, @RequestParam("customerId") int customerId) { + + // get the customer + Customer customer = customerService.findCustomerByCustomerId(customerId); + Order order = new Order(); + order.setCustomer(customer); + + // get list of all available items + List items = itemService.getItems(); + + modelMap.addAttribute("createOrderForm", order); + modelMap.addAttribute("itemsList", items); + + return "orders/orders-createOrder"; + } + + /** + * Handles the submission of orders creation + * + * @param order the order entity (also used as the form backing object) + * @param result Spring Framework's binding result object + * @return model and view + */ + @RequestMapping(value = "orders/createOrder", method = RequestMethod.POST) + public ModelAndView createOrder(@ModelAttribute("createOrderForm") Order order, BindingResult result,HttpServletRequest request) { + + ModelAndView modelAndView = new ModelAndView(); + + if(request.getParameter("items") != null){ + Item item = new Item(); + item.setItemId(Integer.parseInt(request.getParameter("items"))); + order.getItems().add(item); + } + + // custom validation + orderFormValidator.validate(order, result); + + if(result.hasErrors()||order.getItems().isEmpty()) { +// modelAndView.setViewName("orders/orders-createOrder"); + return new ModelAndView("redirect:/orders/create?customerId="+order.getCustomer().getCustomerId()); + } else { + if(orderService.addOrder(order)) { + modelAndView.setViewName("redirect:/customer/"+order.getCustomer().getCustomerId()); + } + // TODO: need to decide what to do in event of unsuccessful order creation + } + + return modelAndView; + } + + /** + * Handles the orders list page + * + * @param modelMap model + * @return view name + */ + @RequestMapping(value="/orders", method=RequestMethod.GET) + public String listOrders(ModelMap modelMap) { + List orders = orderService.getOrders(); + modelMap.addAttribute("orders", orders); + return "orders/orders"; + } + +} diff --git a/src/main/java/com/mycompany/sos/web/validator/OrderFormValidator.java b/src/main/java/com/mycompany/sos/web/validator/OrderFormValidator.java new file mode 100644 index 0000000..516b7d7 --- /dev/null +++ b/src/main/java/com/mycompany/sos/web/validator/OrderFormValidator.java @@ -0,0 +1,46 @@ + +package com.mycompany.sos.web.validator; + +import com.mycompany.sos.model.Order; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.validation.Errors; +import org.springframework.validation.Validator; + +/** + * {@link OrderFormValidator} class + * + * @author Sandeep Bhatt + */ +@Component("orderFormValidator") +public class OrderFormValidator implements Validator{ + + private static final Logger LOGGER = LoggerFactory.getLogger(OrderFormValidator.class); + + @Override + public boolean supports(Class c1) { + return Order.class.equals(c1); + } + + + @Override + public void validate(Object object, Errors errors) { + + Order order = (Order) object; + + String customer = order.getCustomer().toString(); + + LOGGER.debug(customer); + + if(customer == null || StringUtils.isEmpty(customer)) { + errors.rejectValue("customer", "error.empty.customer"); + } + + if(order.getItems().isEmpty()){ + errors.rejectValue("items", "error.null.itemName"); + } + } + +} diff --git a/src/main/resources/error_en.properties b/src/main/resources/error_en.properties new file mode 100644 index 0000000..7e49dbc --- /dev/null +++ b/src/main/resources/error_en.properties @@ -0,0 +1,83 @@ +## Customer Form errors + +# firstname +error.empty.firstname=Firstname cannot be empty +error.blank.firstname=Firstname cannot be blank +error.null.firstname=Firstname is compulsory +error.invalid.firstname=Firstname has invalid characters + +# lastname +error.empty.lastname=Lastname cannot be empty +error.blank.lastname=Lastname cannot be blank +error.null.lastname=Lastname is compulsory +error.invalid.lastname=Lastname has invalid characters + +# date of birth +error.null.dob=DOB is compulsory +error.past.dob=DOB must be in the past + +# email +error.empty.email=Email address cannot be empty +error.blank.email=Email address cannot be blank +error.null.email=Email address is compulsory +error.email=Invalid email address + +# house/Flat No. +error.null.houseFlatNo=House/Flat No. is compulsory +error.min.houseFlatNo=House/Flat No. must be equal to or greater than 1 + +# street +error.empty.street=Street name cannot be empty +error.blank.street=Street name cannot be blank +error.null.street=Street name is compulsory +error.invalid.street=Street name has invalid characters + +# postcode +error.empty.postcode=Postcode cannot be empty +error.blank.postcode=Postcode cannot be blank +error.null.postcode=Postcode is compulsory +error.invalid.postcode=Postcode has invalid characters + +# city +error.empty.city=City cannot be empty +error.blank.city=City cannot be blank +error.null.city=City is compulsory +error.invalid.city=City has invalid characters + +# country +error.empty.country=Country cannot be empty +error.blank.country=Country cannot be blank +error.null.country=Country is compulsory +error.invalid.country=Country has invalid characters + +# cardNo +error.empty.cardNo=Card No. cannot be empty +error.blank.cardNo=Card No. cannot be blank +error.null.cardNo=Card No. is compulsory +error.invalid.cardNo=Card No. has invalid characters +error.invalid.size.cardNo=Invalid number of characters,Size must be 16 + +# exp date +error.null.expDate=Expiry date is compulsory +error.future.expDate=Expiry date must be in the future + +# customer reference +error.empty.customerReference=Customer reference cannot be empty +error.blank.customerReference=Customer reference cannot be blank +error.null.customerReference=Customer reference is compulsory +error.size.customerReference={0} must be between {2} and {1} + +## Order Form errors + +# customer +error.empty.customer=Customer cannot be empty + +## Item Form errors + +# itemName +error.null.itemName=Item name is compulsory + +# itemPrice +error.null.itemPrice=Item price is compulsory + +error.null.file=Please upload file \ No newline at end of file diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties new file mode 100644 index 0000000..4667536 --- /dev/null +++ b/src/main/resources/log4j.properties @@ -0,0 +1,24 @@ +# Direct log messages to a log file +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=output.log +log4j.appender.file.MaxFileSize=100MB +log4j.appender.file.MaxBackupIndex=1 +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n + +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n + +# Root logger option +log4j.rootLogger=WARN, file, stdout + +# Log everything. Good for troubleshooting +log4j.logger.org.hibernate=DEBUG + +log4j.logger.com.mycompany.sos=DEBUG + +# Log all JDBC parameters +#log4j.logger.org.hibernate.type=ALL \ No newline at end of file diff --git a/src/main/resources/scripts/mysql/db-create.sql b/src/main/resources/scripts/mysql/db-create.sql new file mode 100644 index 0000000..cbb1dcf --- /dev/null +++ b/src/main/resources/scripts/mysql/db-create.sql @@ -0,0 +1,11 @@ +create table address (address_id integer not null auto_increment, city varchar(15) not null, country varchar(20) not null, house_flat_no integer not null, postcode varchar(8) not null, street varchar(255) not null, primary key (address_id)) ENGINE=InnoDB +create table customer (customer_id integer not null auto_increment, customer_date_of_birth date not null, customer_email_address TEXT not null, customer_firstname varchar(50) not null, customer_lastname varchar(50) not null, customer_address_id integer, primary key (customer_id)) ENGINE=InnoDB +create table customer_payment_details (customer_payment_details_id integer not null auto_increment, customer_card_expiry_date datetime not null, customer_card_number varchar(16) not null, customer_reference varchar(20) not null, customer_id integer not null, primary key (customer_payment_details_id)) ENGINE=InnoDB +create table items (item_id integer not null auto_increment, item_name varchar(255) not null, item_price decimal(19,2) not null, primary key (item_id)) ENGINE=InnoDB +create table orders (order_id integer not null auto_increment, customer_id integer not null, primary key (order_id)) ENGINE=InnoDB +create table orders_items (order_id integer not null, item_id integer not null, primary key (order_id, item_id)) ENGINE=InnoDB +alter table customer add constraint FK_b95lvfwqwswe6953ms7i58koj foreign key (customer_address_id) references address (address_id) +alter table customer_payment_details add constraint FK_45wvux3gqtvc2s8k4r1312c0j foreign key (customer_id) references customer (customer_id) +alter table orders add constraint FK_astys1dv61mdlp0n0wx0574r2 foreign key (customer_id) references customer (customer_id) +alter table orders_items add constraint FK_erdocw5fhr37d4mkjg3d568pd foreign key (item_id) references items (item_id) +alter table orders_items add constraint FK_sbml7tdyps7g2gbfj9ul40yas foreign key (order_id) references orders (order_id) diff --git a/src/main/resources/scripts/mysql/db-drop-tables.sql b/src/main/resources/scripts/mysql/db-drop-tables.sql new file mode 100644 index 0000000..a4e7a50 --- /dev/null +++ b/src/main/resources/scripts/mysql/db-drop-tables.sql @@ -0,0 +1,6 @@ +DROP TABLE IF EXISTS orders_items; +DROP TABLE IF EXISTS items; +DROP TABLE IF EXISTS orders; +DROP TABLE IF EXISTS customer_payment_details; +DROP TABLE IF EXISTS customer; +DROP TABLE IF EXISTS address; diff --git a/src/main/resources/scripts/mysql/insert.sql b/src/main/resources/scripts/mysql/insert.sql new file mode 100644 index 0000000..d72d8c9 --- /dev/null +++ b/src/main/resources/scripts/mysql/insert.sql @@ -0,0 +1,65 @@ +-- add addresses +-- address (in particular postcodes) are fake - random generated using https://www.doogal.co.uk/PostcodeGenerator.php +insert into address (city, country, house_flat_no, postcode, street) values +('London', 'UK', 50, 'HD4 5HB', 'Rodney Street'), +('Manchester', 'UK', 23, 'SO24 9NF', 'Albert Square'), +('Leeds', 'UK', 556, 'SA15 5NW', 'Tomson Road'), +('Birmingham', 'UK', 128, 'DL8 3AR', 'Milestone Alley'), +('Glasgow', 'UK', 16, 'LL63 5EY', 'Cheap Lane'), +('Newcastle', 'UK', 8, 'WS4 1LP', 'Fife Crescent'), +('Cardiff', 'UK', 3972, 'LL28 5BG', 'Winston Park'), +('Edinburgh', 'UK', 1, 'G32 0LG', 'Victoria Place'), +('Derby', 'UK', 12, 'SK13 2BA', 'Storm Gate'), +('Sheffield', 'UK', 32, 'PL32 9QG', 'Hung Row'); + + +-- add customers +insert into customer (customer_date_of_birth, customer_email_address, customer_firstname, customer_lastname, customer_address_id) values +('2000-12-21', 'firstname1.lastname1@email.com', 'firstname1', 'lastname1', 1), +('2000-12-21', 'firstname2.lastname2@email.com', 'firstname2', 'lastname2', 2), +('2000-12-21', 'firstname3.lastname3@email.com', 'firstname3', 'lastname3', 3), +('2000-12-21', 'firstname4.lastname4@email.com', 'firstname4', 'lastname4', 4), +('2000-12-21', 'firstname5.lastname5@email.com', 'firstname5', 'lastname5', 5), +('2000-12-21', 'firstname6.lastname6@email.com', 'firstname6', 'lastname6', 6), +('2000-12-21', 'firstname7.lastname7@email.com', 'firstname7', 'lastname7', 7), +('2000-12-21', 'firstname8.lastname8@email.com', 'firstname8', 'lastname8', 8), +('2000-12-21', 'firstname9.lastname9@email.com', 'firstname9', 'lastname9', 9), +('2000-12-21', 'firstname10.lastname10@email.com', 'firstname10', 'lastname10', 10); + + + +-- add customer payment details +-- Note* Credit Card numbers are fake - random generated using http://www.getcreditcardnumbers.com/ +insert into customer_payment_details (customer_card_expiry_date, customer_card_number, customer_reference, customer_id) values +('2015-12-31 00:00:00', '1234567812345678', 'customer-ref-1', 1), +('2015-12-31 00:00:00', '4024007135995586', 'customer-ref-2', 2), +('2015-12-31 00:00:00', '4532754928070797', 'customer-ref-3', 3), +('2015-12-31 00:00:00', '4532790030107846', 'customer-ref-4', 4), +('2015-12-31 00:00:00', '4929126881917390', 'customer-ref-5', 5), +('2015-12-31 00:00:00', '4929337860089115', 'customer-ref-6', 6), +('2015-12-31 00:00:00', '5567638144721645', 'customer-ref-7', 7), +('2015-12-31 00:00:00', '5512296550494052', 'customer-ref-8', 8), +('2015-12-31 00:00:00', '5214682212584722', 'customer-ref-9', 9), +('2015-12-31 00:00:00', '5467916103505618', 'customer-ref-10', 10); + + +-- add items +insert into items (item_name, item_price) values +('test-item1',23.2), +('test-item2',25.2), +('test-item3',12.2), +('test-item4',67.2), +('test-item5',34.2), +('test-item6',09.2), +('test-item7',18.2); + +-- add orders +insert into orders (customer_id) values (1); +insert into orders (customer_id) values (2); +insert into orders (customer_id) values (3); +insert into orders (customer_id) values (4); +insert into orders (customer_id) values (5); +insert into orders (customer_id) values (1); + +-- link orders-items +insert into orders_items (order_id, item_id) values (1, 1), (1, 2); diff --git a/src/main/webapp/WEB-INF/application-context.xml b/src/main/webapp/WEB-INF/application-context.xml new file mode 100644 index 0000000..73b3ff2 --- /dev/null +++ b/src/main/webapp/WEB-INF/application-context.xml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/src/main/webapp/WEB-INF/application-datasource.xml b/src/main/webapp/WEB-INF/application-datasource.xml new file mode 100644 index 0000000..dfb4e58 --- /dev/null +++ b/src/main/webapp/WEB-INF/application-datasource.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.hibernate.dialect.MySQL5InnoDBDialect + validate + true + true + true + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/application-security.xml b/src/main/webapp/WEB-INF/application-security.xml new file mode 100644 index 0000000..5f6ebcb --- /dev/null +++ b/src/main/webapp/WEB-INF/application-security.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/application-web.xml b/src/main/webapp/WEB-INF/application-web.xml new file mode 100644 index 0000000..9511dda --- /dev/null +++ b/src/main/webapp/WEB-INF/application-web.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + / + + + .jsp + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..3e385f0 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,82 @@ + + + + + + contextConfigLocation + /WEB-INF/application-*.xml + + + + dispatcher + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + + + 1 + + + dispatcher + / + + + + org.springframework.web.context.ContextLoaderListener + + + + 30 + + + + + index.jsp + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + + + springSecurityFilterChain + /* + + + springMultipartFilter + springMultipartFilter + org.springframework.web.multipart.support.MultipartFilter + + + springMultipartFilter + /* + + + + + + datatablesFilter + com.github.dandelion.datatables.core.web.filter.DatatablesFilter + + + datatablesFilter + /* + + + + + dandelionFilter + com.github.dandelion.core.web.DandelionFilter + + + dandelionFilter + /* + + + diff --git a/src/main/webapp/common/common.jsp b/src/main/webapp/common/common.jsp new file mode 100644 index 0000000..a3ba920 --- /dev/null +++ b/src/main/webapp/common/common.jsp @@ -0,0 +1,12 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + + + + +Insert title here + + + + + \ No newline at end of file diff --git a/src/main/webapp/common/footer.jsp b/src/main/webapp/common/footer.jsp new file mode 100644 index 0000000..a57a3db --- /dev/null +++ b/src/main/webapp/common/footer.jsp @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/main/webapp/common/header.jsp b/src/main/webapp/common/header.jsp new file mode 100644 index 0000000..e0df58a --- /dev/null +++ b/src/main/webapp/common/header.jsp @@ -0,0 +1,25 @@ +<%@ include file="meta.jsp" %> +" > +" > +Sales Order System + + +

+ + + + diff --git a/src/main/webapp/common/index.jsp b/src/main/webapp/common/index.jsp new file mode 100644 index 0000000..b97c1b6 --- /dev/null +++ b/src/main/webapp/common/index.jsp @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/main/webapp/common/meta.jsp b/src/main/webapp/common/meta.jsp new file mode 100644 index 0000000..b0ea903 --- /dev/null +++ b/src/main/webapp/common/meta.jsp @@ -0,0 +1,29 @@ +<%@ page language="java" contentType="text/html; charset=UTF-8" + pageEncoding="UTF-8"%> + +<%@ include file="taglibs.jsp" %> + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/common/nav.jsp b/src/main/webapp/common/nav.jsp new file mode 100644 index 0000000..a69dc3c --- /dev/null +++ b/src/main/webapp/common/nav.jsp @@ -0,0 +1,10 @@ +<%@ include file="taglibs.jsp" %> + \ No newline at end of file diff --git a/src/main/webapp/common/taglibs.jsp b/src/main/webapp/common/taglibs.jsp new file mode 100644 index 0000000..4e56140 --- /dev/null +++ b/src/main/webapp/common/taglibs.jsp @@ -0,0 +1,3 @@ +<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> +<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %> \ No newline at end of file diff --git a/src/main/webapp/css/login.css b/src/main/webapp/css/login.css new file mode 100644 index 0000000..b327206 --- /dev/null +++ b/src/main/webapp/css/login.css @@ -0,0 +1,60 @@ +body { + padding-top: 40px; + padding-bottom: 40px; + background-color: #eee; +} + +.form-signin { + max-width: 330px; + padding: 15px; + margin: 0 auto; +} +.form-signin .form-signin-heading, +.form-signin .checkbox { + margin-bottom: 10px; +} +.form-signin .checkbox { + font-weight: normal; +} +.form-signin .form-control { + position: relative; + height: auto; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 10px; + font-size: 16px; +} +.form-signin .form-control:focus { + z-index: 2; +} +.form-signin input[type="email"] { + margin-bottom: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} +.form-signin input[type="password"] { + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} +.error { + padding: 15px; + margin-bottom: 20px; + border: 1px solid transparent; + border-radius: 4px; + color: #a94442; + background-color: #f2dede; + border-color: #ebccd1; +} + +.msg { + padding: 15px; + margin-bottom: 20px; + border: 1px solid transparent; + border-radius: 4px; + color: #31708f; + background-color: #d9edf7; + border-color: #bce8f1; +} + diff --git a/src/main/webapp/css/logout.css b/src/main/webapp/css/logout.css new file mode 100644 index 0000000..c74b9f7 --- /dev/null +++ b/src/main/webapp/css/logout.css @@ -0,0 +1,7 @@ +a.logoutButton { + float: right; + color: #337ab7; + text-decoration: none; + position: relative; + top: 15px; +} diff --git a/src/main/webapp/css/sos.css b/src/main/webapp/css/sos.css new file mode 100644 index 0000000..743949a --- /dev/null +++ b/src/main/webapp/css/sos.css @@ -0,0 +1,83 @@ +@CHARSET "UTF-8"; + +body { + font-family: sans-serif; + margin:0px; +} + +#header { + width:85%; + height:40px; + margin-top:20px; + margin-left:auto; + margin-right:auto; + border-bottom: 1px solid #DFE2DB; +} + +#header h1 { + margin:0px; + float:left; +} + +#navigation { + width:85%; + margin-left:auto; + margin-right:auto; + margin-top: 30px; +} + +.content { + width:85%; + margin-left:auto; + margin-right:auto; +} + +table { + width:100%; +} + + +th { + background-color: #585858; + height:25px; +} + +tr { + +} + +td { + /*background-color: #DFE2DB;*/ + height:30px; +} + +.myOdd { + background-color: yellow; +} + +.myEven { + background-color: green; +} + +/* Create Customer Page table styles... */ + +table.create-form-table { + width:700px; +} + +/*align all table cells to right aligned*/ +table.create-form-table tr td { + text-align:right; + width:250px; +} + +/*styling for input textbox*/ +table.create-form-table tr td input[type="text"] { + + width:200px; +} + +.error { + text-align:left; + color: #ff0000; +} diff --git a/src/main/webapp/customers/customerDetails.jsp b/src/main/webapp/customers/customerDetails.jsp new file mode 100644 index 0000000..d251e35 --- /dev/null +++ b/src/main/webapp/customers/customerDetails.jsp @@ -0,0 +1,82 @@ +<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %> +<%@ include file="/common/taglibs.jsp" %> + + + +
+ +
+

${customer.firstName} ${customer.lastName}

+ + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + ${customer.firstName} +
+ + + ${customer.lastName} +
+ + + ${customer.dateOfBirth} +
+ + + ${customer.email} +
+
+ + +
+ + +


+ + + + + + + + + + + + + + + +
+ +
+ diff --git a/src/main/webapp/customers/customers-createCustomer.jsp b/src/main/webapp/customers/customers-createCustomer.jsp new file mode 100644 index 0000000..7aaf877 --- /dev/null +++ b/src/main/webapp/customers/customers-createCustomer.jsp @@ -0,0 +1,94 @@ +<%@ include file="/common/taglibs.jsp" %> + +
+ + <%-- enctype="multipart/form-data" --%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Create Customer

+
Firstname:
Lastname:
Date of Birth (DD-MM-YYYY):
Email address:
House/Flat No:
Street:
Postcode:
City:
Country:

Payment Details

Card No.:
Card Exp Date (DD-MM-YYYY):
Customer Reference:
+ + + + +
+
+
+ diff --git a/src/main/webapp/customers/customers.jsp b/src/main/webapp/customers/customers.jsp new file mode 100644 index 0000000..5718dfb --- /dev/null +++ b/src/main/webapp/customers/customers.jsp @@ -0,0 +1,53 @@ +<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %> +<%@ include file="/common/taglibs.jsp" %> + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + +
NameDate Of BirthEmail AddressAddressDeleteEdit
${customer.firstName} ${customer.lastName}${customer.dateOfBirth}${customer.email}${customer.address.houseFlatNo}, ${customer.address.street}, ${customer.address.city}, ${customer.address.postCode}, ${customer.address.country}DeleteEdit
+ + + + + <%-- + + ${customer.firstName} ${customer.lastName} + ${customer.dateOfBirth} + ${customer.email} + + ${customer.address.houseFlatNo}, ${customer.address.street}, ${customer.address.city}, ${customer.address.postCode}, ${customer.address.country} + + Delete + Edit + --%> + +
+ diff --git a/src/main/webapp/items/items-create.jsp b/src/main/webapp/items/items-create.jsp new file mode 100644 index 0000000..3f31943 --- /dev/null +++ b/src/main/webapp/items/items-create.jsp @@ -0,0 +1,34 @@ +<%@ include file="/common/taglibs.jsp" %> + +
+

Create Item

+ + + + + + + + + + + + + + + + +
Item Name: + + + +
Item Price (₹): + + + +
+ +
+
+
+ diff --git a/src/main/webapp/items/items.jsp b/src/main/webapp/items/items.jsp new file mode 100644 index 0000000..c15e89a --- /dev/null +++ b/src/main/webapp/items/items.jsp @@ -0,0 +1,24 @@ +<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %> +<%@ include file="/common/taglibs.jsp" %> + + +
+
+ +
+ + + + ${item.itemName} + ${item.itemPrice} + + +
+ + diff --git a/src/main/webapp/login/login.jsp b/src/main/webapp/login/login.jsp new file mode 100644 index 0000000..2b88534 --- /dev/null +++ b/src/main/webapp/login/login.jsp @@ -0,0 +1,44 @@ +<%@ include file="/common/meta.jsp" %> + + + " rel="stylesheet"> + + Login + + + + + +
+ + + +
+ + + + + + diff --git a/src/main/webapp/orders/orders-createOrder.jsp b/src/main/webapp/orders/orders-createOrder.jsp new file mode 100644 index 0000000..2ae52ab --- /dev/null +++ b/src/main/webapp/orders/orders-createOrder.jsp @@ -0,0 +1,44 @@ +<%@ include file="/common/taglibs.jsp" %> + +
+

Create Order

+ + + + + + + + + + + + + + + + + +
+ Customer: + + ${createOrderForm.customer.firstName} ${createOrderForm.customer.lastName} + + +
Items: +<%-- --%> + + + +
+ + + +
+
+
+ diff --git a/src/main/webapp/orders/orders.jsp b/src/main/webapp/orders/orders.jsp new file mode 100644 index 0000000..e9226a4 --- /dev/null +++ b/src/main/webapp/orders/orders.jsp @@ -0,0 +1,23 @@ +<%@ taglib prefix="datatables" uri="http://github.com/dandelion/datatables" %> +<%@ include file="/common/taglibs.jsp" %> + + +
+
+ + + + orderId + ${order.customer.firstName} ${order.customer.lastName} + + ${order.customer.address.houseFlatNo}, ${order.customer.address.street}, ${order.customer.address.city}, ${order.customer.address.postCode}, ${order.customer.address.country} + + + +
+ +