diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/AddressRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/AddressRepository.java
index 795a73c..87e1cdd 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/AddressRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/AddressRepository.java
@@ -1,33 +1,12 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
-
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Address;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.Customer;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.Store;
-
-public interface AddressRepository extends CrudRepository
{
+import org.springframework.data.repository.CrudRepository;
- /**
- * Find address via address id
- * @param id
- * @return address (Address)
- *
- *
- * */
-
+public interface AddressRepository extends CrudRepository {
Address findAddressById(int id);
-
- /**
- * Find address via the city
- * @param city
- * @return address (Address)
- *
- * */
-
-
-
+
Address findAddressByCity(String city);
}
\ No newline at end of file
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/CategoryRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/CategoryRepository.java
index 724cceb..29ee8fd 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/CategoryRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/CategoryRepository.java
@@ -1,36 +1,36 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Category;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Product;
+import org.springframework.data.repository.CrudRepository;
public interface CategoryRepository extends CrudRepository {
-
- /**
- * Find category by id
- * @param id
- * @return category(Category)
- *
- *
- * */
+
+ /**
+ * Find category by id
+ *
+ * @param id
+ * @return category(Category)
+ */
Category findCategoryById(int id);
-
+
/**
* Find category by the name
+ *
* @param name
* @return category(Category)
- *
- * */
+ */
Category findCategoryByname(String name);
-
+
/**
* Find category by the product
+ *
* @param product
* @return category(Category)
- * */
-
-
+ */
+
+
Category findCategoryByProduct(Product product);
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/CustomerRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/CustomerRepository.java
index e2d68e3..731a8ab 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/CustomerRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/CustomerRepository.java
@@ -1,14 +1,12 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
-
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.Address;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Customer;
+import org.springframework.data.repository.CrudRepository;
public interface CustomerRepository extends CrudRepository {
-
- Customer findCustomberById(int id);
+
+ Customer findCustomerById(int id);
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/EmployeeRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/EmployeeRepository.java
index cf1a865..e5f9de0 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/EmployeeRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/EmployeeRepository.java
@@ -1,18 +1,17 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Employee;
+import org.springframework.data.repository.CrudRepository;
-public interface EmployeeRepository extends CrudRepository{
+public interface EmployeeRepository extends CrudRepository {
-
- /**
- * Find an employee via id
- * @param id
- * @return employee(Employee)
- *
- *
- * */
+
+ /**
+ * Find an employee via id
+ *
+ * @param id
+ * @return employee(Employee)
+ */
Employee findEmployeeById(int id);
-
+
}
\ No newline at end of file
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryOrderRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryOrderRepository.java
index caaf670..488a988 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryOrderRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryOrderRepository.java
@@ -1,18 +1,17 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.GroceryOrder;
+import org.springframework.data.repository.CrudRepository;
public interface GroceryOrderRepository extends CrudRepository {
- /**
- * Find grocery order via id
- * @param id
- * @param groceryOrder (GroceryOrder)
- *
- *
- * */
-
+ /**
+ * Find grocery order via id
+ *
+ * @param id
+ * @param groceryOrder (GroceryOrder)
+ */
+
GroceryOrder findGroceryOrderById(int id);
}
\ No newline at end of file
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryStoreApplicationRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryStoreApplicationRepository.java
index 92da6fb..0a5d085 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryStoreApplicationRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryStoreApplicationRepository.java
@@ -1,33 +1,15 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
-
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.Category;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.GroceryOrder;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.GroceryStoreApplication;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.GroceryUser;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.Product;
+import org.springframework.data.repository.CrudRepository;
public interface GroceryStoreApplicationRepository extends CrudRepository {
- /**
- * Find GroceryStore Application via id
- * @param id
- * @return groceryStoreApplication(GroceryStoreApplication)
- *
- *
- * */
-
+ /**
+ * Find GroceryStore Application via id
+ *
+ * @param id
+ * @return groceryStoreApplication(GroceryStoreApplication)
+ */
GroceryStoreApplication findGroceryStoreApplicationById(int id);
- // GroceryStoreApplication finGroceryOrderByGroceryUser(GroceryUser user);
- // GroceryStoreApplication finGroceryOrderByProducet(Product product);
- // GroceryStoreApplication finGroceryOrderCategoryd(Category category);
- // GroceryStoreApplication finGroceryOrderByGroceryOrder(GroceryOrder order);
- // boolean existsByGroceryUserAndProduct(GroceryUser user, Product product);
- // boolean existsByGroceryUserAndGroceryOrder(GroceryUser user, GroceryOrder order);
- // boolean existsByCategroyAndGroceryOrder(Category category, GroceryOrder order);
-
-
-
-
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryUserRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryUserRepository.java
index cb323ae..6895902 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryUserRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/GroceryUserRepository.java
@@ -1,20 +1,18 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
+import ca.mcgill.ecse321.GroceryApplicationBackend.model.GroceryUser;
import org.springframework.data.repository.CrudRepository;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.GroceryUser;
+public interface GroceryUserRepository extends CrudRepository {
-public interface GroceryUserRepository extends CrudRepository {
-
-
- /**
- * Find grocery user via email
- * @param email
- * @return groceryUser(GroceryUser)
- *
- * */
- GroceryUser findGroceryUserByEmail(String email);
+ /**
+ * Find grocery user via email
+ *
+ * @param email
+ * @return groceryUser(GroceryUser)
+ */
+ GroceryUser findGroceryUserByEmail(String email);
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ManagerRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ManagerRepository.java
index b9705ec..fee94fe 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ManagerRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ManagerRepository.java
@@ -1,22 +1,19 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
+import ca.mcgill.ecse321.GroceryApplicationBackend.model.Manager;
import org.springframework.data.repository.CrudRepository;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.Manager;
+public interface ManagerRepository extends CrudRepository {
-public interface ManagerRepository extends CrudRepository {
-
-
- /**
- * Find manager via Id
- * @param id
- * @return manager(Manager)
- *
- * */
- Manager findManagerById(int Id);
-
-
+ /**
+ * Find manager via Id
+ *
+ * @param id
+ * @return manager(Manager)
+ */
+ Manager findManagerById(int Id);
+
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/PaymentRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/PaymentRepository.java
index d645ded..58c3684 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/PaymentRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/PaymentRepository.java
@@ -1,16 +1,16 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
-
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Payment;
+import org.springframework.data.repository.CrudRepository;
public interface PaymentRepository extends CrudRepository {
-
-
- /**
- * Find payment via id
- * @param id
- * @return payment (Payment)
- * */
- Payment findPaymentById(int id);
+
+
+ /**
+ * Find payment via id
+ *
+ * @param id
+ * @return payment (Payment)
+ */
+ Payment findPaymentById(int id);
}
\ No newline at end of file
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ProductRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ProductRepository.java
index 2b9fc43..a8a4f11 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ProductRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ProductRepository.java
@@ -1,43 +1,39 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-// package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
-// import org.springframework.data.repository.CrudRepository;
-
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.GroceryOrder;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Product;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Product.Availability;
+import org.springframework.data.repository.CrudRepository;
+
+public interface ProductRepository extends CrudRepository {
-public interface ProductRepository extends CrudRepository {
+ /**
+ * Find product via their name
+ *
+ * @param name
+ * @return product(Product)
+ */
+ Product findProductByName(String name);
- /**
- * Find product via their name
- * @param name
- * @return product(Product)
- *
- * */
- Product findProductByName(String name);
-
- /**
- * Find product via their barcode
- * @param barcode
- * @return product (Product)
- *
- * */
+ /**
+ * Find product via their barcode
+ *
+ * @param barcode
+ * @return product (Product)
+ */
- Product findProductByBarcode(int barcode);
-
- /**
- * Find product via availability
- * @param availability
- * @return product (Product)
- * */
+ Product findProductByBarcode(int barcode);
+ /**
+ * Find product via availability
+ *
+ * @param availability
+ * @return product (Product)
+ */
- Product findProductByAvailability (Availability availability);
+ Product findProductByAvailability(Availability availability);
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ShiftRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ShiftRepository.java
index 43ac6a7..4865125 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ShiftRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/ShiftRepository.java
@@ -1,25 +1,25 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Employee;
import ca.mcgill.ecse321.GroceryApplicationBackend.model.Shift;
+import org.springframework.data.repository.CrudRepository;
-public interface ShiftRepository extends CrudRepository{
+public interface ShiftRepository extends CrudRepository {
- /**
- * Find shift by id
- * @param id
- * @return shift(Shift)
- *
- * */
+ /**
+ * Find shift by id
+ *
+ * @param id
+ * @return shift(Shift)
+ */
Shift findShiftById(int id);
-
+
/**
* Find shift by employee
+ *
* @param employee
* @return shift(Shift)
- *
- * */
+ */
Shift findShiftByEmployee(Employee employee);
}
\ No newline at end of file
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/StoreRepository.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/StoreRepository.java
index b17039b..899eaed 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/StoreRepository.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/StoreRepository.java
@@ -1,22 +1,20 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import org.springframework.data.repository.CrudRepository;
+import ca.mcgill.ecse321.GroceryApplicationBackend.model.Store;
import org.springframework.data.repository.CrudRepository;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.Store;
+public interface StoreRepository extends CrudRepository {
+
+
+ /**
+ * Find store via their name
+ *
+ * @param name
+ * @return store(Store)
+ */
+ Store findStoreByName(String name);
+
-public interface StoreRepository extends CrudRepository {
-
-
- /**
- * Find store via their name
- * @param name
- * @return store(Store)
- * */
- Store findStoreByName(String name);
-
+ // boolean existsByStoreName(String name);
-
- // boolean existsByStoreName(String name);
-
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Address.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Address.java
index b6c5128..a60be9a 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Address.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Address.java
@@ -1,6 +1,9 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.model;
-import javax.persistence.*;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
import java.util.Set;
@Entity
@@ -17,59 +20,57 @@ public class Address {
// associations
private Set order1;
private Set order;
-
- public void setStreetNumber(int value) {
- this.streetNumber = value;
- }
+ private String country;
+ private String postalCode;
public int getStreetNumber() {
return this.streetNumber;
}
- public void setStreetName(String value) {
- this.streetName = value;
+ public void setStreetNumber(int value) {
+ this.streetNumber = value;
}
public String getStreetName() {
return this.streetName;
}
- public void setCity(String value) {
- this.city = value;
+ public void setStreetName(String value) {
+ this.streetName = value;
}
public String getCity() {
return this.city;
}
- private String country;
-
- public void setCountry(String value) {
- this.country = value;
+ public void setCity(String value) {
+ this.city = value;
}
public String getCountry() {
return this.country;
}
- private String postalCode;
-
- public void setPostalCode(String value) {
- this.postalCode = value;
+ public void setCountry(String value) {
+ this.country = value;
}
public String getPostalCode() {
return this.postalCode;
}
- public void setProvince(String value) {
- this.province = value;
+ public void setPostalCode(String value) {
+ this.postalCode = value;
}
public String getProvince() {
return this.province;
}
+ public void setProvince(String value) {
+ this.province = value;
+ }
+
@OneToOne(mappedBy = "address")
public Customer getCustomer() {
return this.customer;
@@ -107,12 +108,12 @@ public void setOrder1(Set order1s) {
this.order1 = order1s;
}
- public void setId(int id) {
- this.id = id;
- }
-
@Id
public int getId() {
return id;
}
+
+ public void setId(int id) {
+ this.id = id;
+ }
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Category.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Category.java
index c319c46..3bcef71 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Category.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Category.java
@@ -1,11 +1,10 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.model;
+import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
-
-import javax.persistence.Entity;
-import java.util.Set;
import javax.persistence.OneToMany;
+import java.util.Set;
@Entity
public class Category {
@@ -28,33 +27,28 @@ public void setGroceryStoreApplication(GroceryStoreApplication groceryStoreAppli
this.groceryStoreApplication = groceryStoreApplication;
}
- public void setName(String value) {
- this.name = value;
- }
-
public String getName() {
return this.name;
}
- public void setDescription(String value) {
- this.description = value;
+ public void setName(String value) {
+ this.name = value;
}
public String getDescription() {
return this.description;
}
-
- public void setImage(String value) {
- this.image = value;
+ public void setDescription(String value) {
+ this.description = value;
}
public String getImage() {
return this.image;
}
- public void setId(int value) {
- this.id = value;
+ public void setImage(String value) {
+ this.image = value;
}
@Id
@@ -62,6 +56,10 @@ public int getId() {
return this.id;
}
+ public void setId(int value) {
+ this.id = value;
+ }
+
@OneToMany(mappedBy = "category")
public Set getProduct() {
return this.product;
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Customer.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Customer.java
index 4730e3c..b2f188a 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Customer.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Customer.java
@@ -7,6 +7,7 @@
public class Customer extends UserRole {
// associations
private Address address;
+ private Set order;
@OneToOne(cascade = {CascadeType.ALL}, optional = false)
@JoinColumn(name = "addr_id", referencedColumnName = "id")
@@ -18,8 +19,6 @@ public void setAddress(Address address) {
this.address = address;
}
- private Set order;
-
@OneToMany(mappedBy = "customer")
public Set getOrder() {
return this.order;
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Employee.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Employee.java
index 9103e93..18e4094 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Employee.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Employee.java
@@ -1,11 +1,11 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.model;
-import javax.persistence.Entity;
-import java.sql.Date;
-import java.util.Set;
import javax.persistence.CascadeType;
+import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.OneToMany;
+import java.sql.Date;
+import java.util.Set;
@Entity
public class Employee extends UserRole {
@@ -18,30 +18,30 @@ public class Employee extends UserRole {
// associations
private Set shift;
- public void setHiredDate(Date value) {
- this.hiredDate = value;
- }
-
public Date getHiredDate() {
return this.hiredDate;
}
- public void setHourlyPay(float value) {
- this.hourlyPay = value;
+ public void setHiredDate(Date value) {
+ this.hiredDate = value;
}
public float getHourlyPay() {
return this.hourlyPay;
}
- public void setStatus(EmployeeStatus value) {
- this.status = value;
+ public void setHourlyPay(float value) {
+ this.hourlyPay = value;
}
public EmployeeStatus getStatus() {
return this.status;
}
+ public void setStatus(EmployeeStatus value) {
+ this.status = value;
+ }
+
@OneToMany(mappedBy = "employee", cascade = {CascadeType.ALL})
public Set getShift() {
return this.shift;
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryOrder.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryOrder.java
index 9f71d78..0f988fb 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryOrder.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryOrder.java
@@ -6,14 +6,6 @@
@Entity
public class GroceryOrder {
- public enum PurchaseType {
- INSTORE, ONLINE
- }
-
- public enum OrderStatus {
- INCART, PLACED, READY_FOR_PICKUP, PICKED_UP, SHIPPED, DELIVERED, CANCELLED, PURCHASED_IN_STORE
- }
-
// attributes
@Enumerated
private OrderStatus status;
@@ -24,7 +16,6 @@ public enum OrderStatus {
@Enumerated
private PurchaseType purchaseType;
private Payment payment;
-
// associations
private GroceryStoreApplication groceryStoreApplication;
private Set product;
@@ -41,16 +32,12 @@ public void setGroceryStoreApplication(GroceryStoreApplication groceryStoreAppli
this.groceryStoreApplication = groceryStoreApplication;
}
- public void setStatus(OrderStatus value) {
- this.status = value;
- }
-
private OrderStatus getStatus() {
return this.status;
}
- public void setId(int value) {
- this.id = value;
+ public void setStatus(OrderStatus value) {
+ this.status = value;
}
@Id
@@ -58,38 +45,42 @@ public int getId() {
return this.id;
}
- public void setDatePlaced(Date value) {
- this.datePlaced = value;
+ public void setId(int value) {
+ this.id = value;
}
public Date getDatePlaced() {
return this.datePlaced;
}
- public void setDeliveryDate(Date value) {
- this.deliveryDate = value;
+ public void setDatePlaced(Date value) {
+ this.datePlaced = value;
}
public Date getDeliveryDate() {
return this.deliveryDate;
}
- public void setCustomerNote(String value) {
- this.customerNote = value;
+ public void setDeliveryDate(Date value) {
+ this.deliveryDate = value;
}
public String getCustomerNote() {
return this.customerNote;
}
- public void setPurchaseType(PurchaseType value) {
- this.purchaseType = value;
+ public void setCustomerNote(String value) {
+ this.customerNote = value;
}
private PurchaseType getPurchaseType() {
return this.purchaseType;
}
+ public void setPurchaseType(PurchaseType value) {
+ this.purchaseType = value;
+ }
+
@ManyToOne
public Customer getCustomer() {
return this.customer;
@@ -135,4 +126,12 @@ public void setProduct(Set products) {
this.product = products;
}
+ public enum PurchaseType {
+ INSTORE, ONLINE
+ }
+
+ public enum OrderStatus {
+ INCART, PLACED, READY_FOR_PICKUP, PICKED_UP, SHIPPED, DELIVERED, CANCELLED, PURCHASED_IN_STORE
+ }
+
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryStoreApplication.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryStoreApplication.java
index ff77e82..2ba77df 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryStoreApplication.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryStoreApplication.java
@@ -61,12 +61,12 @@ public void setCategory(Set categorys) {
this.category = categorys;
}
- public void setId(int id) {
- this.id = id;
- }
-
@Id
public int getId() {
return id;
}
+
+ public void setId(int id) {
+ this.id = id;
+ }
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryUser.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryUser.java
index 65e14f9..d5d677a 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryUser.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/GroceryUser.java
@@ -26,40 +26,36 @@ public void setUserRole(Set userRoles) {
this.userRole = userRoles;
}
- public void setUsername(String value) {
- this.username = value;
- }
-
public String getUsername() {
return this.username;
}
- public void setPassword(String value) {
- this.password = value;
+ public void setUsername(String value) {
+ this.username = value;
}
public String getPassword() {
return this.password;
}
- public void setFirstName(String value) {
- this.firstName = value;
+ public void setPassword(String value) {
+ this.password = value;
}
public String getFirstName() {
return this.firstName;
}
- public void setLastName(String value) {
- this.lastName = value;
+ public void setFirstName(String value) {
+ this.firstName = value;
}
public String getLastName() {
return this.lastName;
}
- public void setEmail(String value) {
- this.email = value;
+ public void setLastName(String value) {
+ this.lastName = value;
}
@Id
@@ -67,11 +63,15 @@ public String getEmail() {
return this.email;
}
- public void setDateOfBirth(String value) {
- this.dateOfBirth = value;
+ public void setEmail(String value) {
+ this.email = value;
}
public String getDateOfBirth() {
return this.dateOfBirth;
}
+
+ public void setDateOfBirth(String value) {
+ this.dateOfBirth = value;
+ }
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Payment.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Payment.java
index 555bdcc..c78189b 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Payment.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Payment.java
@@ -7,55 +7,48 @@
@Entity
public class Payment {
- // enums
- public enum PaymentType {
- CREDIT, DEBIT, GIFTCARD
- }
-
// attributes
private int id;
private float amount;
@Enumerated
private PaymentType paymentType;
private String paymentCode;
-
// associations
private GroceryOrder order;
- public void setId(int value) {
- this.id = value;
- }
-
@Id
public int getId() {
return this.id;
}
- public void setAmount(float value) {
- this.amount = value;
+ public void setId(int value) {
+ this.id = value;
}
public float getAmount() {
return this.amount;
}
-
- public void setPaymentCode(String value) {
- this.paymentCode = value;
+ public void setAmount(float value) {
+ this.amount = value;
}
public String getPaymentCode() {
return this.paymentCode;
}
- public void setPaymentType(PaymentType value) {
- this.paymentType = value;
+ public void setPaymentCode(String value) {
+ this.paymentCode = value;
}
public PaymentType getPaymentType() {
return this.paymentType;
}
+ public void setPaymentType(PaymentType value) {
+ this.paymentType = value;
+ }
+
@OneToOne(optional = false)
public GroceryOrder getOrder() {
return this.order;
@@ -65,4 +58,9 @@ public void setOrder(GroceryOrder order) {
this.order = order;
}
+ // enums
+ public enum PaymentType {
+ CREDIT, DEBIT, GIFTCARD
+ }
+
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Product.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Product.java
index 3d98cee..9d1928d 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Product.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Product.java
@@ -23,11 +23,6 @@ public class Product {
private Set order;
private GroceryStoreApplication groceryStoreApplication;
- // enums
- public enum Availability {
- PICKUP, IN_STORE, DELIVERY, UNRESTRICTED
- }
-
@ManyToOne(optional = false)
public GroceryStoreApplication getGroceryStoreApplication() {
return this.groceryStoreApplication;
@@ -37,69 +32,60 @@ public void setGroceryStoreApplication(GroceryStoreApplication groceryStoreAppli
this.groceryStoreApplication = groceryStoreApplication;
}
- public void setName(String value) {
- this.name = value;
- }
-
public String getName() {
return this.name;
}
-
- public void setDescription(String value) {
- this.description = value;
+ public void setName(String value) {
+ this.name = value;
}
public String getDescription() {
return this.description;
}
-
- public void setPrice(float value) {
- this.price = value;
+ public void setDescription(String value) {
+ this.description = value;
}
public float getPrice() {
return this.price;
}
- public void setImage(String value) {
- this.image = value;
+ public void setPrice(float value) {
+ this.price = value;
}
public String getImage() {
return this.image;
}
-
- public void setWeight(float value) {
- this.weight = value;
+ public void setImage(String value) {
+ this.image = value;
}
public float getWeight() {
return this.weight;
}
-
- public void setVolume(float value) {
- this.volume = value;
+ public void setWeight(float value) {
+ this.weight = value;
}
public float getVolume() {
return this.volume;
}
- public void setAvailability(Availability value) {
- this.availability = value;
+ public void setVolume(float value) {
+ this.volume = value;
}
public Availability getAvailability() {
return this.availability;
}
-
- public void setBarcode(int value) {
- this.barcode = value;
+ public void setAvailability(Availability value) {
+ this.availability = value;
}
@Id
@@ -107,24 +93,26 @@ public int getBarcode() {
return this.barcode;
}
-
- public void setIsRefundable(boolean value) {
- this.isRefundable = value;
+ public void setBarcode(int value) {
+ this.barcode = value;
}
public boolean isIsRefundable() {
return this.isRefundable;
}
-
- public void setAvailableQuantity(int value) {
- this.availableQuantity = value;
+ public void setIsRefundable(boolean value) {
+ this.isRefundable = value;
}
public int getAvailableQuantity() {
return this.availableQuantity;
}
+ public void setAvailableQuantity(int value) {
+ this.availableQuantity = value;
+ }
+
@ManyToOne(optional = false)
public Category getCategory() {
return this.category;
@@ -143,4 +131,9 @@ public void setOrder(Set orders) {
this.order = orders;
}
+ // enums
+ public enum Availability {
+ PICKUP, IN_STORE, DELIVERY, UNRESTRICTED
+ }
+
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Shift.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Shift.java
index a45927d..c6ba527 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Shift.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Shift.java
@@ -7,32 +7,22 @@
@Entity
public class Shift {
- // enums
- public enum ShiftType {
- OPENING, CLOSING
- }
-
- public enum Day {
- MONDAY, THUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
- }
-
// attributes
private Day day;
private int id;
@Enumerated
private ShiftType shift;
-
// associations
private Employee employee;
- public void setDay(Day value) {
- this.day = value;
- }
-
public Day getDay() {
return this.day;
}
+ public void setDay(Day value) {
+ this.day = value;
+ }
+
@ManyToOne(optional = false)
public Employee getEmployee() {
return this.employee;
@@ -42,22 +32,30 @@ public void setEmployee(Employee employee) {
this.employee = employee;
}
+ public ShiftType getShift() {
+ return this.shift;
+ }
public void setShift(ShiftType value) {
this.shift = value;
}
- public ShiftType getShift() {
- return this.shift;
+ @Id
+ public int getId() {
+ return this.id;
}
public void setId(int value) {
this.id = value;
}
- @Id
- public int getId() {
- return this.id;
+ // enums
+ public enum ShiftType {
+ OPENING, CLOSING
+ }
+
+ public enum Day {
+ MONDAY, THUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
}
}
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Store.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Store.java
index efbe1c9..c17477e 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Store.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/Store.java
@@ -1,7 +1,6 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.model;
import javax.persistence.*;
-
import java.sql.Time;
@Entity
@@ -26,47 +25,47 @@ public void setGroceryStoreApplication(GroceryStoreApplication groceryStoreAppli
this.groceryStoreApplication = groceryStoreApplication;
}
- public void setName(String value) {
- this.name = value;
- }
-
@Id
public String getName() {
return this.name;
}
- public void setWeekDayOpening(Time value) {
- this.weekDayOpening = value;
+ public void setName(String value) {
+ this.name = value;
}
public Time getWeekDayOpening() {
return this.weekDayOpening;
}
- public void setWeekDayClosing(Time value) {
- this.weekDayClosing = value;
+ public void setWeekDayOpening(Time value) {
+ this.weekDayOpening = value;
}
public Time getWeekDayClosing() {
return this.weekDayClosing;
}
- public void setWeekEndOpening(Time value) {
- this.weekEndOpening = value;
+ public void setWeekDayClosing(Time value) {
+ this.weekDayClosing = value;
}
public Time getWeekEndOpening() {
return this.weekEndOpening;
}
- public void setWeekEndClosing(Time value) {
- this.weekEndClosing = value;
+ public void setWeekEndOpening(Time value) {
+ this.weekEndOpening = value;
}
public Time getWeekEndClosing() {
return this.weekEndClosing;
}
+ public void setWeekEndClosing(Time value) {
+ this.weekEndClosing = value;
+ }
+
@OneToOne(cascade = {CascadeType.ALL}, optional = false)
@JoinColumn(name = "addr_id", referencedColumnName = "id")
public Address getAddress() {
diff --git a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/UserRole.java b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/UserRole.java
index ac0ebc6..4c611b1 100644
--- a/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/UserRole.java
+++ b/GroceryApplication-Backend/src/main/java/ca/mcgill/ecse321/GroceryApplicationBackend/model/UserRole.java
@@ -30,12 +30,12 @@ public void setUser(GroceryUser user) {
this.user = user;
}
- public void setId(int value) {
- this.id = value;
- }
-
@Id
public int getId() {
return this.id;
}
+
+ public void setId(int value) {
+ this.id = value;
+ }
}
diff --git a/GroceryApplication-Backend/src/test/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/TestGroceryApplicationPersistence.java b/GroceryApplication-Backend/src/test/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/TestGroceryApplicationPersistence.java
index 01ae8db..0c80d68 100644
--- a/GroceryApplication-Backend/src/test/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/TestGroceryApplicationPersistence.java
+++ b/GroceryApplication-Backend/src/test/java/ca/mcgill/ecse321/GroceryApplicationBackend/dao/TestGroceryApplicationPersistence.java
@@ -1,11 +1,8 @@
package ca.mcgill.ecse321.GroceryApplicationBackend.dao;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.util.HashSet;
-import java.util.Set;
-
+import ca.mcgill.ecse321.GroceryApplicationBackend.model.*;
+import ca.mcgill.ecse321.GroceryApplicationBackend.model.Product.Availability;
+import ca.mcgill.ecse321.GroceryApplicationBackend.model.Shift.Day;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -13,9 +10,11 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.*;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.Product.Availability;
-import ca.mcgill.ecse321.GroceryApplicationBackend.model.Shift.Day;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
@ExtendWith(SpringExtension.class)
@@ -79,6 +78,8 @@ public void clearDatabase() {
@Test
public void testPersistAndLoadStore() {
+ //create a grocery store application
+ //mandatory to create for a store to exist
GroceryStoreApplication gs = new GroceryStoreApplication();
gs.setId(66);
groceryStoreApplicationRepository.save(gs);
@@ -95,9 +96,6 @@ public void testPersistAndLoadStore() {
store.setName(name);
storeRepository.save(store);
- address = null;
- store = null;
-
store = storeRepository.findStoreByName(name);
address = addressRepository.findAddressById(id);
assertNotNull(store);
@@ -112,19 +110,17 @@ public void testPersistAndLoadStore() {
public void testPersistAndLoadCategory() {
Set productSet = new HashSet();
-
+ //create a grocery store application
+ //mandatory to create for a store to exist
GroceryStoreApplication gs = new GroceryStoreApplication();
gs.setId(66);
groceryStoreApplicationRepository.save(gs);
int id = 11;
- // String name = "perishable";
- // String image = "image";
- // String desc = "desc";
+
Category category = new Category();
category.setId(id);
- // category.setName(name);
category.setGroceryStoreApplication(gs);
category.setName("meat");
categoryRepository.save(category);
@@ -145,8 +141,6 @@ public void testPersistAndLoadCategory() {
productSet.add(product1);
category.setProduct(productSet);
- category = null;
-
category = categoryRepository.findCategoryById(id);
productSet = category.getProduct();
@@ -159,7 +153,8 @@ public void testPersistAndLoadCategory() {
@Test
public void testPersistAndLoadAddress() {
-
+ //create a grocery store application
+ //mandatory to create for a store to exist
GroceryStoreApplication groceryStoreApplication = new GroceryStoreApplication();
groceryStoreApplication.setId(90);
groceryStoreApplicationRepository.save(groceryStoreApplication);
@@ -189,8 +184,6 @@ public void testPersistAndLoadAddress() {
storeRepository.save(store);
addressRepository.save(address);
- address = null;
- store = null;
store = storeRepository.findStoreByName(storeName);
address = store.getAddress();
assertNotNull(address);
@@ -216,7 +209,8 @@ public void testPersistAndLoadProduct() {
boolean refund = false;
float volume = 20f;
int quantity = 30;
-
+ //create a grocery store application
+ //mandatory to create for a store to exist
GroceryStoreApplication groceryStoreApplication = new GroceryStoreApplication();
groceryStoreApplication.setId(90);
groceryStoreApplicationRepository.save(groceryStoreApplication);
@@ -241,9 +235,6 @@ public void testPersistAndLoadProduct() {
product.setAvailability(Availability.DELIVERY);
productRepository.save(product);
- product = null;
- category = null;
-
product = productRepository.findProductByBarcode(barCode);
category = product.getCategory();
assertNotNull(product);
@@ -258,7 +249,8 @@ public void testPersistAndLoadProduct() {
@Test
public void testPersistAndLoadShift() {
-
+ //create a grocery store application
+ //mandatory to create for a store to exist
GroceryStoreApplication gs = new GroceryStoreApplication();
gs.setId(222);
groceryStoreApplicationRepository.save(gs);
@@ -275,8 +267,6 @@ public void testPersistAndLoadShift() {
shift.setEmployee(employee);
shiftRepository.save(shift);
- shift = null;
- employee = null;
shift = shiftRepository.findShiftById(111);
employee = shift.getEmployee();
@@ -292,6 +282,8 @@ public void testPersistAndLoadShift() {
@Test
public void testPersistAndLoadGroceryOrder() {
+ //create a grocery store application
+ //mandatory to create for a store to exist
GroceryStoreApplication gs = new GroceryStoreApplication();
gs.setId(011);
groceryStoreApplicationRepository.save(gs);
@@ -308,9 +300,6 @@ public void testPersistAndLoadGroceryOrder() {
order.setBillingAddress(address);
groceryOrderRepository.save(order);
- order = null;
- address = null;
-
order = groceryOrderRepository.findGroceryOrderById(999);
address = order.getBillingAddress();
assertNotNull(order);
@@ -322,7 +311,8 @@ public void testPersistAndLoadGroceryOrder() {
@Test
public void testPersistAndLoadPayment() {
-
+ //create a grocery store application
+ //mandatory to create for a store to exist
GroceryStoreApplication gs = new GroceryStoreApplication();
gs.setId(90);
groceryStoreApplicationRepository.save(gs);
@@ -338,8 +328,6 @@ public void testPersistAndLoadPayment() {
payment.setOrder(order);
paymentRepository.save(payment);
- payment = null;
- order = null;
payment = paymentRepository.findPaymentById(59);
order = payment.getOrder();
assertNotNull(payment);
@@ -366,9 +354,6 @@ public void testPersistAndLoadEmployee() {
employee.setGroceryStoreApplication(gs);
employeeRepository.save(employee);
- gu = null;
- employee = null;
-
employee = employeeRepository.findEmployeeById(1234567);
gu = employee.getUser();
@@ -382,7 +367,7 @@ public void testPersistAndLoadEmployee() {
@Test
public void testPersistAndLoadGroceryUser() {
Set roleSet = new HashSet<>();
- GroceryStoreApplication gs = new GroceryStoreApplication ();
+ GroceryStoreApplication gs = new GroceryStoreApplication();
gs.setId(95);
groceryStoreApplicationRepository.save(gs);
@@ -430,8 +415,6 @@ public void testPersistAndLoadManager() {
manager.setGroceryStoreApplication(gs);
managerRepository.save(manager);
- manager = null;
-
manager = managerRepository.findManagerById(12345);
assertNotNull(manager);
@@ -479,10 +462,7 @@ public void testPersistAndLoadCustomer() {
customer.setGroceryStoreApplication(gs);
customerRepository.save(customer);
- gu = null;
- customer = null;
-
- customer = customerRepository.findCustomberById(12);
+ customer = customerRepository.findCustomerById(12);
gu = customer.getUser();
assertNotNull(customer);